Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 791692a

Browse files
committed
Use fully qualified names in mtm.alter_sequences
1 parent b8cce29 commit 791692a

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

contrib/mmts/multimaster--1.0.sql

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CREATE TABLE IF NOT EXISTS mtm.local_tables(rel_schema text, rel_name text, prim
8787
CREATE OR REPLACE FUNCTION mtm.alter_sequences() RETURNS boolean AS
8888
$$
8989
DECLARE
90-
seq_class pg_class%rowtype;
90+
seq_class record;
9191
seq_tuple record;
9292
node_id int;
9393
max_nodes int;
@@ -97,25 +97,20 @@ BEGIN
9797
select current_setting('multimaster.max_nodes') into max_nodes;
9898
select id, "allNodes" into node_id from mtm.get_cluster_state();
9999
FOR seq_class IN
100-
SELECT * FROM pg_class WHERE pg_class.relkind = 'S'
100+
SELECT '"' || ns.nspname || '"."' || seq.relname || '"' as seqname FROM pg_namespace ns,pg_class seq WHERE seq.relkind = 'S' and seq.relnamespace=ns.oid
101101
LOOP
102-
BEGIN
103-
EXECUTE 'select * from ' || seq_class.relname || ';' INTO seq_tuple;
102+
EXECUTE 'select * from ' || seq_class.seqname INTO seq_tuple;
104103
IF seq_tuple.increment_by != max_nodes THEN
105104
altered := true;
106105
RAISE NOTICE 'Altering step for sequence % to %.', seq_tuple.sequence_name, max_nodes;
107-
EXECUTE 'ALTER SEQUENCE ' || seq_class.relname || ' INCREMENT BY ' || max_nodes || ';';
106+
EXECUTE 'ALTER SEQUENCE ' || seq_class.seqname || ' INCREMENT BY ' || max_nodes || ';';
108107
END IF;
109108
IF (seq_tuple.last_value % max_nodes) != node_id THEN
110109
altered := true;
111110
new_start := (seq_tuple.last_value / max_nodes + 1)*max_nodes + node_id;
112111
RAISE NOTICE 'Altering start for sequence % to %.', seq_tuple.sequence_name, new_start;
113-
EXECUTE 'ALTER SEQUENCE ' || seq_class.relname || ' RESTART WITH ' || new_start || ';';
112+
EXECUTE 'ALTER SEQUENCE ' || seq_class.seqname || ' RESTART WITH ' || new_start || ';';
114113
END IF;
115-
EXCEPTION
116-
WHEN OTHERS THEN
117-
RAISE NOTICE 'Failed to alter sequence %s', seq_class.relname;
118-
END;
119114
END LOOP;
120115
IF altered = false THEN
121116
RAISE NOTICE 'All found sequnces have proper params.';

contrib/mmts/multimaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4878,8 +4878,8 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
48784878
bool skipCommand = false;
48794879
bool executed = false;
48804880

4881-
MTM_LOG3("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, query=%s",
4882-
MyProcPid, nodeTag(parsetree), context, IsSubTransaction(), queryString);
4881+
MTM_LOG1("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, creating_extension=%d, query=%s",
4882+
MyProcPid, nodeTag(parsetree), context, IsSubTransaction(), creating_extension, queryString);
48834883
switch (nodeTag(parsetree))
48844884
{
48854885
case T_TransactionStmt:

0 commit comments

Comments
 (0)