londiste: Always use TRUNCATE CASCADE
authorMarko Kreen <markokr@gmail.com>
Wed, 9 May 2012 13:23:46 +0000 (16:23 +0300)
committerMarko Kreen <markokr@gmail.com>
Thu, 10 May 2012 18:19:29 +0000 (21:19 +0300)
Otherwise the operation cannot play well with
foreign keys, on both slave and master.

python/londiste/playback.py

index 03a456657567723762aa9153b78112eb9203f0aa..a8c2a51a8679d06229150c91d4f696d0c8145d48 100644 (file)
@@ -634,10 +634,13 @@ class Replicator(CascadedWorker):
             return
 
         fqname = skytools.quote_fqident(t.dest_table)
-        if dst_curs.connection.server_version >= 80400:
-            sql = "TRUNCATE ONLY %s;" % fqname
-        else:
-            sql = "TRUNCATE %s;" % fqname
+
+        #
+        # Always use CASCADE, because without it the
+        # operation cannot work with FKeys, on both
+        # slave and master.
+        #
+        sql = "TRUNCATE %s CASCADE;" % fqname
 
         self.flush_sql(dst_curs)
         dst_curs.execute(sql)