Commit 8fa7e3f6 authored by Sandro Santilli's avatar Sandro Santilli

Upon upgrade, create operators when missing (no matter version)

Fixes #4339

git-svn-id: http://svn.osgeo.org/postgis/trunk@17297 b70326c6-7e19-0410-871a-916f4a2858ee
parent bea93e41
Pipeline #50594808 passed with stage
in 27 minutes and 11 seconds
......@@ -275,19 +275,21 @@ END
EOF
}
# This code handles operators by creating them if we are doing a major upgrade
# This code handles operators by creating them if needed
if ( /^create operator\s+(\S+)\s*\(/i )
{
my $opname = $1;
my $optype = 'unknown';
my $opleft = 'unknown';
my $opright = 'unknown';
my $def = $_;
while(<INPUT>)
{
$def .= $_;
$optype = $1 if ( /leftarg\s*=\s*(\w+)\s*,/i );
$opleft = $1 if ( /leftarg\s*=\s*(\w+)\s*,/i );
$opright = $1 if ( /rightarg\s*=\s*(\w+)\s*,/i );
last if /\);/;
}
my $opsig = $optype . " " . $opname;
my $opsig = $opleft . " " . $opname . " " . $opright;
my $last_updated = parse_last_updated($comment);
if ( ! $last_updated ) {
......@@ -298,7 +300,22 @@ EOF
DO LANGUAGE 'plpgsql'
\$postgis_proc_upgrade\$
BEGIN
IF $last_updated > version_from_num FROM _postgis_upgrade_info THEN
--IF $last_updated > version_from_num FROM _postgis_upgrade_info
--We trust presence of operator rather than version info
IF NOT EXISTS (
SELECT o.oprname
FROM
pg_catalog.pg_operator o,
pg_catalog.pg_type tl,
pg_catalog.pg_type tr
WHERE
o.oprleft = tl.oid AND
o.oprright = tr.oid AND
o.oprname = '$opname' AND
tl.typname = '$opleft' AND
tr.typname = '$opright'
)
THEN
EXECUTE \$postgis_proc_upgrade_parsed_def\$ $def \$postgis_proc_upgrade_parsed_def\$;
END IF;
END
......@@ -432,7 +449,9 @@ EOF
DO LANGUAGE 'plpgsql'
\$postgis_proc_upgrade\$
BEGIN
IF $last_updated > version_from_num FROM _postgis_upgrade_info THEN
IF $last_updated > version_from_num FROM _postgis_upgrade_info
THEN
EXECUTE \$postgis_proc_upgrade_parsed_def\$
$def \$postgis_proc_upgrade_parsed_def\$;
EOF
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment