forked from huawei/openGauss-server
!1616 修复gs_dump备份后序列值递增问题
Merge pull request !1616 from 薛蒙恩/gsdump_sequence
This commit is contained in:
commit
5f0e5f3bcd
|
|
@ -20836,6 +20836,7 @@ static void dumpSequenceData(Archive* fout, TableDataInfo* tdinfo, bool large)
|
||||||
called = (strcmp(PQgetvalue(res, 0, 4), "t") == 0);
|
called = (strcmp(PQgetvalue(res, 0, 4), "t") == 0);
|
||||||
|
|
||||||
#ifdef PGXC
|
#ifdef PGXC
|
||||||
|
#ifdef ENABLE_MULTIPLE_NODES
|
||||||
/*
|
/*
|
||||||
* In Postgres-XC it is possible that the current value of a
|
* In Postgres-XC it is possible that the current value of a
|
||||||
* sequence cached on each node is different as several sessions
|
* sequence cached on each node is different as several sessions
|
||||||
|
|
@ -20897,6 +20898,28 @@ static void dumpSequenceData(Archive* fout, TableDataInfo* tdinfo, bool large)
|
||||||
|
|
||||||
ExecuteSqlStatement(fout, "ROLLBACK TO SAVEPOINT bfnextval");
|
ExecuteSqlStatement(fout, "ROLLBACK TO SAVEPOINT bfnextval");
|
||||||
ExecuteSqlStatement(fout, "RELEASE bfnextval");
|
ExecuteSqlStatement(fout, "RELEASE bfnextval");
|
||||||
|
#else
|
||||||
|
resetPQExpBuffer(query);
|
||||||
|
PQclear(res);
|
||||||
|
appendPQExpBuffer(query, "SELECT last_value, is_called FROM %s;", fmtId(tbinfo->dobj.name));
|
||||||
|
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
|
||||||
|
|
||||||
|
if (PQntuples(res) != 1) {
|
||||||
|
write_msg(NULL,
|
||||||
|
ngettext("query to get nextval of sequence %s "
|
||||||
|
"returned %d rows (expected 1)\n",
|
||||||
|
"query to get nextval of sequence %s "
|
||||||
|
"returned %d rows (expected 1)\n",
|
||||||
|
PQntuples(res)),
|
||||||
|
fmtId(tbinfo->dobj.name),
|
||||||
|
PQntuples(res));
|
||||||
|
PQclear(res);
|
||||||
|
destroyPQExpBuffer(query);
|
||||||
|
exit_nicely(1);
|
||||||
|
}
|
||||||
|
last = PQgetvalue(res, 0, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
resetPQExpBuffer(query);
|
resetPQExpBuffer(query);
|
||||||
|
|
|
||||||
|
|
@ -54,5 +54,6 @@ ALTER TABLE rlsrel1 FORCE ROW LEVEL SECURITY;
|
||||||
ALTER TABLE rlsrel2 ENABLE ROW LEVEL SECURITY;
|
ALTER TABLE rlsrel2 ENABLE ROW LEVEL SECURITY;
|
||||||
\! @abs_bindir@/gs_dump --help > @abs_bindir@/gs_dump.log 2>&1
|
\! @abs_bindir@/gs_dump --help > @abs_bindir@/gs_dump.log 2>&1
|
||||||
\! @abs_bindir@/gs_dump basedb -p @portstring@ --with-encryption=AES128 --with-key=abcdefghigklmnop --include-alter-table -n dumptest -s > @abs_bindir@/dump.sql 2>&1 ; echo $?
|
\! @abs_bindir@/gs_dump basedb -p @portstring@ --with-encryption=AES128 --with-key=abcdefghigklmnop --include-alter-table -n dumptest -s > @abs_bindir@/dump.sql 2>&1 ; echo $?
|
||||||
|
SELECT * FROM dumptest."seq$";
|
||||||
\c regression
|
\c regression
|
||||||
drop database if exists basedb;
|
drop database if exists basedb;
|
||||||
|
|
|
||||||
|
|
@ -57,5 +57,11 @@ ALTER TABLE rlsrel2 ENABLE ROW LEVEL SECURITY;
|
||||||
\! @abs_bindir@/gs_dump --help > @abs_bindir@/gs_dump.log 2>&1
|
\! @abs_bindir@/gs_dump --help > @abs_bindir@/gs_dump.log 2>&1
|
||||||
\! @abs_bindir@/gs_dump basedb -p @portstring@ --with-encryption=AES128 --with-key=abcdefghigklmnop --include-alter-table -n dumptest -s > @abs_bindir@/dump.sql 2>&1 ; echo $?
|
\! @abs_bindir@/gs_dump basedb -p @portstring@ --with-encryption=AES128 --with-key=abcdefghigklmnop --include-alter-table -n dumptest -s > @abs_bindir@/dump.sql 2>&1 ; echo $?
|
||||||
0
|
0
|
||||||
|
SELECT * FROM dumptest."seq$";
|
||||||
|
sequence_name | last_value | start_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called | uuid
|
||||||
|
---------------+------------+-------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------+------
|
||||||
|
seq$ | 101 | 101 | 1 | 9223372036854775807 | 1 | 1 | 0 | f | f | 0
|
||||||
|
(1 row)
|
||||||
|
|
||||||
\c regression
|
\c regression
|
||||||
drop database if exists basedb;
|
drop database if exists basedb;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue