From b436d32eae887813d3d6a81296ed7c546307115a Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Mon, 24 Jan 2011 15:28:21 +0200 Subject: [PATCH] londiste: change behaviour of --create* flags --create now does minimal pkey-only structure --create-full does maximal structure --create-only is dropped as too complex --- python/londiste.py | 6 +++--- python/londiste/setup.py | 46 +++++++++++++--------------------------- tests/londiste/regen.sh | 4 ++-- 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/python/londiste.py b/python/londiste.py index 7b3b4a97..5a852da2 100755 --- a/python/londiste.py +++ b/python/londiste.py @@ -113,9 +113,9 @@ class Londiste(skytools.DBScript): g.add_option("--skip-truncate", action="store_true", dest="skip_truncate", help = "add: keep old data", default=False) g.add_option("--create", action="store_true", - help = "add: create table/seq if not exist") - g.add_option("--create-only", - help = "add: create table/seq if not exist (seq,pkey,full,indexes,fkeys)") + help = "add: create table/seq if not exist, with minimal schema") + g.add_option("--create-full", action="store_true", + help = "add: create table/seq if not exist, with full schema") g.add_option("--trigger-flags", help="add: Set trigger flags (BAIUDLQ)") g.add_option("--trigger-arg", action="append", diff --git a/python/londiste/setup.py b/python/londiste/setup.py index e3d87de7..a2b4c899 100644 --- a/python/londiste/setup.py +++ b/python/londiste/setup.py @@ -53,9 +53,9 @@ class LondisteSetup(CascadeAdmin): p.add_option("--all", action="store_true", help="include all tables", default=False) p.add_option("--create", action="store_true", - help="include all tables", default=False) - p.add_option("--create-only", - help="pkey,fkeys,indexes") + help="create, minimal", default=False) + p.add_option("--create-full", action="store_true", + help="create, full") p.add_option("--trigger-flags", help="Set trigger flags (BAIUDLQ)") p.add_option("--trigger-arg", action="append", @@ -121,21 +121,12 @@ class LondisteSetup(CascadeAdmin): sys.exit(1) # pick proper create flags - create = self.options.create_only - if not create and self.options.create: - create = 'full' - - fmap = { - "full": skytools.T_ALL, - "pkey": skytools.T_PKEY, - } - create_flags = 0 - if create: - create_flags = skytools.T_TABLE - for f in create.split(','): - if f not in fmap: - raise Exception("bad --create-only flag: " + f) - create_flags |= fmap[f] + if self.options.create_full: + create_flags = skytools.T_ALL + elif self.options.create: + create_flags = skytools.T_TABLE | skytools.T_PKEY + else: + create_flags = 0 # seems ok for tbl in args: @@ -244,19 +235,12 @@ class LondisteSetup(CascadeAdmin): args = self.expand_arg_list(dst_db, 'S', False, args) # pick proper create flags - create = self.options.create_only - if not create and self.options.create: - create = 'full' - - fmap = { - "full": skytools.T_SEQUENCE, - } - create_flags = 0 - if create: - for f in create.split(','): - if f not in fmap: - raise Exception("bad --create-only flag: " + f) - create_flags += fmap[f] + if self.options.create_full: + create_flags = skytools.T_SEQUENCE + elif self.options.create: + create_flags = skytools.T_SEQUENCE + else: + create_flags = 0 # seems ok for seq in args: diff --git a/tests/londiste/regen.sh b/tests/londiste/regen.sh index 770a7ed5..17db1506 100755 --- a/tests/londiste/regen.sh +++ b/tests/londiste/regen.sh @@ -96,14 +96,14 @@ msg "Register table on other node with creation" for db in db2 db3 db4 db5; do run psql -d $db -c "create sequence mytable_id_seq" run londiste3 $v conf/londiste_db1.ini add-seq mytable_id_seq - run londiste3 $v conf/londiste_$db.ini add-table mytable --create + run londiste3 $v conf/londiste_$db.ini add-table mytable --create-full done msg "Register another table to test unregistration" run psql -d db1 -c "create table mytable2 (id int4 primary key, data text)" run londiste3 $v conf/londiste_db1.ini add-table mytable2 for db in db2 db3 db4 db5; do - run londiste3 $v conf/londiste_$db.ini add-table mytable2 --create-only=pkey + run londiste3 $v conf/londiste_$db.ini add-table mytable2 --create done msg "Wait until tables are in sync on db5" -- 2.39.5