help="add: Argument to custom handler")
p.add_option("--merge-all", action="store_true",
help="merge tables from all source queues", default=False)
+ p.add_option("--no-merge", action="store_true",
+ help="don't merge tables from source queues", default=False)
return p
def extra_init(self, node_type, node_db, provider_db):
tgargs.append('no_triggers')
if self.options.merge_all:
tgargs.append('merge_all')
+ if self.options.no_merge:
+ tgargs.append('no_merge')
attrs = {}
if self.options.handler:
join pgq_node.node_info n on (n.queue_name = t.queue_name)
left join pgq_node.node_info n2 on (n2.combined_queue = n.combined_queue or
(n2.combined_queue is null and n.combined_queue is null))
- left join londiste.table_info t2 on (t2.table_name = t.table_name and t2.queue_name = n2.queue_name)
+ left join londiste.table_info t2 on (t2.table_name = t.table_name and
+ t2.queue_name = n2.queue_name and (t2.merge_state is null or t2.merge_state != 'ok'))
where t.queue_name = i_queue_name
group by t.nr, t.table_name, t.local, t.merge_state, t.custom_snapshot, t.table_attrs, t.dropped_ddl
order by t.nr, t.table_name
-- skip_truncate - set 'skip_truncate' table attribute
-- expect_sync - set table state to 'ok'
-- tgflags=X - trigger creation flags
--- merge_all - merge table from all sources. required for
+-- merge_all - merge table from all sources. required for
-- multi-source table
+-- no_merge - do not merge tables from different sources
-- skip - create skip trigger. same as S flag
-- virtual_table - skips structure check and trigger creation
--
-- argument flags
_expect_sync boolean := false;
_merge_all boolean := false;
+ _no_merge boolean := false;
_skip_truncate boolean := false;
_no_triggers boolean := false;
_skip boolean := false;
_no_triggers := true;
elsif arg = 'merge_all' then
_merge_all = true;
+ elsif arg = 'no_merge' then
+ _no_merge = true;
elsif lower(arg) = 'skip' then
_skip := true;
elsif arg = 'virtual_table' then
end loop;
end if;
+ if _merge_all and _no_merge then
+ select 405, 'Cannot use merge-all and no-merge together'
+ into ret_code, ret_note;
+ return;
+ end if;
+
fq_table_name := londiste.make_fqname(i_table_name);
-------- TABLE STRUCTURE CHECK
end if;
-- merge all table sources on leaf
- if _node.node_type = 'leaf' then
+ if _node.node_type = 'leaf' and not _no_merge then
for _queue_name, _local in
select t2.queue_name, t2.local
from londiste.table_info t
-- if table from some other source is already marked as local,
-- raise error
if _local then
- select 406, 'found local table '|| fq_table_name
+ select 405, 'Found local table '|| fq_table_name
|| ' in queue ' || _queue_name
|| ', use remove-table first to remove all previous '
|| 'table subscriptions'
return;
end if;
- -- when table comes from multiple sources, merge_all switch is
- -- required
- if not _merge_all then
- select 405, 'multiple source tables '|| fq_table_name
- || ' found, use merge_all'
- into ret_code, ret_note;
- return;
- end if;
+ -- when table comes from multiple sources, merge_all switch is
+ -- required
+ if not _merge_all then
+ select 405, 'Found multiple sources for table '|| fq_table_name
+ || ', use merge-all or no-merge to continue'
+ into ret_code, ret_note;
+ return;
+ end if;
update londiste.table_info
set local = true,