!6039 【中移信息】解决dump指定schema时没有导出同义词问题
Merge pull request !6039 from Rock/bug_fix
This commit is contained in:
@ -1535,7 +1535,6 @@ void getopt_dump(int argc, char** argv, struct option options[], int* result)
|
||||
break;
|
||||
case 'n': /* include schema(s) */
|
||||
simple_string_list_append(&schema_include_patterns, optarg);
|
||||
include_everything = false;
|
||||
break;
|
||||
|
||||
case 'N': /* exclude schema(s) */
|
||||
@ -22539,6 +22538,7 @@ static void dumpSynonym(Archive* fout)
|
||||
int i_tableoid = 0;
|
||||
int i_synname = 0;
|
||||
int i_nspname = 0;
|
||||
int i_nspoid = 0;
|
||||
int i_rolname = 0;
|
||||
int i_synobjschema = 0;
|
||||
int i_synobjname = 0;
|
||||
@ -22569,7 +22569,7 @@ static void dumpSynonym(Archive* fout)
|
||||
* Only the super user can access pg_authid. Therefore, user verification is ignored.
|
||||
*/
|
||||
appendPQExpBuffer(query,
|
||||
"SELECT s.oid, s.tableoid, s.synname, n.nspname, a.rolname, s.synobjschema, s.synobjname "
|
||||
"SELECT s.oid, s.tableoid, s.synname, n.nspname, n.oid as nspoid, a.rolname, s.synobjschema, s.synobjname "
|
||||
"FROM pg_synonym s, pg_namespace n, pg_authid a "
|
||||
"WHERE n.oid = s.synnamespace AND s.synowner = a.oid;");
|
||||
|
||||
@ -22586,11 +22586,16 @@ static void dumpSynonym(Archive* fout)
|
||||
i_tableoid = PQfnumber(res, "tableoid");
|
||||
i_synname = PQfnumber(res, "synname");
|
||||
i_nspname = PQfnumber(res, "nspname");
|
||||
i_nspoid = PQfnumber(res, "nspoid");
|
||||
i_rolname = PQfnumber(res, "rolname");
|
||||
i_synobjschema = PQfnumber(res, "synobjschema");
|
||||
i_synobjname = PQfnumber(res, "synobjname");
|
||||
|
||||
for (i = 0; i < ntups; i++) {
|
||||
Oid schemaOid = atooid(PQgetvalue(res, i, i_nspoid));
|
||||
if (!simple_oid_list_member(&schema_include_oids, schemaOid)) {
|
||||
continue;
|
||||
}
|
||||
char* synname = NULL;
|
||||
char* nspname = NULL;
|
||||
char* rolname = NULL;
|
||||
|
||||
16
src/test/regress/input/gs_dump_synonym.source
Normal file
16
src/test/regress/input/gs_dump_synonym.source
Normal file
@ -0,0 +1,16 @@
|
||||
drop database if exists dump_synonym;
|
||||
create database dump_synonym;
|
||||
create database restore_synonym_db;
|
||||
\c dump_synonym
|
||||
create schema t1;
|
||||
create schema t2;
|
||||
create table t1.test1(col1 int);
|
||||
create or replace synonym t1.syn1 for t1.test1;
|
||||
create or replace synonym t2.syn2 for t1.test1;
|
||||
\! @abs_bindir@/gs_dump -p @portstring@ -n t1 -f @abs_bindir@/dump_synonym.dmp -s dump_synonym > @abs_bindir@/gs_dump.log 2>&1 ; echo $?
|
||||
\! @abs_bindir@/gsql -d restore_synonym_db -p @portstring@ -f @abs_bindir@/dump_synonym.dmp > @abs_bindir@/gs_dump.log 2>&1 ; echo $?
|
||||
\c restore_synonym_db
|
||||
select synname from pg_synonym;
|
||||
drop database dump_synonym;
|
||||
\c regression
|
||||
drop database restore_synonym_db;
|
||||
24
src/test/regress/output/gs_dump_synonym.source
Normal file
24
src/test/regress/output/gs_dump_synonym.source
Normal file
@ -0,0 +1,24 @@
|
||||
drop database if exists dump_synonym;
|
||||
NOTICE: database "dump_synonym" does not exist, skipping
|
||||
create database dump_synonym;
|
||||
create database restore_synonym_db;
|
||||
\c dump_synonym
|
||||
create schema t1;
|
||||
create schema t2;
|
||||
create table t1.test1(col1 int);
|
||||
create or replace synonym t1.syn1 for t1.test1;
|
||||
create or replace synonym t2.syn2 for t1.test1;
|
||||
\! @abs_bindir@/gs_dump -p @portstring@ -n t1 -f @abs_bindir@/dump_synonym.dmp -s dump_synonym > @abs_bindir@/gs_dump.log 2>&1 ; echo $?
|
||||
0
|
||||
\! @abs_bindir@/gsql -d restore_synonym_db -p @portstring@ -f @abs_bindir@/dump_synonym.dmp > @abs_bindir@/gs_dump.log 2>&1 ; echo $?
|
||||
0
|
||||
\c restore_synonym_db
|
||||
select synname from pg_synonym;
|
||||
synname
|
||||
---------
|
||||
syn1
|
||||
(1 row)
|
||||
|
||||
drop database dump_synonym;
|
||||
\c regression
|
||||
drop database restore_synonym_db;
|
||||
@ -73,7 +73,7 @@ test: transaction_with_snapshot
|
||||
test: select_into_user_defined_variables
|
||||
test: select_into_file
|
||||
|
||||
test: gs_dump_package trigger_dump gs_dumpall
|
||||
test: gs_dump_package trigger_dump gs_dumpall gs_dump_synonym
|
||||
test: out_param_func
|
||||
#test: sqlcode_cursor
|
||||
test: gs_dump_tableconstraint
|
||||
|
||||
@ -63,7 +63,7 @@ test: set_transaction_test
|
||||
test: select_into_user_defined_variables
|
||||
test: select_into_file
|
||||
|
||||
test: gs_dump_package trigger_dump
|
||||
test: gs_dump_package trigger_dump gs_dump_synonym
|
||||
test: out_param_func out_param_func_overload
|
||||
#test: sqlcode_cursor
|
||||
test: gs_dump_tableconstraint
|
||||
|
||||
Reference in New Issue
Block a user