修复逻辑复制环境,create schema指定属主同步失败

This commit is contained in:
wenger
2024-09-05 11:06:36 +08:00
parent 5676703d92
commit 48fbcbbf91
11 changed files with 65 additions and 11 deletions

View File

@ -891,7 +891,7 @@ static ObjTree* deparse_AlterSchemaStmt(Oid objectId, Node *parsetree)
* Verbose syntax
* CREATE SCHEMA %{if_not_exists}s %{name}I %{authorization}s
*/
static ObjTree* deparse_CreateSchemaStmt(Oid objectId, Node *parsetree)
static ObjTree* deparse_CreateSchemaStmt(Oid objectId, Node *parsetree, bool *include_owner)
{
CreateSchemaStmt *node = (CreateSchemaStmt *) parsetree;
ObjTree *ret;
@ -904,12 +904,14 @@ static ObjTree* deparse_CreateSchemaStmt(Oid objectId, Node *parsetree)
node->schemaname ? node->schemaname : "");
auth = new_objtree("AUTHORIZATION");
if (node->authid)
if (node->authid) {
append_string_object(auth, "%{authorization_role}I",
"authorization_role",
node->authid);
else
*include_owner = false;
} else {
append_not_present(auth, "%{authorization_role}I");
}
append_object_object(ret, "%{authorization}s", auth);
@ -3658,7 +3660,7 @@ static ObjTree* deparse_simple_command(CollectedCommand *cmd, bool *include_owne
return deparse_CreateFunction(objectId, parsetree);
case T_CreateSchemaStmt:
return deparse_CreateSchemaStmt(objectId, parsetree);
return deparse_CreateSchemaStmt(objectId, parsetree, include_owner);
case T_CreateSeqStmt:
return deparse_CreateSeqStmt(objectId, parsetree);
@ -3685,7 +3687,7 @@ static ObjTree* deparse_simple_command(CollectedCommand *cmd, bool *include_owne
return (ObjTree*)((deparseCollectedCommand)(u_sess->hook_cxt.deparseCollectedCommandHook))
(DEPARSE_SIMPLE_COMMAND, cmd, NULL, NULL);
}
elog(INFO, "unrecognized node type in deparse command: %d",
elog(LOG, "unrecognized node type in deparse command: %d",
(int) nodeTag(parsetree));
}

View File

@ -389,6 +389,7 @@ void AlterSchemaCommand(AlterSchemaStmt* stmt)
AclResult aclresult;
const int STR_SCHEMA_NAME_LENGTH = 9;
const int STR_SNAPSHOT_LENGTH = 8;
ObjectAddress address;
if (withBlockchain && ((strncmp(nspName, "dbe_perf", STR_SCHEMA_NAME_LENGTH) == 0) ||
(strncmp(nspName, "snapshot", STR_SNAPSHOT_LENGTH) == 0))) {
@ -423,6 +424,9 @@ void AlterSchemaCommand(AlterSchemaStmt* stmt)
(errcode(ERRCODE_RESERVED_NAME),
errmsg("The system schema \"%s\" doesn't allow to alter to blockchain schema", nspName)));
ObjectAddressSet(address, NamespaceNameIndexId, HeapTupleGetOid(tup));
EventTriggerCollectSimpleCommand(address, InvalidObjectAddress, (Node*)stmt);
Datum new_record[Natts_pg_namespace] = {0};
bool new_record_nulls[Natts_pg_namespace] = {false};
bool new_record_repl[Natts_pg_namespace] = {false};

View File

@ -5217,6 +5217,7 @@ ProcessUtilitySlow(Node *parse_tree,
}
#else
AlterSchemaCommand((AlterSchemaStmt*)parse_tree);
commandCollected = true;
#endif
break;
@ -6634,7 +6635,7 @@ ProcessUtilitySlow(Node *parse_tree,
ExecUtilityStmtOnNodes(query_string, exec_nodes, sent_to_remote, false, EXEC_ON_ALL_NODES, false);
}
} else {
ExecAlterOwnerStmt((AlterOwnerStmt*)parse_tree);
address = ExecAlterOwnerStmt((AlterOwnerStmt*)parse_tree);
}
#else
AlterOwnerStmt *stmt = (AlterOwnerStmt *) parse_tree;

