From 70223448706dc370d22ae0388737a90345374a9b Mon Sep 17 00:00:00 2001 From: gindibay Date: Mon, 9 Oct 2023 15:14:13 +0300 Subject: [PATCH] Adds missing types --- .../distributed/deparser/citus_deparseutils.c | 10 +++++ .../deparser/deparse_database_stmts.c | 38 ++++++++++--------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/backend/distributed/deparser/citus_deparseutils.c b/src/backend/distributed/deparser/citus_deparseutils.c index 9e65f5700..546360fdf 100644 --- a/src/backend/distributed/deparser/citus_deparseutils.c +++ b/src/backend/distributed/deparser/citus_deparseutils.c @@ -35,6 +35,16 @@ handleOption(StringInfo buf, DefElem *option, const struct option_format *opt_fo bool value = defGetBoolean(option); appendStringInfo(buf, opt_formats[i].format, value ? "true" : "false"); } + else if (strcmp(opt_formats[i].type, "object_id") == 0) + { + Oid value = defGetObjectId(option); + appendStringInfo(buf, opt_formats[i].format, value ); + } + else if (strcmp(opt_formats[i].type, "literal_cstr") == 0) + { + char *value = defGetString(option); + appendStringInfo(buf, opt_formats[i].format, quote_literal_cstr(value) ); + } else { elog(ERROR, "unrecognized option type: %s", opt_formats[i].type); diff --git a/src/backend/distributed/deparser/deparse_database_stmts.c b/src/backend/distributed/deparser/deparse_database_stmts.c index 094c6fc1e..bc5d48f36 100644 --- a/src/backend/distributed/deparser/deparse_database_stmts.c +++ b/src/backend/distributed/deparser/deparse_database_stmts.c @@ -30,6 +30,25 @@ static void AppendAlterDatabaseOwnerStmt(StringInfo buf, AlterOwnerStmt *stmt); static void AppendAlterDatabaseStmt(StringInfo buf, AlterDatabaseStmt *stmt); static void AppendDefElemConnLimit(StringInfo buf, DefElem *def); +const struct option_format create_database_option_formats[] = { + { "template", " TEMPLATE %s", "string" }, + { "owner", " OWNER %s", "string" }, + { "tablespace", " TABLESPACE %s", "string" }, + { "connection_limit", " CONNECTION LIMIT %d", "integer" }, + { "encoding", " ENCODING %s", "literal_cstr" }, + { "locale", " LOCALE %s", "literal_cstr" }, + { "lc_collate", " LC_COLLATE %s", "literal_cstr" }, + { "lc_ctype", " LC_CTYPE %s", "literal_cstr" }, + { "icu_locale", " ICU_LOCALE %s", "literal_cstr" }, + { "icu_rules", " ICU_RULES %s", "literal_cstr" }, + { "locale_provider", " LOCALE_PROVIDER %s", "literal_cstr" }, + { "is_template", " IS_TEMPLATE %s", "boolean" }, + { "allow_connections", " ALLOW_CONNECTIONS %s", "boolean" }, + { "collation_version", " COLLATION_VERSION %s", "literal_cstr" }, + { "strategy", " STRATEGY %s", "literal_cstr" }, + { "oid", " OID %d", "object_id" }, +}; + char * DeparseAlterDatabaseOwnerStmt(Node *node) { @@ -207,22 +226,6 @@ DeparseAlterDatabaseSetStmt(Node *node) } -const struct option_format option_formats[] = { - { "template", " TEMPLATE %s", "string" }, - { "owner", " OWNER %s", "string" }, - { "tablespace", " TABLESPACE %s", "string" }, - { "connection_limit", " CONNECTION LIMIT %d", "integer" }, - { "encoding", " ENCODING %s", "string" }, - { "lc_collate", " LC_COLLATE %s", "string" }, - { "lc_ctype", " LC_CTYPE %s", "string" }, - { "icu_locale", " ICU_LOCALE %s", "string" }, - { "icu_rules", " ICU_RULES %s", "string" }, - { "locale_provider", " LOCALE_PROVIDER %s", "string" }, - { "is_template", " IS_TEMPLATE %s", "boolean" }, - { "allow_connections", " ALLOW_CONNECTIONS %s", "boolean" }, -}; - - static void AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt) { @@ -234,7 +237,8 @@ AppendCreateDatabaseStmt(StringInfo buf, CreatedbStmt *stmt) foreach_ptr(option, stmt->options) { - handleOption(buf, option, option_formats, lengthof(option_formats)); + handleOption(buf, option, create_database_option_formats, lengthof( + create_database_option_formats)); } }