londiste.create_trigger: fixed compatibility with postgres 9+
authormartinko <gamato@users.sf.net>
Tue, 19 Mar 2013 14:43:12 +0000 (15:43 +0100)
committermartinko <gamato@users.sf.net>
Tue, 19 Mar 2013 14:43:12 +0000 (15:43 +0100)
sql/londiste/functions/londiste.create_trigger.sql

index 336460ede433d8945ca079cf03aea28b6e239ca6..01cf6e4ffe56577266951b928b0c61866adeae3d 100644 (file)
@@ -61,8 +61,8 @@ declare
     _tgflags char[];
     -- ordinary argument array
     _args text[];
-    -- array with all tgflags values
-    _check_flags char[] := array['B','A','Q','L','I','U','D','S'];
+    -- array with all valid tgflags values
+    _valid_flags char[] := array['B','A','Q','L','I','U','D','S'];
     -- argument flags
     _skip boolean := false;
     _no_triggers boolean := false;
@@ -75,9 +75,9 @@ begin
             if arg like 'tgflags=%' then
                 -- special flag handling
                 arg := upper(substr(arg, 9));
-                for j in array_lower(_check_flags, 1) .. array_upper(_check_flags, 1) loop
-                    if position(_check_flags[j] in arg) > 0 then
-                        _tgflags := array_append(_tgflags, _check_flags[j]);
+                for j in array_lower(_valid_flags, 1) .. array_upper(_valid_flags, 1) loop
+                    if position(_valid_flags[j] in arg) > 0 then
+                        _tgflags := array_append(_tgflags, _valid_flags[j]);
                     end if;
                 end loop;
             elsif arg = 'no_triggers' then
@@ -157,7 +157,7 @@ begin
         into _skip_trg_count, _skip_trg_name
         from pg_catalog.pg_trigger t
         where t.tgrelid = londiste.find_table_oid(i_dest_table)
-            and position(E'\\000skip\\000' in lower(tgargs::text)) > 0;
+            and position(E'\\000SKIP\\000'::bytea in tgargs) > 0;
         -- if no previous skip triggers, prefix name and add SKIP to args
         if _skip_trg_count = 0 then
             trigger_name := _skip_prefix || trigger_name;