View File

@ -0,0 +1,8 @@
#!/bin/bsh
source $1/env_utils.sh $1 $2
subscription_dir=$1
case_use_db=$3
exec_sql_with_user $case_use_db $pub_node1_port "CREATE USER test_u1 PASSWORD 'Aa123456'"
exec_sql_with_user $case_use_db $sub_node1_port "CREATE USER test_u1 PASSWORD 'Aa123456'"

View File

@ -0,0 +1 @@
create schema test_own authorization test_u1;

View File

@ -0,0 +1,8 @@
#!/bin/sh
source $1/env_utils.sh $1 $2
subscription_dir=$1
case_use_db=$3
exec_sql $case_use_db $sub_node1_port "DROP USER test_u1"
exec_sql $case_use_db $sub_node1_port "DROP USER test_u1"

View File

@ -0,0 +1,17 @@
28,37c28
< -- Name: regtest_unpriv_user; Type: SCHEMA; Schema: -; Owner: regtest_unpriv_user
< --
<
< CREATE SCHEMA regtest_unpriv_user;
<
<
< ALTER SCHEMA regtest_unpriv_user OWNER TO regtest_unpriv_user;
<
< --
< -- Name: test_sche1; Type: SCHEMA; Schema: -; Owner: regtest_unpriv_user
---
> -- Name: test_sche1; Type: SCHEMA; Schema: -; Owner: ddl_test_user
44c35
< ALTER SCHEMA test_sche1 OWNER TO regtest_unpriv_user;
---
> ALTER SCHEMA test_sche1 OWNER TO ddl_test_user;

View File

@ -8,8 +8,4 @@ exec_sql_with_user $case_use_db $pub_node1_port "create schema fastcheck;set sea
exec_sql_with_user $case_use_db $sub_node1_port "create schema fastcheck;set search_path=fastcheck;create table t1_full (a int, b text, myc int); insert into t1_full values (101, 'a', 1), (102, 'b', 2);"
exec_sql_with_user $case_use_db $pub_node1_port "set search_path=fastcheck;create table tkey1 (a int primary key, b text);insert into tkey1 values (1, 'a'), (2, 'b'), (3, 'c');alter table tkey1 replica identity default;"
exec_sql_with_user $case_use_db $sub_node1_port "set search_path=fastcheck;create table tkey1 (a int primary key, b text, myc int); insert into tkey1 values (101, '101a', 1), (102, '102b', 2);"
exec_sql_with_user $case_use_db $pub_node1_port "CREATE USER regtest_unpriv_user PASSWORD 'gauss@123'"
exec_sql_with_user $case_use_db $sub_node1_port "CREATE USER regtest_unpriv_user PASSWORD 'gauss@123'"
exec_sql_with_user $case_use_db $sub_node1_port "set search_path=fastcheck;create table tkey1 (a int primary key, b text, myc int); insert into tkey1 values (101, '101a', 1), (102, '102b', 2);"

View File

@ -0,0 +1,8 @@
#!/bin/bsh
source $1/env_utils.sh $1 $2
subscription_dir=$1
case_use_db=$3
exec_sql_with_user $case_use_db $pub_node1_port "CREATE USER test_u1 PASSWORD 'Aa123456'"
exec_sql_with_user $case_use_db $sub_node1_port "CREATE USER test_u1 PASSWORD 'Aa123456'"

View File

@ -0,0 +1 @@
create schema test_own authorization test_u1;

View File

@ -0,0 +1,8 @@
#!/bin/sh
source $1/env_utils.sh $1 $2
subscription_dir=$1
case_use_db=$3
exec_sql $case_use_db $sub_node1_port "DROP USER test_u1"
exec_sql $case_use_db $sub_node1_port "DROP USER test_u1"