From 491f2aef75f9d044c5f5274a46a733a0ab24fbe9 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Wed, 9 May 2012 16:23:46 +0300 Subject: [PATCH] londiste: Always use TRUNCATE CASCADE Otherwise the operation cannot play well with foreign keys, on both slave and master. --- python/londiste/playback.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/londiste/playback.py b/python/londiste/playback.py index 03a45665..a8c2a51a 100644 --- a/python/londiste/playback.py +++ b/python/londiste/playback.py @@ -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) -- 2.39.5