slony1-bugs at lists.slony.info slony1-bugs at lists.slony.info
Thu Nov 29 08:23:41 PST 2007
http://www.slony.info/bugzilla/show_bug.cgi?id=18

           Summary: Patch to shorten "attkind" on logtrigger functions
           Product: Slony-I
           Version: devel
          Platform: All
               URL: http://lists.slony.info/pipermail/slony1-general/2007-
                    November/006988.html
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: low
         Component: trigger SPI
        AssignedTo: slony1-bugs at lists.slony.info
        ReportedBy: cbbrowne at ca.afilias.info
                CC: slony1-bugs at lists.slony.info
   Estimated Hours: 0.0


The following very quick patch (against 1.2.12) provides the following changes:
- when scanning attributes looking for key columns (in UPDATEs and
DELETEs), stop when we reach the end of the attkind string
- when creating the triggers, final "v"s are stripped

Result:
- one can add columns (without defaults, constraints, etc.) to tables
(destinations first, origin last) without changing the logtrigger and
without using EXECUTE SCRIPT
- as a bonus we save a few cycles in updates and deletes

--- src/backend/slony1_funcs.c.orig Wed Nov 21 15:43:24 2007
+++ src/backend/slony1_funcs.c      Wed Nov 21 15:45:13 2007
@@ -821,6 +821,8 @@
                                continue;

                        attkind_idx++;
+                       if (!attkind[attkind_idx])
+                               break;
                        if (attkind[attkind_idx] != 'k')
                                continue;
                        col_ident = (char
*)slon_quote_identifier(SPI_fname(tupdesc, i + 1));
@@ -888,6 +890,8 @@
                                continue;

                        attkind_idx++;
+                       if (!attkind[attkind_idx])
+                               break;
                        if (attkind[attkind_idx] != 'k')
                                continue;
                        col_ident = (char
*)slon_quote_identifier(SPI_fname(tupdesc, i + 1));
--- src/backend/slony1_funcs.sql.orig       Wed Nov 21 15:45:35 2007
+++ src/backend/slony1_funcs.sql    Wed Nov 21 15:53:11 2007
@@ -5029,6 +5029,11 @@
        end loop;

        --
+       -- Strip final 'v's as these are not needed by the logtrigger
+       --
+       v_attkind := regexp_replace(v_attkind,''v*$'','''');
+
+       --
        -- Return the resulting attkind
        --
        return v_attkind;

-- 
Jacques Caron <jc at oxado.com>


-- 
Configure bugmail: http://www.slony.info/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
You are the assignee for the bug.


More information about the Slony1-bugs mailing list