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

Commit 46962bc

Browse files
knizhnikkelvich
authored andcommitted
Use fully qualified names in mtm.alter_sequences
1 parent 241d31d commit 46962bc

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

multimaster--1.0.sql

+5-10
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.';

multimaster.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4892,8 +4892,8 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
48924892
bool skipCommand = false;
48934893
bool executed = false;
48944894

4895-
MTM_LOG3("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, query=%s",
4896-
MyProcPid, nodeTag(parsetree), context, IsSubTransaction(), queryString);
4895+
MTM_LOG1("%d: Process utility statement tag=%d, context=%d, issubtrans=%d, creating_extension=%d, query=%s",
4896+
MyProcPid, nodeTag(parsetree), context, IsSubTransaction(), creating_extension, queryString);
48974897
switch (nodeTag(parsetree))
48984898
{
48994899
case T_TransactionStmt:

0 commit comments

Comments
 (0)