From a927aed87c5a66f8e6ca51d7c89837c41e913307 Mon Sep 17 00:00:00 2001 From: Ajin Cherian Date: Wed, 22 Mar 2023 23:24:52 -0400 Subject: [PATCH v82 6/8] Support DDL replication. To support DDL replication, we use event trigger and DDL deparsing facilities. During CREATE PUBLICATION we register a command end trigger that deparses the DDL (if the DDL is annotated as ddlreplok for DDL replication in cmdtaglist.h) as a JSON blob, and WAL logs it. The event trigger is automatically removed at the time of DROP PUBLICATION. The WALSender decodes the WAL and sends it downstream similar to other DML commands. The subscriber then converts JSON back to the DDL command string and executes it. In the subscriber, we also add the newly added rel to pg_subscription_rel so that the DML changes on the new table can be replicated without having to manually run "ALTER SUBSCRIPTION ... REFRESH PUBLICATION". - For non-rewrite ALTER object command and - CREATE object command: we deparse the command at ddl_command_end event trigger and WAL log the deparsed json string. The WALSender decodes the WAL and sends it to subscriber if the created/altered table is published. It supports most of ALTER TABLE command except some commands(DDL related to PARTITIONED TABLE ...) that introduced recently which haven't been supported by the current ddl_deparser, we will support that later. - For DROP object: The 'command start' event handler logs a ddl message with the relids of the tables that are dropped which the output plugin (pgoutput) stores in its internal data structure after verifying that it is for a table that is part of the publication. Later the 'command end' event handler sends the actual drop message. Pgoutput on receiving the command end, only sends out the drop command only if it is for one of the relids marked for deleting. The reason we have to do this is because, once the logical decoder receives the 'command end' message, the relid of the table is no longer valid as it has been deleted as part of invalidations received for the drop table command. It is no longer possible to verify if the table is part of the publication list or not. To make this possible, I have added two more elements to the ddl xlog and ddl message, (relid and cmdtype). We could have also handled all this on the subscriber side as well, but that would mean sending spurious ddl messages for tables that are not part of the publication. - For table_rewrite ALTER TABLE command: (ALTER COLUMN TYPE, ADD COLUMN DEFAULT, SET LOGGED, SET ACCESS METHOD) we deparse the command and WAL log the deparsed json string at table_rewrite event trigger. The WALSender decodes the WAL and sends it to subscriber if the altered table is published. Then, the WALSender will convert the upcoming rewrite INSERTs to UPDATEs and send them to subscriber so that the data between publisher and subscriber can always be consistent. Note that the tables that publish rewrite ddl must have a replica identity configured in order to be able to replicate the upcoming rewrite UPDATEs. We do this way because of two reason: (1) The data before the rewrite ddl could already be different among publisher and subscriber. To make sure the extra data in subscriber which doesn't exist in publisher also get rewritten, we need to let the subscriber execute the original rewrite ddl to rewrite all the data at first. (2) the data after executing rewrite ddl could be different among publisher and subscriber(due to different functions/operators used during rewrite), so we need to replicate the rewrite UPDATEs to keep the data consistent. TO IMPROVE: This approach could be improved by letting the subscriber try to update the extra data itself instead of doing fully rewrite ddl and use the upcoming rewrite UPDATEs to rewrite the rest data. To achieve this, we could modify the deparsed json string to temporarily remove the rewrite part and add some logic in subscriber to update the extra data. Besides, we may not need to send rewrite changes for all type of rewrite ddl, for example, it seems fine to skip sending rewrite changes for ALTER TABLE SET LOGGED as the data in the table doesn't actually be changed. We could use the deparser and event trigger to filter these ddls and skip sending rewrite changes for them. --- src/backend/catalog/pg_publication.c | 2 + src/backend/commands/createas.c | 10 + src/backend/commands/event_trigger.c | 310 +++++++- src/backend/commands/publicationcmds.c | 251 +++++- src/backend/commands/tablecmds.c | 10 +- src/backend/parser/parse_utilcmd.c | 1 + src/backend/replication/logical/Makefile | 1 + src/backend/replication/logical/ddltrigger.c | 365 +++++++++ src/backend/replication/logical/logical.c | 49 ++ src/backend/replication/logical/meson.build | 1 + src/backend/replication/logical/proto.c | 43 ++ src/backend/replication/logical/reorderbuffer.c | 20 +- src/backend/replication/logical/worker.c | 240 ++++++ src/backend/replication/pgoutput/pgoutput.c | 191 ++++- src/backend/tcop/cmdtag.c | 26 +- src/backend/tcop/utility.c | 9 +- src/backend/utils/cache/evtcache.c | 2 + src/backend/utils/cache/relcache.c | 2 + src/bin/pg_dump/pg_dump.c | 90 ++- src/bin/pg_dump/pg_dump.h | 2 + src/bin/pg_dump/t/002_pg_dump.pl | 2 +- src/bin/psql/describe.c | 44 +- src/include/catalog/pg_proc.dat | 12 + src/include/catalog/pg_publication.h | 17 + src/include/commands/event_trigger.h | 14 +- src/include/replication/logicalproto.h | 4 + src/include/replication/output_plugin.h | 15 +- src/include/replication/pgoutput.h | 1 + src/include/replication/reorderbuffer.h | 12 + src/include/tcop/cmdtag.h | 4 +- src/include/tcop/cmdtaglist.h | 386 +++++----- src/include/tcop/deparse_utility.h | 1 + src/include/utils/evtcache.h | 3 +- .../test_ddl_deparse_regress/regression.diffs | 847 --------------------- .../test_ddl_deparse_regress/regression.out | 7 - src/test/regress/expected/psql.out | 6 +- src/test/regress/expected/publication.out | 420 +++++----- src/test/subscription/t/032_ddl_replication.pl | 465 +++++++++++ src/tools/pgindent/typedefs.list | 6 + 39 files changed, 2550 insertions(+), 1341 deletions(-) create mode 100644 src/backend/replication/logical/ddltrigger.c delete mode 100644 src/test/modules/test_ddl_deparse_regress/regression.diffs delete mode 100644 src/test/modules/test_ddl_deparse_regress/regression.out create mode 100644 src/test/subscription/t/032_ddl_replication.pl diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index a98fcad..c505f24 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -1005,6 +1005,8 @@ GetPublication(Oid pubid) pub->pubactions.pubupdate = pubform->pubupdate; pub->pubactions.pubdelete = pubform->pubdelete; pub->pubactions.pubtruncate = pubform->pubtruncate; + pub->pubactions.pubddl_all = pubform->pubddl_all; + pub->pubactions.pubddl_table = pubform->pubddl_table; pub->pubviaroot = pubform->pubviaroot; ReleaseSysCache(tup); diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c index d6c6d51..77dcb9c9 100644 --- a/src/backend/commands/createas.c +++ b/src/backend/commands/createas.c @@ -34,6 +34,7 @@ #include "catalog/namespace.h" #include "catalog/toasting.h" #include "commands/createas.h" +#include "commands/event_trigger.h" #include "commands/matview.h" #include "commands/prepare.h" #include "commands/tablecmds.h" @@ -143,6 +144,15 @@ create_ctas_internal(List *attrList, IntoClause *into) StoreViewQuery(intoRelationAddr.objectId, query, false); CommandCounterIncrement(); } + else + { + /* + * Fire the trigger for table_init_write after creating the table so + * that we can access the catalog info about the newly created table + * in the trigger function. + */ + EventTriggerTableInitWrite((Node *) create, intoRelationAddr); + } return intoRelationAddr; } diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index 1928e59..b3f6849 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -36,9 +36,13 @@ #include "lib/ilist.h" #include "miscadmin.h" #include "parser/parse_func.h" +#include "parser/parser.h" #include "pgstat.h" +#include "replication/ddlmessage.h" +#include "replication/message.h" #include "tcop/deparse_utility.h" #include "tcop/utility.h" +#include "tcop/ddl_deparse.h" #include "utils/acl.h" #include "utils/builtins.h" #include "utils/evtcache.h" @@ -92,7 +96,8 @@ CreateEventTrigger(CreateEventTrigStmt *stmt) if (strcmp(stmt->eventname, "ddl_command_start") != 0 && strcmp(stmt->eventname, "ddl_command_end") != 0 && strcmp(stmt->eventname, "sql_drop") != 0 && - strcmp(stmt->eventname, "table_rewrite") != 0) + strcmp(stmt->eventname, "table_rewrite") != 0 && + strcmp(stmt->eventname, "table_init_write") != 0) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("unrecognized event name \"%s\"", @@ -118,7 +123,8 @@ CreateEventTrigger(CreateEventTrigStmt *stmt) /* Validate tag list, if any. */ if ((strcmp(stmt->eventname, "ddl_command_start") == 0 || strcmp(stmt->eventname, "ddl_command_end") == 0 || - strcmp(stmt->eventname, "sql_drop") == 0) + strcmp(stmt->eventname, "sql_drop") == 0 || + strcmp(stmt->eventname, "table_init_write") == 0) && tags != NULL) validate_ddl_tags("tag", tags); else if (strcmp(stmt->eventname, "table_rewrite") == 0 @@ -522,6 +528,7 @@ EventTriggerCommonSetup(Node *parsetree, List *cachelist; ListCell *lc; List *runlist = NIL; + int pub_deparse_func_cnt = 0; /* * We want the list of command tags for which this procedure is actually @@ -544,7 +551,8 @@ EventTriggerCommonSetup(Node *parsetree, dbgtag = CreateCommandTag(parsetree); if (event == EVT_DDLCommandStart || event == EVT_DDLCommandEnd || - event == EVT_SQLDrop) + event == EVT_SQLDrop || + event == EVT_TableInitWrite) { if (!command_tag_event_trigger_ok(dbgtag)) elog(ERROR, "unexpected command tag \"%s\"", GetCommandTagName(dbgtag)); @@ -571,6 +579,12 @@ EventTriggerCommonSetup(Node *parsetree, * once we do anything at all that touches the catalogs, an invalidation * might leave cachelist pointing at garbage, so we must do this before we * can do much else. + * + * Special handling for event triggers created as part of publications. + * If there are multiple publications which publish ddls, only one set of the + * event trigger functions need to be invoked. The ddl deparse event triggers + * write to WAL, so no need to duplicate it as all walsenders will read the same + * WAL. */ foreach(lc, cachelist) { @@ -578,8 +592,25 @@ EventTriggerCommonSetup(Node *parsetree, if (filter_event_trigger(tag, item)) { - /* We must plan to fire this trigger. */ - runlist = lappend_oid(runlist, item->fnoid); + static const char *trigger_func_prefix = "publication_deparse_%s"; + char trigger_func_name[NAMEDATALEN]; + Oid pub_funcoid; + List *pubfuncname; + + /* Get function oid of the publication's ddl deparse event trigger */ + snprintf(trigger_func_name, sizeof(trigger_func_name), trigger_func_prefix, + eventstr); + pubfuncname = SystemFuncName(trigger_func_name); + pub_funcoid = LookupFuncName(pubfuncname, 0, NULL, true); + + if (item->fnoid != pub_funcoid) + runlist = lappend_oid(runlist, item->fnoid); + else + { + /* Only the first ddl deparse event trigger needs to be invoked */ + if (pub_deparse_func_cnt++ == 0) + runlist = lappend_oid(runlist, item->fnoid); + } } } @@ -827,6 +858,141 @@ EventTriggerTableRewrite(Node *parsetree, Oid tableOid, int reason) CommandCounterIncrement(); } + +/* + * EventTriggerTableInitWriteStart + * Prepare to receive data on an CREATE TABLE AS/SELET INTO command about + * to be executed. + */ +void +EventTriggerTableInitWriteStart(Node *parsetree) +{ + MemoryContext oldcxt; + CollectedCommand *command; + CreateTableAsStmt *stmt = (CreateTableAsStmt *)parsetree; + + /* ignore if event trigger context not set, or collection disabled */ + if (!currentEventTriggerState || + currentEventTriggerState->commandCollectionInhibited) + return; + + oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt); + + command = palloc(sizeof(CollectedCommand)); + + command->type = (stmt->objtype == OBJECT_TABLE) ? SCT_CreateTableAs : SCT_Simple; + command->in_extension = creating_extension; + command->d.ctas.address = InvalidObjectAddress; + command->d.ctas.real_create = NULL; + command->parsetree = copyObject(parsetree); + + command->parent = currentEventTriggerState->currentCommand; + currentEventTriggerState->currentCommand = command; + + MemoryContextSwitchTo(oldcxt); +} + +/* + * EventTriggerTableInitWriteEnd + * Finish up saving an CREATE TABLE AS/SELECT INTO command. + * + * FIXME this API isn't considering the possibility that an xact/subxact is + * aborted partway through. Probably it's best to add an + * AtEOSubXact_EventTriggers() to fix this. + */ +void +EventTriggerTableInitWriteEnd(ObjectAddress address) +{ + CollectedCommand *parent; + CreateTableAsStmt *stmt; + + /* ignore if event trigger context not set, or collection disabled */ + if (!currentEventTriggerState || + currentEventTriggerState->commandCollectionInhibited) + return; + + stmt = (CreateTableAsStmt *)currentEventTriggerState->currentCommand->parsetree; + + if (stmt->objtype == OBJECT_TABLE) + { + parent = currentEventTriggerState->currentCommand->parent; + + pfree(currentEventTriggerState->currentCommand); + + currentEventTriggerState->currentCommand = parent; + } + else + { + MemoryContext oldcxt; + + oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt); + + currentEventTriggerState->currentCommand->d.simple.address = address; + currentEventTriggerState->commandList = + lappend(currentEventTriggerState->commandList, + currentEventTriggerState->currentCommand); + + MemoryContextSwitchTo(oldcxt); + } +} + +/* + * Fire table_init_rewrite triggers. + */ +void +EventTriggerTableInitWrite(Node *real_create, ObjectAddress address) +{ + List *runlist; + EventTriggerData trigdata; + CollectedCommand *command; + + /* + * See EventTriggerDDLCommandStart for a discussion about why event + * triggers are disabled in single user mode. + */ + if (!IsUnderPostmaster) + return; + + /* + * Also do nothing if our state isn't set up, which it won't be if there + * weren't any relevant event triggers at the start of the current DDL + * command. This test might therefore seem optional, but it's + * *necessary*, because EventTriggerCommonSetup might find triggers that + * didn't exist at the time the command started. + */ + if (!currentEventTriggerState) + return; + + /* Do nothing if no command was collected. */ + if (!currentEventTriggerState->currentCommand) + return; + + command = currentEventTriggerState->currentCommand; + + runlist = EventTriggerCommonSetup(command->parsetree, + EVT_TableInitWrite, + "table_init_write", + &trigdata); + if (runlist == NIL) + return; + + /* Set the real CreateTable statment and object address */ + command->d.ctas.real_create = real_create; + command->d.ctas.address = address; + + /* Run the triggers. */ + EventTriggerInvoke(runlist, &trigdata); + + /* Cleanup. */ + list_free(runlist); + + /* + * Make sure anything the event triggers did will be visible to the main + * command. + */ + CommandCounterIncrement(); +} + /* * Invoke each event trigger in a list of event triggers. */ @@ -1108,7 +1274,8 @@ trackDroppedObjectsNeeded(void) */ return (EventCacheLookup(EVT_SQLDrop) != NIL) || (EventCacheLookup(EVT_TableRewrite) != NIL) || - (EventCacheLookup(EVT_DDLCommandEnd) != NIL); + (EventCacheLookup(EVT_DDLCommandEnd) != NIL) || + (EventCacheLookup(EVT_TableInitWrite) != NIL); } /* @@ -1499,6 +1666,7 @@ EventTriggerAlterTableStart(Node *parsetree) command->d.alterTable.classId = RelationRelationId; command->d.alterTable.objectId = InvalidOid; + command->d.alterTable.rewrite = false; command->d.alterTable.subcmds = NIL; command->parsetree = copyObject(parsetree); @@ -1532,7 +1700,7 @@ EventTriggerAlterTableRelid(Oid objectId) * internally, so that's all that this code needs to handle at the moment. */ void -EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address) +EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address, bool rewrite) { MemoryContext oldcxt; CollectedATSubcmd *newsub; @@ -1552,6 +1720,83 @@ EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address) newsub->address = address; newsub->parsetree = copyObject(subcmd); + currentEventTriggerState->currentCommand->d.alterTable.rewrite |= rewrite; + currentEventTriggerState->currentCommand->d.alterTable.subcmds = + lappend(currentEventTriggerState->currentCommand->d.alterTable.subcmds, newsub); + + MemoryContextSwitchTo(oldcxt); +} + +/* + * EventTriggerAlterTypeStart + * Save data about a single part of an ALTER TYPE. + * + * ALTER TABLE can have multiple subcommands which might include DROP COLUMN + * command and ALTER TYPE referring the drop column in USING expression. + * As the dropped column cannot be accessed after the execution of DROP COLUMN, + * a special trigger is required to handle this case before the drop column is + * executed. + */ +void +EventTriggerAlterTypeStart(AlterTableCmd *subcmd, Relation rel) +{ + MemoryContext oldcxt; + CollectedATSubcmd *newsub; + ColumnDef *def; + Relation attrelation; + HeapTuple heapTup; + Form_pg_attribute attTup; + AttrNumber attnum; + ObjectAddress address; + + /* ignore if event trigger context not set, or collection disabled */ + if (!currentEventTriggerState || + currentEventTriggerState->commandCollectionInhibited) + return; + + Assert(IsA(subcmd, AlterTableCmd)); + Assert(subcmd->subtype == AT_AlterColumnType); + Assert(currentEventTriggerState->currentCommand != NULL); + Assert(OidIsValid(currentEventTriggerState->currentCommand->d.alterTable.objectId)); + + def = (ColumnDef *) subcmd->def; + Assert(IsA(def, ColumnDef)); + + oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt); + + newsub = palloc(sizeof(CollectedATSubcmd)); + newsub->parsetree = (Node *)copyObject(subcmd); + + attrelation = table_open(AttributeRelationId, RowExclusiveLock); + + /* Look up the target column */ + heapTup = SearchSysCacheCopyAttName(RelationGetRelid(rel), subcmd->name); + if (!HeapTupleIsValid(heapTup)) /* shouldn't happen */ + ereport(ERROR, + errcode(ERRCODE_UNDEFINED_COLUMN), + errmsg("column \"%s\" of relation \"%s\" does not exist", + subcmd->name, RelationGetRelationName(rel))); + attTup = (Form_pg_attribute) GETSTRUCT(heapTup); + attnum = attTup->attnum; + + ObjectAddressSubSet(address, RelationRelationId, + RelationGetRelid(rel), attnum); + heap_freetuple(heapTup); + table_close(attrelation, RowExclusiveLock); + newsub->address = address; + + if (def->raw_default) + { + char *defexpr; + + defexpr = nodeToString(def->cooked_default); + newsub->usingexpr = TextDatumGetCString(DirectFunctionCall2(pg_get_expr, + CStringGetTextDatum(defexpr), + RelationGetRelid(rel))); + } + else + newsub->usingexpr = NULL; + currentEventTriggerState->currentCommand->d.alterTable.subcmds = lappend(currentEventTriggerState->currentCommand->d.alterTable.subcmds, newsub); @@ -1559,6 +1804,57 @@ EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address) } /* + * EventTriggerAlterTypeEnd + * Finish up saving an ALTER TYPE command, and add it to command list. + */ +void +EventTriggerAlterTypeEnd(Node *subcmd, ObjectAddress address, bool rewrite) +{ + MemoryContext oldcxt; + CollectedATSubcmd *newsub; + ListCell *cell; + CollectedCommand *cmd; + AlterTableCmd *altsubcmd = (AlterTableCmd *)subcmd; + + /* ignore if event trigger context not set, or collection disabled */ + if (!currentEventTriggerState || + currentEventTriggerState->commandCollectionInhibited) + return; + + cmd = currentEventTriggerState->currentCommand; + + Assert(IsA(subcmd, AlterTableCmd)); + Assert(cmd != NULL); + Assert(OidIsValid(cmd->d.alterTable.objectId)); + + foreach(cell, cmd->d.alterTable.subcmds) + { + CollectedATSubcmd *sub = (CollectedATSubcmd *) lfirst(cell); + AlterTableCmd *collcmd = (AlterTableCmd *) sub->parsetree; + + if (collcmd->subtype == altsubcmd->subtype && + address.classId == sub->address.classId && + address.objectId == sub->address.objectId && + address.objectSubId == sub->address.objectSubId) + { + cmd->d.alterTable.rewrite |= rewrite; + return; + } + } + + oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt); + + newsub = palloc(sizeof(CollectedATSubcmd)); + newsub->address = address; + newsub->parsetree = copyObject(subcmd); + + cmd->d.alterTable.rewrite |= rewrite; + cmd->d.alterTable.subcmds = lappend(cmd->d.alterTable.subcmds, newsub); + + MemoryContextSwitchTo(oldcxt); +} + +/* * EventTriggerAlterTableEnd * Finish up saving an ALTER TABLE command, and add it to command list. * diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c index f4ba572..23add32 100644 --- a/src/backend/commands/publicationcmds.c +++ b/src/backend/commands/publicationcmds.c @@ -38,10 +38,12 @@ #include "commands/publicationcmds.h" #include "funcapi.h" #include "miscadmin.h" +#include "nodes/makefuncs.h" #include "nodes/nodeFuncs.h" #include "parser/parse_clause.h" #include "parser/parse_collate.h" #include "parser/parse_relation.h" +#include "parser/parser.h" #include "storage/lmgr.h" #include "utils/acl.h" #include "utils/array.h" @@ -82,21 +84,26 @@ static void PublicationDropSchemas(Oid pubid, List *schemas, bool missing_ok); static void parse_publication_options(ParseState *pstate, List *options, + bool for_all_tables, bool *publish_given, PublicationActions *pubactions, bool *publish_via_partition_root_given, - bool *publish_via_partition_root) + bool *publish_via_partition_root, + bool *ddl_type_given) { ListCell *lc; *publish_given = false; *publish_via_partition_root_given = false; + *ddl_type_given = false; /* defaults */ pubactions->pubinsert = true; pubactions->pubupdate = true; pubactions->pubdelete = true; pubactions->pubtruncate = true; + pubactions->pubddl_all = false; + pubactions->pubddl_table = false; *publish_via_partition_root = false; /* Parse options */ @@ -123,7 +130,7 @@ parse_publication_options(ParseState *pstate, pubactions->pubtruncate = false; *publish_given = true; - publish = defGetString(defel); + publish = pstrdup(defGetString(defel)); if (!SplitIdentifierString(publish, ',', &publish_list)) ereport(ERROR, @@ -158,6 +165,52 @@ parse_publication_options(ParseState *pstate, *publish_via_partition_root_given = true; *publish_via_partition_root = defGetBoolean(defel); } + else if (strcmp(defel->defname, "ddl") == 0) + { + char *ddl_level; + List *ddl_list; + ListCell *lc3; + + if (*ddl_type_given) + errorConflictingDefElem(defel, pstate); + + if (!for_all_tables) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("DDL replication is only supported in FOR ALL TABLES publication"))); + /* + * If ddl option was given only the explicitly listed ddl types + * should be published. + */ + pubactions->pubddl_all = false; + pubactions->pubddl_table = false; + + *ddl_type_given = true; + ddl_level = defGetString(defel); + + if (!SplitIdentifierString(ddl_level, ',', &ddl_list)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid list syntax for \"ddl\" option"))); + + /* Process the option list. */ + foreach(lc3, ddl_list) + { + char *publish_opt = (char *) lfirst(lc3); + + if (strcmp(publish_opt, "all") == 0) + { + pubactions->pubddl_all = true; + pubactions->pubddl_table = true; + } + else if (strcmp(publish_opt, "table") == 0) + pubactions->pubddl_table = true; + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("unrecognized \"ddl\" value: \"%s\"", publish_opt))); + } + } else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -600,13 +653,56 @@ check_simple_rowfilter_expr(Node *node, ParseState *pstate) } /* + * Helper function to tranform a where clause. + * + * Also check the publication row filter expression and throw an error if + * anything not permitted or unexpected is encountered. + */ +static Node * +GetTransformWhereClauses(const char *queryString, Relation relation, + Node *whereClause, bool check_expr) +{ + Node *transformedWhereClause = NULL; + ParseNamespaceItem *nsitem; + ParseState *pstate; + + /* + * A fresh pstate is required so that we only have "this" table in its + * rangetable + */ + pstate = make_parsestate(NULL); + pstate->p_sourcetext = queryString; + nsitem = addRangeTableEntryForRelation(pstate, relation, + AccessShareLock, NULL, + false, false); + addNSItemToQuery(pstate, nsitem, false, true, true); + + transformedWhereClause = transformWhereClause(pstate, + copyObject(whereClause), + EXPR_KIND_WHERE, + "PUBLICATION WHERE"); + + /* Fix up collation information */ + assign_expr_collations(pstate, transformedWhereClause); + + /* + * We allow only simple expressions in row filters. See + * check_simple_rowfilter_expr_walker. + */ + if (check_expr) + check_simple_rowfilter_expr(transformedWhereClause, pstate); + + free_parsestate(pstate); + + return transformedWhereClause; +} + +/* * Transform the publication WHERE expression for all the relations in the list, * ensuring it is coerced to boolean and necessary collation information is * added if required, and add a new nsitem/RTE for the associated relation to * the ParseState's namespace list. * - * Also check the publication row filter expression and throw an error if - * anything not permitted or unexpected is encountered. */ static void TransformPubWhereClauses(List *tables, const char *queryString, @@ -616,9 +712,7 @@ TransformPubWhereClauses(List *tables, const char *queryString, foreach(lc, tables) { - ParseNamespaceItem *nsitem; - Node *whereclause = NULL; - ParseState *pstate; + PublicationRelInfo *pri = (PublicationRelInfo *) lfirst(lc); if (pri->whereClause == NULL) @@ -638,38 +732,11 @@ TransformPubWhereClauses(List *tables, const char *queryString, errdetail("WHERE clause cannot be used for a partitioned table when %s is false.", "publish_via_partition_root"))); - /* - * A fresh pstate is required so that we only have "this" table in its - * rangetable - */ - pstate = make_parsestate(NULL); - pstate->p_sourcetext = queryString; - nsitem = addRangeTableEntryForRelation(pstate, pri->relation, - AccessShareLock, NULL, - false, false); - addNSItemToQuery(pstate, nsitem, false, true, true); - - whereclause = transformWhereClause(pstate, - copyObject(pri->whereClause), - EXPR_KIND_WHERE, - "PUBLICATION WHERE"); - - /* Fix up collation information */ - assign_expr_collations(pstate, whereclause); - - /* - * We allow only simple expressions in row filters. See - * check_simple_rowfilter_expr_walker. - */ - check_simple_rowfilter_expr(whereclause, pstate); - - free_parsestate(pstate); - - pri->whereClause = whereclause; + pri->whereClause = GetTransformWhereClauses(queryString, pri->relation, + pri->whereClause, true); } } - /* * Given a list of tables that are going to be added to a publication, * verify that they fulfill the necessary preconditions, namely: no tables @@ -729,6 +796,52 @@ CheckPubRelationColumnList(char *pubname, List *tables, } /* + * Create event trigger which is used for DDL replication. + */ +static void +CreateDDLReplicaEventTrigger(char *eventname, CommandTag *commands, + int ncommands, ObjectAddress pubaddress, + Oid puboid) +{ + int i; + List *tags = NIL; + Oid trigger_id; + ObjectAddress referenced; + CreateEventTrigStmt *ddl_trigger; + char trigger_name[NAMEDATALEN]; + char trigger_func_name[NAMEDATALEN]; + static const char *trigger_func_prefix = "publication_deparse_%s"; + + ddl_trigger = makeNode(CreateEventTrigStmt); + + snprintf(trigger_name, sizeof(trigger_name), PUB_EVENT_TRIG_PREFIX, + eventname, puboid); + snprintf(trigger_func_name, sizeof(trigger_func_name), trigger_func_prefix, + eventname); + + ddl_trigger->trigname = pstrdup(trigger_name); + ddl_trigger->eventname = eventname; + ddl_trigger->funcname = SystemFuncName(trigger_func_name); + + for (i = 0; i < ncommands; i++) + { + String *tag = makeString(pstrdup(GetCommandTagName(commands[i]))); + + tags = lappend(tags, tag); + } + + ddl_trigger->whenclause = list_make1(makeDefElem("tag", (Node *) tags, -1)); + + trigger_id = CreateEventTrigger(ddl_trigger); + + /* + * Register the event triggers as internally dependent on the publication. + */ + ObjectAddressSet(referenced, EventTriggerRelationId, trigger_id); + recordDependencyOn(&referenced, &pubaddress, DEPENDENCY_INTERNAL); +} + +/* * Create new publication. */ ObjectAddress @@ -741,6 +854,7 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt) Datum values[Natts_pg_publication]; HeapTuple tup; bool publish_given; + bool ddl_type_given; PublicationActions pubactions; bool publish_via_partition_root_given; bool publish_via_partition_root; @@ -781,9 +895,11 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt) parse_publication_options(pstate, stmt->options, + stmt->for_all_tables, &publish_given, &pubactions, &publish_via_partition_root_given, - &publish_via_partition_root); + &publish_via_partition_root, + &ddl_type_given); puboid = GetNewOidWithIndex(rel, PublicationObjectIndexId, Anum_pg_publication_oid); @@ -798,6 +914,10 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt) BoolGetDatum(pubactions.pubdelete); values[Anum_pg_publication_pubtruncate - 1] = BoolGetDatum(pubactions.pubtruncate); + values[Anum_pg_publication_pubddl_all - 1] = + BoolGetDatum(pubactions.pubddl_all); + values[Anum_pg_publication_pubddl_table - 1] = + BoolGetDatum(pubactions.pubddl_table); values[Anum_pg_publication_pubviaroot - 1] = BoolGetDatum(publish_via_partition_root); @@ -858,6 +978,50 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt) } } + /* + * Create an event trigger to allow logging of DDL statements. + * + */ + if (pubactions.pubddl_table || pubactions.pubddl_all) + { + CommandTag start_commands[] = {CMDTAG_DROP_TABLE}; + CommandTag rewrite_commands[] = {CMDTAG_ALTER_TABLE}; + CommandTag init_commands[] = { + CMDTAG_CREATE_TABLE_AS, + CMDTAG_SELECT_INTO + }; + int ncommands = 0; + CommandTag *end_commands = NULL; + + if (pubactions.pubddl_all) + end_commands = GetCommandTagsForDDLRepl(&ncommands); + else if (pubactions.pubddl_table) + { + ncommands = 3; + end_commands = palloc0(ncommands * sizeof(CommandTag)); + end_commands[0] = CMDTAG_CREATE_TABLE; + end_commands[1] = CMDTAG_ALTER_TABLE; + end_commands[2] = CMDTAG_DROP_TABLE; + } + + /* Create the ddl_command_end event trigger */ + CreateDDLReplicaEventTrigger(PUB_TRIG_EVENT1, end_commands, + ncommands, myself, puboid); + pfree(end_commands); + + /* Create the ddl_command_start event trigger */ + CreateDDLReplicaEventTrigger(PUB_TRIG_EVENT2, start_commands, + lengthof(start_commands), myself, puboid); + + /* Create the table_rewrite event trigger */ + CreateDDLReplicaEventTrigger(PUB_TRIG_EVENT3, rewrite_commands, + lengthof(rewrite_commands), myself, puboid); + + /* Create the table_init_write event trigger */ + CreateDDLReplicaEventTrigger(PUB_TRIG_EVENT4, init_commands, + lengthof(init_commands), myself, puboid); + } + table_close(rel, RowExclusiveLock); InvokeObjectPostCreateHook(PublicationRelationId, puboid, 0); @@ -882,6 +1046,7 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt, bool replaces[Natts_pg_publication]; Datum values[Natts_pg_publication]; bool publish_given; + bool ddl_type_given; PublicationActions pubactions; bool publish_via_partition_root_given; bool publish_via_partition_root; @@ -890,11 +1055,15 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt, List *root_relids = NIL; ListCell *lc; + pubform = (Form_pg_publication) GETSTRUCT(tup); + parse_publication_options(pstate, stmt->options, + pubform->puballtables, &publish_given, &pubactions, &publish_via_partition_root_given, - &publish_via_partition_root); + &publish_via_partition_root, + &ddl_type_given); pubform = (Form_pg_publication) GETSTRUCT(tup); @@ -996,6 +1165,12 @@ AlterPublicationOptions(ParseState *pstate, AlterPublicationStmt *stmt, values[Anum_pg_publication_pubtruncate - 1] = BoolGetDatum(pubactions.pubtruncate); replaces[Anum_pg_publication_pubtruncate - 1] = true; + + values[Anum_pg_publication_pubddl_all - 1] = BoolGetDatum(pubactions.pubddl_all); + replaces[Anum_pg_publication_pubddl_all - 1] = true; + + values[Anum_pg_publication_pubddl_table - 1] = BoolGetDatum(pubactions.pubddl_table); + replaces[Anum_pg_publication_pubddl_table - 1] = true; } if (publish_via_partition_root_given) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 3e2c5f7..84a038b 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -4718,6 +4718,9 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, cmd = ATParseTransformCmd(wqueue, tab, rel, cmd, recurse, lockmode, AT_PASS_UNSET, context); Assert(cmd != NULL); + + EventTriggerAlterTypeStart(cmd, rel); + /* Performs own recursion */ ATPrepAlterColumnType(wqueue, tab, rel, recurse, recursing, cmd, lockmode, context); @@ -4989,6 +4992,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, { ObjectAddress address = InvalidObjectAddress; Relation rel = tab->rel; + bool commandCollected = false; switch (cmd->subtype) { @@ -5112,6 +5116,8 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, case AT_AlterColumnType: /* ALTER COLUMN TYPE */ /* parse transformation was done earlier */ address = ATExecAlterColumnType(tab, rel, cmd, lockmode); + EventTriggerAlterTypeEnd((Node *) cmd, address, tab->rewrite); + commandCollected = true; break; case AT_AlterColumnGenericOptions: /* ALTER COLUMN OPTIONS */ address = @@ -5284,8 +5290,8 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, /* * Report the subcommand to interested event triggers. */ - if (cmd) - EventTriggerCollectAlterTableSubcmd((Node *) cmd, address); + if (cmd && !commandCollected) + EventTriggerCollectAlterTableSubcmd((Node *) cmd, address, tab->rewrite); /* * Bump the command counter to ensure the next subcommand in the sequence diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index f9218f4..8b53b43 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1392,6 +1392,7 @@ expandTableLikeClause(RangeVar *heapRel, TableLikeClause *table_like_clause) atcmd->cmds = atsubcmds; atcmd->objtype = OBJECT_TABLE; atcmd->missing_ok = false; + atcmd->table_like = true; result = lcons(atcmd, result); } diff --git a/src/backend/replication/logical/Makefile b/src/backend/replication/logical/Makefile index d3680e9..b79ddd8 100644 --- a/src/backend/replication/logical/Makefile +++ b/src/backend/replication/logical/Makefile @@ -17,6 +17,7 @@ override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) OBJS = \ applyparallelworker.o \ ddlmessage.o \ + ddltrigger.o \ decode.o \ launcher.o \ logical.o \ diff --git a/src/backend/replication/logical/ddltrigger.c b/src/backend/replication/logical/ddltrigger.c new file mode 100644 index 0000000..d68a507 --- /dev/null +++ b/src/backend/replication/logical/ddltrigger.c @@ -0,0 +1,365 @@ +/*------------------------------------------------------------------------- + * + * ddltrigger.c + * Logical DDL messages. + * + * Copyright (c) 2022, PostgreSQL Global Development Group + * + * IDENTIFICATION + * src/backend/replication/logical/ddltrigger.c + * + * NOTES + * + * Deparse the ddl command and log it. + * + * --------------------------------------------------------------------------- + */ + +#include "postgres.h" + +#include "access/table.h" +#include "catalog/pg_class.h" +#include "commands/event_trigger.h" +#include "funcapi.h" +#include "lib/ilist.h" +#include "replication/ddlmessage.h" +#include "tcop/ddl_deparse.h" +#include "utils/fmgrprotos.h" +#include "utils/lsyscache.h" + +extern EventTriggerQueryState *currentEventTriggerState; + +/* + * Deparse the ddl command and log it prior to + * execution. Currently only used for DROP TABLE command + * so that catalog can be accessed before being deleted. + * This is to check if the table is part of the publication + * or not. + */ +Datum +publication_deparse_ddl_command_start(PG_FUNCTION_ARGS) +{ + EventTriggerData *trigdata; + char *command = psprintf("Drop table command start"); + DropStmt *stmt; + ListCell *cell1; + + if (!CALLED_AS_EVENT_TRIGGER(fcinfo)) + elog(ERROR, "not fired by event trigger manager"); + + trigdata = (EventTriggerData *) fcinfo->context; + stmt = (DropStmt *) trigdata->parsetree; + + /* Extract the relid from the parse tree */ + foreach(cell1, stmt->objects) + { + char relpersist; + Node *object = lfirst(cell1); + ObjectAddress address; + Relation relation = NULL; + + address = get_object_address(stmt->removeType, + object, + &relation, + AccessExclusiveLock, + true); + + /* Object does not exist, nothing to do */ + if (!relation) + continue; + + relpersist = get_rel_persistence(address.objectId); + + /* + * Do not generate wal log for commands whose target table is a + * temporary table. + * + * We will generate wal logs for unlogged tables so that unlogged + * tables can also be created and altered on the subscriber side. This + * makes it possible to directly replay the SET LOGGED command and the + * incoming rewrite message without creating a new table. + */ + if (relpersist != RELPERSISTENCE_TEMP) + LogLogicalDDLMessage("deparse", address.objectId, DCT_TableDropStart, + command, strlen(command) + 1); + + if (relation) + table_close(relation, NoLock); + } + return PointerGetDatum(NULL); +} + +/* + * publication_deparse_table_rewrite + * + * Deparse the ddl table rewrite command and log it. + */ +Datum +publication_deparse_table_rewrite(PG_FUNCTION_ARGS) +{ + char relpersist; + CollectedCommand *cmd; + char *json_string; + + if (!CALLED_AS_EVENT_TRIGGER(fcinfo)) + elog(ERROR, "not fired by event trigger manager"); + + cmd = currentEventTriggerState->currentCommand; + + Assert(cmd && cmd->d.alterTable.rewrite); + + relpersist = get_rel_persistence(cmd->d.alterTable.objectId); + + /* + * Do not generate wal log for commands whose target table is a temporary + * table. + * + * We will generate wal logs for unlogged tables so that unlogged tables + * can also be created and altered on the subscriber side. This makes it + * possible to directly replay the SET LOGGED command and the incoming + * rewrite message without creating a new table. + */ + if (relpersist != RELPERSISTENCE_TEMP) + { + /* Deparse the DDL command and WAL log it to allow decoding of the same. */ + json_string = deparse_utility_command(cmd, false); + + if (json_string != NULL) + LogLogicalDDLMessage("deparse", cmd->d.alterTable.objectId, DCT_TableAlter, + json_string, strlen(json_string) + 1); + } + + return PointerGetDatum(NULL); +} + +/* + * Deparse the ddl command and log it. This function + * is called after the execution of the command but before the + * transaction commits. + */ +Datum +publication_deparse_ddl_command_end(PG_FUNCTION_ARGS) +{ + ListCell *lc; + slist_iter iter; + DeparsedCommandType type; + Oid relid; + char relkind; + + if (!CALLED_AS_EVENT_TRIGGER(fcinfo)) + elog(ERROR, "not fired by event trigger manager"); + + foreach(lc, currentEventTriggerState->commandList) + { + char relpersist = RELPERSISTENCE_PERMANENT; + CollectedCommand *cmd = lfirst(lc); + char *json_string; + + /* Rewrite DDL has been handled in table_rewrite trigger */ + if (cmd->d.alterTable.rewrite) + { + RenameStmt *renameStmt = (RenameStmt *) cmd->parsetree; + + if (renameStmt && renameStmt->relationType != OBJECT_TYPE && + renameStmt->relationType != OBJECT_TABLE) + continue; + } + + if (cmd->type == SCT_Simple && + !OidIsValid(cmd->d.simple.address.objectId)) + continue; + + if (cmd->type == SCT_AlterTable) + { + relid = cmd->d.alterTable.objectId; + type = DCT_TableAlter; + } + else + { + /* Only SCT_Simple for now */ + relid = cmd->d.simple.address.objectId; + type = DCT_SimpleCmd; + } + + relkind = get_rel_relkind(relid); + if (relkind) + relpersist = get_rel_persistence(relid); + + /* + * Do not generate wal log for commands whose target table is a + * temporary table. + * + * We will generate wal logs for unlogged tables so that unlogged + * tables can also be created and altered on the subscriber side. This + * makes it possible to directly replay the SET LOGGED command and the + * incoming rewrite message without creating a new table. + */ + if (relpersist != RELPERSISTENCE_TEMP) + { + /* + * Deparse the DDL command and WAL log it to allow decoding of the + * same. + */ + json_string = deparse_utility_command(cmd, false); + + if (json_string != NULL) + LogLogicalDDLMessage("deparse", relid, type, json_string, + strlen(json_string) + 1); + } + } + + slist_foreach(iter, &(currentEventTriggerState->SQLDropList)) + { + SQLDropObject *obj; + DropStmt *stmt; + EventTriggerData *trigdata; + char *command; + DeparsedCommandType cmdtype; + const char *tmptype; + ObjectClass objclass; + ObjectAddress objaddr; + + trigdata = (EventTriggerData *) fcinfo->context; + stmt = (DropStmt *) trigdata->parsetree; + + obj = slist_container(SQLDropObject, next, iter.cur); + objaddr = obj->address; + objclass = getObjectClass(&objaddr); + + if (strcmp(obj->objecttype, "table") == 0) + cmdtype = DCT_TableDropEnd; + else if (objclass == OCLASS_SCHEMA || + objclass == OCLASS_OPERATOR || + objclass == OCLASS_OPCLASS || + objclass == OCLASS_OPFAMILY || + objclass == OCLASS_CAST || + objclass == OCLASS_TYPE || + objclass == OCLASS_TRIGGER || + objclass == OCLASS_CONVERSION || + objclass == OCLASS_POLICY || + objclass == OCLASS_REWRITE || + objclass == OCLASS_EXTENSION || + objclass == OCLASS_FDW || + objclass == OCLASS_TSCONFIG || + objclass == OCLASS_TSDICT || + objclass == OCLASS_TSTEMPLATE || + objclass == OCLASS_TSPARSER || + objclass == OCLASS_TRANSFORM || + objclass == OCLASS_FOREIGN_SERVER || + objclass == OCLASS_COLLATION || + objclass == OCLASS_USER_MAPPING || + objclass == OCLASS_LANGUAGE || + objclass == OCLASS_STATISTIC_EXT || + objclass == OCLASS_AM || + objclass == OCLASS_PUBLICATION || + objclass == OCLASS_PUBLICATION_REL || + objclass == OCLASS_PUBLICATION_NAMESPACE || + strcmp(obj->objecttype, "foreign table") == 0 || + strcmp(obj->objecttype, "index") == 0 || + strcmp(obj->objecttype, "sequence") == 0 || + strcmp(obj->objecttype, "view") == 0 || + strcmp(obj->objecttype, "function") == 0 || + strcmp(obj->objecttype, "materialized view") == 0 || + strcmp(obj->objecttype, "procedure") == 0 || + strcmp(obj->objecttype, "routine") == 0 || + strcmp(obj->objecttype, "aggregate") == 0) + cmdtype = DCT_ObjectDrop; + else + continue; + + /* Change foreign-data wrapper to foreign data wrapper */ + if (strncmp(obj->objecttype, "foreign-data wrapper", 20) == 0) + { + tmptype = pstrdup("foreign data wrapper"); + command = deparse_drop_command(obj->objidentity, tmptype, + stmt->behavior); + } + + /* Change statistics object to statistics */ + else if (strncmp(obj->objecttype, "statistics object", + strlen("statistics object")) == 0) + { + tmptype = pstrdup("statistics"); + command = deparse_drop_command(obj->objidentity, tmptype, + stmt->behavior); + } + + /* + * Object identity needs to be modified to make the drop work + * + * FROM: on server TO : for server + * + * + */ + else if (strncmp(obj->objecttype, "user mapping", 12) == 0) + { + char *on_server; + + tmptype = palloc(strlen(obj->objidentity) + 2); + on_server = strstr(obj->objidentity, "on server"); + + sprintf((char *) tmptype, "for "); + strncat((char *) tmptype, obj->objidentity, on_server - obj->objidentity); + strcat((char *) tmptype, on_server + 3); + command = deparse_drop_command(tmptype, obj->objecttype, + stmt->behavior); + } + else if (strncmp(obj->objecttype, "publication namespace", + strlen("publication namespace")) == 0 || + strncmp(obj->objecttype, "publication relation", + strlen("publication relation")) == 0) + command = deparse_AlterPublicationDropStmt(obj); + else + command = deparse_drop_command(obj->objidentity, obj->objecttype, + stmt->behavior); + + if (command) + LogLogicalDDLMessage("deparse", obj->address.objectId, cmdtype, + command, strlen(command) + 1); + } + + return PointerGetDatum(NULL); +} + + +/* + * publication_deparse_table_init_write + * + * Deparse the ddl table create command and log it. + */ +Datum +publication_deparse_table_init_write(PG_FUNCTION_ARGS) +{ + char relpersist; + CollectedCommand *cmd; + char *json_string; + + if (!CALLED_AS_EVENT_TRIGGER(fcinfo)) + elog(ERROR, "not fired by event trigger manager"); + + cmd = currentEventTriggerState->currentCommand; + Assert(cmd); + + relpersist = get_rel_persistence(cmd->d.simple.address.objectId); + + /* + * Do not generate wal log for commands whose target table is a temporary + * table. + * + * We will generate wal logs for unlogged tables so that unlogged tables + * can also be created and altered on the subscriber side. This makes it + * possible to directly replay the SET LOGGED command and the incoming + * rewrite message without creating a new table. + */ + if (relpersist == RELPERSISTENCE_TEMP) + return PointerGetDatum(NULL); + + /* Deparse the DDL command and WAL log it to allow decoding of the same. */ + json_string = deparse_utility_command(cmd, false); + + if (json_string != NULL) + LogLogicalDDLMessage("deparse", cmd->d.simple.address.objectId, DCT_SimpleCmd, + json_string, strlen(json_string) + 1); + + return PointerGetDatum(NULL); +} diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index 39e6861..f56a716 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -95,6 +95,11 @@ static void stream_change_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn static void stream_message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size message_size, const char *message); +static void stream_ddl_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, + XLogRecPtr message_lsn, + const char *prefix, + Oid relid, DeparsedCommandType cmdtype, + Size message_size, const char *message); static void stream_truncate_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change); @@ -245,6 +250,7 @@ StartupDecodingContext(List *output_plugin_options, (ctx->callbacks.stream_commit_cb != NULL) || (ctx->callbacks.stream_change_cb != NULL) || (ctx->callbacks.stream_message_cb != NULL) || + (ctx->callbacks.stream_ddl_cb != NULL) || (ctx->callbacks.stream_truncate_cb != NULL); /* @@ -262,6 +268,7 @@ StartupDecodingContext(List *output_plugin_options, ctx->reorder->stream_commit = stream_commit_cb_wrapper; ctx->reorder->stream_change = stream_change_cb_wrapper; ctx->reorder->stream_message = stream_message_cb_wrapper; + ctx->reorder->stream_ddl = stream_ddl_cb_wrapper; ctx->reorder->stream_truncate = stream_truncate_cb_wrapper; @@ -1593,6 +1600,48 @@ stream_message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, } static void +stream_ddl_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, + XLogRecPtr message_lsn, + const char *prefix, Oid relid, DeparsedCommandType cmdtype, + Size message_size, + const char *message) +{ + LogicalDecodingContext *ctx = cache->private_data; + LogicalErrorCallbackState state; + ErrorContextCallback errcallback; + + Assert(!ctx->fast_forward); + + /* We're only supposed to call this when streaming is supported. */ + Assert(ctx->streaming); + + /* this callback is optional */ + if (ctx->callbacks.stream_ddl_cb == NULL) + return; + + /* Push callback + info on the error context stack */ + state.ctx = ctx; + state.callback_name = "stream_ddl"; + state.report_location = message_lsn; + errcallback.callback = output_plugin_error_callback; + errcallback.arg = (void *) &state; + errcallback.previous = error_context_stack; + error_context_stack = &errcallback; + + /* set output state */ + ctx->accept_writes = true; + ctx->write_xid = txn != NULL ? txn->xid : InvalidTransactionId; + ctx->write_location = message_lsn; + + /* do the actual work: call callback */ + ctx->callbacks.stream_ddl_cb(ctx, txn, message_lsn, prefix, relid, + cmdtype, message_size, message); + + /* Pop the error context stack */ + error_context_stack = errcallback.previous; +} + +static void stream_truncate_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change) diff --git a/src/backend/replication/logical/meson.build b/src/backend/replication/logical/meson.build index 99c608d..05e7756 100644 --- a/src/backend/replication/logical/meson.build +++ b/src/backend/replication/logical/meson.build @@ -3,6 +3,7 @@ backend_sources += files( 'applyparallelworker.c', 'ddlmessage.c', + 'ddltrigger.c', 'decode.c', 'launcher.c', 'logical.c', diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c index f308713..1ba3feb 100644 --- a/src/backend/replication/logical/proto.c +++ b/src/backend/replication/logical/proto.c @@ -664,6 +664,47 @@ logicalrep_write_message(StringInfo out, TransactionId xid, XLogRecPtr lsn, } /* + * Read DDL MESSAGE from stream + */ +char * +logicalrep_read_ddl(StringInfo in, XLogRecPtr *lsn, + const char **prefix, + Size *sz) +{ + uint8 flags; + char *msg; + + flags = pq_getmsgint(in, 1); + if (flags != 0) + elog(ERROR, "unrecognized flags %u in ddl message", flags); + + *lsn = pq_getmsgint64(in); + *prefix = pq_getmsgstring(in); + *sz = pq_getmsgint(in, 4); + msg = (char *) pq_getmsgbytes(in, *sz); + + return msg; +} + +/* + * Write DDL MESSAGE to stream + */ +void +logicalrep_write_ddl(StringInfo out, XLogRecPtr lsn, + const char *prefix, Size sz, const char *message) +{ + uint8 flags = 0; + + pq_sendbyte(out, LOGICAL_REP_MSG_DDL); + + pq_sendint8(out, flags); + pq_sendint64(out, lsn); + pq_sendstring(out, prefix); + pq_sendint32(out, sz); + pq_sendbytes(out, message, sz); +} + +/* * Write relation description to the output stream. */ void @@ -1238,6 +1279,8 @@ logicalrep_message_type(LogicalRepMsgType action) return "TYPE"; case LOGICAL_REP_MSG_MESSAGE: return "MESSAGE"; + case LOGICAL_REP_MSG_DDL: + return "DDL"; case LOGICAL_REP_MSG_BEGIN_PREPARE: return "BEGIN PREPARE"; case LOGICAL_REP_MSG_PREPARE: diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 2f5016e..e88eb2f 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -2043,12 +2043,20 @@ static inline void ReorderBufferApplyDDLMessage(ReorderBuffer *rb, ReorderBufferTXN *txn, ReorderBufferChange *change, bool streaming) { - rb->ddl(rb, txn, change->lsn, - change->data.ddl.prefix, - change->data.ddl.relid, - change->data.ddl.cmdtype, - change->data.ddl.message_size, - change->data.ddl.message); + if (streaming) + rb->stream_ddl(rb, txn, change->lsn, + change->data.ddl.prefix, + change->data.ddl.relid, + change->data.ddl.cmdtype, + change->data.ddl.message_size, + change->data.ddl.message); + else + rb->ddl(rb, txn, change->lsn, + change->data.ddl.prefix, + change->data.ddl.relid, + change->data.ddl.cmdtype, + change->data.ddl.message_size, + change->data.ddl.message); } /* diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 10f9711..9e053a3 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -166,6 +166,7 @@ #include "miscadmin.h" #include "nodes/makefuncs.h" #include "optimizer/optimizer.h" +#include "parser/analyze.h" #include "parser/parse_relation.h" #include "pgstat.h" #include "postmaster/bgworker.h" @@ -191,7 +192,10 @@ #include "storage/lmgr.h" #include "storage/proc.h" #include "storage/procarray.h" +#include "tcop/ddl_deparse.h" +#include "tcop/pquery.h" #include "tcop/tcopprot.h" +#include "tcop/utility.h" #include "utils/acl.h" #include "utils/builtins.h" #include "utils/catcache.h" @@ -3228,6 +3232,238 @@ apply_handle_truncate(StringInfo s) end_replication_step(); } +/* + * Special handling for CREATE TABLE AS and SELECT INTO + * to not populate data from the source table on the subscriber. + * Allow the data to be replicated through INSERTs on the publisher. + */ +static void +preprocess_create_table(RawStmt *command) +{ + CommandTag commandTag; + + commandTag = CreateCommandTag((Node *) command); + + switch (commandTag) + { + case CMDTAG_CREATE_TABLE_AS: + case CMDTAG_SELECT_INTO: + { + CreateTableAsStmt *castmt = (CreateTableAsStmt *) command->stmt; + + if (castmt->objtype == OBJECT_TABLE) + { + /* + * Force skipping data population to avoid data + * inconsistency. Data should be replicated from the + * publisher instead. + */ + castmt->into->skipData = true; + } + } + break; + case CMDTAG_SELECT: + { + SelectStmt *sstmt = (SelectStmt *) command->stmt; + + if (sstmt->intoClause != NULL) + { + /* + * Force skipping data population to avoid data + * inconsistency. Data should be replicated from the + * publisher instead. + */ + sstmt->intoClause->skipData = true; + } + } + break; + default: + break; + } +} + +/* + * Handle CREATE TABLE command + * + * Call AddSubscriptionRelState for CREATE LABEL command to set the relstate to + * SUBREL_STATE_READY so DML changes on this new table can be replicated without + * having to manually run "alter subscription ... refresh publication" + */ +static void +handle_create_table(RawStmt *command) +{ + CommandTag commandTag; + RangeVar *rv = NULL; + Oid relid; + Oid relnamespace = InvalidOid; + CreateStmt *cstmt; + char *schemaname = NULL; + char *relname = NULL; + + commandTag = CreateCommandTag((Node *) command); + cstmt = (CreateStmt *) command->stmt; + rv = cstmt->relation; + + if (commandTag == CMDTAG_CREATE_TABLE) + { + cstmt = (CreateStmt *) command->stmt; + rv = cstmt->relation; + } + else + { + return; + } + + if (!rv) + return; + + schemaname = rv->schemaname; + relname = rv->relname; + + if (schemaname != NULL) + relnamespace = get_namespace_oid(schemaname, false); + + if (relnamespace != InvalidOid) + relid = get_relname_relid(relname, relnamespace); + else + relid = RelnameGetRelid(relname); + + if (OidIsValid(relid)) + { + AddSubscriptionRelState(MySubscription->oid, relid, + SUBREL_STATE_READY, + InvalidXLogRecPtr); + ereport(DEBUG1, + (errmsg_internal("table \"%s\" added to subscription \"%s\"", + relname, MySubscription->name))); + } +} + +/* + * Handle DDL replication messages. + */ +static void +apply_handle_ddl(StringInfo s) +{ + XLogRecPtr lsn; + const char *prefix = NULL; + char *message = NULL; + char *ddl_command; + Size sz; + List *parsetree_list; + ListCell *parsetree_item; + DestReceiver *receiver; + MemoryContext oldcontext; + const char *save_debug_query_string = debug_query_string; + + message = logicalrep_read_ddl(s, &lsn, &prefix, &sz); + + /* Make sure we are in a transaction command */ + begin_replication_step(); + + ddl_command = deparse_ddl_json_to_string(message); + debug_query_string = ddl_command; + + /* DestNone for logical replication */ + receiver = CreateDestReceiver(DestNone); + parsetree_list = pg_parse_query(ddl_command); + + foreach(parsetree_item, parsetree_list) + { + List *plantree_list; + List *querytree_list; + RawStmt *command = (RawStmt *) lfirst(parsetree_item); + CommandTag commandTag; + MemoryContext per_parsetree_context = NULL; + Portal portal; + bool snapshot_set = false; + + commandTag = CreateCommandTag((Node *) command); + + /* If we got a cancel signal in parsing or prior command, quit */ + CHECK_FOR_INTERRUPTS(); + + /* Remove data population from the command */ + preprocess_create_table(command); + + /* + * Set up a snapshot if parse analysis/planning will need one. + */ + if (analyze_requires_snapshot(command)) + { + PushActiveSnapshot(GetTransactionSnapshot()); + snapshot_set = true; + } + + /* + * We do the work for each parsetree in a short-lived context, to + * limit the memory used when there are many commands in the string. + */ + per_parsetree_context = + AllocSetContextCreate(CurrentMemoryContext, + "execute_sql_string per-statement context", + ALLOCSET_DEFAULT_SIZES); + oldcontext = MemoryContextSwitchTo(per_parsetree_context); + + querytree_list = pg_analyze_and_rewrite_fixedparams(command, + ddl_command, + NULL, 0, NULL); + + plantree_list = pg_plan_queries(querytree_list, ddl_command, 0, NULL); + + /* Done with the snapshot used for parsing/planning */ + if (snapshot_set) + PopActiveSnapshot(); + + portal = CreatePortal("logical replication", true, true); + + /* + * We don't have to copy anything into the portal, because everything + * we are passing here is in ApplyMessageContext or the + * per_parsetree_context, and so will outlive the portal anyway. + */ + PortalDefineQuery(portal, + NULL, + ddl_command, + commandTag, + plantree_list, + NULL); + + /* + * Start the portal. No parameters here. + */ + PortalStart(portal, NULL, 0, InvalidSnapshot); + + /* + * Switch back to transaction context for execution. + */ + MemoryContextSwitchTo(oldcontext); + + (void) PortalRun(portal, + FETCH_ALL, + true, + true, + receiver, + receiver, + NULL); + + PortalDrop(portal, false); + + CommandCounterIncrement(); + + /* + * Table created by DDL replication (database level) is automatically + * added to the subscription here. + */ + handle_create_table(command); + + /* Now we may drop the per-parsetree context, if one was created. */ + MemoryContextDelete(per_parsetree_context); + } + + debug_query_string = save_debug_query_string; + end_replication_step(); +} /* * Logical replication protocol message dispatcher. @@ -3293,6 +3529,10 @@ apply_dispatch(StringInfo s) */ break; + case LOGICAL_REP_MSG_DDL: + apply_handle_ddl(s); + break; + case LOGICAL_REP_MSG_STREAM_START: apply_handle_stream_start(s); break; diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 17daa26..b2a2bde 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -56,6 +56,11 @@ static void pgoutput_message(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size sz, const char *message); +static void pgoutput_ddl(LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, XLogRecPtr message_lsn, + const char *prefix, Oid relid, + DeparsedCommandType cmdtype, + Size sz, const char *message); static bool pgoutput_origin_filter(LogicalDecodingContext *ctx, RepOriginId origin_id); static void pgoutput_begin_prepare_txn(LogicalDecodingContext *ctx, @@ -255,6 +260,7 @@ _PG_output_plugin_init(OutputPluginCallbacks *cb) cb->change_cb = pgoutput_change; cb->truncate_cb = pgoutput_truncate; cb->message_cb = pgoutput_message; + cb->ddl_cb = pgoutput_ddl; cb->commit_cb = pgoutput_commit_txn; cb->begin_prepare_cb = pgoutput_begin_prepare_txn; @@ -271,6 +277,7 @@ _PG_output_plugin_init(OutputPluginCallbacks *cb) cb->stream_commit_cb = pgoutput_stream_commit; cb->stream_change_cb = pgoutput_change; cb->stream_message_cb = pgoutput_message; + cb->stream_ddl_cb = pgoutput_ddl; cb->stream_truncate_cb = pgoutput_truncate; /* transaction streaming - two-phase commit */ cb->stream_prepare_cb = pgoutput_stream_prepare_txn; @@ -426,6 +433,7 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, /* This plugin uses binary protocol. */ opt->output_type = OUTPUT_PLUGIN_BINARY_OUTPUT; + opt->receive_rewrites = true; /* * This is replication start and not slot initialization. @@ -506,6 +514,7 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, /* Init publication state. */ data->publications = NIL; + data->deleted_relids = NIL; publications_valid = false; /* @@ -1412,6 +1421,20 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, ReorderBufferChangeType action = change->action; TupleTableSlot *old_slot = NULL; TupleTableSlot *new_slot = NULL; + bool table_rewrite = false; + + /* + * For heap rewrites, we might need to replicate them if the rewritten + * table publishes rewrite ddl message. So get the actual relation here + * and check the pubaction later. + */ + if (relation->rd_rel->relrewrite) + { + table_rewrite = true; + relation = RelationIdGetRelation(relation->rd_rel->relrewrite); + targetrel = relation; + } + if (!is_publishable_relation(relation)) return; @@ -1446,6 +1469,13 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Assert(false); } + /* + * We don't publish table rewrite change unless we publish the rewrite ddl + * message. + */ + if (table_rewrite && !relentry->pubactions.pubddl_table) + return; + /* Avoid leaking memory by using and resetting our own context */ old = MemoryContextSwitchTo(data->context); @@ -1475,8 +1505,8 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, } /* Check row filter */ - if (!pgoutput_row_filter(targetrel, NULL, &new_slot, relentry, - &action)) + if (!table_rewrite && + !pgoutput_row_filter(targetrel, NULL, &new_slot, relentry, &action)) break; /* @@ -1496,8 +1526,19 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, maybe_send_schema(ctx, change, relation, relentry); OutputPluginPrepareWrite(ctx, true); - logicalrep_write_insert(ctx->out, xid, targetrel, new_slot, - data->binary, relentry->columns); + + /* + * Convert the rewrite inserts to updates so that the subscriber + * can replay it. This is needed to make sure the data between + * publisher and subscriber is consistent. + */ + if (table_rewrite) + logicalrep_write_update(ctx->out, xid, targetrel, + NULL, new_slot, data->binary, + relentry->columns); + else + logicalrep_write_insert(ctx->out, xid, targetrel, new_slot, + data->binary, relentry->columns); OutputPluginWrite(ctx, true); break; case REORDER_BUFFER_CHANGE_UPDATE: @@ -1629,6 +1670,9 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, ancestor = NULL; } + if (table_rewrite) + RelationClose(relation); + /* Cleanup */ MemoryContextSwitchTo(old); MemoryContextReset(data->context); @@ -1744,6 +1788,138 @@ pgoutput_message(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, } /* + * Send the decoded DDL over wire. + */ +static void +pgoutput_ddl(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, + XLogRecPtr message_lsn, + const char *prefix, Oid relid, DeparsedCommandType cmdtype, + Size sz, const char *message) +{ + PGOutputData *data = (PGOutputData *) ctx->output_plugin_private; + PGOutputTxnData *txndata = (PGOutputTxnData *) txn->output_plugin_private; + Relation relation = NULL; + RelationSyncEntry *relentry; + + switch (cmdtype) + { + case DCT_TableDropStart: + + /* + * On DROP start, add the relid to a deleted_relid list if the + * relid is part of a publication that supports ddl publication. + * We need this because on DROP end, the relid will no longer be + * valid. Later on Drop end, verify that the drop is for a relid + * that is on the deleted_rid list, and only then send the ddl + * message. + */ + relation = RelationIdGetRelation(relid); + + Assert(relation); + relentry = get_rel_sync_entry(data, relation); + + if (relentry->pubactions.pubddl_table) + data->deleted_relids = lappend_oid(data->deleted_relids, relid); + + RelationClose(relation); + return; + + case DCT_TableDropEnd: + if (!list_member_oid(data->deleted_relids, relid)) + return; + else + data->deleted_relids = list_delete_oid(data->deleted_relids, relid); + break; + + case DCT_TableAlter: + + /* + * For table rewrite ddl, we first send the original ddl message + * to subscriber, then convert the upcoming rewrite INSERT to + * UPDATE and send them to subscriber so that the data between + * publisher and subscriber can always be consistent. + * + * We do this way because of two reason: + * + * (1) The data before the rewrite ddl could already be different + * among publisher and subscriber. To make sure the extra data in + * subscriber which doesn't exist in publisher also get rewritten, + * we need to let the subscriber execute the original rewrite ddl + * to rewrite all the data at first. + * + * (2) the data after executing rewrite ddl could be different + * among publisher and subscriber(due to different + * functions/operators used during rewrite), so we need to + * replicate the rewrite UPDATEs to keep the data consistent. + * + * TO IMPROVE: We could improve this by letting the subscriber + * only rewrite the extra data instead of doing fully rewrite and + * use the upcoming rewrite UPDATEs to rewrite the rest data. + * Besides, we may not need to send rewrite changes for all type + * of rewrite ddl, for example, it seems fine to skip sending + * rewrite changes for ALTER TABLE SET LOGGED as the data in the + * table doesn't actually be changed. + */ + relation = RelationIdGetRelation(relid); + Assert(relation); + + relentry = get_rel_sync_entry(data, relation); + + /* + * Skip sending this ddl if we don't publish ddl message or the + * ddl need to be published via its root relation. + */ + if (!relentry->pubactions.pubddl_table || + relentry->publish_as_relid != relid) + { + RelationClose(relation); + return; + } + + break; + + case DCT_SimpleCmd: + relation = RelationIdGetRelation(relid); + + if (relation == NULL) + break; + + relentry = get_rel_sync_entry(data, relation); + + if (!relentry->pubactions.pubddl_table) + { + RelationClose(relation); + return; + } + + break; + + case DCT_ObjectDrop: + /* do nothing */ + break; + + default: + elog(ERROR, "unsupported type %d", cmdtype); + break; + } + + /* Send BEGIN if we haven't yet */ + if (txndata && !txndata->sent_begin_txn) + pgoutput_send_begin(ctx, txn); + + OutputPluginPrepareWrite(ctx, true); + logicalrep_write_ddl(ctx->out, + message_lsn, + prefix, + sz, + message); + OutputPluginWrite(ctx, true); + + if (relation) + RelationClose(relation); +} + +/* * Return true if the data is associated with an origin and the user has * requested the changes that don't have an origin, false otherwise. */ @@ -2051,7 +2227,8 @@ get_rel_sync_entry(PGOutputData *data, Relation relation) entry->schema_sent = false; entry->streamed_txns = NIL; entry->pubactions.pubinsert = entry->pubactions.pubupdate = - entry->pubactions.pubdelete = entry->pubactions.pubtruncate = false; + entry->pubactions.pubdelete = entry->pubactions.pubtruncate = + entry->pubactions.pubddl_all = entry->pubactions.pubddl_table = false; entry->new_slot = NULL; entry->old_slot = NULL; memset(entry->exprstate, 0, sizeof(entry->exprstate)); @@ -2109,6 +2286,8 @@ get_rel_sync_entry(PGOutputData *data, Relation relation) entry->pubactions.pubupdate = false; entry->pubactions.pubdelete = false; entry->pubactions.pubtruncate = false; + entry->pubactions.pubddl_all = false; + entry->pubactions.pubddl_table = false; /* * Tuple slots cleanups. (Will be rebuilt later if needed). @@ -2222,6 +2401,8 @@ get_rel_sync_entry(PGOutputData *data, Relation relation) entry->pubactions.pubupdate |= pub->pubactions.pubupdate; entry->pubactions.pubdelete |= pub->pubactions.pubdelete; entry->pubactions.pubtruncate |= pub->pubactions.pubtruncate; + entry->pubactions.pubddl_all |= pub->pubactions.pubddl_all; + entry->pubactions.pubddl_table |= pub->pubactions.pubddl_table; /* * We want to publish the changes as the top-most ancestor diff --git a/src/backend/tcop/cmdtag.c b/src/backend/tcop/cmdtag.c index 4bd713a..ce09c5f 100644 --- a/src/backend/tcop/cmdtag.c +++ b/src/backend/tcop/cmdtag.c @@ -26,10 +26,11 @@ typedef struct CommandTagBehavior const bool table_rewrite_ok; const bool display_rowcount; /* should the number of rows affected be * shown in the command completion string */ + const bool ddl_replication_ok; } CommandTagBehavior; -#define PG_CMDTAG(tag, name, evtrgok, rwrok, rowcnt) \ - { name, (uint8) (sizeof(name) - 1), evtrgok, rwrok, rowcnt }, +#define PG_CMDTAG(tag, name, evtrgok, rwrok, rowcnt, ddlreplok) \ + { name, (uint8) (sizeof(name) - 1), evtrgok, rwrok, rowcnt, ddlreplok }, static const CommandTagBehavior tag_behavior[COMMAND_TAG_NEXTTAG] = { #include "tcop/cmdtaglist.h" @@ -57,6 +58,21 @@ GetCommandTagNameAndLen(CommandTag commandTag, Size *len) return tag_behavior[commandTag].name; } +CommandTag * +GetCommandTagsForDDLRepl(int *ncommands) +{ + CommandTag *ddlrepl_commands = palloc0(COMMAND_TAG_NEXTTAG * sizeof(CommandTag)); + *ncommands = 0; + + for(int i = 0; i < COMMAND_TAG_NEXTTAG; i++) + { + if (tag_behavior[i].ddl_replication_ok) + ddlrepl_commands[(*ncommands)++] = (CommandTag) i; + } + + return ddlrepl_commands; +} + bool command_tag_display_rowcount(CommandTag commandTag) { @@ -75,6 +91,12 @@ command_tag_table_rewrite_ok(CommandTag commandTag) return tag_behavior[commandTag].table_rewrite_ok; } +bool +command_tag_ddl_replication_ok(CommandTag commandTag) +{ + return tag_behavior[commandTag].ddl_replication_ok; +} + /* * Search CommandTag by name * diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 491e351..88e9b08 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -1669,8 +1669,11 @@ ProcessUtilitySlow(ParseState *pstate, break; case T_CreateTableAsStmt: + EventTriggerTableInitWriteStart(parsetree); address = ExecCreateTableAs(pstate, (CreateTableAsStmt *) parsetree, params, queryEnv, qc); + EventTriggerTableInitWriteEnd(address); + commandCollected = true; break; case T_RefreshMatViewStmt: @@ -2256,6 +2259,8 @@ stringify_objtype(ObjectType objtype, bool isgrant) return "POLICY"; case OBJECT_PROCEDURE: return "PROCEDURE"; + case OBJECT_PUBLICATION: + return "PUBLICATION"; case OBJECT_ROLE: return "ROLE"; case OBJECT_ROUTINE: @@ -2268,6 +2273,8 @@ stringify_objtype(ObjectType objtype, bool isgrant) return "SEQUENCE"; case OBJECT_STATISTIC_EXT: return "STATISTICS"; + case OBJECT_SUBSCRIPTION: + return "SUBSCRIPTION"; case OBJECT_TABLE: return "TABLE"; case OBJECT_TABLESPACE: @@ -2296,10 +2303,8 @@ stringify_objtype(ObjectType objtype, bool isgrant) case OBJECT_DEFACL: case OBJECT_DOMCONSTRAINT: case OBJECT_PARAMETER_ACL: - case OBJECT_PUBLICATION: case OBJECT_PUBLICATION_NAMESPACE: case OBJECT_PUBLICATION_REL: - case OBJECT_SUBSCRIPTION: case OBJECT_TABCONSTRAINT: case OBJECT_TRANSFORM: elog(ERROR, "unsupported object type %d", objtype); diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c index 1f5e7eb..f2a9f5d 100644 --- a/src/backend/utils/cache/evtcache.c +++ b/src/backend/utils/cache/evtcache.c @@ -167,6 +167,8 @@ BuildEventTriggerCache(void) event = EVT_SQLDrop; else if (strcmp(evtevent, "table_rewrite") == 0) event = EVT_TableRewrite; + else if (strcmp(evtevent, "table_init_write") == 0) + event = EVT_TableInitWrite; else continue; diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 40140de..f522bcc 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -5720,6 +5720,8 @@ RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc) pubdesc->pubactions.pubupdate |= pubform->pubupdate; pubdesc->pubactions.pubdelete |= pubform->pubdelete; pubdesc->pubactions.pubtruncate |= pubform->pubtruncate; + pubdesc->pubactions.pubddl_all |= pubform->pubddl_all; + pubdesc->pubactions.pubddl_table |= pubform->pubddl_table; /* * Check if all columns referenced in the filter expression are part diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index d62780a..2928493 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -51,6 +51,7 @@ #include "catalog/pg_largeobject_d.h" #include "catalog/pg_largeobject_metadata_d.h" #include "catalog/pg_proc_d.h" +#include "catalog/pg_publication.h" #include "catalog/pg_subscription.h" #include "catalog/pg_trigger_d.h" #include "catalog/pg_type_d.h" @@ -4063,6 +4064,8 @@ getPublications(Archive *fout, int *numPublications) int i_pubupdate; int i_pubdelete; int i_pubtruncate; + int i_pubddl_all; + int i_pubddl_table; int i_pubviaroot; int i, ntups; @@ -4078,23 +4081,23 @@ getPublications(Archive *fout, int *numPublications) resetPQExpBuffer(query); /* Get the publications. */ - if (fout->remoteVersion >= 130000) + if (fout->remoteVersion >= 160000) appendPQExpBufferStr(query, "SELECT p.tableoid, p.oid, p.pubname, " "p.pubowner, " - "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, p.pubviaroot " + "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, p.pubddl_all, p.pubddl_table, p.pubviaroot " "FROM pg_publication p"); else if (fout->remoteVersion >= 110000) appendPQExpBufferStr(query, "SELECT p.tableoid, p.oid, p.pubname, " "p.pubowner, " - "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false AS pubviaroot " + "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false as p.pubddl_all, false as p.pubddl_table, false AS pubviaroot " "FROM pg_publication p"); else appendPQExpBufferStr(query, "SELECT p.tableoid, p.oid, p.pubname, " "p.pubowner, " - "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, false AS pubtruncate, false AS pubviaroot " + "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, false AS pubtruncate, false as p.pubddl_all, false as p.pubddl_table, false AS pubviaroot " "FROM pg_publication p"); res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); @@ -4110,6 +4113,8 @@ getPublications(Archive *fout, int *numPublications) i_pubupdate = PQfnumber(res, "pubupdate"); i_pubdelete = PQfnumber(res, "pubdelete"); i_pubtruncate = PQfnumber(res, "pubtruncate"); + i_pubddl_all = PQfnumber(res, "pubddl_all"); + i_pubddl_table = PQfnumber(res, "pubddl_table"); i_pubviaroot = PQfnumber(res, "pubviaroot"); pubinfo = pg_malloc(ntups * sizeof(PublicationInfo)); @@ -4133,6 +4138,10 @@ getPublications(Archive *fout, int *numPublications) (strcmp(PQgetvalue(res, i, i_pubdelete), "t") == 0); pubinfo[i].pubtruncate = (strcmp(PQgetvalue(res, i, i_pubtruncate), "t") == 0); + pubinfo[i].pubddl_all = + (strcmp(PQgetvalue(res, i, i_pubddl_all), "t") == 0); + pubinfo[i].pubddl_table = + (strcmp(PQgetvalue(res, i, i_pubddl_table), "t") == 0); pubinfo[i].pubviaroot = (strcmp(PQgetvalue(res, i, i_pubviaroot), "t") == 0); @@ -4212,7 +4221,24 @@ dumpPublication(Archive *fout, const PublicationInfo *pubinfo) first = false; } - appendPQExpBufferChar(query, '\''); + appendPQExpBufferStr(query, "'"); + + if (pubinfo->pubddl_all || pubinfo->pubddl_table) + { + appendPQExpBufferStr(query, ", ddl = '"); + if (pubinfo->pubddl_all) + appendPQExpBufferStr(query, "all"); + + if (pubinfo->pubddl_table) + { + if (pubinfo->pubddl_all) + appendPQExpBufferStr(query, ", "); + + appendPQExpBufferStr(query, "table"); + } + + appendPQExpBufferStr(query, "'"); + } if (pubinfo->pubviaroot) appendPQExpBufferStr(query, ", publish_via_partition_root = true"); @@ -7965,6 +7991,50 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables) } /* + * getPublicationEventTriggers + * get the publication event triggers that should be skipped + */ +static void +getPublicationEventTriggers(Archive *fout, SimpleStringList *skipTriggers) +{ + PQExpBuffer query; + PGresult *res; + int i; + int ntups; + + query = createPQExpBuffer(); + + appendPQExpBufferStr(query, + "SELECT oid FROM pg_publication " + "WHERE pubddl_all OR pubddl_table"); + + res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); + ntups = PQntuples(res); + + for (i = 0; i < ntups; i++) + { + char *trigname; + Oid pubid = atooid(PQgetvalue(res, 0, 0)); + + trigname = psprintf(PUB_EVENT_TRIG_PREFIX, PUB_TRIG_EVENT1, pubid); + simple_string_list_append(skipTriggers, trigname); + + trigname = psprintf(PUB_EVENT_TRIG_PREFIX, PUB_TRIG_EVENT2, pubid); + simple_string_list_append(skipTriggers, trigname); + + trigname = psprintf(PUB_EVENT_TRIG_PREFIX, PUB_TRIG_EVENT3, pubid); + simple_string_list_append(skipTriggers, trigname); + + trigname = psprintf(PUB_EVENT_TRIG_PREFIX, PUB_TRIG_EVENT4, pubid); + simple_string_list_append(skipTriggers, trigname); + } + + PQclear(res); + + destroyPQExpBuffer(query); +} + +/* * getEventTriggers * get information about event triggers */ @@ -7984,6 +8054,7 @@ getEventTriggers(Archive *fout, int *numEventTriggers) i_evtfname, i_evtenabled; int ntups; + SimpleStringList skipTriggers = {NULL, NULL}; /* Before 9.3, there are no event triggers */ if (fout->remoteVersion < 90300) @@ -7992,6 +8063,8 @@ getEventTriggers(Archive *fout, int *numEventTriggers) return NULL; } + getPublicationEventTriggers(fout, &skipTriggers); + query = createPQExpBuffer(); appendPQExpBufferStr(query, @@ -8036,9 +8109,14 @@ getEventTriggers(Archive *fout, int *numEventTriggers) evtinfo[i].evtenabled = *(PQgetvalue(res, i, i_evtenabled)); /* Decide whether we want to dump it */ - selectDumpableObject(&(evtinfo[i].dobj), fout); + if (simple_string_list_member(&skipTriggers, evtinfo[i].evtname)) + evtinfo[i].dobj.dump= DUMP_COMPONENT_NONE; + else + selectDumpableObject(&(evtinfo[i].dobj), fout); } + simple_string_list_destroy(&skipTriggers); + PQclear(res); destroyPQExpBuffer(query); diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 283cd1a..ed23883 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -620,6 +620,8 @@ typedef struct _PublicationInfo bool pubupdate; bool pubdelete; bool pubtruncate; + bool pubddl_all; + bool pubddl_table; bool pubviaroot; } PublicationInfo; diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index a22f27f..21e22ed 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -2781,7 +2781,7 @@ my %tests = ( create_order => 50, create_sql => 'CREATE PUBLICATION pub2 FOR ALL TABLES - WITH (publish = \'\');', + WITH (publish = \'\', ddl = \'\');', regexp => qr/^ \QCREATE PUBLICATION pub2 FOR ALL TABLES WITH (publish = '');\E /xm, diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 99e28f6..48bf37a 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -6183,7 +6183,7 @@ listPublications(const char *pattern) PQExpBufferData buf; PGresult *res; printQueryOpt myopt = pset.popt; - static const bool translate_columns[] = {false, false, false, false, false, false, false, false}; + static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; if (pset.sversion < 100000) { @@ -6200,13 +6200,23 @@ listPublications(const char *pattern) printfPQExpBuffer(&buf, "SELECT pubname AS \"%s\",\n" " pg_catalog.pg_get_userbyid(pubowner) AS \"%s\",\n" - " puballtables AS \"%s\",\n" - " pubinsert AS \"%s\",\n" - " pubupdate AS \"%s\",\n" - " pubdelete AS \"%s\"", + " puballtables AS \"%s\"", gettext_noop("Name"), gettext_noop("Owner"), - gettext_noop("All tables"), + gettext_noop("All tables")); + if (pset.sversion >= 160000) + { + appendPQExpBuffer(&buf, + ",\n pubddl_all AS \"%s\"", + gettext_noop("All DDLs")); + appendPQExpBuffer(&buf, + ",\n pubddl_table AS \"%s\"", + gettext_noop("Table DDLs")); + } + appendPQExpBuffer(&buf, + ",\n pubinsert AS \"%s\",\n" + " pubupdate AS \"%s\",\n" + " pubdelete AS \"%s\"", gettext_noop("Inserts"), gettext_noop("Updates"), gettext_noop("Deletes")); @@ -6218,7 +6228,6 @@ listPublications(const char *pattern) appendPQExpBuffer(&buf, ",\n pubviaroot AS \"%s\"", gettext_noop("Via root")); - appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_publication\n"); @@ -6308,6 +6317,7 @@ describePublications(const char *pattern) PGresult *res; bool has_pubtruncate; bool has_pubviaroot; + bool has_pubddl; PQExpBufferData title; printTableContent cont; @@ -6324,13 +6334,19 @@ describePublications(const char *pattern) has_pubtruncate = (pset.sversion >= 110000); has_pubviaroot = (pset.sversion >= 130000); + has_pubddl = (pset.sversion >= 160000); initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "SELECT oid, pubname,\n" " pg_catalog.pg_get_userbyid(pubowner) AS owner,\n" - " puballtables, pubinsert, pubupdate, pubdelete"); + " puballtables"); + if (has_pubddl) + appendPQExpBufferStr(&buf, + ", pubddl_all, pubddl_table"); + appendPQExpBufferStr(&buf, + ", pubinsert, pubupdate, pubdelete"); if (has_pubtruncate) appendPQExpBufferStr(&buf, ", pubtruncate"); @@ -6388,6 +6404,8 @@ describePublications(const char *pattern) ncols++; if (has_pubviaroot) ncols++; + if (has_pubddl) + ncols += 2; initPQExpBuffer(&title); printfPQExpBuffer(&title, _("Publication %s"), pubname); @@ -6395,6 +6413,11 @@ describePublications(const char *pattern) printTableAddHeader(&cont, gettext_noop("Owner"), true, align); printTableAddHeader(&cont, gettext_noop("All tables"), true, align); + if (has_pubddl) + { + printTableAddHeader(&cont, gettext_noop("All DDLs"), true, align); + printTableAddHeader(&cont, gettext_noop("Table DDLs"), true, align); + } printTableAddHeader(&cont, gettext_noop("Inserts"), true, align); printTableAddHeader(&cont, gettext_noop("Updates"), true, align); printTableAddHeader(&cont, gettext_noop("Deletes"), true, align); @@ -6412,6 +6435,11 @@ describePublications(const char *pattern) printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false); if (has_pubviaroot) printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false); + if (has_pubddl) + { + printTableAddCell(&cont, PQgetvalue(res, i, 9), false, false); + printTableAddCell(&cont, PQgetvalue(res, i, 10), false, false); + } if (!puballtables) { diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index f5a4689..85ebdc8 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -11981,5 +11981,17 @@ { oid => '4643', descr => 'expand JSON format DDL to a plain text DDL command', proname => 'ddl_deparse_expand_command', prorettype => 'text', proargtypes => 'text', prosrc => 'ddl_deparse_expand_command' }, +{ oid => '4644', descr => 'trigger for ddl command deparse end', + proname => 'publication_deparse_ddl_command_end', prorettype => 'event_trigger', + proargtypes => '', prosrc => 'publication_deparse_ddl_command_end' }, +{ oid => '4645', descr => 'trigger for ddl command deparse start', + proname => 'publication_deparse_ddl_command_start', prorettype => 'event_trigger', + proargtypes => '', prosrc => 'publication_deparse_ddl_command_start' }, +{ oid => '4646', descr => 'trigger for ddl command deparse table rewrite', + proname => 'publication_deparse_table_rewrite', prorettype => 'event_trigger', + proargtypes => '', prosrc => 'publication_deparse_table_rewrite' }, +{ oid => '4647', descr => 'trigger for ddl command deparse table init', + proname => 'publication_deparse_table_init_write', prorettype => 'event_trigger', + proargtypes => '', prosrc => 'publication_deparse_table_init_write' }, ] diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h index 715f2a2..1cf02a4 100644 --- a/src/include/catalog/pg_publication.h +++ b/src/include/catalog/pg_publication.h @@ -21,6 +21,15 @@ #include "catalog/pg_publication_d.h" #include "nodes/pg_list.h" +/* Publication trigger events */ +#define PUB_TRIG_EVENT1 "ddl_command_end" +#define PUB_TRIG_EVENT2 "ddl_command_start" +#define PUB_TRIG_EVENT3 "table_rewrite" +#define PUB_TRIG_EVENT4 "table_init_write" + +/* Publication event trigger prefix */ +#define PUB_EVENT_TRIG_PREFIX "pg_deparse_trig_%s_%u" + /* ---------------- * pg_publication definition. cpp turns this into * typedef struct FormData_pg_publication @@ -54,6 +63,12 @@ CATALOG(pg_publication,6104,PublicationRelationId) /* true if partition changes are published using root schema */ bool pubviaroot; + + /* true if all supported ddls are published */ + bool pubddl_all; + + /* true if table ddls are published */ + bool pubddl_table; } FormData_pg_publication; /* ---------------- @@ -72,6 +87,8 @@ typedef struct PublicationActions bool pubupdate; bool pubdelete; bool pubtruncate; + bool pubddl_all; + bool pubddl_table; } PublicationActions; typedef struct PublicationDesc diff --git a/src/include/commands/event_trigger.h b/src/include/commands/event_trigger.h index a97e8b7..5f6dd22 100644 --- a/src/include/commands/event_trigger.h +++ b/src/include/commands/event_trigger.h @@ -94,6 +94,10 @@ extern void EventTriggerDDLCommandEnd(Node *parsetree); extern void EventTriggerSQLDrop(Node *parsetree); extern void EventTriggerTableRewrite(Node *parsetree, Oid tableOid, int reason); +extern void EventTriggerTableInitWriteStart(Node *parsetree); +extern void EventTriggerTableInitWrite(Node *parsetree, ObjectAddress address); +extern void EventTriggerTableInitWriteEnd(ObjectAddress address); + extern bool EventTriggerBeginCompleteQuery(void); extern void EventTriggerEndCompleteQuery(void); extern bool trackDroppedObjectsNeeded(void); @@ -110,7 +114,12 @@ extern void EventTriggerCollectSimpleCommand(ObjectAddress address, extern void EventTriggerAlterTableStart(Node *parsetree); extern void EventTriggerAlterTableRelid(Oid objectId); extern void EventTriggerCollectAlterTableSubcmd(Node *subcmd, - ObjectAddress address); + ObjectAddress address, + bool rewrite); + +extern void EventTriggerAlterTypeStart(AlterTableCmd *subcmd, Relation rel); +extern void EventTriggerAlterTypeEnd(Node *subcmd, ObjectAddress address, + bool rewrite); extern void EventTriggerAlterTableEnd(void); extern void EventTriggerCollectGrant(InternalGrant *istmt); @@ -120,6 +129,9 @@ extern void EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, extern void EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, Oid opcoid, List *operators, List *procedures); +extern void EventTriggerCollectCreatePublication(CreatePublicationStmt *stmt, + Oid pubid, List *relations, + List *schemas); extern void EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId, Oid *dictIds, int ndicts); extern void EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt); diff --git a/src/include/replication/logicalproto.h b/src/include/replication/logicalproto.h index 0ea2df5..5fb3baa 100644 --- a/src/include/replication/logicalproto.h +++ b/src/include/replication/logicalproto.h @@ -66,6 +66,7 @@ typedef enum LogicalRepMsgType LOGICAL_REP_MSG_RELATION = 'R', LOGICAL_REP_MSG_TYPE = 'Y', LOGICAL_REP_MSG_MESSAGE = 'M', + LOGICAL_REP_MSG_DDL = 'L', LOGICAL_REP_MSG_BEGIN_PREPARE = 'b', LOGICAL_REP_MSG_PREPARE = 'P', LOGICAL_REP_MSG_COMMIT_PREPARED = 'K', @@ -246,6 +247,9 @@ extern List *logicalrep_read_truncate(StringInfo in, bool *cascade, bool *restart_seqs); extern void logicalrep_write_message(StringInfo out, TransactionId xid, XLogRecPtr lsn, bool transactional, const char *prefix, Size sz, const char *message); +extern void logicalrep_write_ddl(StringInfo out, XLogRecPtr lsn, + const char *prefix, Size sz, const char *message); +extern char *logicalrep_read_ddl(StringInfo in, XLogRecPtr *lsn, const char **prefix, Size *sz); extern void logicalrep_write_rel(StringInfo out, TransactionId xid, Relation rel, Bitmapset *columns); extern LogicalRepRelation *logicalrep_read_rel(StringInfo in); diff --git a/src/include/replication/output_plugin.h b/src/include/replication/output_plugin.h index 5ed5e6a..44baf40 100644 --- a/src/include/replication/output_plugin.h +++ b/src/include/replication/output_plugin.h @@ -9,7 +9,6 @@ #ifndef OUTPUT_PLUGIN_H #define OUTPUT_PLUGIN_H -#include "replication/ddlmessage.h" #include "replication/reorderbuffer.h" struct LogicalDecodingContext; @@ -215,6 +214,19 @@ typedef void (*LogicalDecodeStreamMessageCB) (struct LogicalDecodingContext *ctx const char *message); /* + * Callback for streaming logical decoding DDL messages from in-progress + * transactions. + */ +typedef void (*LogicalDecodeStreamDDLMessageCB) (struct LogicalDecodingContext *ctx, + ReorderBufferTXN *txn, + XLogRecPtr message_lsn, + const char *prefix, + Oid relid, + DeparsedCommandType cmdtype, + Size message_size, + const char *message); + +/* * Callback for streaming truncates from in-progress transactions. */ typedef void (*LogicalDecodeStreamTruncateCB) (struct LogicalDecodingContext *ctx, @@ -253,6 +265,7 @@ typedef struct OutputPluginCallbacks LogicalDecodeStreamCommitCB stream_commit_cb; LogicalDecodeStreamChangeCB stream_change_cb; LogicalDecodeStreamMessageCB stream_message_cb; + LogicalDecodeStreamDDLMessageCB stream_ddl_cb; LogicalDecodeStreamTruncateCB stream_truncate_cb; } OutputPluginCallbacks; diff --git a/src/include/replication/pgoutput.h b/src/include/replication/pgoutput.h index b4a8015..a2cf99b 100644 --- a/src/include/replication/pgoutput.h +++ b/src/include/replication/pgoutput.h @@ -25,6 +25,7 @@ typedef struct PGOutputData uint32 protocol_version; List *publication_names; List *publications; + List *deleted_relids; bool binary; char streaming; bool messages; diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index 0158fbd..25a061a 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -559,6 +559,17 @@ typedef void (*ReorderBufferStreamMessageCB) ( const char *prefix, Size sz, const char *message); +/* stream DDL message callback signature */ +typedef void (*ReorderBufferStreamDDLMessageCB) ( + ReorderBuffer *rb, + ReorderBufferTXN *txn, + XLogRecPtr message_lsn, + const char *prefix, + Oid relid, + DeparsedCommandType cmdtype, + Size sz, + const char *message); + /* stream truncate callback signature */ typedef void (*ReorderBufferStreamTruncateCB) ( ReorderBuffer *rb, @@ -635,6 +646,7 @@ struct ReorderBuffer ReorderBufferStreamCommitCB stream_commit; ReorderBufferStreamChangeCB stream_change; ReorderBufferStreamMessageCB stream_message; + ReorderBufferStreamDDLMessageCB stream_ddl; ReorderBufferStreamTruncateCB stream_truncate; /* diff --git a/src/include/tcop/cmdtag.h b/src/include/tcop/cmdtag.h index 1e7514d..076c27e 100644 --- a/src/include/tcop/cmdtag.h +++ b/src/include/tcop/cmdtag.h @@ -16,7 +16,7 @@ /* buffer size required for command completion tags */ #define COMPLETION_TAG_BUFSIZE 64 -#define PG_CMDTAG(tag, name, evtrgok, rwrok, rowcnt) \ +#define PG_CMDTAG(tag, name, evtrgok, rwrok, rowcnt, ddlreplok) \ tag, typedef enum CommandTag @@ -53,9 +53,11 @@ CopyQueryCompletion(QueryCompletion *dst, const QueryCompletion *src) extern void InitializeQueryCompletion(QueryCompletion *qc); extern const char *GetCommandTagName(CommandTag commandTag); extern const char *GetCommandTagNameAndLen(CommandTag commandTag, Size *len); +extern CommandTag *GetCommandTagsForDDLRepl(int *ncommands); extern bool command_tag_display_rowcount(CommandTag commandTag); extern bool command_tag_event_trigger_ok(CommandTag commandTag); extern bool command_tag_table_rewrite_ok(CommandTag commandTag); +extern bool command_tag_ddl_replication_ok(CommandTag commandTag); extern CommandTag GetCommandTagEnum(const char *commandname); extern Size BuildQueryCompletionString(char *buff, const QueryCompletion *qc, bool nameonly); diff --git a/src/include/tcop/cmdtaglist.h b/src/include/tcop/cmdtaglist.h index e738ac1..18b69e4 100644 --- a/src/include/tcop/cmdtaglist.h +++ b/src/include/tcop/cmdtaglist.h @@ -23,196 +23,196 @@ * textual name, so that we can bsearch on it; see GetCommandTagEnum(). */ -/* symbol name, textual name, event_trigger_ok, table_rewrite_ok, rowcount */ -PG_CMDTAG(CMDTAG_UNKNOWN, "???", false, false, false) -PG_CMDTAG(CMDTAG_ALTER_ACCESS_METHOD, "ALTER ACCESS METHOD", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_AGGREGATE, "ALTER AGGREGATE", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_CAST, "ALTER CAST", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_COLLATION, "ALTER COLLATION", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_CONSTRAINT, "ALTER CONSTRAINT", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_CONVERSION, "ALTER CONVERSION", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_DATABASE, "ALTER DATABASE", false, false, false) -PG_CMDTAG(CMDTAG_ALTER_DEFAULT_PRIVILEGES, "ALTER DEFAULT PRIVILEGES", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_DOMAIN, "ALTER DOMAIN", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_EVENT_TRIGGER, "ALTER EVENT TRIGGER", false, false, false) -PG_CMDTAG(CMDTAG_ALTER_EXTENSION, "ALTER EXTENSION", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_FOREIGN_DATA_WRAPPER, "ALTER FOREIGN DATA WRAPPER", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_FOREIGN_TABLE, "ALTER FOREIGN TABLE", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_FUNCTION, "ALTER FUNCTION", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_INDEX, "ALTER INDEX", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_LANGUAGE, "ALTER LANGUAGE", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_LARGE_OBJECT, "ALTER LARGE OBJECT", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_MATERIALIZED_VIEW, "ALTER MATERIALIZED VIEW", true, true, false) -PG_CMDTAG(CMDTAG_ALTER_OPERATOR, "ALTER OPERATOR", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_OPERATOR_CLASS, "ALTER OPERATOR CLASS", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_OPERATOR_FAMILY, "ALTER OPERATOR FAMILY", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_POLICY, "ALTER POLICY", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_PROCEDURE, "ALTER PROCEDURE", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_PUBLICATION, "ALTER PUBLICATION", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_ROLE, "ALTER ROLE", false, false, false) -PG_CMDTAG(CMDTAG_ALTER_ROUTINE, "ALTER ROUTINE", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_RULE, "ALTER RULE", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_SCHEMA, "ALTER SCHEMA", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_SEQUENCE, "ALTER SEQUENCE", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_SERVER, "ALTER SERVER", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_STATISTICS, "ALTER STATISTICS", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_SUBSCRIPTION, "ALTER SUBSCRIPTION", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_SYSTEM, "ALTER SYSTEM", false, false, false) -PG_CMDTAG(CMDTAG_ALTER_TABLE, "ALTER TABLE", true, true, false) -PG_CMDTAG(CMDTAG_ALTER_TABLESPACE, "ALTER TABLESPACE", false, false, false) -PG_CMDTAG(CMDTAG_ALTER_TEXT_SEARCH_CONFIGURATION, "ALTER TEXT SEARCH CONFIGURATION", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_TEXT_SEARCH_DICTIONARY, "ALTER TEXT SEARCH DICTIONARY", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_TEXT_SEARCH_PARSER, "ALTER TEXT SEARCH PARSER", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_TEXT_SEARCH_TEMPLATE, "ALTER TEXT SEARCH TEMPLATE", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_TRANSFORM, "ALTER TRANSFORM", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_TRIGGER, "ALTER TRIGGER", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_TYPE, "ALTER TYPE", true, true, false) -PG_CMDTAG(CMDTAG_ALTER_USER_MAPPING, "ALTER USER MAPPING", true, false, false) -PG_CMDTAG(CMDTAG_ALTER_VIEW, "ALTER VIEW", true, false, false) -PG_CMDTAG(CMDTAG_ANALYZE, "ANALYZE", false, false, false) -PG_CMDTAG(CMDTAG_BEGIN, "BEGIN", false, false, false) -PG_CMDTAG(CMDTAG_CALL, "CALL", false, false, false) -PG_CMDTAG(CMDTAG_CHECKPOINT, "CHECKPOINT", false, false, false) -PG_CMDTAG(CMDTAG_CLOSE, "CLOSE", false, false, false) -PG_CMDTAG(CMDTAG_CLOSE_CURSOR, "CLOSE CURSOR", false, false, false) -PG_CMDTAG(CMDTAG_CLOSE_CURSOR_ALL, "CLOSE CURSOR ALL", false, false, false) -PG_CMDTAG(CMDTAG_CLUSTER, "CLUSTER", false, false, false) -PG_CMDTAG(CMDTAG_COMMENT, "COMMENT", true, false, false) -PG_CMDTAG(CMDTAG_COMMIT, "COMMIT", false, false, false) -PG_CMDTAG(CMDTAG_COMMIT_PREPARED, "COMMIT PREPARED", false, false, false) -PG_CMDTAG(CMDTAG_COPY, "COPY", false, false, true) -PG_CMDTAG(CMDTAG_COPY_FROM, "COPY FROM", false, false, false) -PG_CMDTAG(CMDTAG_CREATE_ACCESS_METHOD, "CREATE ACCESS METHOD", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_AGGREGATE, "CREATE AGGREGATE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_CAST, "CREATE CAST", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_COLLATION, "CREATE COLLATION", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_CONSTRAINT, "CREATE CONSTRAINT", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_CONVERSION, "CREATE CONVERSION", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_DATABASE, "CREATE DATABASE", false, false, false) -PG_CMDTAG(CMDTAG_CREATE_DOMAIN, "CREATE DOMAIN", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_EVENT_TRIGGER, "CREATE EVENT TRIGGER", false, false, false) -PG_CMDTAG(CMDTAG_CREATE_EXTENSION, "CREATE EXTENSION", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_FOREIGN_DATA_WRAPPER, "CREATE FOREIGN DATA WRAPPER", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_FOREIGN_TABLE, "CREATE FOREIGN TABLE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_FUNCTION, "CREATE FUNCTION", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_INDEX, "CREATE INDEX", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_LANGUAGE, "CREATE LANGUAGE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_MATERIALIZED_VIEW, "CREATE MATERIALIZED VIEW", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_OPERATOR, "CREATE OPERATOR", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_OPERATOR_CLASS, "CREATE OPERATOR CLASS", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_OPERATOR_FAMILY, "CREATE OPERATOR FAMILY", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_POLICY, "CREATE POLICY", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_PROCEDURE, "CREATE PROCEDURE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_PUBLICATION, "CREATE PUBLICATION", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_ROLE, "CREATE ROLE", false, false, false) -PG_CMDTAG(CMDTAG_CREATE_ROUTINE, "CREATE ROUTINE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_RULE, "CREATE RULE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_SCHEMA, "CREATE SCHEMA", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_SEQUENCE, "CREATE SEQUENCE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_SERVER, "CREATE SERVER", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_STATISTICS, "CREATE STATISTICS", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_SUBSCRIPTION, "CREATE SUBSCRIPTION", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TABLE, "CREATE TABLE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TABLE_AS, "CREATE TABLE AS", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TABLESPACE, "CREATE TABLESPACE", false, false, false) -PG_CMDTAG(CMDTAG_CREATE_TEXT_SEARCH_CONFIGURATION, "CREATE TEXT SEARCH CONFIGURATION", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TEXT_SEARCH_DICTIONARY, "CREATE TEXT SEARCH DICTIONARY", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TEXT_SEARCH_PARSER, "CREATE TEXT SEARCH PARSER", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TEXT_SEARCH_TEMPLATE, "CREATE TEXT SEARCH TEMPLATE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TRANSFORM, "CREATE TRANSFORM", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TRIGGER, "CREATE TRIGGER", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_TYPE, "CREATE TYPE", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_USER_MAPPING, "CREATE USER MAPPING", true, false, false) -PG_CMDTAG(CMDTAG_CREATE_VIEW, "CREATE VIEW", true, false, false) -PG_CMDTAG(CMDTAG_DEALLOCATE, "DEALLOCATE", false, false, false) -PG_CMDTAG(CMDTAG_DEALLOCATE_ALL, "DEALLOCATE ALL", false, false, false) -PG_CMDTAG(CMDTAG_DECLARE_CURSOR, "DECLARE CURSOR", false, false, false) -PG_CMDTAG(CMDTAG_DELETE, "DELETE", false, false, true) -PG_CMDTAG(CMDTAG_DISCARD, "DISCARD", false, false, false) -PG_CMDTAG(CMDTAG_DISCARD_ALL, "DISCARD ALL", false, false, false) -PG_CMDTAG(CMDTAG_DISCARD_PLANS, "DISCARD PLANS", false, false, false) -PG_CMDTAG(CMDTAG_DISCARD_SEQUENCES, "DISCARD SEQUENCES", false, false, false) -PG_CMDTAG(CMDTAG_DISCARD_TEMP, "DISCARD TEMP", false, false, false) -PG_CMDTAG(CMDTAG_DO, "DO", false, false, false) -PG_CMDTAG(CMDTAG_DROP_ACCESS_METHOD, "DROP ACCESS METHOD", true, false, false) -PG_CMDTAG(CMDTAG_DROP_AGGREGATE, "DROP AGGREGATE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_CAST, "DROP CAST", true, false, false) -PG_CMDTAG(CMDTAG_DROP_COLLATION, "DROP COLLATION", true, false, false) -PG_CMDTAG(CMDTAG_DROP_CONSTRAINT, "DROP CONSTRAINT", true, false, false) -PG_CMDTAG(CMDTAG_DROP_CONVERSION, "DROP CONVERSION", true, false, false) -PG_CMDTAG(CMDTAG_DROP_DATABASE, "DROP DATABASE", false, false, false) -PG_CMDTAG(CMDTAG_DROP_DOMAIN, "DROP DOMAIN", true, false, false) -PG_CMDTAG(CMDTAG_DROP_EVENT_TRIGGER, "DROP EVENT TRIGGER", false, false, false) -PG_CMDTAG(CMDTAG_DROP_EXTENSION, "DROP EXTENSION", true, false, false) -PG_CMDTAG(CMDTAG_DROP_FOREIGN_DATA_WRAPPER, "DROP FOREIGN DATA WRAPPER", true, false, false) -PG_CMDTAG(CMDTAG_DROP_FOREIGN_TABLE, "DROP FOREIGN TABLE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_FUNCTION, "DROP FUNCTION", true, false, false) -PG_CMDTAG(CMDTAG_DROP_INDEX, "DROP INDEX", true, false, false) -PG_CMDTAG(CMDTAG_DROP_LANGUAGE, "DROP LANGUAGE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_MATERIALIZED_VIEW, "DROP MATERIALIZED VIEW", true, false, false) -PG_CMDTAG(CMDTAG_DROP_OPERATOR, "DROP OPERATOR", true, false, false) -PG_CMDTAG(CMDTAG_DROP_OPERATOR_CLASS, "DROP OPERATOR CLASS", true, false, false) -PG_CMDTAG(CMDTAG_DROP_OPERATOR_FAMILY, "DROP OPERATOR FAMILY", true, false, false) -PG_CMDTAG(CMDTAG_DROP_OWNED, "DROP OWNED", true, false, false) -PG_CMDTAG(CMDTAG_DROP_POLICY, "DROP POLICY", true, false, false) -PG_CMDTAG(CMDTAG_DROP_PROCEDURE, "DROP PROCEDURE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_PUBLICATION, "DROP PUBLICATION", true, false, false) -PG_CMDTAG(CMDTAG_DROP_ROLE, "DROP ROLE", false, false, false) -PG_CMDTAG(CMDTAG_DROP_ROUTINE, "DROP ROUTINE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_RULE, "DROP RULE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_SCHEMA, "DROP SCHEMA", true, false, false) -PG_CMDTAG(CMDTAG_DROP_SEQUENCE, "DROP SEQUENCE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_SERVER, "DROP SERVER", true, false, false) -PG_CMDTAG(CMDTAG_DROP_STATISTICS, "DROP STATISTICS", true, false, false) -PG_CMDTAG(CMDTAG_DROP_SUBSCRIPTION, "DROP SUBSCRIPTION", true, false, false) -PG_CMDTAG(CMDTAG_DROP_TABLE, "DROP TABLE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_TABLESPACE, "DROP TABLESPACE", false, false, false) -PG_CMDTAG(CMDTAG_DROP_TEXT_SEARCH_CONFIGURATION, "DROP TEXT SEARCH CONFIGURATION", true, false, false) -PG_CMDTAG(CMDTAG_DROP_TEXT_SEARCH_DICTIONARY, "DROP TEXT SEARCH DICTIONARY", true, false, false) -PG_CMDTAG(CMDTAG_DROP_TEXT_SEARCH_PARSER, "DROP TEXT SEARCH PARSER", true, false, false) -PG_CMDTAG(CMDTAG_DROP_TEXT_SEARCH_TEMPLATE, "DROP TEXT SEARCH TEMPLATE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_TRANSFORM, "DROP TRANSFORM", true, false, false) -PG_CMDTAG(CMDTAG_DROP_TRIGGER, "DROP TRIGGER", true, false, false) -PG_CMDTAG(CMDTAG_DROP_TYPE, "DROP TYPE", true, false, false) -PG_CMDTAG(CMDTAG_DROP_USER_MAPPING, "DROP USER MAPPING", true, false, false) -PG_CMDTAG(CMDTAG_DROP_VIEW, "DROP VIEW", true, false, false) -PG_CMDTAG(CMDTAG_EXECUTE, "EXECUTE", false, false, false) -PG_CMDTAG(CMDTAG_EXPLAIN, "EXPLAIN", false, false, false) -PG_CMDTAG(CMDTAG_FETCH, "FETCH", false, false, true) -PG_CMDTAG(CMDTAG_GRANT, "GRANT", true, false, false) -PG_CMDTAG(CMDTAG_GRANT_ROLE, "GRANT ROLE", false, false, false) -PG_CMDTAG(CMDTAG_IMPORT_FOREIGN_SCHEMA, "IMPORT FOREIGN SCHEMA", true, false, false) -PG_CMDTAG(CMDTAG_INSERT, "INSERT", false, false, true) -PG_CMDTAG(CMDTAG_LISTEN, "LISTEN", false, false, false) -PG_CMDTAG(CMDTAG_LOAD, "LOAD", false, false, false) -PG_CMDTAG(CMDTAG_LOCK_TABLE, "LOCK TABLE", false, false, false) -PG_CMDTAG(CMDTAG_MERGE, "MERGE", false, false, true) -PG_CMDTAG(CMDTAG_MOVE, "MOVE", false, false, true) -PG_CMDTAG(CMDTAG_NOTIFY, "NOTIFY", false, false, false) -PG_CMDTAG(CMDTAG_PREPARE, "PREPARE", false, false, false) -PG_CMDTAG(CMDTAG_PREPARE_TRANSACTION, "PREPARE TRANSACTION", false, false, false) -PG_CMDTAG(CMDTAG_REASSIGN_OWNED, "REASSIGN OWNED", false, false, false) -PG_CMDTAG(CMDTAG_REFRESH_MATERIALIZED_VIEW, "REFRESH MATERIALIZED VIEW", true, false, false) -PG_CMDTAG(CMDTAG_REINDEX, "REINDEX", false, false, false) -PG_CMDTAG(CMDTAG_RELEASE, "RELEASE", false, false, false) -PG_CMDTAG(CMDTAG_RESET, "RESET", false, false, false) -PG_CMDTAG(CMDTAG_REVOKE, "REVOKE", true, false, false) -PG_CMDTAG(CMDTAG_REVOKE_ROLE, "REVOKE ROLE", false, false, false) -PG_CMDTAG(CMDTAG_ROLLBACK, "ROLLBACK", false, false, false) -PG_CMDTAG(CMDTAG_ROLLBACK_PREPARED, "ROLLBACK PREPARED", false, false, false) -PG_CMDTAG(CMDTAG_SAVEPOINT, "SAVEPOINT", false, false, false) -PG_CMDTAG(CMDTAG_SECURITY_LABEL, "SECURITY LABEL", true, false, false) -PG_CMDTAG(CMDTAG_SELECT, "SELECT", false, false, true) -PG_CMDTAG(CMDTAG_SELECT_FOR_KEY_SHARE, "SELECT FOR KEY SHARE", false, false, false) -PG_CMDTAG(CMDTAG_SELECT_FOR_NO_KEY_UPDATE, "SELECT FOR NO KEY UPDATE", false, false, false) -PG_CMDTAG(CMDTAG_SELECT_FOR_SHARE, "SELECT FOR SHARE", false, false, false) -PG_CMDTAG(CMDTAG_SELECT_FOR_UPDATE, "SELECT FOR UPDATE", false, false, false) -PG_CMDTAG(CMDTAG_SELECT_INTO, "SELECT INTO", true, false, false) -PG_CMDTAG(CMDTAG_SET, "SET", false, false, false) -PG_CMDTAG(CMDTAG_SET_CONSTRAINTS, "SET CONSTRAINTS", false, false, false) -PG_CMDTAG(CMDTAG_SHOW, "SHOW", false, false, false) -PG_CMDTAG(CMDTAG_START_TRANSACTION, "START TRANSACTION", false, false, false) -PG_CMDTAG(CMDTAG_TRUNCATE_TABLE, "TRUNCATE TABLE", false, false, false) -PG_CMDTAG(CMDTAG_UNLISTEN, "UNLISTEN", false, false, false) -PG_CMDTAG(CMDTAG_UPDATE, "UPDATE", false, false, true) -PG_CMDTAG(CMDTAG_VACUUM, "VACUUM", false, false, false) +/* symbol name, textual name, event_trigger_ok, table_rewrite_ok, rowcount, ddlreplok */ +PG_CMDTAG(CMDTAG_UNKNOWN, "???", false, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_ACCESS_METHOD, "ALTER ACCESS METHOD", true, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_AGGREGATE, "ALTER AGGREGATE", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_CAST, "ALTER CAST", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_COLLATION, "ALTER COLLATION", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_CONSTRAINT, "ALTER CONSTRAINT", true, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_CONVERSION, "ALTER CONVERSION", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_DATABASE, "ALTER DATABASE", false, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_DEFAULT_PRIVILEGES, "ALTER DEFAULT PRIVILEGES", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_DOMAIN, "ALTER DOMAIN", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_EVENT_TRIGGER, "ALTER EVENT TRIGGER", false, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_EXTENSION, "ALTER EXTENSION", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_FOREIGN_DATA_WRAPPER, "ALTER FOREIGN DATA WRAPPER", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_FOREIGN_TABLE, "ALTER FOREIGN TABLE", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_FUNCTION, "ALTER FUNCTION", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_INDEX, "ALTER INDEX", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_LANGUAGE, "ALTER LANGUAGE", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_LARGE_OBJECT, "ALTER LARGE OBJECT", true, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_MATERIALIZED_VIEW, "ALTER MATERIALIZED VIEW", true, true, false, true) +PG_CMDTAG(CMDTAG_ALTER_OPERATOR, "ALTER OPERATOR", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_OPERATOR_CLASS, "ALTER OPERATOR CLASS", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_OPERATOR_FAMILY, "ALTER OPERATOR FAMILY", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_POLICY, "ALTER POLICY", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_PROCEDURE, "ALTER PROCEDURE", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_PUBLICATION, "ALTER PUBLICATION", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_ROLE, "ALTER ROLE", false, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_ROUTINE, "ALTER ROUTINE", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_RULE, "ALTER RULE", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_SCHEMA, "ALTER SCHEMA", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_SEQUENCE, "ALTER SEQUENCE", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_SERVER, "ALTER SERVER", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_STATISTICS, "ALTER STATISTICS", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_SUBSCRIPTION, "ALTER SUBSCRIPTION", true, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_SYSTEM, "ALTER SYSTEM", false, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_TABLE, "ALTER TABLE", true, true, false, true) +PG_CMDTAG(CMDTAG_ALTER_TABLESPACE, "ALTER TABLESPACE", false, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_TEXT_SEARCH_CONFIGURATION, "ALTER TEXT SEARCH CONFIGURATION", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_TEXT_SEARCH_DICTIONARY, "ALTER TEXT SEARCH DICTIONARY", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_TEXT_SEARCH_PARSER, "ALTER TEXT SEARCH PARSER", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_TEXT_SEARCH_TEMPLATE, "ALTER TEXT SEARCH TEMPLATE", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_TRANSFORM, "ALTER TRANSFORM", true, false, false, false) +PG_CMDTAG(CMDTAG_ALTER_TRIGGER, "ALTER TRIGGER", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_TYPE, "ALTER TYPE", true, true, false, true) +PG_CMDTAG(CMDTAG_ALTER_USER_MAPPING, "ALTER USER MAPPING", true, false, false, true) +PG_CMDTAG(CMDTAG_ALTER_VIEW, "ALTER VIEW", true, false, false, true) +PG_CMDTAG(CMDTAG_ANALYZE, "ANALYZE", false, false, false, false) +PG_CMDTAG(CMDTAG_BEGIN, "BEGIN", false, false, false, false) +PG_CMDTAG(CMDTAG_CALL, "CALL", false, false, false, false) +PG_CMDTAG(CMDTAG_CHECKPOINT, "CHECKPOINT", false, false, false, false) +PG_CMDTAG(CMDTAG_CLOSE, "CLOSE", false, false, false, false) +PG_CMDTAG(CMDTAG_CLOSE_CURSOR, "CLOSE CURSOR", false, false, false, false) +PG_CMDTAG(CMDTAG_CLOSE_CURSOR_ALL, "CLOSE CURSOR ALL", false, false, false, false) +PG_CMDTAG(CMDTAG_CLUSTER, "CLUSTER", false, false, false, false) +PG_CMDTAG(CMDTAG_COMMENT, "COMMENT", true, false, false, true) +PG_CMDTAG(CMDTAG_COMMIT, "COMMIT", false, false, false, false) +PG_CMDTAG(CMDTAG_COMMIT_PREPARED, "COMMIT PREPARED", false, false, false, false) +PG_CMDTAG(CMDTAG_COPY, "COPY", false, false, true, false) +PG_CMDTAG(CMDTAG_COPY_FROM, "COPY FROM", false, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_ACCESS_METHOD, "CREATE ACCESS METHOD", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_AGGREGATE, "CREATE AGGREGATE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_CAST, "CREATE CAST", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_COLLATION, "CREATE COLLATION", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_CONSTRAINT, "CREATE CONSTRAINT", true, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_CONVERSION, "CREATE CONVERSION", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_DATABASE, "CREATE DATABASE", false, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_DOMAIN, "CREATE DOMAIN", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_EVENT_TRIGGER, "CREATE EVENT TRIGGER", false, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_EXTENSION, "CREATE EXTENSION", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_FOREIGN_DATA_WRAPPER, "CREATE FOREIGN DATA WRAPPER", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_FOREIGN_TABLE, "CREATE FOREIGN TABLE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_FUNCTION, "CREATE FUNCTION", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_INDEX, "CREATE INDEX", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_LANGUAGE, "CREATE LANGUAGE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_MATERIALIZED_VIEW, "CREATE MATERIALIZED VIEW", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_OPERATOR, "CREATE OPERATOR", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_OPERATOR_CLASS, "CREATE OPERATOR CLASS", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_OPERATOR_FAMILY, "CREATE OPERATOR FAMILY", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_POLICY, "CREATE POLICY", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_PROCEDURE, "CREATE PROCEDURE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_PUBLICATION, "CREATE PUBLICATION", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_ROLE, "CREATE ROLE", false, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_ROUTINE, "CREATE ROUTINE", true, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_RULE, "CREATE RULE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_SCHEMA, "CREATE SCHEMA", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_SEQUENCE, "CREATE SEQUENCE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_SERVER, "CREATE SERVER", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_STATISTICS, "CREATE STATISTICS", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_SUBSCRIPTION, "CREATE SUBSCRIPTION", true, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_TABLE, "CREATE TABLE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_TABLE_AS, "CREATE TABLE AS", true, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_TABLESPACE, "CREATE TABLESPACE", false, false, false, false) +PG_CMDTAG(CMDTAG_CREATE_TEXT_SEARCH_CONFIGURATION, "CREATE TEXT SEARCH CONFIGURATION", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_TEXT_SEARCH_DICTIONARY, "CREATE TEXT SEARCH DICTIONARY", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_TEXT_SEARCH_PARSER, "CREATE TEXT SEARCH PARSER", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_TEXT_SEARCH_TEMPLATE, "CREATE TEXT SEARCH TEMPLATE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_TRANSFORM, "CREATE TRANSFORM", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_TRIGGER, "CREATE TRIGGER", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_TYPE, "CREATE TYPE", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_USER_MAPPING, "CREATE USER MAPPING", true, false, false, true) +PG_CMDTAG(CMDTAG_CREATE_VIEW, "CREATE VIEW", true, false, false, true) +PG_CMDTAG(CMDTAG_DEALLOCATE, "DEALLOCATE", false, false, false, false) +PG_CMDTAG(CMDTAG_DEALLOCATE_ALL, "DEALLOCATE ALL", false, false, false, false) +PG_CMDTAG(CMDTAG_DECLARE_CURSOR, "DECLARE CURSOR", false, false, false, false) +PG_CMDTAG(CMDTAG_DELETE, "DELETE", false, false, true, false) +PG_CMDTAG(CMDTAG_DISCARD, "DISCARD", false, false, false, false) +PG_CMDTAG(CMDTAG_DISCARD_ALL, "DISCARD ALL", false, false, false, false) +PG_CMDTAG(CMDTAG_DISCARD_PLANS, "DISCARD PLANS", false, false, false, false) +PG_CMDTAG(CMDTAG_DISCARD_SEQUENCES, "DISCARD SEQUENCES", false, false, false, false) +PG_CMDTAG(CMDTAG_DISCARD_TEMP, "DISCARD TEMP", false, false, false, false) +PG_CMDTAG(CMDTAG_DO, "DO", false, false, false, false) +PG_CMDTAG(CMDTAG_DROP_ACCESS_METHOD, "DROP ACCESS METHOD", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_AGGREGATE, "DROP AGGREGATE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_CAST, "DROP CAST", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_COLLATION, "DROP COLLATION", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_CONSTRAINT, "DROP CONSTRAINT", true, false, false, false) +PG_CMDTAG(CMDTAG_DROP_CONVERSION, "DROP CONVERSION", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_DATABASE, "DROP DATABASE", false, false, false, false) +PG_CMDTAG(CMDTAG_DROP_DOMAIN, "DROP DOMAIN", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_EVENT_TRIGGER, "DROP EVENT TRIGGER", false, false, false, false) +PG_CMDTAG(CMDTAG_DROP_EXTENSION, "DROP EXTENSION", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_FOREIGN_DATA_WRAPPER, "DROP FOREIGN DATA WRAPPER", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_FOREIGN_TABLE, "DROP FOREIGN TABLE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_FUNCTION, "DROP FUNCTION", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_INDEX, "DROP INDEX", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_LANGUAGE, "DROP LANGUAGE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_MATERIALIZED_VIEW, "DROP MATERIALIZED VIEW", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_OPERATOR, "DROP OPERATOR", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_OPERATOR_CLASS, "DROP OPERATOR CLASS", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_OPERATOR_FAMILY, "DROP OPERATOR FAMILY", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_OWNED, "DROP OWNED", true, false, false, false) +PG_CMDTAG(CMDTAG_DROP_POLICY, "DROP POLICY", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_PROCEDURE, "DROP PROCEDURE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_PUBLICATION, "DROP PUBLICATION", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_ROLE, "DROP ROLE", false, false, false, false) +PG_CMDTAG(CMDTAG_DROP_ROUTINE, "DROP ROUTINE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_RULE, "DROP RULE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_SCHEMA, "DROP SCHEMA", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_SEQUENCE, "DROP SEQUENCE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_SERVER, "DROP SERVER", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_STATISTICS, "DROP STATISTICS", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_SUBSCRIPTION, "DROP SUBSCRIPTION", true, false, false, false) +PG_CMDTAG(CMDTAG_DROP_TABLE, "DROP TABLE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_TABLESPACE, "DROP TABLESPACE", false, false, false, false) +PG_CMDTAG(CMDTAG_DROP_TEXT_SEARCH_CONFIGURATION, "DROP TEXT SEARCH CONFIGURATION", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_TEXT_SEARCH_DICTIONARY, "DROP TEXT SEARCH DICTIONARY", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_TEXT_SEARCH_PARSER, "DROP TEXT SEARCH PARSER", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_TEXT_SEARCH_TEMPLATE, "DROP TEXT SEARCH TEMPLATE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_TRANSFORM, "DROP TRANSFORM", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_TRIGGER, "DROP TRIGGER", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_TYPE, "DROP TYPE", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_USER_MAPPING, "DROP USER MAPPING", true, false, false, true) +PG_CMDTAG(CMDTAG_DROP_VIEW, "DROP VIEW", true, false, false, true) +PG_CMDTAG(CMDTAG_EXECUTE, "EXECUTE", false, false, false, false) +PG_CMDTAG(CMDTAG_EXPLAIN, "EXPLAIN", false, false, false, false) +PG_CMDTAG(CMDTAG_FETCH, "FETCH", false, false, true, false) +PG_CMDTAG(CMDTAG_GRANT, "GRANT", true, false, false, true) +PG_CMDTAG(CMDTAG_GRANT_ROLE, "GRANT ROLE", false, false, false, false) +PG_CMDTAG(CMDTAG_IMPORT_FOREIGN_SCHEMA, "IMPORT FOREIGN SCHEMA", true, false, false, true) +PG_CMDTAG(CMDTAG_INSERT, "INSERT", false, false, true, false) +PG_CMDTAG(CMDTAG_LISTEN, "LISTEN", false, false, false, false) +PG_CMDTAG(CMDTAG_LOAD, "LOAD", false, false, false, false) +PG_CMDTAG(CMDTAG_LOCK_TABLE, "LOCK TABLE", false, false, false, false) +PG_CMDTAG(CMDTAG_MERGE, "MERGE", false, false, true, false) +PG_CMDTAG(CMDTAG_MOVE, "MOVE", false, false, true, false) +PG_CMDTAG(CMDTAG_NOTIFY, "NOTIFY", false, false, false, false) +PG_CMDTAG(CMDTAG_PREPARE, "PREPARE", false, false, false, false) +PG_CMDTAG(CMDTAG_PREPARE_TRANSACTION, "PREPARE TRANSACTION", false, false, false, false) +PG_CMDTAG(CMDTAG_REASSIGN_OWNED, "REASSIGN OWNED", false, false, false, false) +PG_CMDTAG(CMDTAG_REFRESH_MATERIALIZED_VIEW, "REFRESH MATERIALIZED VIEW", true, false, false, true) +PG_CMDTAG(CMDTAG_REINDEX, "REINDEX", false, false, false, false) +PG_CMDTAG(CMDTAG_RELEASE, "RELEASE", false, false, false, false) +PG_CMDTAG(CMDTAG_RESET, "RESET", false, false, false, false) +PG_CMDTAG(CMDTAG_REVOKE, "REVOKE", true, false, false, true) +PG_CMDTAG(CMDTAG_REVOKE_ROLE, "REVOKE ROLE", false, false, false, false) +PG_CMDTAG(CMDTAG_ROLLBACK, "ROLLBACK", false, false, false, false) +PG_CMDTAG(CMDTAG_ROLLBACK_PREPARED, "ROLLBACK PREPARED", false, false, false, false) +PG_CMDTAG(CMDTAG_SAVEPOINT, "SAVEPOINT", false, false, false, false) +PG_CMDTAG(CMDTAG_SECURITY_LABEL, "SECURITY LABEL", true, false, false, true) +PG_CMDTAG(CMDTAG_SELECT, "SELECT", false, false, true, false) +PG_CMDTAG(CMDTAG_SELECT_FOR_KEY_SHARE, "SELECT FOR KEY SHARE", false, false, false, false) +PG_CMDTAG(CMDTAG_SELECT_FOR_NO_KEY_UPDATE, "SELECT FOR NO KEY UPDATE", false, false, false, false) +PG_CMDTAG(CMDTAG_SELECT_FOR_SHARE, "SELECT FOR SHARE", false, false, false, false) +PG_CMDTAG(CMDTAG_SELECT_FOR_UPDATE, "SELECT FOR UPDATE", false, false, false, false) +PG_CMDTAG(CMDTAG_SELECT_INTO, "SELECT INTO", true, false, false, false) +PG_CMDTAG(CMDTAG_SET, "SET", false, false, false, false) +PG_CMDTAG(CMDTAG_SET_CONSTRAINTS, "SET CONSTRAINTS", false, false, false, false) +PG_CMDTAG(CMDTAG_SHOW, "SHOW", false, false, false, false) +PG_CMDTAG(CMDTAG_START_TRANSACTION, "START TRANSACTION", false, false, false, false) +PG_CMDTAG(CMDTAG_TRUNCATE_TABLE, "TRUNCATE TABLE", false, false, false, false) +PG_CMDTAG(CMDTAG_UNLISTEN, "UNLISTEN", false, false, false, false) +PG_CMDTAG(CMDTAG_UPDATE, "UPDATE", false, false, true, false) +PG_CMDTAG(CMDTAG_VACUUM, "VACUUM", false, false, false, false) diff --git a/src/include/tcop/deparse_utility.h b/src/include/tcop/deparse_utility.h index 9e262d7..fbd0976 100644 --- a/src/include/tcop/deparse_utility.h +++ b/src/include/tcop/deparse_utility.h @@ -65,6 +65,7 @@ typedef struct CollectedCommand { Oid objectId; Oid classId; + bool rewrite; List *subcmds; } alterTable; diff --git a/src/include/utils/evtcache.h b/src/include/utils/evtcache.h index d340026..91d4bdd 100644 --- a/src/include/utils/evtcache.h +++ b/src/include/utils/evtcache.h @@ -22,7 +22,8 @@ typedef enum EVT_DDLCommandStart, EVT_DDLCommandEnd, EVT_SQLDrop, - EVT_TableRewrite + EVT_TableRewrite, + EVT_TableInitWrite } EventTriggerEvent; typedef struct diff --git a/src/test/modules/test_ddl_deparse_regress/regression.diffs b/src/test/modules/test_ddl_deparse_regress/regression.diffs deleted file mode 100644 index 3be15de..0000000 --- a/src/test/modules/test_ddl_deparse_regress/regression.diffs +++ /dev/null @@ -1,847 +0,0 @@ -diff -U3 /home/ajin/postgresql/postgres/postgres2/postgres/src/test/modules/test_ddl_deparse_regress/expected/create_table.out /home/ajin/postgresql/postgres/postgres2/postgres/src/test/modules/test_ddl_deparse_regress/results/create_table.out ---- /home/ajin/postgresql/postgres/postgres2/postgres/src/test/modules/test_ddl_deparse_regress/expected/create_table.out 2023-03-22 23:08:34.915184709 -0400 -+++ /home/ajin/postgresql/postgres/postgres2/postgres/src/test/modules/test_ddl_deparse_regress/results/create_table.out 2023-03-22 23:09:46.810424685 -0400 -@@ -566,8 +566,8 @@ - CREATE TABLE ctlt1_like (LIKE ctlt1 INCLUDING ALL); - NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "ctlt1_like", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "a", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "main", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "b", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "external", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "ctlt1_a_check", "type": "constraint", "contype": "check", "definition": "CHECK ((pg_catalog.length(a) OPERATOR(pg_catalog.>) 2))"}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "ctlt1_like_pkey", "type": "constraint", "contype": "primary key", "definition": "PRIMARY KEY (a)"}]} - NOTICE: re-formed command: CREATE TABLE public.ctlt1_like (a pg_catalog.text STORAGE main COLLATE pg_catalog."default" , b pg_catalog.text STORAGE external COLLATE pg_catalog."default" , CONSTRAINT ctlt1_a_check CHECK ((pg_catalog.length(a) OPERATOR(pg_catalog.>) 2)), CONSTRAINT ctlt1_like_pkey PRIMARY KEY (a)) --NOTICE: deparsed json: --NOTICE: re-formed command: -+NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "ctlt1_a_check", "type": "add constraint", "definition": "CHECK ((pg_catalog.length(a) OPERATOR(pg_catalog.>) 2))"}], "identity": {"objname": "ctlt1_like", "schemaname": "public"}} -+NOTICE: re-formed command: ALTER TABLE public.ctlt1_like ADD CONSTRAINT ctlt1_a_check CHECK ((pg_catalog.length(a) OPERATOR(pg_catalog.>) 2)) - NOTICE: deparsed json: - NOTICE: re-formed command: - -- Test foreign key constraint is handled in a following ALTER TABLE ADD CONSTRAINT FOREIGN KEY REFERENCES subcommand -diff -U3 /home/ajin/postgresql/postgres/postgres2/postgres/src/test/modules/test_ddl_deparse_regress/expected/alter_table.out /home/ajin/postgresql/postgres/postgres2/postgres/src/test/modules/test_ddl_deparse_regress/results/alter_table.out ---- /home/ajin/postgresql/postgres/postgres2/postgres/src/test/modules/test_ddl_deparse_regress/expected/alter_table.out 2023-03-22 23:07:40.279002342 -0400 -+++ /home/ajin/postgresql/postgres/postgres2/postgres/src/test/modules/test_ddl_deparse_regress/results/alter_table.out 2023-03-22 23:09:48.466430212 -0400 -@@ -100,825 +100,7 @@ - NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER %{objtype}s %{column}I SET DATA TYPE %{datatype}T %{collation}s %{using}s", "type": "alter column type", "using": {"fmt": "USING", "present": false}, "column": "quantity", "objtype": "COLUMN", "datatype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "collation": {"fmt": "COLLATE", "present": false}}], "identity": {"objname": "test_alter_type", "schemaname": "public"}} - NOTICE: re-formed command: ALTER TABLE public.test_alter_type ALTER COLUMN quantity SET DATA TYPE pg_catalog.float4 - ALTER TABLE test_alter_type ALTER name TYPE int USING id::integer; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER %{objtype}s %{column}I SET DATA TYPE %{datatype}T %{collation}s %{using}s", "type": "alter column type", "using": {"fmt": "USING %{expression}s", "expression": "id"}, "column": "name", "objtype": "COLUMN", "datatype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "collation": {"fmt": "COLLATE", "present": false}}], "identity": {"objname": "test_alter_type", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_type ALTER COLUMN name SET DATA TYPE pg_catalog.int4 USING id ---- ALTER [ COLUMN ] column_name SET DEFAULT expression --CREATE TABLE test_alter_set_default( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_alter_set_default", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_alter_set_default (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_alter_set_default ALTER price SET DEFAULT 100; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET DEFAULT %{definition}s", "type": "set default", "column": "price", "definition": "100"}], "identity": {"objname": "test_alter_set_default", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_set_default ALTER COLUMN price SET DEFAULT 100 --ALTER TABLE test_alter_set_default ALTER COLUMN quantity SET DEFAULT 10; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET DEFAULT %{definition}s", "type": "set default", "column": "quantity", "definition": "10"}], "identity": {"objname": "test_alter_set_default", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_set_default ALTER COLUMN quantity SET DEFAULT 10 ---- ALTER [ COLUMN ] column_name DROP DEFAULT --CREATE TABLE test_drop_default( -- LIKE orders, -- default_price float4 DEFAULT 10.0, -- default_name varchar DEFAULT 'foo' --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_drop_default", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "default_price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT %{default}s", "default": "10.0"}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "default_name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT %{default}s", "default": "'foo'::character varying"}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_drop_default (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , default_price pg_catalog.float4 STORAGE plain DEFAULT 10.0 , default_name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" DEFAULT 'foo'::character varying ) --ALTER TABLE test_drop_default ALTER default_price DROP DEFAULT; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I DROP DEFAULT", "type": "drop default", "column": "default_price"}], "identity": {"objname": "test_drop_default", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_default ALTER COLUMN default_price DROP DEFAULT --ALTER TABLE test_drop_default ALTER COLUMN default_name DROP DEFAULT; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I DROP DEFAULT", "type": "drop default", "column": "default_name"}], "identity": {"objname": "test_drop_default", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_default ALTER COLUMN default_name DROP DEFAULT ---- ALTER [ COLUMN ] column_name { SET | DROP } NOT NULL --CREATE TABLE test_set_not_null( -- LIKE orders, -- size int NOT NULL --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_not_null", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "size", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "NOT NULL", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_not_null (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , size pg_catalog.int4 STORAGE plain NOT NULL ) --ALTER TABLE test_set_not_null ALTER COLUMN id SET NOT NULL; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET NOT NULL", "type": "set not null", "column": "id"}], "identity": {"objname": "test_set_not_null", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_not_null ALTER COLUMN id SET NOT NULL --ALTER TABLE test_set_not_null ALTER size DROP NOT NULL; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I DROP NOT NULL", "type": "drop not null", "column": "size"}], "identity": {"objname": "test_set_not_null", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_not_null ALTER COLUMN size DROP NOT NULL ---- ALTER [ COLUMN ] column_name DROP EXPRESSION [ IF EXISTS ] --CREATE TABLE test_drop_expression( -- LIKE orders, -- new_id int GENERATED ALWAYS AS ( 3 * ID ) STORED --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_drop_expression", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "new_id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS (%{generation_expr}s) STORED", "generation_expr": "(3 OPERATOR(pg_catalog.*) id)"}}]} --NOTICE: re-formed command: CREATE TABLE public.test_drop_expression (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , new_id pg_catalog.int4 STORAGE plain GENERATED ALWAYS AS ((3 OPERATOR(pg_catalog.*) id)) STORED) --ALTER TABLE test_drop_expression ALTER new_id DROP EXPRESSION; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I DROP EXPRESSION %{if_exists}s", "type": "drop expression", "column": "new_id", "if_exists": ""}], "identity": {"objname": "test_drop_expression", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_expression ALTER COLUMN new_id DROP EXPRESSION --ALTER TABLE test_drop_expression ALTER id DROP EXPRESSION IF EXISTS; --NOTICE: column "id" of relation "test_drop_expression" is not a stored generated column, skipping --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I DROP EXPRESSION %{if_exists}s", "type": "drop expression", "column": "id", "if_exists": "IF EXISTS"}], "identity": {"objname": "test_drop_expression", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_expression ALTER COLUMN id DROP EXPRESSION IF EXISTS ---- ALTER [ COLUMN ] column_name ADD GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( sequence_options ) ] --CREATE TABLE test_add_generated( -- LIKE orders, -- col1 int NOT NULL, -- col2 int NOT NULL, -- col3 int NOT NULL --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_add_generated", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "col1", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "NOT NULL", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "col2", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "NOT NULL", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "col3", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "NOT NULL", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_add_generated (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , col1 pg_catalog.int4 STORAGE plain NOT NULL , col2 pg_catalog.int4 STORAGE plain NOT NULL , col3 pg_catalog.int4 STORAGE plain NOT NULL ) --ALTER TABLE test_add_generated ALTER col1 ADD GENERATED ALWAYS AS IDENTITY; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I ADD %{identity_column}s", "type": "add identity", "column": "col1", "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "ALWAYS"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}}], "identity": {"objname": "test_add_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_generated ALTER COLUMN col1 ADD GENERATED ALWAYS AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) --ALTER TABLE test_add_generated ALTER COLUMN col2 ADD GENERATED BY DEFAULT AS IDENTITY; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I ADD %{identity_column}s", "type": "add identity", "column": "col2", "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "BY DEFAULT"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}}], "identity": {"objname": "test_add_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_generated ALTER COLUMN col2 ADD GENERATED BY DEFAULT AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) --ALTER TABLE test_add_generated ALTER col3 ADD GENERATED BY DEFAULT AS IDENTITY ( INCREMENT BY 10 ); --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I ADD %{identity_column}s", "type": "add identity", "column": "col3", "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "BY DEFAULT"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "10", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}}], "identity": {"objname": "test_add_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_generated ALTER COLUMN col3 ADD GENERATED BY DEFAULT AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 10 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) ---- ALTER [ COLUMN ] column_name { SET GENERATED { ALWAYS | BY DEFAULT } | SET sequence_option | RESTART [ [ WITH ] restart ] } [...] --CREATE TABLE test_set_generated( -- id1 int GENERATED BY DEFAULT AS IDENTITY, -- id2 int GENERATED ALWAYS AS IDENTITY, -- id3 int GENERATED ALWAYS AS IDENTITY, -- id4 int GENERATED ALWAYS AS IDENTITY, -- id5 int GENERATED ALWAYS AS IDENTITY, -- id6 int GENERATED ALWAYS AS IDENTITY, -- id7 int GENERATED ALWAYS AS IDENTITY --); --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_generated", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{identity_column}s %{generated_column}s", "name": "id1", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "BY DEFAULT"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{identity_column}s %{generated_column}s", "name": "id2", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "ALWAYS"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{identity_column}s %{generated_column}s", "name": "id3", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "ALWAYS"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{identity_column}s %{generated_column}s", "name": "id4", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "ALWAYS"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{identity_column}s %{generated_column}s", "name": "id5", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "ALWAYS"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{identity_column}s %{generated_column}s", "name": "id6", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "ALWAYS"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{identity_column}s %{generated_column}s", "name": "id7", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "ALWAYS"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_generated (id1 pg_catalog.int4 STORAGE plain GENERATED BY DEFAULT AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) , id2 pg_catalog.int4 STORAGE plain GENERATED ALWAYS AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) , id3 pg_catalog.int4 STORAGE plain GENERATED ALWAYS AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) , id4 pg_catalog.int4 STORAGE plain GENERATED ALWAYS AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) , id5 pg_catalog.int4 STORAGE plain GENERATED ALWAYS AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) , id6 pg_catalog.int4 STORAGE plain GENERATED ALWAYS AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) , id7 pg_catalog.int4 STORAGE plain GENERATED ALWAYS AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) ) --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --ALTER TABLE test_set_generated ALTER id1 SET GENERATED ALWAYS; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{definition}s", "type": "set identity", "column": "id1", "definition": {"fmt": "%{identity_type}s %{seq_definition: }s", "identity_type": {"fmt": "SET GENERATED %{option}s", "option": "ALWAYS"}, "seq_definition": [{"fmt": "SET CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "SET %{no}s CYCLE", "clause": "cycle"}, {"fmt": "SET INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "SET MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "SET MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "SET START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}}], "identity": {"objname": "test_set_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_generated ALTER COLUMN id1 SET GENERATED ALWAYS SET CACHE 1 SET NO CYCLE SET INCREMENT BY 1 SET MINVALUE 1 SET MAXVALUE 2147483647 SET START WITH 1 RESTART 1 --ALTER TABLE test_set_generated ALTER id2 SET GENERATED BY DEFAULT; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{definition}s", "type": "set identity", "column": "id2", "definition": {"fmt": "%{identity_type}s %{seq_definition: }s", "identity_type": {"fmt": "SET GENERATED %{option}s", "option": "BY DEFAULT"}, "seq_definition": [{"fmt": "SET CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "SET %{no}s CYCLE", "clause": "cycle"}, {"fmt": "SET INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "SET MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "SET MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "SET START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}}], "identity": {"objname": "test_set_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_generated ALTER COLUMN id2 SET GENERATED BY DEFAULT SET CACHE 1 SET NO CYCLE SET INCREMENT BY 1 SET MINVALUE 1 SET MAXVALUE 2147483647 SET START WITH 1 RESTART 1 --ALTER TABLE test_set_generated ALTER id3 SET INCREMENT BY 10; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{definition}s", "type": "set identity", "column": "id3", "definition": {"fmt": "%{identity_type}s %{seq_definition: }s", "identity_type": {"fmt": "SET GENERATED ", "present": false}, "seq_definition": [{"fmt": "SET CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "SET %{no}s CYCLE", "clause": "cycle"}, {"fmt": "SET INCREMENT BY %{value}s", "value": "10", "clause": "seqincrement"}, {"fmt": "SET MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "SET MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "SET START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}}], "identity": {"objname": "test_set_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_generated ALTER COLUMN id3 SET CACHE 1 SET NO CYCLE SET INCREMENT BY 10 SET MINVALUE 1 SET MAXVALUE 2147483647 SET START WITH 1 RESTART 1 --ALTER TABLE test_set_generated ALTER id4 RESTART; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{definition}s", "type": "set identity", "column": "id4", "definition": {"fmt": "%{identity_type}s %{seq_definition: }s", "identity_type": {"fmt": "SET GENERATED ", "present": false}, "seq_definition": [{"fmt": "SET CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "SET %{no}s CYCLE", "clause": "cycle"}, {"fmt": "SET INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "SET MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "SET MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "SET START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}}], "identity": {"objname": "test_set_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_generated ALTER COLUMN id4 SET CACHE 1 SET NO CYCLE SET INCREMENT BY 1 SET MINVALUE 1 SET MAXVALUE 2147483647 SET START WITH 1 RESTART 1 --ALTER TABLE test_set_generated ALTER id5 RESTART WITH 101; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{definition}s", "type": "set identity", "column": "id5", "definition": {"fmt": "%{identity_type}s %{seq_definition: }s", "identity_type": {"fmt": "SET GENERATED ", "present": false}, "seq_definition": [{"fmt": "SET CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "SET %{no}s CYCLE", "clause": "cycle"}, {"fmt": "SET INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "SET MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "SET MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "SET START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "101", "clause": "restart"}]}}], "identity": {"objname": "test_set_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_generated ALTER COLUMN id5 SET CACHE 1 SET NO CYCLE SET INCREMENT BY 1 SET MINVALUE 1 SET MAXVALUE 2147483647 SET START WITH 1 RESTART 101 --ALTER TABLE test_set_generated ALTER id6 RESTART WITH 201; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{definition}s", "type": "set identity", "column": "id6", "definition": {"fmt": "%{identity_type}s %{seq_definition: }s", "identity_type": {"fmt": "SET GENERATED ", "present": false}, "seq_definition": [{"fmt": "SET CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "SET %{no}s CYCLE", "clause": "cycle"}, {"fmt": "SET INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "SET MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "SET MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "SET START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "201", "clause": "restart"}]}}], "identity": {"objname": "test_set_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_generated ALTER COLUMN id6 SET CACHE 1 SET NO CYCLE SET INCREMENT BY 1 SET MINVALUE 1 SET MAXVALUE 2147483647 SET START WITH 1 RESTART 201 --ALTER TABLE test_set_generated ALTER COLUMN id7 SET GENERATED BY DEFAULT SET INCREMENT BY 100 RESTART WITH 301; --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{definition}s", "type": "set identity", "column": "id7", "definition": {"fmt": "%{identity_type}s %{seq_definition: }s", "identity_type": {"fmt": "SET GENERATED %{option}s", "option": "BY DEFAULT"}, "seq_definition": [{"fmt": "SET CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "SET %{no}s CYCLE", "clause": "cycle"}, {"fmt": "SET INCREMENT BY %{value}s", "value": "100", "clause": "seqincrement"}, {"fmt": "SET MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "SET MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "SET START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "301", "clause": "restart"}]}}], "identity": {"objname": "test_set_generated", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_generated ALTER COLUMN id7 SET GENERATED BY DEFAULT SET CACHE 1 SET NO CYCLE SET INCREMENT BY 100 SET MINVALUE 1 SET MAXVALUE 2147483647 SET START WITH 1 RESTART 301 ---- ALTER [ COLUMN ] column_name DROP IDENTITY [ IF EXISTS ] --CREATE TABLE test_drop_identity( -- id int, -- id_generated int GENERATED ALWAYS AS IDENTITY --); --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_drop_identity", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{identity_column}s %{generated_column}s", "name": "id_generated", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "identity_column": {"fmt": "%{identity_type}s ( %{seq_definition: }s )", "identity_type": {"fmt": "GENERATED %{option}s AS IDENTITY", "option": "ALWAYS"}, "seq_definition": [{"fmt": "CACHE %{value}s", "value": "1", "clause": "cache"}, {"no": "NO", "fmt": "%{no}s CYCLE", "clause": "cycle"}, {"fmt": "INCREMENT BY %{value}s", "value": "1", "clause": "seqincrement"}, {"fmt": "MINVALUE %{value}s", "value": "1", "clause": "minvalue"}, {"fmt": "MAXVALUE %{value}s", "value": "2147483647", "clause": "maxvalue"}, {"fmt": "START WITH %{value}s", "value": "1", "clause": "start"}, {"fmt": "RESTART %{value}s", "value": "1", "clause": "restart"}]}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_drop_identity (id pg_catalog.int4 STORAGE plain , id_generated pg_catalog.int4 STORAGE plain GENERATED ALWAYS AS IDENTITY ( CACHE 1 NO CYCLE INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 RESTART 1 ) ) --NOTICE: deparsed json: --NOTICE: re-formed command: --ALTER TABLE test_drop_identity ALTER id_generated DROP IDENTITY; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I DROP IDENTITY %{if_exists}s", "type": "drop identity", "column": "id_generated", "if_exists": ""}], "identity": {"objname": "test_drop_identity", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_identity ALTER COLUMN id_generated DROP IDENTITY --ALTER TABLE test_drop_identity ALTER id DROP IDENTITY IF EXISTS; --NOTICE: column "id" of relation "test_drop_identity" is not an identity column, skipping --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I DROP IDENTITY %{if_exists}s", "type": "drop identity", "column": "id", "if_exists": "IF EXISTS"}], "identity": {"objname": "test_drop_identity", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_identity ALTER COLUMN id DROP IDENTITY IF EXISTS ---- ALTER [ COLUMN ] column_name SET STATISTICS integer --CREATE TABLE test_set_statistics( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_statistics", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_statistics (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_statistics ALTER id SET STATISTICS 1; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET STATISTICS %{statistics}n", "type": "set statistics", "column": "id", "statistics": 1}], "identity": {"objname": "test_set_statistics", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_statistics ALTER COLUMN id SET STATISTICS 1 ---- ALTER [ COLUMN ] column_name SET ( attribute_option = value [, ... ] ) --CREATE TABLE test_set_attribute( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_attribute", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_attribute (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_attribute ALTER name SET (n_distinct = 102); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{option}s (%{options:, }s)", "column": "name", "option": "SET", "options": [{"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "n_distinct"}, "value": "102"}]}], "identity": {"objname": "test_set_attribute", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_attribute ALTER COLUMN name SET (n_distinct = '102') --ALTER TABLE test_set_attribute ALTER id SET (n_distinct_inherited = 99, n_distinct = 9); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{option}s (%{options:, }s)", "column": "id", "option": "SET", "options": [{"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "n_distinct_inherited"}, "value": "99"}, {"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "n_distinct"}, "value": "9"}]}], "identity": {"objname": "test_set_attribute", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_attribute ALTER COLUMN id SET (n_distinct_inherited = '99', n_distinct = '9') ---- ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] ) --CREATE TABLE test_reset_attribute( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_reset_attribute", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_reset_attribute (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_reset_attribute ALTER name RESET (n_distinct); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{option}s (%{options:, }s)", "column": "name", "option": "RESET", "options": [{"fmt": "%{label}s", "label": {"fmt": "%{label}I", "label": "n_distinct"}}]}], "identity": {"objname": "test_reset_attribute", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_reset_attribute ALTER COLUMN name RESET (n_distinct) --ALTER TABLE test_reset_attribute ALTER id RESET (n_distinct, n_distinct_inherited); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I %{option}s (%{options:, }s)", "column": "id", "option": "RESET", "options": [{"fmt": "%{label}s", "label": {"fmt": "%{label}I", "label": "n_distinct"}}, {"fmt": "%{label}s", "label": {"fmt": "%{label}I", "label": "n_distinct_inherited"}}]}], "identity": {"objname": "test_reset_attribute", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_reset_attribute ALTER COLUMN id RESET (n_distinct, n_distinct_inherited) ---- ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN } --CREATE TABLE test_set_storage( -- LIKE orders, -- product_name text --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_storage", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "product_name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_storage (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , product_name pg_catalog.text STORAGE extended COLLATE pg_catalog."default" ) --ALTER TABLE test_set_storage ALTER id SET STORAGE PLAIN; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET STORAGE %{storage}s", "type": "set storage", "column": "id", "storage": "plain"}], "identity": {"objname": "test_set_storage", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_storage ALTER COLUMN id SET STORAGE plain --ALTER TABLE test_set_storage ALTER name SET STORAGE EXTERNAL; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET STORAGE %{storage}s", "type": "set storage", "column": "name", "storage": "external"}], "identity": {"objname": "test_set_storage", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_storage ALTER COLUMN name SET STORAGE external --ALTER TABLE test_set_storage ALTER description SET STORAGE EXTENDED; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET STORAGE %{storage}s", "type": "set storage", "column": "description", "storage": "extended"}], "identity": {"objname": "test_set_storage", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_storage ALTER COLUMN description SET STORAGE extended --ALTER TABLE test_set_storage ALTER product_name SET STORAGE MAIN; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET STORAGE %{storage}s", "type": "set storage", "column": "product_name", "storage": "main"}], "identity": {"objname": "test_set_storage", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_storage ALTER COLUMN product_name SET STORAGE main ---- ALTER [ COLUMN ] column_name SET COMPRESSION compression_method --CREATE TABLE test_set_compression( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_compression", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_compression (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_compression ALTER name SET COMPRESSION "lz4"; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET COMPRESSION %{compression_method}s", "type": "set compression", "column": "name", "compression_method": "lz4"}], "identity": {"objname": "test_set_compression", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_compression ALTER COLUMN name SET COMPRESSION lz4 --ALTER TABLE test_set_compression ALTER COLUMN description SET COMPRESSION "lz4"; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET COMPRESSION %{compression_method}s", "type": "set compression", "column": "description", "compression_method": "lz4"}], "identity": {"objname": "test_set_compression", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_compression ALTER COLUMN description SET COMPRESSION lz4 ---- ADD table_constraint [ NOT VALID ] --CREATE TABLE test_add_table_constraint( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_add_table_constraint", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_add_table_constraint (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_add_table_constraint ADD PRIMARY KEY (id); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER COLUMN %{column}I SET NOT NULL", "type": "set not null", "column": "id"}, {"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "test_add_table_constraint_pkey", "type": "add constraint", "definition": "PRIMARY KEY (id)"}], "identity": {"objname": "test_add_table_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_table_constraint ALTER COLUMN id SET NOT NULL, ADD CONSTRAINT test_add_table_constraint_pkey PRIMARY KEY (id) --ALTER TABLE test_add_table_constraint ADD CONSTRAINT max_name_len CHECK (length(name) < 4) NOT VALID; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "max_name_len", "type": "add constraint", "definition": "CHECK ((pg_catalog.length((name)::pg_catalog.text) OPERATOR(pg_catalog.<) 4)) NOT VALID"}], "identity": {"objname": "test_add_table_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_table_constraint ADD CONSTRAINT max_name_len CHECK ((pg_catalog.length((name)::pg_catalog.text) OPERATOR(pg_catalog.<) 4)) NOT VALID --ALTER TABLE test_add_table_constraint ADD CHECK (id < 10); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "test_add_table_constraint_id_check", "type": "add constraint", "definition": "CHECK ((id OPERATOR(pg_catalog.<) 10))"}], "identity": {"objname": "test_add_table_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_table_constraint ADD CONSTRAINT test_add_table_constraint_id_check CHECK ((id OPERATOR(pg_catalog.<) 10)) ---- ADD table_constraint_using_index --CREATE TABLE test_add_constraint_using_index( -- id1 int, -- id2 int, -- id3 int, -- id4 int, -- id5 int, -- id6 int, -- id7 int --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_add_constraint_using_index", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id1", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id2", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id3", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id4", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id5", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id6", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id7", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_add_constraint_using_index (id1 pg_catalog.int4 STORAGE plain , id2 pg_catalog.int4 STORAGE plain , id3 pg_catalog.int4 STORAGE plain , id4 pg_catalog.int4 STORAGE plain , id5 pg_catalog.int4 STORAGE plain , id6 pg_catalog.int4 STORAGE plain , id7 pg_catalog.int4 STORAGE plain ) --CREATE UNIQUE INDEX test_add_constraint_used_index1 ON test_add_constraint_using_index (id1); --NOTICE: deparsed json: {"fmt": "CREATE %{unique}s INDEX %{concurrently}s %{if_not_exists}s %{name}I ON %{only}s %{table}D USING %{index_am}s %{definition}s NULLS DISTINCT %{with}s %{tablespace}s %{where_clause}s", "name": "test_add_constraint_used_index1", "only": "", "with": {"fmt": "WITH", "present": false}, "table": {"objname": "test_add_constraint_using_index", "schemaname": "public"}, "unique": "UNIQUE", "index_am": "btree", "definition": "(id1 pg_catalog.int4_ops)", "tablespace": {"fmt": "TABLESPACE", "present": false}, "concurrently": "", "where_clause": {"fmt": "WHERE", "present": false}, "if_not_exists": ""} --NOTICE: re-formed command: CREATE UNIQUE INDEX test_add_constraint_used_index1 ON public.test_add_constraint_using_index USING btree (id1 pg_catalog.int4_ops) NULLS DISTINCT --ALTER TABLE test_add_constraint_using_index ADD UNIQUE USING INDEX test_add_constraint_used_index1; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{constraint_type}s USING INDEX %{index_name}I %{deferrable}s %{init_deferred}s", "name": "test_add_constraint_used_index1", "type": "add constraint using index", "deferrable": "NOT DEFERRABLE", "index_name": "test_add_constraint_used_index1", "init_deferred": "INITIALLY IMMEDIATE", "constraint_type": "UNIQUE"}], "identity": {"objname": "test_add_constraint_using_index", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_constraint_using_index ADD CONSTRAINT test_add_constraint_used_index1 UNIQUE USING INDEX test_add_constraint_used_index1 NOT DEFERRABLE INITIALLY IMMEDIATE --CREATE UNIQUE INDEX test_add_constraint_used_index2 ON test_add_constraint_using_index (id2); --NOTICE: deparsed json: {"fmt": "CREATE %{unique}s INDEX %{concurrently}s %{if_not_exists}s %{name}I ON %{only}s %{table}D USING %{index_am}s %{definition}s NULLS DISTINCT %{with}s %{tablespace}s %{where_clause}s", "name": "test_add_constraint_used_index2", "only": "", "with": {"fmt": "WITH", "present": false}, "table": {"objname": "test_add_constraint_using_index", "schemaname": "public"}, "unique": "UNIQUE", "index_am": "btree", "definition": "(id2 pg_catalog.int4_ops)", "tablespace": {"fmt": "TABLESPACE", "present": false}, "concurrently": "", "where_clause": {"fmt": "WHERE", "present": false}, "if_not_exists": ""} --NOTICE: re-formed command: CREATE UNIQUE INDEX test_add_constraint_used_index2 ON public.test_add_constraint_using_index USING btree (id2 pg_catalog.int4_ops) NULLS DISTINCT ----TOFIX ---- ALTER TABLE test_add_constraint_using_index ADD CONSTRAINT primary_constraint_using_index PRIMARY KEY USING INDEX test_add_constraint_used_index2; --CREATE UNIQUE INDEX test_add_constraint_used_index3 ON test_add_constraint_using_index (id3); --NOTICE: deparsed json: {"fmt": "CREATE %{unique}s INDEX %{concurrently}s %{if_not_exists}s %{name}I ON %{only}s %{table}D USING %{index_am}s %{definition}s NULLS DISTINCT %{with}s %{tablespace}s %{where_clause}s", "name": "test_add_constraint_used_index3", "only": "", "with": {"fmt": "WITH", "present": false}, "table": {"objname": "test_add_constraint_using_index", "schemaname": "public"}, "unique": "UNIQUE", "index_am": "btree", "definition": "(id3 pg_catalog.int4_ops)", "tablespace": {"fmt": "TABLESPACE", "present": false}, "concurrently": "", "where_clause": {"fmt": "WHERE", "present": false}, "if_not_exists": ""} --NOTICE: re-formed command: CREATE UNIQUE INDEX test_add_constraint_used_index3 ON public.test_add_constraint_using_index USING btree (id3 pg_catalog.int4_ops) NULLS DISTINCT --ALTER TABLE test_add_constraint_using_index ADD UNIQUE USING INDEX test_add_constraint_used_index3 DEFERRABLE; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{constraint_type}s USING INDEX %{index_name}I %{deferrable}s %{init_deferred}s", "name": "test_add_constraint_used_index3", "type": "add constraint using index", "deferrable": "DEFERRABLE", "index_name": "test_add_constraint_used_index3", "init_deferred": "INITIALLY IMMEDIATE", "constraint_type": "UNIQUE"}], "identity": {"objname": "test_add_constraint_using_index", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_constraint_using_index ADD CONSTRAINT test_add_constraint_used_index3 UNIQUE USING INDEX test_add_constraint_used_index3 DEFERRABLE INITIALLY IMMEDIATE --CREATE UNIQUE INDEX test_add_constraint_used_index4 ON test_add_constraint_using_index (id4); --NOTICE: deparsed json: {"fmt": "CREATE %{unique}s INDEX %{concurrently}s %{if_not_exists}s %{name}I ON %{only}s %{table}D USING %{index_am}s %{definition}s NULLS DISTINCT %{with}s %{tablespace}s %{where_clause}s", "name": "test_add_constraint_used_index4", "only": "", "with": {"fmt": "WITH", "present": false}, "table": {"objname": "test_add_constraint_using_index", "schemaname": "public"}, "unique": "UNIQUE", "index_am": "btree", "definition": "(id4 pg_catalog.int4_ops)", "tablespace": {"fmt": "TABLESPACE", "present": false}, "concurrently": "", "where_clause": {"fmt": "WHERE", "present": false}, "if_not_exists": ""} --NOTICE: re-formed command: CREATE UNIQUE INDEX test_add_constraint_used_index4 ON public.test_add_constraint_using_index USING btree (id4 pg_catalog.int4_ops) NULLS DISTINCT --ALTER TABLE test_add_constraint_using_index ADD UNIQUE USING INDEX test_add_constraint_used_index4 NOT DEFERRABLE; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{constraint_type}s USING INDEX %{index_name}I %{deferrable}s %{init_deferred}s", "name": "test_add_constraint_used_index4", "type": "add constraint using index", "deferrable": "NOT DEFERRABLE", "index_name": "test_add_constraint_used_index4", "init_deferred": "INITIALLY IMMEDIATE", "constraint_type": "UNIQUE"}], "identity": {"objname": "test_add_constraint_using_index", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_constraint_using_index ADD CONSTRAINT test_add_constraint_used_index4 UNIQUE USING INDEX test_add_constraint_used_index4 NOT DEFERRABLE INITIALLY IMMEDIATE --CREATE UNIQUE INDEX test_add_constraint_used_index5 ON test_add_constraint_using_index (id5); --NOTICE: deparsed json: {"fmt": "CREATE %{unique}s INDEX %{concurrently}s %{if_not_exists}s %{name}I ON %{only}s %{table}D USING %{index_am}s %{definition}s NULLS DISTINCT %{with}s %{tablespace}s %{where_clause}s", "name": "test_add_constraint_used_index5", "only": "", "with": {"fmt": "WITH", "present": false}, "table": {"objname": "test_add_constraint_using_index", "schemaname": "public"}, "unique": "UNIQUE", "index_am": "btree", "definition": "(id5 pg_catalog.int4_ops)", "tablespace": {"fmt": "TABLESPACE", "present": false}, "concurrently": "", "where_clause": {"fmt": "WHERE", "present": false}, "if_not_exists": ""} --NOTICE: re-formed command: CREATE UNIQUE INDEX test_add_constraint_used_index5 ON public.test_add_constraint_using_index USING btree (id5 pg_catalog.int4_ops) NULLS DISTINCT --ALTER TABLE test_add_constraint_using_index ADD UNIQUE USING INDEX test_add_constraint_used_index5 INITIALLY DEFERRED; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{constraint_type}s USING INDEX %{index_name}I %{deferrable}s %{init_deferred}s", "name": "test_add_constraint_used_index5", "type": "add constraint using index", "deferrable": "DEFERRABLE", "index_name": "test_add_constraint_used_index5", "init_deferred": "INITIALLY DEFERRED", "constraint_type": "UNIQUE"}], "identity": {"objname": "test_add_constraint_using_index", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_constraint_using_index ADD CONSTRAINT test_add_constraint_used_index5 UNIQUE USING INDEX test_add_constraint_used_index5 DEFERRABLE INITIALLY DEFERRED --CREATE UNIQUE INDEX test_add_constraint_used_index6 ON test_add_constraint_using_index (id6); --NOTICE: deparsed json: {"fmt": "CREATE %{unique}s INDEX %{concurrently}s %{if_not_exists}s %{name}I ON %{only}s %{table}D USING %{index_am}s %{definition}s NULLS DISTINCT %{with}s %{tablespace}s %{where_clause}s", "name": "test_add_constraint_used_index6", "only": "", "with": {"fmt": "WITH", "present": false}, "table": {"objname": "test_add_constraint_using_index", "schemaname": "public"}, "unique": "UNIQUE", "index_am": "btree", "definition": "(id6 pg_catalog.int4_ops)", "tablespace": {"fmt": "TABLESPACE", "present": false}, "concurrently": "", "where_clause": {"fmt": "WHERE", "present": false}, "if_not_exists": ""} --NOTICE: re-formed command: CREATE UNIQUE INDEX test_add_constraint_used_index6 ON public.test_add_constraint_using_index USING btree (id6 pg_catalog.int4_ops) NULLS DISTINCT --ALTER TABLE test_add_constraint_using_index ADD UNIQUE USING INDEX test_add_constraint_used_index6 INITIALLY IMMEDIATE; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{constraint_type}s USING INDEX %{index_name}I %{deferrable}s %{init_deferred}s", "name": "test_add_constraint_used_index6", "type": "add constraint using index", "deferrable": "NOT DEFERRABLE", "index_name": "test_add_constraint_used_index6", "init_deferred": "INITIALLY IMMEDIATE", "constraint_type": "UNIQUE"}], "identity": {"objname": "test_add_constraint_using_index", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_constraint_using_index ADD CONSTRAINT test_add_constraint_used_index6 UNIQUE USING INDEX test_add_constraint_used_index6 NOT DEFERRABLE INITIALLY IMMEDIATE --CREATE UNIQUE INDEX test_add_constraint_used_index7 ON test_add_constraint_using_index (id7); --NOTICE: deparsed json: {"fmt": "CREATE %{unique}s INDEX %{concurrently}s %{if_not_exists}s %{name}I ON %{only}s %{table}D USING %{index_am}s %{definition}s NULLS DISTINCT %{with}s %{tablespace}s %{where_clause}s", "name": "test_add_constraint_used_index7", "only": "", "with": {"fmt": "WITH", "present": false}, "table": {"objname": "test_add_constraint_using_index", "schemaname": "public"}, "unique": "UNIQUE", "index_am": "btree", "definition": "(id7 pg_catalog.int4_ops)", "tablespace": {"fmt": "TABLESPACE", "present": false}, "concurrently": "", "where_clause": {"fmt": "WHERE", "present": false}, "if_not_exists": ""} --NOTICE: re-formed command: CREATE UNIQUE INDEX test_add_constraint_used_index7 ON public.test_add_constraint_using_index USING btree (id7 pg_catalog.int4_ops) NULLS DISTINCT --ALTER TABLE test_add_constraint_using_index ADD UNIQUE USING INDEX test_add_constraint_used_index7 DEFERRABLE INITIALLY DEFERRED; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{constraint_type}s USING INDEX %{index_name}I %{deferrable}s %{init_deferred}s", "name": "test_add_constraint_used_index7", "type": "add constraint using index", "deferrable": "DEFERRABLE", "index_name": "test_add_constraint_used_index7", "init_deferred": "INITIALLY DEFERRED", "constraint_type": "UNIQUE"}], "identity": {"objname": "test_add_constraint_using_index", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_add_constraint_using_index ADD CONSTRAINT test_add_constraint_used_index7 UNIQUE USING INDEX test_add_constraint_used_index7 DEFERRABLE INITIALLY DEFERRED ---- ALTER CONSTRAINT constraint_name [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] --CREATE TABLE test_alter_constraint_referenced( -- id1 int UNIQUE, -- id2 int UNIQUE, -- id3 int UNIQUE, -- id4 int UNIQUE --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_alter_constraint_referenced", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id1", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id2", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id3", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id4", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_alter_constraint_referenced_id1_key", "type": "constraint", "contype": "unique", "definition": "UNIQUE (id1)"}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_alter_constraint_referenced_id2_key", "type": "constraint", "contype": "unique", "definition": "UNIQUE (id2)"}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_alter_constraint_referenced_id3_key", "type": "constraint", "contype": "unique", "definition": "UNIQUE (id3)"}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_alter_constraint_referenced_id4_key", "type": "constraint", "contype": "unique", "definition": "UNIQUE (id4)"}]} --NOTICE: re-formed command: CREATE TABLE public.test_alter_constraint_referenced (id1 pg_catalog.int4 STORAGE plain , id2 pg_catalog.int4 STORAGE plain , id3 pg_catalog.int4 STORAGE plain , id4 pg_catalog.int4 STORAGE plain , CONSTRAINT test_alter_constraint_referenced_id1_key UNIQUE (id1), CONSTRAINT test_alter_constraint_referenced_id2_key UNIQUE (id2), CONSTRAINT test_alter_constraint_referenced_id3_key UNIQUE (id3), CONSTRAINT test_alter_constraint_referenced_id4_key UNIQUE (id4)) --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --NOTICE: deparsed json: --NOTICE: re-formed command: --CREATE TABLE test_alter_constraint( -- id1 int, -- id2 int, -- id3 int, -- id4 int, -- id5 int, -- CONSTRAINT alter_cstr1 FOREIGN KEY (id1) REFERENCES test_alter_constraint_referenced (id1) DEFERRABLE INITIALLY DEFERRED, -- CONSTRAINT alter_cstr2 FOREIGN KEY (id2) REFERENCES test_alter_constraint_referenced (id2) NOT DEFERRABLE, -- CONSTRAINT alter_cstr3 FOREIGN KEY (id3) REFERENCES test_alter_constraint_referenced (id3) DEFERRABLE INITIALLY DEFERRED, -- CONSTRAINT alter_cstr4 FOREIGN KEY (id4) REFERENCES test_alter_constraint_referenced (id4) DEFERRABLE INITIALLY IMMEDIATE --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_alter_constraint", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id1", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id2", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id3", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id4", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id5", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_alter_constraint (id1 pg_catalog.int4 STORAGE plain , id2 pg_catalog.int4 STORAGE plain , id3 pg_catalog.int4 STORAGE plain , id4 pg_catalog.int4 STORAGE plain , id5 pg_catalog.int4 STORAGE plain ) --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "alter_cstr1", "type": "add constraint", "definition": "FOREIGN KEY (id1) REFERENCES public.test_alter_constraint_referenced(id1) DEFERRABLE INITIALLY DEFERRED"}, {"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "alter_cstr2", "type": "add constraint", "definition": "FOREIGN KEY (id2) REFERENCES public.test_alter_constraint_referenced(id2)"}, {"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "alter_cstr3", "type": "add constraint", "definition": "FOREIGN KEY (id3) REFERENCES public.test_alter_constraint_referenced(id3) DEFERRABLE INITIALLY DEFERRED"}, {"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "alter_cstr4", "type": "add constraint", "definition": "FOREIGN KEY (id4) REFERENCES public.test_alter_constraint_referenced(id4) DEFERRABLE"}], "identity": {"objname": "test_alter_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_constraint ADD CONSTRAINT alter_cstr1 FOREIGN KEY (id1) REFERENCES public.test_alter_constraint_referenced(id1) DEFERRABLE INITIALLY DEFERRED, ADD CONSTRAINT alter_cstr2 FOREIGN KEY (id2) REFERENCES public.test_alter_constraint_referenced(id2), ADD CONSTRAINT alter_cstr3 FOREIGN KEY (id3) REFERENCES public.test_alter_constraint_referenced(id3) DEFERRABLE INITIALLY DEFERRED, ADD CONSTRAINT alter_cstr4 FOREIGN KEY (id4) REFERENCES public.test_alter_constraint_referenced(id4) DEFERRABLE --ALTER TABLE test_alter_constraint ALTER CONSTRAINT alter_cstr1 NOT DEFERRABLE; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER CONSTRAINT %{name}I %{deferrable}s %{init_deferred}s", "name": "alter_cstr1", "type": "alter constraint", "deferrable": "NOT DEFERRABLE", "init_deferred": "INITIALLY IMMEDIATE"}], "identity": {"objname": "test_alter_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_constraint ALTER CONSTRAINT alter_cstr1 NOT DEFERRABLE INITIALLY IMMEDIATE --ALTER TABLE test_alter_constraint ALTER CONSTRAINT alter_cstr2 DEFERRABLE; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER CONSTRAINT %{name}I %{deferrable}s %{init_deferred}s", "name": "alter_cstr2", "type": "alter constraint", "deferrable": "DEFERRABLE", "init_deferred": "INITIALLY IMMEDIATE"}], "identity": {"objname": "test_alter_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_constraint ALTER CONSTRAINT alter_cstr2 DEFERRABLE INITIALLY IMMEDIATE --ALTER TABLE test_alter_constraint ALTER CONSTRAINT alter_cstr3 DEFERRABLE INITIALLY IMMEDIATE; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER CONSTRAINT %{name}I %{deferrable}s %{init_deferred}s", "name": "alter_cstr3", "type": "alter constraint", "deferrable": "DEFERRABLE", "init_deferred": "INITIALLY IMMEDIATE"}], "identity": {"objname": "test_alter_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_constraint ALTER CONSTRAINT alter_cstr3 DEFERRABLE INITIALLY IMMEDIATE --ALTER TABLE test_alter_constraint ALTER CONSTRAINT alter_cstr4 DEFERRABLE INITIALLY DEFERRED; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ALTER CONSTRAINT %{name}I %{deferrable}s %{init_deferred}s", "name": "alter_cstr4", "type": "alter constraint", "deferrable": "DEFERRABLE", "init_deferred": "INITIALLY DEFERRED"}], "identity": {"objname": "test_alter_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_constraint ALTER CONSTRAINT alter_cstr4 DEFERRABLE INITIALLY DEFERRED ---- VALIDATE CONSTRAINT constraint_name --CREATE TABLE test_validate_constraint( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_validate_constraint", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_validate_constraint (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_validate_constraint ADD CONSTRAINT test_validate_constraint_cstr CHECK (length(name) < 10) NOT VALID; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "test_validate_constraint_cstr", "type": "add constraint", "definition": "CHECK ((pg_catalog.length((name)::pg_catalog.text) OPERATOR(pg_catalog.<) 10)) NOT VALID"}], "identity": {"objname": "test_validate_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_validate_constraint ADD CONSTRAINT test_validate_constraint_cstr CHECK ((pg_catalog.length((name)::pg_catalog.text) OPERATOR(pg_catalog.<) 10)) NOT VALID --ALTER TABLE test_validate_constraint VALIDATE CONSTRAINT test_validate_constraint_cstr; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "VALIDATE CONSTRAINT %{constraint}I", "type": "validate constraint", "constraint": "test_validate_constraint_cstr"}], "identity": {"objname": "test_validate_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_validate_constraint VALIDATE CONSTRAINT test_validate_constraint_cstr ---- DROP CONSTRAINT [ IF EXISTS ] constraint_name [ RESTRICT | CASCADE ] --CREATE TABLE test_drop_constraint( -- LIKE orders, -- CONSTRAINT test_drop_constraint_check CHECK (id < 100), -- CONSTRAINT test_drop_constraint_uniq UNIQUE (id) --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_drop_constraint", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_drop_constraint_check", "type": "constraint", "contype": "check", "definition": "CHECK ((id OPERATOR(pg_catalog.<) 100))"}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_drop_constraint_uniq", "type": "constraint", "contype": "unique", "definition": "UNIQUE (id)"}]} --NOTICE: re-formed command: CREATE TABLE public.test_drop_constraint (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , CONSTRAINT test_drop_constraint_check CHECK ((id OPERATOR(pg_catalog.<) 100)), CONSTRAINT test_drop_constraint_uniq UNIQUE (id)) --NOTICE: deparsed json: --NOTICE: re-formed command: --CREATE TABLE test_drop_constraint_reference( -- id int REFERENCES test_drop_constraint (id), -- name varchar, -- CONSTRAINT test_drop_constraint_reference_cstr1 CHECK (length(name) < 10) --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_drop_constraint_reference", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_drop_constraint_reference_cstr1", "type": "constraint", "contype": "check", "definition": "CHECK ((pg_catalog.length((name)::pg_catalog.text) OPERATOR(pg_catalog.<) 10))"}]} --NOTICE: re-formed command: CREATE TABLE public.test_drop_constraint_reference (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , CONSTRAINT test_drop_constraint_reference_cstr1 CHECK ((pg_catalog.length((name)::pg_catalog.text) OPERATOR(pg_catalog.<) 10))) --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ADD CONSTRAINT %{name}I %{definition}s", "name": "test_drop_constraint_reference_id_fkey", "type": "add constraint", "definition": "FOREIGN KEY (id) REFERENCES public.test_drop_constraint(id)"}], "identity": {"objname": "test_drop_constraint_reference", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_constraint_reference ADD CONSTRAINT test_drop_constraint_reference_id_fkey FOREIGN KEY (id) REFERENCES public.test_drop_constraint(id) --ALTER TABLE test_drop_constraint_reference DROP CONSTRAINT test_drop_constraint_reference_cstr1; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "DROP CONSTRAINT %{if_exists}s %{constraint}I %{cascade}s", "type": "drop constraint", "cascade": "", "if_exists": "", "constraint": "test_drop_constraint_reference_cstr1"}], "identity": {"objname": "test_drop_constraint_reference", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_constraint_reference DROP CONSTRAINT test_drop_constraint_reference_cstr1 --ALTER TABLE test_drop_constraint DROP CONSTRAINT test_drop_constraint_check RESTRICT; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "DROP CONSTRAINT %{if_exists}s %{constraint}I %{cascade}s", "type": "drop constraint", "cascade": "", "if_exists": "", "constraint": "test_drop_constraint_check"}], "identity": {"objname": "test_drop_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_constraint DROP CONSTRAINT test_drop_constraint_check --ALTER TABLE test_drop_constraint DROP CONSTRAINT IF EXISTS test_drop_constraint_check RESTRICT; --NOTICE: constraint "test_drop_constraint_check" of relation "test_drop_constraint" does not exist, skipping --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "DROP CONSTRAINT %{if_exists}s %{constraint}I %{cascade}s", "type": "drop constraint", "cascade": "", "if_exists": "IF EXISTS", "constraint": "test_drop_constraint_check"}], "identity": {"objname": "test_drop_constraint", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_drop_constraint DROP CONSTRAINT IF EXISTS test_drop_constraint_check ---- TOFIX ---- ALTER TABLE test_drop_constraint DROP CONSTRAINT test_drop_constraint_uniq CASCADE; ---- TODO: This should be tested with TRIGGER related testing ---- DISABLE TRIGGER [ trigger_name | ALL | USER ] ---- ENABLE TRIGGER [ trigger_name | ALL | USER ] ---- ENABLE REPLICA TRIGGER trigger_name ---- ENABLE ALWAYS TRIGGER trigger_name ---- DISABLE RULE rewrite_rule_name --CREATE TABLE test_disable_rule( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_disable_rule", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_disable_rule (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --CREATE RULE sample_rule1 AS -- ON UPDATE TO test_disable_rule -- DO INSTEAD -- SELECT * FROM test_disable_rule; --NOTICE: deparsed json: {"fmt": "CREATE RULE %{or_replace}s %{identity}I AS ON %{event}s TO %{table}D %{where_clause}s DO %{instead}s %{actions:; }s", "event": "UPDATE", "table": {"objname": "test_disable_rule", "schemaname": "public"}, "actions": ["SELECT test_disable_rule.id, test_disable_rule.name, test_disable_rule.description, test_disable_rule.price, test_disable_rule.quantity, test_disable_rule.purchase_date FROM public.test_disable_rule"], "instead": "INSTEAD", "identity": "sample_rule1", "or_replace": "", "where_clause": {"fmt": "WHERE %{clause}s", "clause": null, "present": false}} --NOTICE: re-formed command: CREATE RULE sample_rule1 AS ON UPDATE TO public.test_disable_rule DO INSTEAD SELECT test_disable_rule.id, test_disable_rule.name, test_disable_rule.description, test_disable_rule.price, test_disable_rule.quantity, test_disable_rule.purchase_date FROM public.test_disable_rule --ALTER TABLE test_disable_rule DISABLE RULE sample_rule1; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "DISABLE RULE %{rule}I", "rule": "sample_rule1", "type": "disable rule"}], "identity": {"objname": "test_disable_rule", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_disable_rule DISABLE RULE sample_rule1 ---- ENABLE RULE rewrite_rule_name --CREATE TABLE test_enable_rule( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_enable_rule", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_enable_rule (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --CREATE RULE sample_rule2 AS -- ON UPDATE TO test_enable_rule -- DO INSTEAD -- SELECT * FROM test_enable_rule; --NOTICE: deparsed json: {"fmt": "CREATE RULE %{or_replace}s %{identity}I AS ON %{event}s TO %{table}D %{where_clause}s DO %{instead}s %{actions:; }s", "event": "UPDATE", "table": {"objname": "test_enable_rule", "schemaname": "public"}, "actions": ["SELECT test_enable_rule.id, test_enable_rule.name, test_enable_rule.description, test_enable_rule.price, test_enable_rule.quantity, test_enable_rule.purchase_date FROM public.test_enable_rule"], "instead": "INSTEAD", "identity": "sample_rule2", "or_replace": "", "where_clause": {"fmt": "WHERE %{clause}s", "clause": null, "present": false}} --NOTICE: re-formed command: CREATE RULE sample_rule2 AS ON UPDATE TO public.test_enable_rule DO INSTEAD SELECT test_enable_rule.id, test_enable_rule.name, test_enable_rule.description, test_enable_rule.price, test_enable_rule.quantity, test_enable_rule.purchase_date FROM public.test_enable_rule --ALTER TABLE test_enable_rule DISABLE RULE sample_rule2; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "DISABLE RULE %{rule}I", "rule": "sample_rule2", "type": "disable rule"}], "identity": {"objname": "test_enable_rule", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_enable_rule DISABLE RULE sample_rule2 --ALTER TABLE test_enable_rule ENABLE RULE sample_rule2; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ENABLE RULE %{rule}I", "rule": "sample_rule2", "type": "enable rule"}], "identity": {"objname": "test_enable_rule", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_enable_rule ENABLE RULE sample_rule2 ---- ENABLE REPLICA RULE rewrite_rule_name --CREATE TABLE test_enable_replica_rule( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_enable_replica_rule", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_enable_replica_rule (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --CREATE RULE sample_rule_enable_replica AS -- ON UPDATE TO test_enable_replica_rule -- DO INSTEAD -- SELECT * FROM test_enable_replica_rule; --NOTICE: deparsed json: {"fmt": "CREATE RULE %{or_replace}s %{identity}I AS ON %{event}s TO %{table}D %{where_clause}s DO %{instead}s %{actions:; }s", "event": "UPDATE", "table": {"objname": "test_enable_replica_rule", "schemaname": "public"}, "actions": ["SELECT test_enable_replica_rule.id, test_enable_replica_rule.name, test_enable_replica_rule.description, test_enable_replica_rule.price, test_enable_replica_rule.quantity, test_enable_replica_rule.purchase_date FROM public.test_enable_replica_rule"], "instead": "INSTEAD", "identity": "sample_rule_enable_replica", "or_replace": "", "where_clause": {"fmt": "WHERE %{clause}s", "clause": null, "present": false}} --NOTICE: re-formed command: CREATE RULE sample_rule_enable_replica AS ON UPDATE TO public.test_enable_replica_rule DO INSTEAD SELECT test_enable_replica_rule.id, test_enable_replica_rule.name, test_enable_replica_rule.description, test_enable_replica_rule.price, test_enable_replica_rule.quantity, test_enable_replica_rule.purchase_date FROM public.test_enable_replica_rule --ALTER TABLE test_enable_replica_rule ENABLE REPLICA RULE sample_rule_enable_replica; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ENABLE REPLICA RULE %{rule}I", "rule": "sample_rule_enable_replica", "type": "enable replica rule"}], "identity": {"objname": "test_enable_replica_rule", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_enable_replica_rule ENABLE REPLICA RULE sample_rule_enable_replica ---- ENABLE ALWAYS RULE rewrite_rule_name --CREATE TABLE test_enable_always_rule( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_enable_always_rule", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_enable_always_rule (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --CREATE RULE sample_rule_enable_always AS -- ON UPDATE TO test_enable_always_rule -- DO INSTEAD -- SELECT * FROM test_enable_always_rule; --NOTICE: deparsed json: {"fmt": "CREATE RULE %{or_replace}s %{identity}I AS ON %{event}s TO %{table}D %{where_clause}s DO %{instead}s %{actions:; }s", "event": "UPDATE", "table": {"objname": "test_enable_always_rule", "schemaname": "public"}, "actions": ["SELECT test_enable_always_rule.id, test_enable_always_rule.name, test_enable_always_rule.description, test_enable_always_rule.price, test_enable_always_rule.quantity, test_enable_always_rule.purchase_date FROM public.test_enable_always_rule"], "instead": "INSTEAD", "identity": "sample_rule_enable_always", "or_replace": "", "where_clause": {"fmt": "WHERE %{clause}s", "clause": null, "present": false}} --NOTICE: re-formed command: CREATE RULE sample_rule_enable_always AS ON UPDATE TO public.test_enable_always_rule DO INSTEAD SELECT test_enable_always_rule.id, test_enable_always_rule.name, test_enable_always_rule.description, test_enable_always_rule.price, test_enable_always_rule.quantity, test_enable_always_rule.purchase_date FROM public.test_enable_always_rule --ALTER TABLE test_enable_always_rule ENABLE REPLICA RULE sample_rule_enable_always; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ENABLE REPLICA RULE %{rule}I", "rule": "sample_rule_enable_always", "type": "enable replica rule"}], "identity": {"objname": "test_enable_always_rule", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_enable_always_rule ENABLE REPLICA RULE sample_rule_enable_always ---- DISABLE ROW LEVEL SECURITY --CREATE TABLE test_disable_row_security( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_disable_row_security", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_disable_row_security (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_disable_row_security DISABLE ROW LEVEL SECURITY; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "DISABLE ROW LEVEL SECURITY", "type": "disable row security"}], "identity": {"objname": "test_disable_row_security", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_disable_row_security DISABLE ROW LEVEL SECURITY ---- ENABLE ROW LEVEL SECURITY --CREATE TABLE test_enable_row_security( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_enable_row_security", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_enable_row_security (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_enable_row_security ENABLE ROW LEVEL SECURITY; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "ENABLE ROW LEVEL SECURITY", "type": "enable row security"}], "identity": {"objname": "test_enable_row_security", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_enable_row_security ENABLE ROW LEVEL SECURITY ---- FORCE ROW LEVEL SECURITY --CREATE TABLE test_force_row_security( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_force_row_security", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_force_row_security (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_force_row_security FORCE ROW LEVEL SECURITY; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "FORCE ROW LEVEL SECURITY"}], "identity": {"objname": "test_force_row_security", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_force_row_security FORCE ROW LEVEL SECURITY ---- NO FORCE ROW LEVEL SECURITY --CREATE TABLE test_no_force_row_security( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_no_force_row_security", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_no_force_row_security (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_no_force_row_security NO FORCE ROW LEVEL SECURITY; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "NO FORCE ROW LEVEL SECURITY"}], "identity": {"objname": "test_no_force_row_security", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_no_force_row_security NO FORCE ROW LEVEL SECURITY ---- CLUSTER ON index_name --CREATE TABLE test_cluster( -- LIKE orders, -- PRIMARY KEY (id) --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_cluster", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_cluster_pkey", "type": "constraint", "contype": "primary key", "definition": "PRIMARY KEY (id)"}]} --NOTICE: re-formed command: CREATE TABLE public.test_cluster (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , CONSTRAINT test_cluster_pkey PRIMARY KEY (id)) --NOTICE: deparsed json: --NOTICE: re-formed command: --ALTER TABLE test_cluster CLUSTER ON test_cluster_pkey; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "CLUSTER ON %{index}I", "type": "cluster on", "index": "test_cluster_pkey"}], "identity": {"objname": "test_cluster", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_cluster CLUSTER ON test_cluster_pkey ---- SET WITHOUT CLUSTER --CREATE TABLE test_without_cluster( -- LIKE orders, -- PRIMARY KEY (id) --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_without_cluster", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_without_cluster_pkey", "type": "constraint", "contype": "primary key", "definition": "PRIMARY KEY (id)"}]} --NOTICE: re-formed command: CREATE TABLE public.test_without_cluster (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , CONSTRAINT test_without_cluster_pkey PRIMARY KEY (id)) --NOTICE: deparsed json: --NOTICE: re-formed command: --ALTER TABLE test_without_cluster CLUSTER ON test_without_cluster_pkey; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "CLUSTER ON %{index}I", "type": "cluster on", "index": "test_without_cluster_pkey"}], "identity": {"objname": "test_without_cluster", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_without_cluster CLUSTER ON test_without_cluster_pkey --ALTER TABLE test_without_cluster SET WITHOUT CLUSTER; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "SET WITHOUT CLUSTER", "type": "set without cluster"}], "identity": {"objname": "test_without_cluster", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_without_cluster SET WITHOUT CLUSTER ---- SET WITHOUT OIDS --CREATE TABLE test_set_without_oids( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_without_oids", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_without_oids (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_without_oids SET WITHOUT OIDS; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "SET WITHOUT OIDS", "type": "set without oids"}], "identity": {"objname": "test_set_without_oids", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_without_oids SET WITHOUT OIDS ---- SET ACCESS METHOD new_access_method --CREATE TABLE test_set_access_method( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_access_method", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_access_method (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_access_method SET ACCESS METHOD heap; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "SET ACCESS METHOD %{access_method}I", "type": "set access method", "access_method": "heap"}], "identity": {"objname": "test_set_access_method", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_access_method SET ACCESS METHOD heap ---- SET TABLESPACE new_tablespace --CREATE TABLE test_set_tablespace( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_tablespace", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_tablespace (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_tablespace SET TABLESPACE pg_default; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "SET TABLESPACE %{tablespace}I", "type": "set tablespace", "tablespace": "pg_default"}], "identity": {"objname": "test_set_tablespace", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_tablespace SET TABLESPACE pg_default ---- SET { LOGGED | UNLOGGED } --CREATE TABLE test_set_logged( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_logged", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_logged (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_logged SET LOGGED; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "SET LOGGED", "type": "set logged"}], "identity": {"objname": "test_set_logged", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_logged SET LOGGED --CREATE TABLE test_set_unlogged( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_unlogged", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_unlogged (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_unlogged SET UNLOGGED; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "SET UNLOGGED", "type": "set unlogged"}], "identity": {"objname": "test_set_unlogged", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_unlogged SET UNLOGGED ---- SET ( storage_parameter [= value] [, ... ] ) --CREATE TABLE test_set_storage_params1( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_storage_params1", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_storage_params1 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_storage_params1 SET (vacuum_index_cleanup = ON, autovacuum_vacuum_scale_factor = 0.2, vacuum_truncate = true); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "%{set_reset}s (%{options:, }s)", "options": [{"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "vacuum_index_cleanup"}, "value": "on"}, {"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "autovacuum_vacuum_scale_factor"}, "value": "0.2"}, {"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "vacuum_truncate"}, "value": "true"}], "set_reset": "SET"}], "identity": {"objname": "test_set_storage_params1", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_storage_params1 SET (vacuum_index_cleanup = 'on', autovacuum_vacuum_scale_factor = '0.2', vacuum_truncate = 'true') --CREATE TABLE test_set_storage_params2( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_storage_params2", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_storage_params2 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_storage_params2 SET (vacuum_index_cleanup = ON); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "%{set_reset}s (%{options:, }s)", "options": [{"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "vacuum_index_cleanup"}, "value": "on"}], "set_reset": "SET"}], "identity": {"objname": "test_set_storage_params2", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_storage_params2 SET (vacuum_index_cleanup = 'on') ---- RESET ( storage_parameter [, ... ] ) --CREATE TABLE test_reset_storage_params1( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_reset_storage_params1", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_reset_storage_params1 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_storage_params1 SET (vacuum_index_cleanup = ON, autovacuum_vacuum_scale_factor = 0.2, vacuum_truncate = true); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "%{set_reset}s (%{options:, }s)", "options": [{"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "vacuum_index_cleanup"}, "value": "on"}, {"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "autovacuum_vacuum_scale_factor"}, "value": "0.2"}, {"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "vacuum_truncate"}, "value": "true"}], "set_reset": "SET"}], "identity": {"objname": "test_set_storage_params1", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_storage_params1 SET (vacuum_index_cleanup = 'on', autovacuum_vacuum_scale_factor = '0.2', vacuum_truncate = 'true') --ALTER TABLE test_reset_storage_params1 RESET (vacuum_index_cleanup, autovacuum_vacuum_scale_factor, vacuum_truncate); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "%{set_reset}s (%{options:, }s)", "options": [{"fmt": "%{label}s", "label": {"fmt": "%{label}I", "label": "vacuum_index_cleanup"}}, {"fmt": "%{label}s", "label": {"fmt": "%{label}I", "label": "autovacuum_vacuum_scale_factor"}}, {"fmt": "%{label}s", "label": {"fmt": "%{label}I", "label": "vacuum_truncate"}}], "set_reset": "RESET"}], "identity": {"objname": "test_reset_storage_params1", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_reset_storage_params1 RESET (vacuum_index_cleanup, autovacuum_vacuum_scale_factor, vacuum_truncate) --CREATE TABLE test_reset_storage_params2( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_reset_storage_params2", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_reset_storage_params2 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_set_storage_params2 SET (vacuum_index_cleanup = ON); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "%{set_reset}s (%{options:, }s)", "options": [{"fmt": "%{label}s = %{value}L", "label": {"fmt": "%{label}I", "label": "vacuum_index_cleanup"}, "value": "on"}], "set_reset": "SET"}], "identity": {"objname": "test_set_storage_params2", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_set_storage_params2 SET (vacuum_index_cleanup = 'on') --ALTER TABLE test_reset_storage_params2 RESET (vacuum_index_cleanup); --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "%{set_reset}s (%{options:, }s)", "options": [{"fmt": "%{label}s", "label": {"fmt": "%{label}I", "label": "vacuum_index_cleanup"}}], "set_reset": "RESET"}], "identity": {"objname": "test_reset_storage_params2", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_reset_storage_params2 RESET (vacuum_index_cleanup) ---- INHERIT parent_table --CREATE TABLE test_inherit_parent( -- parent_id int --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_inherit_parent", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "parent_id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_inherit_parent (parent_id pg_catalog.int4 STORAGE plain ) --CREATE TABLE test_inherit_child( -- parent_id int, -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_inherit_child", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "parent_id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_inherit_child (parent_id pg_catalog.int4 STORAGE plain , id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_inherit_child INHERIT test_inherit_parent; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "INHERIT %{parent}D", "type": "inherit", "parent": {"objname": "test_inherit_parent", "schemaname": "public"}}], "identity": {"objname": "test_inherit_child", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_inherit_child INHERIT public.test_inherit_parent ---- NO INHERIT parent_table --CREATE TABLE test_no_inherit_parent( -- parent_id int --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_no_inherit_parent", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "parent_id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_no_inherit_parent (parent_id pg_catalog.int4 STORAGE plain ) --CREATE TABLE test_no_inherit_child( -- LIKE orders --) INHERITS (test_no_inherit_parent); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_no_inherit_child", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": [{"objname": "test_no_inherit_parent", "schemaname": "public"}]}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_no_inherit_child (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) INHERITS (public.test_no_inherit_parent) --ALTER TABLE test_no_inherit_child NO INHERIT test_no_inherit_parent; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "NO INHERIT %{parent}D", "type": "drop inherit", "parent": {"objname": "test_no_inherit_parent", "schemaname": "public"}}], "identity": {"objname": "test_no_inherit_child", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_no_inherit_child NO INHERIT public.test_no_inherit_parent ---- OF type_name --CREATE TYPE test_type_product_type AS ( -- id int, -- name varchar --); --NOTICE: deparsed json: {"fmt": "CREATE TYPE %{identity}D AS (%{columns:, }s)", "columns": [{"fmt": "%{name}I %{coltype}T %{compression}s %{collation}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "collation": {"fmt": "COLLATE", "present": false}, "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}}, {"fmt": "%{name}I %{coltype}T %{compression}s %{collation}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}}], "identity": {"objname": "test_type_product_type", "schemaname": "public"}} --NOTICE: re-formed command: CREATE TYPE public.test_type_product_type AS (id pg_catalog.int4 , name pg_catalog."varchar" COLLATE pg_catalog."default") --CREATE TABLE test_type( -- id int, -- name varchar --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_type", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_type (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" ) --ALTER TABLE test_type OF test_type_product_type; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "OF %{type_of}T", "type": "add of", "type_of": {"typmod": "", "typarray": false, "typename": "test_type_product_type", "schemaname": "public"}}], "identity": {"objname": "test_type", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_type OF public.test_type_product_type ---- NOT OF --CREATE TABLE test_type_not_of OF test_type_product_type; --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D OF %{of_type}T %{table_elements}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "of_type": {"typmod": "", "typarray": false, "typename": "test_type_product_type", "schemaname": "public"}, "identity": {"objname": "test_type_not_of", "schemaname": "public"}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": {"fmt": "", "present": false}} --NOTICE: re-formed command: CREATE TABLE public.test_type_not_of OF public.test_type_product_type --ALTER TABLE test_type_not_of NOT OF; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "NOT OF", "type": "not of"}], "identity": {"objname": "test_type_not_of", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_type_not_of NOT OF ---- TODO: This should be tested with ROLE/USER related testing ---- OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER } ---- REPLICA IDENTITY { DEFAULT | USING INDEX index_name | FULL | NOTHING } --CREATE TABLE test_replica_identity1( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_replica_identity1", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_replica_identity1 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_replica_identity1 REPLICA IDENTITY DEFAULT; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "REPLICA IDENTITY %{ident}s", "type": "replica identity", "ident": "DEFAULT"}], "identity": {"objname": "test_replica_identity1", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_replica_identity1 REPLICA IDENTITY DEFAULT --CREATE TABLE test_replica_identity2( -- LIKE orders, -- PRIMARY KEY (id) --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_replica_identity2", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_replica_identity2_pkey", "type": "constraint", "contype": "primary key", "definition": "PRIMARY KEY (id)"}]} --NOTICE: re-formed command: CREATE TABLE public.test_replica_identity2 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , CONSTRAINT test_replica_identity2_pkey PRIMARY KEY (id)) --NOTICE: deparsed json: --NOTICE: re-formed command: --ALTER TABLE test_replica_identity2 REPLICA IDENTITY USING INDEX test_replica_identity2_pkey; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "REPLICA IDENTITY %{ident}s", "type": "replica identity", "ident": {"fmt": "USING INDEX %{index}I", "index": "test_replica_identity2_pkey"}}], "identity": {"objname": "test_replica_identity2", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_replica_identity2 REPLICA IDENTITY USING INDEX test_replica_identity2_pkey --CREATE TABLE test_replica_identity3( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_replica_identity3", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_replica_identity3 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_replica_identity3 REPLICA IDENTITY FULL; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "REPLICA IDENTITY %{ident}s", "type": "replica identity", "ident": "FULL"}], "identity": {"objname": "test_replica_identity3", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_replica_identity3 REPLICA IDENTITY FULL --CREATE TABLE test_replica_identity4( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_replica_identity4", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_replica_identity4 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_replica_identity4 REPLICA IDENTITY NOTHING; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}D %{subcmds:, }s", "only": "", "objtype": "TABLE", "subcmds": [{"fmt": "REPLICA IDENTITY %{ident}s", "type": "replica identity", "ident": "NOTHING"}], "identity": {"objname": "test_replica_identity4", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_replica_identity4 REPLICA IDENTITY NOTHING ---- RENAME [ COLUMN ] column_name TO new_column_name --CREATE TABLE test_alter_col_name( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_alter_col_name", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_alter_col_name (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_alter_col_name RENAME id TO new_id; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{if_exists}s %{identity}D RENAME COLUMN %{colname}I TO %{newname}I", "colname": "id", "newname": "new_id", "objtype": "TABLE", "identity": {"objname": "test_alter_col_name", "schemaname": "public"}, "if_exists": ""} --NOTICE: re-formed command: ALTER TABLE public.test_alter_col_name RENAME COLUMN id TO new_id --ALTER TABLE test_alter_col_name RENAME COLUMN name TO new_name; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{if_exists}s %{identity}D RENAME COLUMN %{colname}I TO %{newname}I", "colname": "name", "newname": "new_name", "objtype": "TABLE", "identity": {"objname": "test_alter_col_name", "schemaname": "public"}, "if_exists": ""} --NOTICE: re-formed command: ALTER TABLE public.test_alter_col_name RENAME COLUMN name TO new_name ---- RENAME CONSTRAINT constraint_name TO new_constraint_name --CREATE TABLE test_alter_constraint_name( -- LIKE orders, -- CONSTRAINT test_alter_constraint_name_old CHECK (id > 10) --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_alter_constraint_name", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "CONSTRAINT %{name}I %{definition}s", "name": "test_alter_constraint_name_old", "type": "constraint", "contype": "check", "definition": "CHECK ((id OPERATOR(pg_catalog.>) 10))"}]} --NOTICE: re-formed command: CREATE TABLE public.test_alter_constraint_name (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain , CONSTRAINT test_alter_constraint_name_old CHECK ((id OPERATOR(pg_catalog.>) 10))) --ALTER TABLE test_alter_constraint_name RENAME CONSTRAINT test_alter_constraint_name_old TO test_alter_constraint_name_new; --NOTICE: deparsed json: {"fmt": "ALTER TABLE %{only}s %{identity}D RENAME CONSTRAINT %{oldname}I TO %{newname}I", "only": "", "newname": "test_alter_constraint_name_new", "oldname": "test_alter_constraint_name_old", "identity": {"objname": "test_alter_constraint_name", "schemaname": "public"}} --NOTICE: re-formed command: ALTER TABLE public.test_alter_constraint_name RENAME CONSTRAINT test_alter_constraint_name_old TO test_alter_constraint_name_new ---- RENAME TO new_name --CREATE TABLE test_rename_table( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_rename_table", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_rename_table (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --ALTER TABLE test_rename_table RENAME to new_test_rename_table; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{if_exists}s %{identity}D RENAME TO %{newname}I", "newname": "new_test_rename_table", "objtype": "TABLE", "identity": {"objname": "test_rename_table", "schemaname": "public"}, "if_exists": ""} --NOTICE: re-formed command: ALTER TABLE public.test_rename_table RENAME TO new_test_rename_table ---- SET SCHEMA new_schema --CREATE TABLE test_set_schema( -- LIKE orders --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_set_schema", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_set_schema (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --CREATE SCHEMA new_test_schema; --NOTICE: deparsed json: {"fmt": "CREATE SCHEMA %{if_not_exists}s %{name}I %{authorization}s", "name": "new_test_schema", "authorization": {"fmt": "AUTHORIZATION %{authorization_role}I", "present": false, "authorization_role": null}, "if_not_exists": ""} --NOTICE: re-formed command: CREATE SCHEMA new_test_schema --ALTER TABLE test_set_schema SET SCHEMA new_test_schema; --NOTICE: deparsed json: {"fmt": "ALTER %{objtype}s %{identity}s SET SCHEMA %{newschema}I", "objtype": "TABLE", "identity": "public.test_set_schema", "newschema": "new_test_schema"} --NOTICE: re-formed command: ALTER TABLE public.test_set_schema SET SCHEMA new_test_schema ---- ALTER TABLE ALL IN TABLESPACE name [ OWNED BY role_name [, ... ] ] ---- SET TABLESPACE new_tablespace [ NOWAIT ] ---- TOFIX: can not be caught by ddl_command_end event trigger. ---- Deparse of T_AlterTableMoveAllStmt is not supported, ---- TABLESPACE commands (global object commands) are also not supported. ---- ALTER TABLE ALL IN TABLESPACE pg_default SET TABLESPACE pg_default; ---- ALTER TABLE ALL IN TABLESPACE pg_default OWNED BY ddl_testing_role SET TABLESPACE pg_default; ---- ATTACH PARTITION partition_name { FOR VALUES partition_bound_spec | DEFAULT } --CREATE TABLE test_partition_attach_range( -- LIKE orders --) PARTITION BY RANGE (id); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_partition_attach_range", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "definition": "RANGE (id)"}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_partition_attach_range (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) PARTITION BY RANGE (id) --CREATE TABLE test_partition_attach_range_p_1( -- LIKE test_partition_attach_range --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_partition_attach_range_p_1", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_partition_attach_range_p_1 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) ---- TOFIX ---- ALTER TABLE test_partition_attach_range ATTACH PARTITION test_partition_attach_range_p_1 DEFAULT; --CREATE TABLE test_partition_attach_range_p_2( -- LIKE test_partition_attach_range --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_partition_attach_range_p_2", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_partition_attach_range_p_2 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) ---- TOFIX ---- ALTER TABLE test_partition_attach_range ATTACH PARTITION test_partition_attach_range_p_2 FOR VALUES FROM (100) TO (200); --CREATE TABLE test_partition_attach_hash( -- LIKE orders --) PARTITION BY HASH (id); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_partition_attach_hash", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "definition": "HASH (id)"}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_partition_attach_hash (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) PARTITION BY HASH (id) --CREATE TABLE test_partition_attach_hash_p( -- LIKE test_partition_attach_hash --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_partition_attach_hash_p", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_partition_attach_hash_p (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) ---- TOFIX ---- ALTER TABLE test_partition_attach_hash ATTACH PARTITION test_partition_attach_hash_p FOR VALUES WITH (MODULUS 10, REMAINDER 1); --CREATE TABLE test_partition_attach_list( -- LIKE orders --) PARTITION BY LIST (name); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_partition_attach_list", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "definition": "LIST (name)"}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_partition_attach_list (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) PARTITION BY LIST (name) --CREATE TABLE test_partition_attach_list_p1( -- LIKE test_partition_attach_list --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_partition_attach_list_p1", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_partition_attach_list_p1 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) --CREATE TABLE test_partition_attach_list_p2( -- LIKE test_partition_attach_list --); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_partition_attach_list_p2", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_partition_attach_list_p2 (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) ---- TOFIX ---- ALTER TABLE test_partition_attach_list ATTACH PARTITION test_partition_attach_list_p1 FOR VALUES IN ('key1'); ---- ALTER TABLE test_partition_attach_list ATTACH PARTITION test_partition_attach_list_p2 FOR VALUES IN ('key2', 'key3'); ---- DETACH PARTITION partition_name [ CONCURRENTLY | FINALIZE ] --CREATE TABLE test_detach_partition( -- LIKE orders --) PARTITION BY RANGE (id); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D (%{table_elements:, }s) %{inherits}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_detach_partition", "schemaname": "public"}, "inherits": {"fmt": "INHERITS (%{parents:, }D)", "parents": null, "present": false}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "definition": "RANGE (id)"}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": [{"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "id", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "name", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "varchar", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "description", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "text", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE %{name}D", "name": {"objname": "default", "schemaname": "pg_catalog"}}, "colstorage": "extended", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "price", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "float4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "quantity", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "int4", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}, {"fmt": "%{name}I %{coltype}T STORAGE %{colstorage}s %{compression}s %{collation}s %{not_null}s %{default}s %{generated_column}s", "name": "purchase_date", "type": "column", "coltype": {"typmod": "", "typarray": false, "typename": "date", "schemaname": "pg_catalog"}, "default": {"fmt": "DEFAULT", "present": false}, "not_null": "", "collation": {"fmt": "COLLATE", "present": false}, "colstorage": "plain", "compression": {"fmt": "COMPRESSION %{compression_method}I", "present": false, "compression_method": null}, "generated_column": {"fmt": "GENERATED ALWAYS AS", "present": false}}]} --NOTICE: re-formed command: CREATE TABLE public.test_detach_partition (id pg_catalog.int4 STORAGE plain , name pg_catalog."varchar" STORAGE extended COLLATE pg_catalog."default" , description pg_catalog.text STORAGE extended COLLATE pg_catalog."default" , price pg_catalog.float4 STORAGE plain , quantity pg_catalog.int4 STORAGE plain , purchase_date pg_catalog.date STORAGE plain ) PARTITION BY RANGE (id) --CREATE TABLE test_detach_partition_p1 PARTITION OF test_detach_partition FOR VALUES FROM (1) TO (100); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D PARTITION OF %{parent_identity}D %{table_elements}s %{partition_bound}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_detach_partition_p1", "schemaname": "public"}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": {"fmt": "", "present": false}, "parent_identity": {"objname": "test_detach_partition", "schemaname": "public"}, "partition_bound": "FOR VALUES FROM (1) TO (100)"} --NOTICE: re-formed command: CREATE TABLE public.test_detach_partition_p1 PARTITION OF public.test_detach_partition FOR VALUES FROM (1) TO (100) --CREATE TABLE test_detach_partition_p2 PARTITION OF test_detach_partition FOR VALUES FROM (101) TO (200); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D PARTITION OF %{parent_identity}D %{table_elements}s %{partition_bound}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_detach_partition_p2", "schemaname": "public"}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": {"fmt": "", "present": false}, "parent_identity": {"objname": "test_detach_partition", "schemaname": "public"}, "partition_bound": "FOR VALUES FROM (101) TO (200)"} --NOTICE: re-formed command: CREATE TABLE public.test_detach_partition_p2 PARTITION OF public.test_detach_partition FOR VALUES FROM (101) TO (200) --CREATE TABLE test_detach_partition_p3 PARTITION OF test_detach_partition FOR VALUES FROM (201) TO (300); --NOTICE: deparsed json: {"fmt": "CREATE %{persistence}s TABLE %{if_not_exists}s %{identity}D PARTITION OF %{parent_identity}D %{table_elements}s %{partition_bound}s %{partition_by}s %{access_method}s %{with_clause}s %{on_commit}s %{tablespace}s", "identity": {"objname": "test_detach_partition_p3", "schemaname": "public"}, "on_commit": {"fmt": "ON COMMIT %{on_commit_value}s", "present": false, "on_commit_value": null}, "tablespace": {"fmt": "TABLESPACE %{tablespace}I", "present": false, "tablespace": null}, "persistence": "", "with_clause": {"fmt": "WITH", "present": false}, "partition_by": {"fmt": "PARTITION BY %{definition}s", "present": false, "definition": null}, "access_method": {"fmt": "USING %{access_method}I", "present": false, "access_method": null}, "if_not_exists": "", "table_elements": {"fmt": "", "present": false}, "parent_identity": {"objname": "test_detach_partition", "schemaname": "public"}, "partition_bound": "FOR VALUES FROM (201) TO (300)"} --NOTICE: re-formed command: CREATE TABLE public.test_detach_partition_p3 PARTITION OF public.test_detach_partition FOR VALUES FROM (201) TO (300) ---- TOFIX ---- ALTER TABLE test_detach_partition DETACH PARTITION test_detach_partition_p1; ---- ALTER TABLE test_detach_partition DETACH PARTITION test_detach_partition_p2 CONCURRENTLY; ---- TOFIX: FINALIZE option is not testable ---- ALTER TABLE test_detach_partition DETACH PARTITION test_detach_partition_p3 FINALIZE; -+server closed the connection unexpectedly -+ This probably means the server terminated abnormally -+ before or while processing the request. -+connection to server was lost diff --git a/src/test/modules/test_ddl_deparse_regress/regression.out b/src/test/modules/test_ddl_deparse_regress/regression.out deleted file mode 100644 index a44b91f..0000000 --- a/src/test/modules/test_ddl_deparse_regress/regression.out +++ /dev/null @@ -1,7 +0,0 @@ -test test_ddl_deparse ... ok 31 ms -test create_extension ... ok 52 ms -test create_schema ... ok 19 ms -test aggregate ... ok 19 ms -test create_table ... FAILED 269 ms -test constraints ... ok 319 ms -test alter_table ... FAILED (test process exited with exit code 2) 1324 ms diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out index c00e283..722b391 100644 --- a/src/test/regress/expected/psql.out +++ b/src/test/regress/expected/psql.out @@ -6223,9 +6223,9 @@ List of schemas (0 rows) \dRp "no.such.publication" - List of publications - Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root -------+-------+------------+---------+---------+---------+-----------+---------- + List of publications + Name | Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +------+-------+------------+----------+------------+---------+---------+---------+-----------+---------- (0 rows) \dRs "no.such.subscription" diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out index 427f87e..b2317e7 100644 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@ -30,20 +30,20 @@ ERROR: conflicting or redundant options LINE 1: ...ub_xxx WITH (publish_via_partition_root = 'true', publish_vi... ^ \dRp - List of publications - Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------+--------------------------+------------+---------+---------+---------+-----------+---------- - testpib_ins_trunct | regress_publication_user | f | t | f | f | f | f - testpub_default | regress_publication_user | f | f | t | f | f | f + List of publications + Name | Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------+--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + testpib_ins_trunct | regress_publication_user | f | f | f | t | f | f | f | f + testpub_default | regress_publication_user | f | f | f | f | t | f | f | f (2 rows) ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete'); \dRp - List of publications - Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------+--------------------------+------------+---------+---------+---------+-----------+---------- - testpib_ins_trunct | regress_publication_user | f | t | f | f | f | f - testpub_default | regress_publication_user | f | t | t | t | f | f + List of publications + Name | Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------+--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + testpib_ins_trunct | regress_publication_user | f | f | f | t | f | f | f | f + testpub_default | regress_publication_user | f | f | f | t | t | t | f | f (2 rows) --- adding tables @@ -87,10 +87,10 @@ RESET client_min_messages; -- should be able to add schema to 'FOR TABLE' publication ALTER PUBLICATION testpub_fortable ADD TABLES IN SCHEMA pub_test; \dRp+ testpub_fortable - Publication testpub_fortable - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_fortable + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "public.testpub_tbl1" Tables from schemas: @@ -99,20 +99,20 @@ Tables from schemas: -- should be able to drop schema from 'FOR TABLE' publication ALTER PUBLICATION testpub_fortable DROP TABLES IN SCHEMA pub_test; \dRp+ testpub_fortable - Publication testpub_fortable - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_fortable + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "public.testpub_tbl1" -- should be able to set schema to 'FOR TABLE' publication ALTER PUBLICATION testpub_fortable SET TABLES IN SCHEMA pub_test; \dRp+ testpub_fortable - Publication testpub_fortable - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_fortable + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test" @@ -123,10 +123,10 @@ CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pub_test; CREATE PUBLICATION testpub_for_tbl_schema FOR TABLES IN SCHEMA pub_test, TABLE pub_test.testpub_nopk; RESET client_min_messages; \dRp+ testpub_for_tbl_schema - Publication testpub_for_tbl_schema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_for_tbl_schema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "pub_test.testpub_nopk" Tables from schemas: @@ -135,10 +135,10 @@ Tables from schemas: -- should be able to add a table of the same schema to the schema publication ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk; \dRp+ testpub_forschema - Publication testpub_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "pub_test.testpub_nopk" Tables from schemas: @@ -147,10 +147,10 @@ Tables from schemas: -- should be able to drop the table ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk; \dRp+ testpub_forschema - Publication testpub_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test" @@ -161,10 +161,10 @@ ERROR: relation "testpub_nopk" is not part of the publication -- should be able to set table to schema publication ALTER PUBLICATION testpub_forschema SET TABLE pub_test.testpub_nopk; \dRp+ testpub_forschema - Publication testpub_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "pub_test.testpub_nopk" @@ -186,10 +186,10 @@ Publications: "testpub_foralltables" \dRp+ testpub_foralltables - Publication testpub_foralltables - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | t | t | t | f | f | f + Publication testpub_foralltables + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | t | f | f | t | t | f | f | f (1 row) DROP TABLE testpub_tbl2; @@ -201,19 +201,19 @@ CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3; CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3; RESET client_min_messages; \dRp+ testpub3 - Publication testpub3 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub3 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "public.testpub_tbl3" "public.testpub_tbl3a" \dRp+ testpub4 - Publication testpub4 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub4 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "public.testpub_tbl3" @@ -234,10 +234,10 @@ UPDATE testpub_parted1 SET a = 1; -- only parent is listed as being in publication, not the partition ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted; \dRp+ testpub_forparted - Publication testpub_forparted - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_forparted + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "public.testpub_parted" @@ -252,10 +252,10 @@ ALTER TABLE testpub_parted DETACH PARTITION testpub_parted1; UPDATE testpub_parted1 SET a = 1; ALTER PUBLICATION testpub_forparted SET (publish_via_partition_root = true); \dRp+ testpub_forparted - Publication testpub_forparted - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | t + Publication testpub_forparted + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | t Tables: "public.testpub_parted" @@ -284,10 +284,10 @@ SET client_min_messages = 'ERROR'; CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert'); RESET client_min_messages; \dRp+ testpub5 - Publication testpub5 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | f | f | f | f + Publication testpub5 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | f | f | f | f Tables: "public.testpub_rf_tbl1" "public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5)) @@ -300,10 +300,10 @@ Tables: ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000); \dRp+ testpub5 - Publication testpub5 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | f | f | f | f + Publication testpub5 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | f | f | f | f Tables: "public.testpub_rf_tbl1" "public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5)) @@ -319,10 +319,10 @@ Publications: ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2; \dRp+ testpub5 - Publication testpub5 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | f | f | f | f + Publication testpub5 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | f | f | f | f Tables: "public.testpub_rf_tbl1" "public.testpub_rf_tbl3" WHERE ((e > 1000) AND (e < 2000)) @@ -330,10 +330,10 @@ Tables: -- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression) ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500); \dRp+ testpub5 - Publication testpub5 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | f | f | f | f + Publication testpub5 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | f | f | f | f Tables: "public.testpub_rf_tbl3" WHERE ((e > 300) AND (e < 500)) @@ -366,10 +366,10 @@ SET client_min_messages = 'ERROR'; CREATE PUBLICATION testpub_syntax1 FOR TABLE testpub_rf_tbl1, ONLY testpub_rf_tbl3 WHERE (e < 999) WITH (publish = 'insert'); RESET client_min_messages; \dRp+ testpub_syntax1 - Publication testpub_syntax1 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | f | f | f | f + Publication testpub_syntax1 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | f | f | f | f Tables: "public.testpub_rf_tbl1" "public.testpub_rf_tbl3" WHERE (e < 999) @@ -379,10 +379,10 @@ SET client_min_messages = 'ERROR'; CREATE PUBLICATION testpub_syntax2 FOR TABLE testpub_rf_tbl1, testpub_rf_schema1.testpub_rf_tbl5 WHERE (h < 999) WITH (publish = 'insert'); RESET client_min_messages; \dRp+ testpub_syntax2 - Publication testpub_syntax2 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | f | f | f | f + Publication testpub_syntax2 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | f | f | f | f Tables: "public.testpub_rf_tbl1" "testpub_rf_schema1.testpub_rf_tbl5" WHERE (h < 999) @@ -497,10 +497,10 @@ CREATE PUBLICATION testpub6 FOR TABLES IN SCHEMA testpub_rf_schema2; ALTER PUBLICATION testpub6 SET TABLES IN SCHEMA testpub_rf_schema2, TABLE testpub_rf_schema2.testpub_rf_tbl6 WHERE (i < 99); RESET client_min_messages; \dRp+ testpub6 - Publication testpub6 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub6 + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "testpub_rf_schema2.testpub_rf_tbl6" WHERE (i < 99) Tables from schemas: @@ -714,10 +714,10 @@ CREATE PUBLICATION testpub_table_ins WITH (publish = 'insert, truncate'); RESET client_min_messages; ALTER PUBLICATION testpub_table_ins ADD TABLE testpub_tbl5 (a); -- ok \dRp+ testpub_table_ins - Publication testpub_table_ins - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | f | f | t | f + Publication testpub_table_ins + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | f | f | t | f Tables: "public.testpub_tbl5" (a) @@ -891,10 +891,10 @@ CREATE TABLE testpub_tbl_both_filters (a int, b int, c int, PRIMARY KEY (a,c)); ALTER TABLE testpub_tbl_both_filters REPLICA IDENTITY USING INDEX testpub_tbl_both_filters_pkey; ALTER PUBLICATION testpub_both_filters ADD TABLE testpub_tbl_both_filters (a,c) WHERE (c != 1); \dRp+ testpub_both_filters - Publication testpub_both_filters - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_both_filters + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "public.testpub_tbl_both_filters" (a, c) WHERE (c <> 1) @@ -1099,10 +1099,10 @@ ERROR: relation "testpub_tbl1" is already member of publication "testpub_fortbl CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1; ERROR: publication "testpub_fortbl" already exists \dRp+ testpub_fortbl - Publication testpub_fortbl - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_fortbl + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "pub_test.testpub_nopk" "public.testpub_tbl1" @@ -1140,10 +1140,10 @@ Publications: "testpub_fortbl" \dRp+ testpub_default - Publication testpub_default - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | f | f + Publication testpub_default + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | f | f Tables: "pub_test.testpub_nopk" "public.testpub_tbl1" @@ -1221,10 +1221,10 @@ REVOKE CREATE ON DATABASE regression FROM regress_publication_user2; DROP TABLE testpub_parted; DROP TABLE testpub_tbl1; \dRp+ testpub_default - Publication testpub_default - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | f | f + Publication testpub_default + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | f | f (1 row) -- fail - must be owner of publication @@ -1234,20 +1234,20 @@ ERROR: must be owner of publication testpub_default RESET ROLE; ALTER PUBLICATION testpub_default RENAME TO testpub_foo; \dRp testpub_foo - List of publications - Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root --------------+--------------------------+------------+---------+---------+---------+-----------+---------- - testpub_foo | regress_publication_user | f | t | t | t | f | f + List of publications + Name | Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +-------------+--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + testpub_foo | regress_publication_user | f | f | f | t | t | t | f | f (1 row) -- rename back to keep the rest simple ALTER PUBLICATION testpub_foo RENAME TO testpub_default; ALTER PUBLICATION testpub_default OWNER TO regress_publication_user2; \dRp testpub_default - List of publications - Name | Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ------------------+---------------------------+------------+---------+---------+---------+-----------+---------- - testpub_default | regress_publication_user2 | f | t | t | t | f | f + List of publications + Name | Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +-----------------+---------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + testpub_default | regress_publication_user2 | f | f | f | t | t | t | f | f (1 row) -- adding schemas and tables @@ -1263,19 +1263,19 @@ CREATE TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA"(id int); SET client_min_messages = 'ERROR'; CREATE PUBLICATION testpub1_forschema FOR TABLES IN SCHEMA pub_test1; \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" CREATE PUBLICATION testpub2_forschema FOR TABLES IN SCHEMA pub_test1, pub_test2, pub_test3; \dRp+ testpub2_forschema - Publication testpub2_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub2_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" "pub_test2" @@ -1289,44 +1289,44 @@ CREATE PUBLICATION testpub6_forschema FOR TABLES IN SCHEMA "CURRENT_SCHEMA", CUR CREATE PUBLICATION testpub_fortable FOR TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA"; RESET client_min_messages; \dRp+ testpub3_forschema - Publication testpub3_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub3_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "public" \dRp+ testpub4_forschema - Publication testpub4_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub4_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "CURRENT_SCHEMA" \dRp+ testpub5_forschema - Publication testpub5_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub5_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "CURRENT_SCHEMA" "public" \dRp+ testpub6_forschema - Publication testpub6_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub6_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "CURRENT_SCHEMA" "public" \dRp+ testpub_fortable - Publication testpub_fortable - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_fortable + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "CURRENT_SCHEMA.CURRENT_SCHEMA" @@ -1360,10 +1360,10 @@ ERROR: schema "testpub_view" does not exist -- dropping the schema should reflect the change in publication DROP SCHEMA pub_test3; \dRp+ testpub2_forschema - Publication testpub2_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub2_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" "pub_test2" @@ -1371,20 +1371,20 @@ Tables from schemas: -- renaming the schema should reflect the change in publication ALTER SCHEMA pub_test1 RENAME to pub_test1_renamed; \dRp+ testpub2_forschema - Publication testpub2_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub2_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1_renamed" "pub_test2" ALTER SCHEMA pub_test1_renamed RENAME to pub_test1; \dRp+ testpub2_forschema - Publication testpub2_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub2_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" "pub_test2" @@ -1392,10 +1392,10 @@ Tables from schemas: -- alter publication add schema ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test2; \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" "pub_test2" @@ -1404,10 +1404,10 @@ Tables from schemas: ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA non_existent_schema; ERROR: schema "non_existent_schema" does not exist \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" "pub_test2" @@ -1416,10 +1416,10 @@ Tables from schemas: ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test1; ERROR: schema "pub_test1" is already member of publication "testpub1_forschema" \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" "pub_test2" @@ -1427,10 +1427,10 @@ Tables from schemas: -- alter publication drop schema ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2; \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" @@ -1438,10 +1438,10 @@ Tables from schemas: ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2; ERROR: tables from schema "pub_test2" are not part of the publication \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" @@ -1449,29 +1449,29 @@ Tables from schemas: ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA non_existent_schema; ERROR: schema "non_existent_schema" does not exist \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" -- drop all schemas ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1; \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f (1 row) -- alter publication set multiple schema ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test2; \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" "pub_test2" @@ -1480,10 +1480,10 @@ Tables from schemas: ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA non_existent_schema; ERROR: schema "non_existent_schema" does not exist \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" "pub_test2" @@ -1492,10 +1492,10 @@ Tables from schemas: -- removing the duplicate schemas ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test1; \dRp+ testpub1_forschema - Publication testpub1_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub1_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" @@ -1574,18 +1574,18 @@ SET client_min_messages = 'ERROR'; CREATE PUBLICATION testpub3_forschema; RESET client_min_messages; \dRp+ testpub3_forschema - Publication testpub3_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub3_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f (1 row) ALTER PUBLICATION testpub3_forschema SET TABLES IN SCHEMA pub_test1; \dRp+ testpub3_forschema - Publication testpub3_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub3_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables from schemas: "pub_test1" @@ -1595,20 +1595,20 @@ CREATE PUBLICATION testpub_forschema_fortable FOR TABLES IN SCHEMA pub_test1, TA CREATE PUBLICATION testpub_fortable_forschema FOR TABLE pub_test2.tbl1, TABLES IN SCHEMA pub_test1; RESET client_min_messages; \dRp+ testpub_forschema_fortable - Publication testpub_forschema_fortable - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_forschema_fortable + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "pub_test2.tbl1" Tables from schemas: "pub_test1" \dRp+ testpub_fortable_forschema - Publication testpub_fortable_forschema - Owner | All tables | Inserts | Updates | Deletes | Truncates | Via root ---------------------------+------------+---------+---------+---------+-----------+---------- - regress_publication_user | f | t | t | t | t | f + Publication testpub_fortable_forschema + Owner | All tables | All DDLs | Table DDLs | Inserts | Updates | Deletes | Truncates | Via root +--------------------------+------------+----------+------------+---------+---------+---------+-----------+---------- + regress_publication_user | f | f | f | t | t | t | t | f Tables: "pub_test2.tbl1" Tables from schemas: diff --git a/src/test/subscription/t/032_ddl_replication.pl b/src/test/subscription/t/032_ddl_replication.pl new file mode 100644 index 0000000..4bc4ff2 --- /dev/null +++ b/src/test/subscription/t/032_ddl_replication.pl @@ -0,0 +1,465 @@ +# Copyright (c) 2022, PostgreSQL Global Development Group +# Regression tests for logical replication of DDLs +# +use strict; +use warnings; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More; + +my $node_publisher = PostgreSQL::Test::Cluster->new('publisher'); +$node_publisher->init(allows_streaming => 'logical'); +$node_publisher->start; + +my $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber'); +$node_subscriber->init(allows_streaming => 'logical'); +$node_subscriber->start; + +my $ddl = "CREATE TABLE test_rep(id int primary key, name varchar, value integer);"; +$node_publisher->safe_psql('postgres', $ddl); +$node_publisher->safe_psql('postgres', "INSERT INTO test_rep VALUES (1, 'data1', 1);"); +$node_subscriber->safe_psql('postgres', $ddl); + +my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres'; +$node_publisher->safe_psql('postgres', + "CREATE PUBLICATION mypub FOR ALL TABLES with (publish = 'insert, update, delete', ddl = 'all');"); +$node_subscriber->safe_psql('postgres', + "CREATE SUBSCRIPTION mysub CONNECTION '$publisher_connstr' PUBLICATION mypub;"); +$node_publisher->wait_for_catchup('mysub'); + +# Make sure we have fully synchronized the table. +# This prevents ALTER TABLE command below from being executed during table synchronization. +$node_subscriber->poll_query_until('postgres', + "SELECT COUNT(1) = 0 FROM pg_subscription_rel sr WHERE sr.srsubstate NOT IN ('s', 'r') AND sr.srrelid = 'test_rep'::regclass" +); + +# Test ALTER TABLE ADD +$node_publisher->safe_psql('postgres', "ALTER TABLE test_rep ADD c4 int;"); +$node_publisher->safe_psql('postgres', "INSERT INTO test_rep VALUES (2, 'data2', 2, 2);"); +$node_publisher->wait_for_catchup('mysub'); +my $result = $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM test_rep WHERE c4 = 2;"); +is($result, qq(1), 'ALTER test_rep ADD replicated'); + +# Test ALTER TABLE DROP +$node_publisher->safe_psql('postgres', "ALTER TABLE test_rep DROP c4;"); +$node_publisher->safe_psql('postgres', "DELETE FROM test_rep where id = 2;"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from test_rep;"); +is($result, qq(1), 'ALTER test_rep DROP replicated'); + +# Test ALTER TABLE ALTER TYPE +$node_publisher->safe_psql('postgres', "ALTER TABLE test_rep ALTER value TYPE varchar"); +$node_publisher->safe_psql('postgres', "INSERT INTO test_rep VALUES (3, 'data3', '3');"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM test_rep WHERE value = '3';"); +is($result, qq(1), 'ALTER test_rep ALTER COLUMN TYPE replicated'); + +# Test ALTER TABLE ALTER SET DEFAULT +# Check if we have the default value after the direct insert to subscriber node. +$node_publisher->safe_psql('postgres', "ALTER TABLE test_rep ALTER COLUMN value SET DEFAULT 'foo'"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->safe_psql('postgres', "INSERT INTO test_rep VALUES (4, 'data4');"); +$result = $node_subscriber->safe_psql('postgres', "SELECT value FROM test_rep WHERE id = 4;"); +is($result, 'foo', 'ALTER test_rep ALTER SET DEFAULT replicated'); + +# Test ALTER TABLE ALTER DROP DEFAULT +# Check if we don't have the default value previously defined. +$node_publisher->safe_psql('postgres', "ALTER TABLE test_rep ALTER COLUMN value DROP DEFAULT;"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->safe_psql('postgres', "INSERT INTO test_rep VALUES (5, 'data5');"); +$result = $node_subscriber->safe_psql('postgres', "SELECT value IS NULL FROM test_rep WHERE id = 5;"); +is($result, q(t), 'ALTER test_rep ALTER DROP DEFAULT replicated'); + +# Test ALTER TABLE ALTER SET NOT NULL +# Remove the existing record that contains null value first. +my ($stdout, $stderr); +$node_subscriber->safe_psql('postgres', "DELETE FROM test_rep WHERE id = 5;"); +$node_publisher->safe_psql('postgres', "ALTER TABLE test_rep ALTER value SET NOT NULL;"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO test_rep VALUES (6, 'data6');", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: null value in column \"value\" of relation \"test_rep\" violates not-null constraint/ + or die "failed to replicate ALTER TABLE ALTER SET NOT NULL"; + +# Test ALTER TABLE ALTER DROP NOT NULL +$node_publisher->safe_psql('postgres', "ALTER TABLE test_rep ALTER value DROP NOT NULL;"); +$node_publisher->wait_for_catchup('mysub'); +# Insert same data that has NULL value. This failed before but now should succeed. +$node_subscriber->safe_psql('postgres', "INSERT INTO test_rep VALUES (6, 'data6');"); +$result = $node_subscriber->safe_psql('postgres', "SELECT value IS NULL FROM test_rep WHERE id = 6;"); +is($result, q(t), "ALTER test_rep ALTER DROP NOT NULL replicated"); + +# Test ALTER TABLE SET UNLOGGED +$node_publisher->safe_psql('postgres', 'ALTER TABLE test_rep SET UNLOGGED;'); +$node_publisher->wait_for_catchup('mysub'); +$node_publisher->safe_psql('postgres', "INSERT INTO test_rep VALUES (7, 'data7', '7');"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM test_rep WHERE id = 7;"); +is($result, qq(0), 'ALTER test_rep SET UNLOGGED replicated'); + +# Test ALTER TABLE SET LOGGED +$node_publisher->safe_psql('postgres', 'ALTER TABLE test_rep SET LOGGED;'); +$node_publisher->wait_for_catchup('mysub'); +$node_publisher->safe_psql('postgres', "INSERT INTO test_rep VALUES (8, 'data8', '8');"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM test_rep WHERE id = 8;"); +is($result, qq(1), 'ALTER test_rep SET LOGGED replicated'); + +# Test CREATE TABLE and DML changes +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (a int, b varchar);"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from pg_tables where tablename = 'tmp';"); +is($result, qq(1), 'CREATE tmp is replicated'); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp values (1, 'a')"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp values (2, 'b')"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp;"); +is($result, qq(2), 'DML Changes to tmp are replicated'); + +# Test CREATE TABLE INHERITS +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp2 (c3 int) INHERITS (tmp);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp2 VALUES (1, 'a', 1);"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from pg_tables where tablename = 'tmp2';"); +is($result, qq(1), 'CREATE TABLE INHERITS is replicated'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp2;"); +is($result, qq(1), 'inserting some data to inherited table replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp2"); + +# Test CREATE TABLE LIKE +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp3 (c3 int, LIKE tmp);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp3 VALUES (1, 1, 'a');"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from pg_tables where tablename = 'tmp3';"); +is($result, qq(1), 'CREATE TABLE LIKE replicated'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp3;"); +is($result, qq(1), 'insert some data to a table defined with LIKE replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp3"); + +# Test DROP TABLE +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from pg_tables where tablename = 'tmp';"); +is($result, qq(0), 'TABLE tmp is dropped'); + +# Test CREATE UNLOGGED TABLE +$node_publisher->safe_psql('postgres', "CREATE UNLOGGED TABLE tmp (id int);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from pg_tables where tablename = 'tmp';"); +is($result, qq(1), 'CREATE UNLOGGED TABLE is replicated correctly'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp;"); +is($result, qq(0), 'inserting data to unlogged table is not replicated correctly'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); + +# Test CREATE TABLE IF NOT EXISTS +$node_publisher->safe_psql('postgres', "CREATE TABLE IF NOT EXISTS tmp (id int);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from pg_tables where tablename = 'tmp';"); +is($result, qq(1), 'CREATE TABLE IF NOT EXISTS replicated'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp;"); +is($result, qq(1), 'inserting data to a table replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); + +# Test CREATE TABLE IF NOT EXISTS (check if we skip to create a table +# when we have the table on the subscriber in advance, and if we succeed +# in replicating changes.) +$node_subscriber->safe_psql('postgres', "CREATE TABLE tmp (id int);"); +$node_publisher->safe_psql('postgres', "CREATE TABLE IF NOT EXISTS tmp (id int);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp;"); +is($result, qq(1), 'CREATE TABLE IF NOT EXISTS replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); + +# Test CREATE TABLE IF NOT EXISTS (check if we skip to create a table +# when we have the table on the publisher, but not on the subscriber.) +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int);"); +$node_publisher->safe_psql('postgres', "CREATE TABLE IF NOT EXISTS tmp (id int);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp;"); +is($result, qq(1), 'CREATE TABLE IF NOT EXISTS replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); + +# Test CREATE TABLE with collate +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (name text COLLATE \"C\");"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES ('foo');"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT collation_name FROM information_schema.columns WHERE table_name = 'tmp';"); +is($result, qq(C), 'CREATE TABLE with collate replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); + +# Test CREATE TABLE with named constraint +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int CONSTRAINT \"must be bigger than 10\" CHECK (id > 10));"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO tmp VALUES (1);", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: new row for relation "tmp" violates check constraint "must be bigger than 10"/ + or die "failed to replicate named constraint at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# Test CREATE TABLE with various types of constraints. +# NOT NULL constraint +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int, name text NOT NULL);"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO tmp VALUES (1);", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: null value in column "name" of relation "tmp" violates not-null constraint/ + or die "failed to replicate non null constraint at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# NULL constraint +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int, name text NULL);"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$result = $node_subscriber->safe_psql('postgres', "SELECT name IS NULL FROM tmp;"); +is($result, qq(t), "CREATE TABLE with NULL constraint replicated"); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); + +# CHECK constraint +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int, product_ame text, price int CHECK (price > 0));"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO tmp VALUES (1, 'foo', -100);", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: new row for relation "tmp" violates check constraint "tmp_price_check"/ + or die "failed to replicate CHECK constraint"; +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# DEFAULT +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int, name text DEFAULT 'foo');"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$result = $node_subscriber->safe_psql('postgres', "SELECT name from tmp;"); +is($result, qq(foo), "CREATE TABLE with default value replicated"); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); + +# UNIQUE constraint +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int UNIQUE);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO tmp VALUES (1);", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: duplicate key value violates unique constraint "tmp_id_key"/ + or die "failed to replicate constraint at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# PRIMARY KEY +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int PRIMARY KEY, name text);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1, 'foo');"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO tmp VALUES (1, 'bar');", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: duplicate key value violates unique constraint "tmp_pkey"/ + or die "failed to replicate primary key at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# EXCLUDE +$node_publisher->safe_psql('postgres', "CREATE TABLE circles (c circle, EXCLUDE USING gist (c WITH &&));"); +$node_publisher->safe_psql('postgres', "INSERT INTO circles VALUES ('<(1, 1), 1>'::circle);"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO circles VALUES ('<(1, 1), 1>'::circle);", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: conflicting key value violates exclusion constraint "circles_c_excl"/ + or die "failed to replicate EXCLUDE at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE circles"); + +# REFERENCES +$node_publisher->safe_psql('postgres', "CREATE TABLE product (id int PRIMARY KEY, name text);"); +$node_publisher->safe_psql('postgres', "INSERT INTO product VALUES (1, 'foo');"); +$node_publisher->safe_psql('postgres', "INSERT INTO product VALUES (2, 'bar');"); +$node_publisher->safe_psql('postgres', "CREATE TABLE orders (order_id int PRIMARY KEY, product_id int REFERENCES product (id))"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO orders VALUES (1, 10)", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: insert or update on table "orders" violates foreign key constraint "orders_product_id_fkey"/ + or die "failed to replicate REFERENCES at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE orders"); +$node_publisher->safe_psql('postgres', "DROP TABLE product"); + +# DEFERRABLE +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int PRIMARY KEY DEFERRABLE, name text);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1, 'foo');"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (2, 'bar');"); +$node_publisher->wait_for_catchup('mysub'); +# Quick check of deferrable clause +$node_subscriber->safe_psql('postgres', "UPDATE tmp SET id = id + 1;"); +# Also, execute a test that should fail for INITIALLY IMMEDIATE(the default) +$node_subscriber->psql('postgres', qq( +BEGIN; +UPDATE tmp SET id = id + 1; +INSERT INTO tmp VALUES (3, 'foobar'); +DELETE FROM tmp WHERE id = 3; +COMMIT; +), on_error_stop => 0, stderr => \$stderr, stdout => \$stdout); +$stderr =~ /ERROR: duplicate key value violates unique constraint "tmp_pkey"/ + or die "failed to replicate DEFERRABLE at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# NOT DEFERRABLE +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int PRIMARY KEY NOT DEFERRABLE, name text);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1, 'foo');"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (2, 'bar');"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "UPDATE tmp SET id = id + 1;", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: duplicate key value violates unique constraint "tmp_pkey"/ + or die "failed to replicate NOT DEFERRABLE at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# DEFERRABLE and INITIALLY DEFERRED +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int PRIMARY KEY DEFERRABLE INITIALLY DEFERRED, name text);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1, 'foo');"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (2, 'bar');"); +$node_publisher->wait_for_catchup('mysub'); +# Quick check of deferrable clause +$node_subscriber->safe_psql('postgres', "UPDATE tmp SET id = id + 1;"); +# Also, execute a test that should succeed for INITIALLY DEFERRED +$node_subscriber->safe_psql('postgres', qq( +BEGIN; +UPDATE tmp SET id = id + 1; +INSERT INTO tmp VALUES (3, 'foobar'); +DELETE FROM tmp WHERE id = 3; +COMMIT; +)); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# Test CREATE TABLE with table constraint +# We will set two checks and conduct two inserts that should fail respectively. +$node_publisher->safe_psql('postgres', + "CREATE TABLE tmp (price int, discounted_price int, CHECK (discounted_price > 0 AND price > discounted_price));"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "INSERT INTO tmp VALUES (100, 0);", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: new row for relation "tmp" violates check constraint "tmp_check"/ + or die "failed to replicate table constraint (first condition) at creating table"; +$node_subscriber->psql('postgres', "INSERT INTO tmp VALUES (50, 100);", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stderr =~ /ERROR: new row for relation "tmp" violates check constraint "tmp_check"/ + or die "failed to replicate table constraint (second condition) at creating table"; +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# Test CREATE TABLE WITH strorage_parameter +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int) WITH (fillfactor = 80);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$node_publisher->wait_for_catchup('mysub'); +$node_subscriber->psql('postgres', "SELECT reloptions FROM pg_class WHERE relname = 'tmp';", + on_error_stop => 0, + stderr => \$stderr, + stdout => \$stdout); +$stdout =~ /{fillfactor=80}/ + or die "failed to replicate storage option"; +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp;"); +is($result, qq(1), 'CREATE TABLE with storage_parameter replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# Test CREATE TABLE TABLESPACE (creating a tablespace is not replicated) +# Prepare the directories for the publisher and subscriber first. +my ($basedir, $tablespace_dir); + +$basedir = $node_publisher->basedir; +$tablespace_dir = "$basedir/tblspc_pub"; +mkdir($tablespace_dir); +$node_publisher->safe_psql('postgres', "CREATE TABLESPACE mytblspc LOCATION '$tablespace_dir';"); +$basedir = $node_subscriber->basedir; +$tablespace_dir = "$basedir/tblspc_sub"; +mkdir ($tablespace_dir); +$node_subscriber->safe_psql('postgres', "CREATE TABLESPACE mytblspc LOCATION '$tablespace_dir';"); + +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (id int) TABLESPACE mytblspc;"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1);"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp;"); +is($result, qq(1), 'CREATE TABLE TABLESPACE replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp;"); + +# Test CREATE TYPE +$node_publisher->safe_psql('postgres', "CREATE TYPE mytype AS (id int, name text, age int);"); +$node_publisher->wait_for_catchup('mysub'); +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp OF mytype;"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES (1, 'bar');"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT count(*) from tmp;"); +is($result, qq(1), 'CREATE TABLE OF replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); +$node_publisher->safe_psql('postgres', "DROP TYPE mytype"); + +# Test CREATE ENUM TYPE +$node_publisher->safe_psql('postgres', "CREATE TYPE myenumtype AS ENUM ('new', 'open', 'closed');"); +$node_publisher->wait_for_catchup('mysub'); +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (status myenumtype);"); +$node_publisher->safe_psql('postgres', "INSERT INTO tmp VALUES ('new');"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT * from tmp;"); +is($result, qq(new), 'CREATE TABLE OF replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); +$node_publisher->safe_psql('postgres', "DROP TYPE myenumtype"); + +# Test CREATE RANGE TYPE +$node_publisher->safe_psql('postgres', "CREATE TYPE float8_range AS RANGE (subtype = float8, subtype_diff = float8mi);"); +$node_publisher->wait_for_catchup('mysub'); +$node_publisher->safe_psql('postgres', "CREATE TABLE tmp (val float8_range);"); +$node_publisher->safe_psql('postgres', "insert into tmp values(float8_range(-12.34, '1.111113e3'));"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT * from tmp;"); +is($result, qq([-12.34,1111.113\)), 'CREATE TABLE OF replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); +$node_publisher->safe_psql('postgres', "DROP TYPE float8_range"); + +# Test CREATE BASE DATA TYPE and use it in table definition +$node_publisher->safe_psql('postgres', " +CREATE TYPE int42; +CREATE FUNCTION int42_in(cstring) + RETURNS int42 + AS 'int4in' + LANGUAGE internal STRICT IMMUTABLE; +CREATE FUNCTION int42_out(int42) + RETURNS cstring + AS 'int4out' + LANGUAGE internal STRICT IMMUTABLE; +CREATE TYPE int42 ( + internallength = 4, + input = int42_in, + output = int42_out, + alignment = int4, + default = 42, + passedbyvalue +); +CREATE TABLE tmp (f1 int42); +INSERT INTO tmp DEFAULT VALUES; +"); +$node_publisher->wait_for_catchup('mysub'); +$result = $node_subscriber->safe_psql('postgres', "SELECT * from tmp;"); +is($result, qq(42), 'CREATE TABLE OF replicated'); +$node_publisher->safe_psql('postgres', "DROP TABLE tmp"); +$node_publisher->safe_psql('postgres', "DROP TYPE int42 cascade"); + +pass "DDL replication tests passed:"; + +$node_subscriber->stop; +$node_publisher->stop; + +done_testing(); diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 3f45ccd..e22a200 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -561,6 +561,7 @@ DefElemAction DefaultACLInfo DefineStmt DeleteStmt +DeparsedCommandType DependencyGenerator DependencyGeneratorData DependencyType @@ -1451,6 +1452,8 @@ LogicalDecodeBeginPrepareCB LogicalDecodeChangeCB LogicalDecodeCommitCB LogicalDecodeCommitPreparedCB +LogicalDecodeDDLMessageCB +LogicalDecodeStreamDDLMessageCB LogicalDecodeFilterByOriginCB LogicalDecodeFilterPrepareCB LogicalDecodeMessageCB @@ -2306,6 +2309,8 @@ ReorderBufferChange ReorderBufferChangeType ReorderBufferCommitCB ReorderBufferCommitPreparedCB +ReorderBufferDDLMessageCB +ReorderBufferStreamDDLMessageCB ReorderBufferDiskChange ReorderBufferIterTXNEntry ReorderBufferIterTXNState @@ -3608,6 +3613,7 @@ pthread_mutex_t pthread_once_t pthread_t ptrdiff_t +publication_rel pull_var_clause_context pull_varattnos_context pull_varnos_context -- 1.8.3.1