Skip to content

Commit

Permalink
Merge branch 'bug305'
Browse files Browse the repository at this point in the history
  • Loading branch information
ssinger committed Jul 29, 2013
2 parents bcd79f5 + bed4153 commit 8bb7618
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/backend/slony1_funcs.c
Expand Up @@ -989,9 +989,11 @@ versionFunc(logApply)(PG_FUNCTION_ARGS)
char *ddl_script;
bool localNodeFound = true;
Datum script_insert_args[5];
char query[1024];

apply_num_script++;


/*
* Turn the log_cmdargs into a plain array of Text Datums.
*/
Expand Down Expand Up @@ -1036,12 +1038,27 @@ versionFunc(logApply)(PG_FUNCTION_ARGS)
*/
if (localNodeFound)
{
sprintf(query,"set session_replication_role to local;");
if(SPI_exec(query,0) < 0)
{
elog(ERROR, "SPI_exec() failed for statement '%s'",
query);
}


if (SPI_exec(ddl_script, 0) < 0)
{
elog(ERROR, "SPI_exec() failed for DDL statement '%s'",
ddl_script);
}

sprintf(query,"set session_replication_role to replica;");
if(SPI_exec(query,0) < 0)
{
elog(ERROR, "SPI_exec() failed for statement '%s'",
query);
}

/*
* Set the currentXid to invalid to flush the apply query cache.
*/
Expand Down Expand Up @@ -1130,6 +1147,7 @@ versionFunc(logApply)(PG_FUNCTION_ARGS)
elog(ERROR, "SPI_exec() failed for statement '%s'",
query);
}


/*
* Set the currentXid to invalid to flush the apply query cache.
Expand Down
2 changes: 2 additions & 0 deletions tools/slony1_dump.sh
Expand Up @@ -281,7 +281,9 @@ begin
execute v_command;
end if;
if NEW.log_cmdtype = 'S' then
execute 'set session_replication_role to local;';
execute NEW.log_cmdargs[1];
execute 'set session_replication_role to replica;';
end if;
if NEW.log_cmdtype = 'T' then
Expand Down

0 comments on commit 8bb7618

Please sign in to comment.