Merge branch 'create_alter_database' into alter_database_additional_options

pull/7253/head
Gürkan İndibay 2023-10-16 14:44:32 +03:00 committed by GitHub
commit c3a9a37ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 83 additions and 16 deletions

View File

@ -439,7 +439,10 @@ jobs:
else
echo "Detected tests " $tests
fi
echo tests="$tests" >> "$GITHUB_OUTPUT"
echo 'tests<<EOF' >> $GITHUB_OUTPUT
echo "$tests" >> "$GITHUB_OUTPUT"
echo 'EOF' >> $GITHUB_OUTPUT
test-flakyness:
if: ${{ needs.test-flakyness-pre.outputs.tests != ''}}
name: Test flakyness

View File

@ -344,7 +344,6 @@ citus_internal_database_command(PG_FUNCTION_ARGS)
(superuser() ? PGC_SUSET : PGC_USERSET), PGC_S_SESSION,
GUC_ACTION_LOCAL, true, 0, false);
/*
* createdb() / DropDatabase() uses ParseState to report the error position for the
* input command and the position is reported to be 0 when it's provided as NULL.
@ -379,20 +378,6 @@ citus_internal_database_command(PG_FUNCTION_ARGS)
DropDatabase(pstate, (DropdbStmt *) parseTree);
}
}
else if (IsA(parseTree, AlterDatabaseStmt))
{
elog(DEBUG1, "Altering DB");
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, parseTree);
bool missingOk = false;
Oid databaseOid = get_database_oid(stmt->dbname, missingOk);
if (OidIsValid(databaseOid))
{
AlterDatabase(NULL, (AlterDatabaseStmt *) parseTree, true);
}
}
else
{
ereport(ERROR, (errmsg("unsupported command type %d", nodeTag(parseTree))));

View File

@ -55,6 +55,25 @@ const struct option_format alter_database_option_formats[] = {
{ "connection_limit", " CONNECTION_LIMIT %d", OPTION_FORMAT_INTEGER },
};
const struct option_format create_database_option_formats[] = {
{ "owner", " OWNER %s", OPTION_FORMAT_STRING },
{ "template", " TEMPLATE %s", OPTION_FORMAT_STRING },
{ "encoding", " ENCODING %s", OPTION_FORMAT_LITERAL_CSTR },
{ "strategy", " STRATEGY %s", OPTION_FORMAT_LITERAL_CSTR },
{ "locale", " LOCALE %s", OPTION_FORMAT_LITERAL_CSTR },
{ "lc_collate", " LC_COLLATE %s", OPTION_FORMAT_LITERAL_CSTR },
{ "lc_ctype", " LC_CTYPE %s", OPTION_FORMAT_LITERAL_CSTR },
{ "icu_locale", " ICU_LOCALE %s", OPTION_FORMAT_LITERAL_CSTR },
{ "icu_rules", " ICU_RULES %s", OPTION_FORMAT_LITERAL_CSTR },
{ "locale_provider", " LOCALE_PROVIDER %s", OPTION_FORMAT_LITERAL_CSTR },
{ "collation_version", " COLLATION_VERSION %s", OPTION_FORMAT_LITERAL_CSTR },
{ "tablespace", " TABLESPACE %s", OPTION_FORMAT_STRING },
{ "allow_connections", " ALLOW_CONNECTIONS %s", OPTION_FORMAT_BOOLEAN },
{ "connection_limit", " CONNECTION LIMIT %d", OPTION_FORMAT_INTEGER },
{ "is_template", " IS_TEMPLATE %s", OPTION_FORMAT_BOOLEAN },
{ "oid", " OID %d", OPTION_FORMAT_OBJECT_ID }
};
char *
DeparseAlterDatabaseOwnerStmt(Node *node)
{

View File

@ -245,6 +245,7 @@ extern List * PreprocessAlterDatabaseRenameStmt(Node *node, const char *queryStr
ProcessUtilityContext
processUtilityContext);
/* domain.c - forward declarations */
extern List * CreateDomainStmtObjectAddress(Node *node, bool missing_ok, bool
isPostprocess);

View File

@ -255,6 +255,7 @@ extern char * DeparseDropDatabaseStmt(Node *node);
extern char * DeparseAlterDatabaseRenameStmt(Node *node);
/* forward declaration for deparse_publication_stmts.c */
extern char * DeparseCreatePublicationStmt(Node *stmt);
extern char * DeparseCreatePublicationStmtExtended(Node *node,

View File

@ -152,6 +152,7 @@ DEPS = {
worker_count=6,
),
"function_propagation": TestDeps("minimal_schedule"),
"citus_shards": TestDeps("minimal_schedule"),
"grant_on_foreign_server_propagation": TestDeps("minimal_schedule"),
"multi_modifying_xacts": TestDeps("minimal_schedule"),
"multi_mx_modifying_xacts": TestDeps(None, ["multi_mx_create_table"]),

View File

@ -0,0 +1,37 @@
CREATE SCHEMA citus_shards;
SET search_path TO citus_shards;
SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 1;
SET citus.next_shard_id TO 99456900;
ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 456900;
CREATE TABLE t1 (i int);
SELECT create_distributed_table('t1', 'i');
create_distributed_table
---------------------------------------------------------------------
(1 row)
CREATE TABLE "t with space" (i int);
SELECT create_distributed_table('"t with space"', 'i');
create_distributed_table
---------------------------------------------------------------------
(1 row)
INSERT INTO t1 SELECT generate_series(1, 100);
INSERT INTO "t with space" SELECT generate_series(1, 1000);
SELECT * FROM citus_shards;
table_name | shardid | shard_name | citus_table_type | colocation_id | nodename | nodeport | shard_size
---------------------------------------------------------------------
"t with space" | 99456904 | citus_shards."t with space_99456904" | distributed | 456900 | localhost | 57637 | 40960
"t with space" | 99456905 | citus_shards."t with space_99456905" | distributed | 456900 | localhost | 57638 | 40960
"t with space" | 99456906 | citus_shards."t with space_99456906" | distributed | 456900 | localhost | 57637 | 40960
"t with space" | 99456907 | citus_shards."t with space_99456907" | distributed | 456900 | localhost | 57638 | 40960
t1 | 99456900 | citus_shards.t1_99456900 | distributed | 456900 | localhost | 57637 | 8192
t1 | 99456901 | citus_shards.t1_99456901 | distributed | 456900 | localhost | 57638 | 8192
t1 | 99456902 | citus_shards.t1_99456902 | distributed | 456900 | localhost | 57637 | 8192
t1 | 99456903 | citus_shards.t1_99456903 | distributed | 456900 | localhost | 57638 | 8192
(8 rows)
SET client_min_messages TO WARNING;
DROP SCHEMA citus_shards CASCADE;

View File

@ -54,6 +54,9 @@ test: grant_on_database_propagation
test: alter_database_propagation
test: create_drop_database_propagation
test: citus_shards
# ----------
# multi_citus_tools tests utility functions written for citus tools
# ----------

View File

@ -0,0 +1,17 @@
CREATE SCHEMA citus_shards;
SET search_path TO citus_shards;
SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 1;
SET citus.next_shard_id TO 99456900;
ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 456900;
CREATE TABLE t1 (i int);
SELECT create_distributed_table('t1', 'i');
CREATE TABLE "t with space" (i int);
SELECT create_distributed_table('"t with space"', 'i');
INSERT INTO t1 SELECT generate_series(1, 100);
INSERT INTO "t with space" SELECT generate_series(1, 1000);
SELECT * FROM citus_shards;
SET client_min_messages TO WARNING;
DROP SCHEMA citus_shards CASCADE;