Expand tests of test_ddl_deparse/ for ALTER TABLE
authorMichael Paquier <michael@paquier.xyz>
Sun, 31 Jul 2022 02:48:14 +0000 (11:48 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sun, 31 Jul 2022 02:48:14 +0000 (11:48 +0900)
This module is expanded to track the description of the objects changed
in the subcommands of ALTER TABLE by reworking the function
get_altertable_subcmdtypes() (now named get_altertable_subcmdinfo) used
in the event trigger of the test.  It now returns a set of rows made of
(subcommand type, object description) instead of a text array with only
the information about the subcommand type.

The tests have been lacking a lot of the subcommands added to
AlterTableType over the years.  All the missing subcommands are added,
and the code is now structured so as the addition of a new subcommand
is detected by removing the default clause used in the switch for the
subcommand types.

The coverage of the module is increased from roughly 30% to 50%.  More
could be done but this is already a nice improvement.

Author: Michael Paquier, Hou Zhijie
Reviewed-by: Álvaro Herrera, Amit Kapila, Hayato Kuroda
Discussion: https://postgr.es/m/OS0PR01MB571626984BD099DADF53F38394899@OS0PR01MB5716.jpnprd01.prod.outlook.com

src/test/modules/test_ddl_deparse/expected/alter_table.out
src/test/modules/test_ddl_deparse/expected/create_table.out
src/test/modules/test_ddl_deparse/expected/create_view.out
src/test/modules/test_ddl_deparse/expected/test_ddl_deparse.out
src/test/modules/test_ddl_deparse/sql/alter_table.sql
src/test/modules/test_ddl_deparse/sql/test_ddl_deparse.sql
src/test/modules/test_ddl_deparse/test_ddl_deparse--1.0.sql
src/test/modules/test_ddl_deparse/test_ddl_deparse.c

index 141060fbdcf72dc5fd31947195278b2cd6a4711f..5445fb04e4dcc6c6eed3087be6b8bb761527f6d5 100644 (file)
@@ -2,6 +2,24 @@ CREATE TABLE parent (
    a int
 );
 NOTICE:  DDL test: type simple, tag CREATE TABLE
+ALTER TABLE parent SET (fillfactor = 50);
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET RELOPTIONS desc <NULL>
+ALTER TABLE parent RESET (fillfactor);
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type RESET RELOPTIONS desc <NULL>
+ALTER TABLE parent SET UNLOGGED;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET UNLOGGED desc <NULL>
+ALTER TABLE parent SET LOGGED;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET LOGGED desc <NULL>
+CREATE INDEX parent_index ON parent(a);
+NOTICE:  DDL test: type simple, tag CREATE INDEX
+ALTER TABLE parent CLUSTER ON parent_index;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type CLUSTER desc index parent_index
+DROP INDEX parent_index;
 CREATE TABLE child () INHERITS (parent);
 NOTICE:  DDL test: type simple, tag CREATE TABLE
 CREATE TABLE grandchild () INHERITS (child);
@@ -9,21 +27,119 @@ NOTICE:  DDL test: type simple, tag CREATE TABLE
 ALTER TABLE parent ADD COLUMN b serial;
 NOTICE:  DDL test: type simple, tag CREATE SEQUENCE
 NOTICE:  DDL test: type alter table, tag ALTER TABLE
-NOTICE:    subcommand: ADD COLUMN (and recurse)
+NOTICE:    subcommand: type ADD COLUMN (and recurse) desc column b of table parent
 NOTICE:  DDL test: type simple, tag ALTER SEQUENCE
 ALTER TABLE parent RENAME COLUMN b TO c;
 NOTICE:  DDL test: type simple, tag ALTER TABLE
+-- Constraint, no recursion
+ALTER TABLE ONLY grandchild ADD CONSTRAINT a_pos CHECK (a > 0);
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type ADD CONSTRAINT desc constraint a_pos on table grandchild
+-- Constraint, with recursion
 ALTER TABLE parent ADD CONSTRAINT a_pos CHECK (a > 0);
+NOTICE:  merging constraint "a_pos" with inherited definition
 NOTICE:  DDL test: type alter table, tag ALTER TABLE
-NOTICE:    subcommand: ADD CONSTRAINT (and recurse)
+NOTICE:    subcommand: type ADD CONSTRAINT (and recurse) desc constraint a_pos on table parent
 CREATE TABLE part (
    a int
 ) PARTITION BY RANGE (a);
 NOTICE:  DDL test: type simple, tag CREATE TABLE
 CREATE TABLE part1 PARTITION OF part FOR VALUES FROM (1) to (100);
 NOTICE:  DDL test: type simple, tag CREATE TABLE
+CREATE TABLE part2 (a int);
+NOTICE:  DDL test: type simple, tag CREATE TABLE
+ALTER TABLE part ATTACH PARTITION part2 FOR VALUES FROM (101) to (200);
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type ATTACH PARTITION desc <NULL>
+ALTER TABLE part DETACH PARTITION part2;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type DETACH PARTITION desc <NULL>
+DROP TABLE part2;
 ALTER TABLE part ADD PRIMARY KEY (a);
 NOTICE:  DDL test: type alter table, tag ALTER TABLE
-NOTICE:    subcommand: SET NOT NULL
-NOTICE:    subcommand: SET NOT NULL
-NOTICE:    subcommand: ADD INDEX
+NOTICE:    subcommand: type SET NOT NULL desc column a of table part
+NOTICE:    subcommand: type SET NOT NULL desc column a of table part1
+NOTICE:    subcommand: type ADD INDEX desc index part_pkey
+ALTER TABLE parent ALTER COLUMN a SET NOT NULL;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET NOT NULL desc column a of table parent
+NOTICE:    subcommand: type SET NOT NULL desc column a of table child
+NOTICE:    subcommand: type SET NOT NULL desc column a of table grandchild
+ALTER TABLE parent ALTER COLUMN a DROP NOT NULL;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type DROP NOT NULL desc column a of table parent
+NOTICE:    subcommand: type DROP NOT NULL desc column a of table child
+NOTICE:    subcommand: type DROP NOT NULL desc column a of table grandchild
+ALTER TABLE parent ALTER COLUMN a SET NOT NULL;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET NOT NULL desc column a of table parent
+NOTICE:    subcommand: type SET NOT NULL desc column a of table child
+NOTICE:    subcommand: type SET NOT NULL desc column a of table grandchild
+ALTER TABLE parent ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY;
+NOTICE:  DDL test: type simple, tag CREATE SEQUENCE
+NOTICE:  DDL test: type simple, tag ALTER SEQUENCE
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type ADD IDENTITY desc column a of table parent
+ALTER TABLE parent ALTER COLUMN a SET GENERATED BY DEFAULT;
+NOTICE:  DDL test: type simple, tag ALTER SEQUENCE
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET IDENTITY desc column a of table parent
+ALTER TABLE parent ALTER COLUMN a DROP IDENTITY;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type DROP IDENTITY desc column a of table parent
+ALTER TABLE parent ALTER COLUMN a SET STATISTICS 100;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET STATS desc column a of table parent
+NOTICE:    subcommand: type SET STATS desc column a of table child
+NOTICE:    subcommand: type SET STATS desc column a of table grandchild
+ALTER TABLE parent ALTER COLUMN a SET STORAGE PLAIN;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET STORAGE desc column a of table parent
+NOTICE:    subcommand: type SET STORAGE desc column a of table child
+NOTICE:    subcommand: type SET STORAGE desc column a of table grandchild
+ALTER TABLE parent ENABLE ROW LEVEL SECURITY;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type ENABLE ROW SECURITY desc <NULL>
+ALTER TABLE parent NO FORCE ROW LEVEL SECURITY;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type NO FORCE ROW SECURITY desc <NULL>
+ALTER TABLE parent FORCE ROW LEVEL SECURITY;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type FORCE ROW SECURITY desc <NULL>
+ALTER TABLE parent DISABLE ROW LEVEL SECURITY;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type DISABLE ROW SECURITY desc <NULL>
+CREATE STATISTICS parent_stat (dependencies) ON a, c FROM parent;
+NOTICE:  DDL test: type simple, tag CREATE STATISTICS
+ALTER TABLE parent ALTER COLUMN c TYPE numeric;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type ALTER COLUMN SET TYPE desc column c of table parent
+NOTICE:    subcommand: type ALTER COLUMN SET TYPE desc column c of table child
+NOTICE:    subcommand: type ALTER COLUMN SET TYPE desc column c of table grandchild
+NOTICE:    subcommand: type (re) ADD STATS desc statistics object parent_stat
+ALTER TABLE parent ALTER COLUMN c SET DEFAULT 0;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type ALTER COLUMN SET DEFAULT desc column c of table parent
+NOTICE:    subcommand: type ALTER COLUMN SET DEFAULT desc column c of table child
+NOTICE:    subcommand: type ALTER COLUMN SET DEFAULT desc column c of table grandchild
+CREATE TABLE tbl (
+   a int generated always as (b::int * 2) stored,
+   b text
+);
+NOTICE:  DDL test: type simple, tag CREATE TABLE
+ALTER TABLE tbl ALTER COLUMN a DROP EXPRESSION;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type DROP EXPRESSION desc column a of table tbl
+ALTER TABLE tbl ALTER COLUMN b SET COMPRESSION pglz;
+NOTICE:  DDL test: type alter table, tag ALTER TABLE
+NOTICE:    subcommand: type SET COMPRESSION desc column b of table tbl
+CREATE TYPE comptype AS (r float8);
+NOTICE:  DDL test: type simple, tag CREATE TYPE
+CREATE DOMAIN dcomptype AS comptype;
+NOTICE:  DDL test: type simple, tag CREATE DOMAIN
+ALTER DOMAIN dcomptype ADD CONSTRAINT c1 check ((value).r > 0);
+NOTICE:  DDL test: type simple, tag ALTER DOMAIN
+ALTER TYPE comptype ALTER ATTRIBUTE r TYPE bigint;
+NOTICE:  DDL test: type alter table, tag ALTER TYPE
+NOTICE:    subcommand: type ALTER COLUMN SET TYPE desc column r of composite type comptype
+NOTICE:    subcommand: type (re) ADD DOMAIN CONSTRAINT desc type dcomptype
index 0f2a2c164eb566899608b4a4cb72aab20ec1028e..2178ce83e9dca56219aca248598d8967dd6ad5fb 100644 (file)
@@ -77,8 +77,8 @@ NOTICE:  DDL test: type simple, tag CREATE TABLE
 NOTICE:  DDL test: type simple, tag CREATE INDEX
 NOTICE:  DDL test: type simple, tag CREATE INDEX
 NOTICE:  DDL test: type alter table, tag ALTER TABLE
-NOTICE:    subcommand: ADD CONSTRAINT (and recurse)
-NOTICE:    subcommand: ADD CONSTRAINT (and recurse)
+NOTICE:    subcommand: type ADD CONSTRAINT (and recurse) desc constraint fkey_table_datatype_id_fkey on table fkey_table
+NOTICE:    subcommand: type ADD CONSTRAINT (and recurse) desc constraint fkey_big_id on table fkey_table
 -- Typed table
 CREATE TABLE employees OF employee_type (
     PRIMARY KEY (name),
@@ -86,7 +86,7 @@ CREATE TABLE employees OF employee_type (
 );
 NOTICE:  DDL test: type simple, tag CREATE TABLE
 NOTICE:  DDL test: type alter table, tag ALTER TABLE
-NOTICE:    subcommand: SET NOT NULL
+NOTICE:    subcommand: type SET NOT NULL desc column name of table employees
 NOTICE:  DDL test: type simple, tag CREATE INDEX
 -- Inheritance
 CREATE TABLE person (
@@ -136,7 +136,7 @@ CREATE TABLE like_fkey_table (
 );
 NOTICE:  DDL test: type simple, tag CREATE TABLE
 NOTICE:  DDL test: type alter table, tag ALTER TABLE
-NOTICE:    subcommand: ALTER COLUMN SET DEFAULT (precooked)
+NOTICE:    subcommand: type ALTER COLUMN SET DEFAULT (precooked) desc column id of table like_fkey_table
 NOTICE:  DDL test: type simple, tag CREATE INDEX
 NOTICE:  DDL test: type simple, tag CREATE INDEX
 -- Volatile table types
index 2ae4e2d225e5f41b262ca9be449400f83eb52895..4ae0f4978ec1ac7bb1db357d1f0c2ea5b41a6da8 100644 (file)
@@ -8,7 +8,7 @@ CREATE OR REPLACE VIEW static_view AS
   SELECT 'bar'::TEXT AS col;
 NOTICE:  DDL test: type simple, tag CREATE VIEW
 NOTICE:  DDL test: type alter table, tag CREATE VIEW
-NOTICE:    subcommand: REPLACE RELOPTIONS
+NOTICE:    subcommand: type REPLACE RELOPTIONS desc <NULL>
 CREATE VIEW datatype_view AS
   SELECT * FROM datatype_table;
 NOTICE:  DDL test: type simple, tag CREATE VIEW
index 4a5ea9e9ed6fbe09baac470e19fc6de919b17e4a..fc657ff49b906ce8e0bb936c086bc3f9a57b4e3a 100644 (file)
@@ -28,9 +28,9 @@ BEGIN
        -- if alter table, log more
        IF cmdtype = 'alter table' THEN
            FOR r2 IN SELECT *
-                       FROM unnest(public.get_altertable_subcmdtypes(r.command))
+                       FROM public.get_altertable_subcmdinfo(r.command)
            LOOP
-               RAISE NOTICE '  subcommand: %', r2.unnest;
+               RAISE NOTICE '  subcommand: type % desc %', r2.cmdtype, r2.objdesc;
            END LOOP;
        END IF;
    END LOOP;
index dec53a0640f260dc070a10690ca5262f6c76efa4..9ad1cf908d42814f8b4eb8a63172d4c49dedfb07 100644 (file)
@@ -2,6 +2,15 @@ CREATE TABLE parent (
    a int
 );
 
+ALTER TABLE parent SET (fillfactor = 50);
+ALTER TABLE parent RESET (fillfactor);
+ALTER TABLE parent SET UNLOGGED;
+ALTER TABLE parent SET LOGGED;
+
+CREATE INDEX parent_index ON parent(a);
+ALTER TABLE parent CLUSTER ON parent_index;
+DROP INDEX parent_index;
+
 CREATE TABLE child () INHERITS (parent);
 
 CREATE TABLE grandchild () INHERITS (child);
@@ -10,6 +19,9 @@ ALTER TABLE parent ADD COLUMN b serial;
 
 ALTER TABLE parent RENAME COLUMN b TO c;
 
+-- Constraint, no recursion
+ALTER TABLE ONLY grandchild ADD CONSTRAINT a_pos CHECK (a > 0);
+-- Constraint, with recursion
 ALTER TABLE parent ADD CONSTRAINT a_pos CHECK (a > 0);
 
 CREATE TABLE part (
@@ -18,4 +30,48 @@ CREATE TABLE part (
 
 CREATE TABLE part1 PARTITION OF part FOR VALUES FROM (1) to (100);
 
+CREATE TABLE part2 (a int);
+ALTER TABLE part ATTACH PARTITION part2 FOR VALUES FROM (101) to (200);
+ALTER TABLE part DETACH PARTITION part2;
+DROP TABLE part2;
+
 ALTER TABLE part ADD PRIMARY KEY (a);
+
+ALTER TABLE parent ALTER COLUMN a SET NOT NULL;
+ALTER TABLE parent ALTER COLUMN a DROP NOT NULL;
+ALTER TABLE parent ALTER COLUMN a SET NOT NULL;
+
+ALTER TABLE parent ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY;
+
+ALTER TABLE parent ALTER COLUMN a SET GENERATED BY DEFAULT;
+
+ALTER TABLE parent ALTER COLUMN a DROP IDENTITY;
+
+ALTER TABLE parent ALTER COLUMN a SET STATISTICS 100;
+
+ALTER TABLE parent ALTER COLUMN a SET STORAGE PLAIN;
+
+ALTER TABLE parent ENABLE ROW LEVEL SECURITY;
+ALTER TABLE parent NO FORCE ROW LEVEL SECURITY;
+ALTER TABLE parent FORCE ROW LEVEL SECURITY;
+ALTER TABLE parent DISABLE ROW LEVEL SECURITY;
+
+CREATE STATISTICS parent_stat (dependencies) ON a, c FROM parent;
+
+ALTER TABLE parent ALTER COLUMN c TYPE numeric;
+
+ALTER TABLE parent ALTER COLUMN c SET DEFAULT 0;
+
+CREATE TABLE tbl (
+   a int generated always as (b::int * 2) stored,
+   b text
+);
+
+ALTER TABLE tbl ALTER COLUMN a DROP EXPRESSION;
+
+ALTER TABLE tbl ALTER COLUMN b SET COMPRESSION pglz;
+
+CREATE TYPE comptype AS (r float8);
+CREATE DOMAIN dcomptype AS comptype;
+ALTER DOMAIN dcomptype ADD CONSTRAINT c1 check ((value).r > 0);
+ALTER TYPE comptype ALTER ATTRIBUTE r TYPE bigint;
index e257a215e4fbcb1eb9a0394d8683c33f49d0a3ef..a4716153dfac06b7f202829a9e408a068acc7276 100644 (file)
@@ -29,9 +29,9 @@ BEGIN
        -- if alter table, log more
        IF cmdtype = 'alter table' THEN
            FOR r2 IN SELECT *
-                       FROM unnest(public.get_altertable_subcmdtypes(r.command))
+                       FROM public.get_altertable_subcmdinfo(r.command)
            LOOP
-               RAISE NOTICE '  subcommand: %', r2.unnest;
+               RAISE NOTICE '  subcommand: type % desc %', r2.cmdtype, r2.objdesc;
            END LOOP;
        END IF;
    END LOOP;
index 093005ad801fa1b483bb17ddd64c028c9dffc3b5..861d843690bbef5a6ee71305268be1d441cac0a2 100644 (file)
@@ -11,6 +11,8 @@ CREATE FUNCTION get_command_tag(pg_ddl_command)
   RETURNS text IMMUTABLE STRICT
   AS 'MODULE_PATHNAME' LANGUAGE C;
 
-CREATE FUNCTION get_altertable_subcmdtypes(pg_ddl_command)
-  RETURNS text[] IMMUTABLE STRICT
+CREATE FUNCTION get_altertable_subcmdinfo(IN cmd pg_ddl_command,
+    OUT cmdtype text,
+    OUT objdesc text)
+  RETURNS SETOF record IMMUTABLE STRICT
   AS 'MODULE_PATHNAME' LANGUAGE C;
index 9476c3f76e04923bd8692ecac8f27b2619b66054..bdbe05ceebcb3cced7c9afe2a09bfbff3bb47ba1 100644 (file)
@@ -11,6 +11,8 @@
 #include "postgres.h"
 
 #include "catalog/pg_type.h"
+#include "funcapi.h"
+#include "nodes/execnodes.h"
 #include "tcop/deparse_utility.h"
 #include "tcop/utility.h"
 #include "utils/builtins.h"
@@ -19,7 +21,7 @@ PG_MODULE_MAGIC;
 
 PG_FUNCTION_INFO_V1(get_command_type);
 PG_FUNCTION_INFO_V1(get_command_tag);
-PG_FUNCTION_INFO_V1(get_altertable_subcmdtypes);
+PG_FUNCTION_INFO_V1(get_altertable_subcmdinfo);
 
 /*
  * Return the textual representation of the struct type used to represent a
@@ -82,20 +84,30 @@ get_command_tag(PG_FUNCTION_ARGS)
  * command.
  */
 Datum
-get_altertable_subcmdtypes(PG_FUNCTION_ARGS)
+get_altertable_subcmdinfo(PG_FUNCTION_ARGS)
 {
    CollectedCommand *cmd = (CollectedCommand *) PG_GETARG_POINTER(0);
-   ArrayBuildState *astate = NULL;
    ListCell   *cell;
+   ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
 
    if (cmd->type != SCT_AlterTable)
        elog(ERROR, "command is not ALTER TABLE");
 
+   SetSingleFuncCall(fcinfo, 0);
+
+   if (list_length(cmd->d.alterTable.subcmds) == 0)
+       elog(ERROR, "empty alter table subcommand list");
+
    foreach(cell, cmd->d.alterTable.subcmds)
    {
        CollectedATSubcmd *sub = lfirst(cell);
        AlterTableCmd *subcmd = castNode(AlterTableCmd, sub->parsetree);
-       const char *strtype;
+       const char *strtype = "unrecognized";
+       Datum       values[2];
+       bool        nulls[2];
+
+       memset(values, 0, sizeof(values));
+       memset(nulls, 0, sizeof(nulls));
 
        switch (subcmd->subtype)
        {
@@ -120,6 +132,9 @@ get_altertable_subcmdtypes(PG_FUNCTION_ARGS)
            case AT_SetNotNull:
                strtype = "SET NOT NULL";
                break;
+           case AT_DropExpression:
+               strtype = "DROP EXPRESSION";
+               break;
            case AT_CheckNotNull:
                strtype = "CHECK NOT NULL";
                break;
@@ -135,6 +150,9 @@ get_altertable_subcmdtypes(PG_FUNCTION_ARGS)
            case AT_SetStorage:
                strtype = "SET STORAGE";
                break;
+           case AT_SetCompression:
+               strtype = "SET COMPRESSION";
+               break;
            case AT_DropColumn:
                strtype = "DROP COLUMN";
                break;
@@ -156,6 +174,9 @@ get_altertable_subcmdtypes(PG_FUNCTION_ARGS)
            case AT_ReAddConstraint:
                strtype = "(re) ADD CONSTRAINT";
                break;
+           case AT_ReAddDomainConstraint:
+               strtype = "(re) ADD DOMAIN CONSTRAINT";
+               break;
            case AT_AlterConstraint:
                strtype = "ALTER CONSTRAINT";
                break;
@@ -201,6 +222,9 @@ get_altertable_subcmdtypes(PG_FUNCTION_ARGS)
            case AT_DropOids:
                strtype = "DROP OIDS";
                break;
+           case AT_SetAccessMethod:
+               strtype = "SET ACCESS METHOD";
+               break;
            case AT_SetTableSpace:
                strtype = "SET TABLESPACE";
                break;
@@ -279,18 +303,41 @@ get_altertable_subcmdtypes(PG_FUNCTION_ARGS)
            case AT_GenericOptions:
                strtype = "SET OPTIONS";
                break;
-           default:
-               strtype = "unrecognized";
+           case AT_DetachPartition:
+               strtype = "DETACH PARTITION";
+               break;
+           case AT_AttachPartition:
+               strtype = "ATTACH PARTITION";
+               break;
+           case AT_DetachPartitionFinalize:
+               strtype = "DETACH PARTITION ... FINALIZE";
+               break;
+           case AT_AddIdentity:
+               strtype = "ADD IDENTITY";
+               break;
+           case AT_SetIdentity:
+               strtype = "SET IDENTITY";
+               break;
+           case AT_DropIdentity:
+               strtype = "DROP IDENTITY";
+               break;
+           case AT_ReAddStatistics:
+               strtype = "(re) ADD STATS";
                break;
        }
 
-       astate =
-           accumArrayResult(astate, CStringGetTextDatum(strtype),
-                            false, TEXTOID, CurrentMemoryContext);
-   }
+       values[0] = CStringGetTextDatum(strtype);
+       if (OidIsValid(sub->address.objectId))
+       {
+           char       *objdesc;
+           objdesc = getObjectDescription((const ObjectAddress *) &sub->address, false);
+           values[1] = CStringGetTextDatum(objdesc);
+       }
+       else
+           nulls[1] = true;
 
-   if (astate == NULL)
-       elog(ERROR, "empty alter table subcommand list");
+       tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
+   }
 
-   PG_RETURN_ARRAYTYPE_P(makeArrayResult(astate, CurrentMemoryContext));
+   return (Datum) 0;
 }