londiste add-table: make trigger check sql 9.1-compatible
authorSébastien Lardière <slardiere@hi-media.com>
Tue, 15 Nov 2011 21:52:51 +0000 (23:52 +0200)
committerMarko Kreen <markokr@gmail.com>
Tue, 15 Nov 2011 21:52:51 +0000 (23:52 +0200)
Makefile
debian/packages.in
python/londiste/setup.py

index 115ca465135397d365350d6c1795118c674486b0..305bf2b5293679835c1f648af6b2c9d6b7e076d2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -92,6 +92,12 @@ deb90:
        yada rebuild
        debuild -uc -us -b
 
+deb91:
+       ./configure --with-pgconfig=/usr/lib/postgresql/9.1/bin/pg_config --with-python=$(PYTHON)
+       sed -e s/PGVER/9.1/g -e s/PYVER/$(pyver)/g < debian/packages.in > debian/packages
+       yada rebuild
+       debuild -uc -us -b
+
 tgz: config.mak clean
        $(MAKE) -C doc man
        $(PYTHON) setup.py sdist -t source.cfg -m source.list
index 2a098501095078056a525fa007c98d2458824393..8625a5ec71eb79050e036636e41e38effdcbaeeb 100644 (file)
@@ -20,7 +20,7 @@ Build-Depends: python-dev, postgresql-server-dev-PGVER
 
 Package: skytools
 Architecture: any
-Depends: python-psycopg2 | pythonPYVER-psycopg2 | python-psycopg | pythonPYVER-psycopg, skytools-modules-9.0 | skytools-modules-8.4 | skytools-modules-8.3 | skytools-modules-8.2 | skytools-modules-8.1 | skytools-modules-8.0, rsync, []
+Depends: python-psycopg2 | pythonPYVER-psycopg2 | python-psycopg | pythonPYVER-psycopg, skytools-modules-9.1 |skytools-modules-9.0 | skytools-modules-8.4 | skytools-modules-8.3 | skytools-modules-8.2 | skytools-modules-8.1 | skytools-modules-8.0, rsync, []
 Description: Skype database tools - Python parts
  .
  londiste - replication
index c9eba3ea41f719555f2c4aba859e962816088ffa..189a9bcb460990155c1a9205cc29c3b918e73a65 100644 (file)
@@ -278,11 +278,32 @@ class ProviderSetup(CommonSetup):
         self.provider_notify_change()
 
     def provider_add_table(self, tbl):
+
+        src_db = self.get_database('provider_db')
+        src_curs = src_db.cursor()
+        pg_vers = src_curs.connection.server_version
+
         q = "select londiste.provider_add_table(%s, %s)"
         self.exec_provider(q, [self.pgq_queue_name, tbl])
 
         # detect dangerous triggers
-        q = """
+        if pg_vers >= 90100:
+            q = """
+            select tg.trigger_name
+                from londiste.provider_table tbl,
+                     information_schema.triggers tg
+                where tbl.queue_name = %s
+                  and tbl.table_name = %s
+                  and tg.event_object_schema = %s
+                  and tg.event_object_table = %s
+                  and tg.action_timing = 'AFTER'
+                  and tg.trigger_name != tbl.trigger_name
+                  and tg.trigger_name < tbl.trigger_name
+                  and substring(tg.trigger_name from 1 for 10) != '_londiste_'
+                  and substring(tg.trigger_name from char_length(tg.trigger_name) - 6) != '_logger'
+            """
+        else:
+            q = """
             select tg.trigger_name
                 from londiste.provider_table tbl,
                      information_schema.triggers tg
@@ -296,9 +317,8 @@ class ProviderSetup(CommonSetup):
                   and substring(tg.trigger_name from 1 for 10) != '_londiste_'
                   and substring(tg.trigger_name from char_length(tg.trigger_name) - 6) != '_logger'
             """
+
         sname, tname = skytools.fq_name_parts(tbl)
-        src_db = self.get_database('provider_db')
-        src_curs = src_db.cursor()
         src_curs.execute(q, [self.pgq_queue_name, tbl, sname, tname])
         for r in src_curs.fetchall():
             self.log.warning("Table %s has AFTER trigger '%s' which runs before Londiste trigger.  "\