mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 01:12:56 +00:00
Do vacuum freeze before copying data
This commit is contained in:
@@ -263,6 +263,7 @@ copy_from(PG_FUNCTION_ARGS)
|
||||
char const* declare_cursor = "declare copy_data_cursor no scroll cursor for select * from copydata() as raw_page(relid text, fork text, blkno integer, content bytea)";
|
||||
char* fetch_cursor = psprintf("fetch forward %d copy_data_cursor", COPY_FETCH_COUNT);
|
||||
char const* close_cursor = "close copy_data_cursor";
|
||||
char const* vacuum_freeze = "vacuum freeze";
|
||||
char *content;
|
||||
char const* relname;
|
||||
BlockNumber blkno;
|
||||
@@ -294,6 +295,12 @@ copy_from(PG_FUNCTION_ARGS)
|
||||
report_error(ERROR, res, conn, true, CREATE_COPYDATA_FUNC);
|
||||
PQclear(res);
|
||||
|
||||
/* Freeze all tables to prevent problems with XID mapping */
|
||||
res = PQexec(conn, vacuum_freeze);
|
||||
if (res == NULL || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
report_error(ERROR, res, conn, true, vacuum_freeze);
|
||||
PQclear(res);
|
||||
|
||||
/* Start transaction to use cursor */
|
||||
res = PQexec(conn, "BEGIN");
|
||||
if (res == NULL || PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
|
||||
Reference in New Issue
Block a user