londiste.get_table_list: If no merge happens return copy_role=NULL
authorMarko Kreen <markokr@gmail.com>
Fri, 23 Dec 2011 12:41:51 +0000 (14:41 +0200)
committerMarko Kreen <markokr@gmail.com>
Fri, 23 Dec 2011 12:41:51 +0000 (14:41 +0200)
Seems we started to return 'lead' in such case, which turned on
multi-tx copy.  Although it works, it's annoying.

Add regtest for such case.

sql/londiste/expected/londiste_subscriber.out
sql/londiste/functions/londiste.get_table_list.sql
sql/londiste/sql/londiste_subscriber.sql

index 42aa3e4db629b4077966e532367f606856b96d23..6640f91c9ca286ee349f3fcaf494f2127148ecc6 100644 (file)
@@ -67,6 +67,19 @@ select * from londiste.get_table_list('branch_set');
  public.tmp       | f     |             |                 |             |             |           |        0 | 
 (2 rows)
 
+select * from londiste.local_set_table_state('branch_set', 'public.slavedata', null, 'in-copy');
+ ret_code |                   ret_note                    
+----------+-----------------------------------------------
+      200 | Table public.slavedata state set to 'in-copy'
+(1 row)
+
+select * from londiste.get_table_list('branch_set');
+    table_name    | local | merge_state | custom_snapshot | table_attrs | dropped_ddl | copy_role | copy_pos | dest_table 
+------------------+-------+-------------+-----------------+-------------+-------------+-----------+----------+------------
+ public.slavedata | t     | in-copy     |                 |             |             |           |        0 | 
+ public.tmp       | f     |             |                 |             |             |           |        0 | 
+(2 rows)
+
 select * from londiste.global_remove_table('branch_set', 'public.tmp');
  ret_code |         ret_note          
 ----------+---------------------------
index d1bbec879001933725f9ef50087c709e4dbf7492..26569495a93579eaceef3208efe656a2d02085b9 100644 (file)
@@ -79,6 +79,11 @@ begin
         -- be more robust against late joiners
         q_part1 := coalesce(q_part_ddl, q_part1);
 
+        -- turn the logic off if no merge is happening
+        if n_parts = 1 then
+            q_part1 := null;
+        end if;
+
         if q_part1 is not null then
             if i_queue_name = q_part1 then
                 -- lead
index a7f3cf61a3f7bfaff29cf0fad8134542e7dc20f4..9d372ac481c43d90827f73278540245250579989 100644 (file)
@@ -23,6 +23,10 @@ select * from londiste.global_add_table('branch_set', 'public.slavedata');
 select * from londiste.local_add_table('branch_set', 'public.slavedata');
 select * from londiste.global_add_table('branch_set', 'public.tmp');
 select * from londiste.get_table_list('branch_set');
+
+select * from londiste.local_set_table_state('branch_set', 'public.slavedata', null, 'in-copy');
+select * from londiste.get_table_list('branch_set');
+
 select * from londiste.global_remove_table('branch_set', 'public.tmp');
 select * from londiste.local_remove_table('branch_set', 'public.slavedata');
 select * from londiste.local_remove_table('branch_set', 'public.slavedata');