diff --git a/contrib/test_decoding/expected/ivy_ddl.out b/contrib/test_decoding/expected/ivy_ddl.out index f4d396d7726..0c9ec1088ba 100644 --- a/contrib/test_decoding/expected/ivy_ddl.out +++ b/contrib/test_decoding/expected/ivy_ddl.out @@ -494,12 +494,12 @@ CREATE TABLE replication_metadata ( WITH (user_catalog_table = true) ; \d+ replication_metadata - Table "public.replication_metadata" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------+-----------------+-----------+----------+--------------------------------------------------+----------+--------------+------------- - id | pg_catalog.int4 | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | | - relation | name | | not null | | plain | | - options | text[] | | | | extended | | + Table "public.replication_metadata" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +----------+-----------------+-----------+----------+--------------------------------------------------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | not null | nextval('replication_metadata_id_seq'::regclass) | | plain | | + relation | name | | not null | | | plain | | + options | text[] | | | | | extended | | Indexes: "replication_metadata_pkey" PRIMARY KEY, btree (id) Not-null constraints: @@ -511,12 +511,12 @@ INSERT INTO replication_metadata(relation, options) VALUES ('foo', ARRAY['a', 'b']); ALTER TABLE replication_metadata RESET (user_catalog_table); \d+ replication_metadata - Table "public.replication_metadata" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------+-----------------+-----------+----------+--------------------------------------------------+----------+--------------+------------- - id | pg_catalog.int4 | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | | - relation | name | | not null | | plain | | - options | text[] | | | | extended | | + Table "public.replication_metadata" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +----------+-----------------+-----------+----------+--------------------------------------------------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | not null | nextval('replication_metadata_id_seq'::regclass) | | plain | | + relation | name | | not null | | | plain | | + options | text[] | | | | | extended | | Indexes: "replication_metadata_pkey" PRIMARY KEY, btree (id) Not-null constraints: @@ -527,12 +527,12 @@ INSERT INTO replication_metadata(relation, options) VALUES ('bar', ARRAY['a', 'b']); ALTER TABLE replication_metadata SET (user_catalog_table = true); \d+ replication_metadata - Table "public.replication_metadata" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------+-----------------+-----------+----------+--------------------------------------------------+----------+--------------+------------- - id | pg_catalog.int4 | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | | - relation | name | | not null | | plain | | - options | text[] | | | | extended | | + Table "public.replication_metadata" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +----------+-----------------+-----------+----------+--------------------------------------------------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | not null | nextval('replication_metadata_id_seq'::regclass) | | plain | | + relation | name | | not null | | | plain | | + options | text[] | | | | | extended | | Indexes: "replication_metadata_pkey" PRIMARY KEY, btree (id) Not-null constraints: @@ -548,13 +548,13 @@ ALTER TABLE replication_metadata ALTER COLUMN rewritemeornot TYPE text; ERROR: cannot rewrite table "replication_metadata" used as a catalog table ALTER TABLE replication_metadata SET (user_catalog_table = false); \d+ replication_metadata - Table "public.replication_metadata" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------------+-----------------+-----------+----------+--------------------------------------------------+----------+--------------+------------- - id | pg_catalog.int4 | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | | - relation | name | | not null | | plain | | - options | text[] | | | | extended | | - rewritemeornot | pg_catalog.int4 | | | | plain | | + Table "public.replication_metadata" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +----------------+-----------------+-----------+----------+--------------------------------------------------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | not null | nextval('replication_metadata_id_seq'::regclass) | | plain | | + relation | name | | not null | | | plain | | + options | text[] | | | | | extended | | + rewritemeornot | pg_catalog.int4 | | | | | plain | | Indexes: "replication_metadata_pkey" PRIMARY KEY, btree (id) Not-null constraints: diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index bc80caee117..835d12d3d7d 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -155,6 +155,7 @@ CreateTupleDescCopy(TupleDesc tupdesc) att->atthasmissing = false; att->attidentity = '\0'; att->attgenerated = '\0'; + att->attisinvisible = false; } /* We can copy the tuple type identification, too */ @@ -483,6 +484,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) return false; if (attr1->attcollation != attr2->attcollation) return false; + if (attr1->attisinvisible != attr2->attisinvisible) + return false; /* variable-length fields are not even present... */ } @@ -665,6 +668,7 @@ TupleDescInitEntry(TupleDesc desc, att->attstorage = typeForm->typstorage; att->attcompression = InvalidCompressionMethod; att->attcollation = typeForm->typcollation; + att->attisinvisible = false; ReleaseSysCache(tuple); } @@ -713,6 +717,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc, att->attisdropped = false; att->attislocal = true; att->attinhcount = 0; + att->attisinvisible = false; /* variable-length fields are not present in tupledescs */ att->atttypid = oidtypeid; diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index c73f7bcd011..2adaf7fc0f5 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -736,6 +736,7 @@ InsertPgAttributeTuples(Relation pg_attribute_rel, slot[slotCount]->tts_values[Anum_pg_attribute_attnum - 1] = Int16GetDatum(attrs->attnum); slot[slotCount]->tts_values[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1); slot[slotCount]->tts_values[Anum_pg_attribute_atttypmod - 1] = Int32GetDatum(attrs->atttypmod); + slot[slotCount]->tts_values[Anum_pg_attribute_attisinvisible - 1] = BoolGetDatum(attrs->attisinvisible); slot[slotCount]->tts_values[Anum_pg_attribute_attndims - 1] = Int16GetDatum(attrs->attndims); slot[slotCount]->tts_values[Anum_pg_attribute_attbyval - 1] = BoolGetDatum(attrs->attbyval); slot[slotCount]->tts_values[Anum_pg_attribute_attalign - 1] = CharGetDatum(attrs->attalign); diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index cc0786c6f4a..cca16ac5e79 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -828,7 +828,7 @@ ProcessCopyOptions(ParseState *pstate, * * The input attnamelist is either the user-specified column list, * or NIL if there was none (in which case we want all the non-dropped - * columns). + * and not invisible columns). * * We don't include generated columns in the generated full list and we don't * allow them to be specified explicitly. They don't make sense for COPY @@ -850,7 +850,7 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist) for (i = 0; i < attr_count; i++) { - if (TupleDescAttr(tupDesc, i)->attisdropped) + if (TupleDescAttr(tupDesc, i)->attisdropped || TupleDescAttr(tupDesc, i)->attisinvisible) continue; if (TupleDescAttr(tupDesc, i)->attgenerated) continue; diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index d0447446032..fd0879e4952 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -661,6 +661,10 @@ static List *GetParentedForeignKeyRefs(Relation partition); static void ATDetachCheckNoForeignKeyRefs(Relation partition); static char GetAttributeCompression(Oid atttypid, const char *compression); static char GetAttributeStorage(Oid atttypid, const char *storagemode); +static ObjectAddress ATExecDropInvisible(Relation rel, const char *colName, + LOCKMODE lockmode); +static ObjectAddress ATExecSetInvisible(Relation rel, const char *colName, + LOCKMODE lockmode); /* ---------------------------------------------------------------- @@ -708,6 +712,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, LOCKMODE parentLockmode; const char *accessMethod = NULL; Oid accessMethodId = InvalidOid; + bool has_visible_col = false; /* * Truncate relname to appropriate length (probably a waste of time, as @@ -952,6 +957,22 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, cookedDefaults = lappend(cookedDefaults, cooked); attr->atthasdef = true; } + + if (colDef->is_invisible) + attr->attisinvisible = true; + else + has_visible_col = true; + + /* + * Verify that we have at least one visible column + * when there is invisible ones + */ + if (attnum > 1 && !has_visible_col) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("a table must have at least one visible column"))); + + } /* @@ -1360,6 +1381,7 @@ BuildDescForRelation(const List *columns) has_not_null |= entry->is_not_null; att->attislocal = entry->is_local; att->attinhcount = entry->inhcount; + att->attisinvisible = entry->is_invisible; att->attidentity = entry->identity; att->attgenerated = entry->generated; att->attcompression = GetAttributeCompression(att->atttypid, entry->compression); @@ -2555,6 +2577,7 @@ MergeAttributes(List *columns, const List *supers, char relpersistence, coldef->cooked_default = restdef->cooked_default; coldef->constraints = restdef->constraints; coldef->is_from_type = false; + coldef->is_invisible = restdef->is_invisible; columns = list_delete_nth_cell(columns, restpos); } else @@ -2726,6 +2749,8 @@ MergeAttributes(List *columns, const List *supers, char relpersistence, newdef->compression = pstrdup(GetCompressionMethodName(attribute->attcompression)); + newdef->is_invisible = attribute->attisinvisible; + /* * Regular inheritance children are independent enough not to * inherit identity columns. But partitions are integral part of @@ -3048,6 +3073,7 @@ MergeAttributes(List *columns, const List *supers, char relpersistence, errhint("A child table column cannot be generated unless its parent column is."))); } + coldef->is_invisible |= restdef->is_invisible; /* * Override the parent's default value for this column * (coldef->cooked_default) with the partition's local @@ -3283,6 +3309,11 @@ MergeChildAttribute(List *inh_columns, int exist_attno, int newcol_attno, const */ inhdef->is_not_null |= newdef->is_not_null; + /* + * Merge of INVISIBLE attribute = OR 'em together + */ + inhdef->is_invisible |= newdef->is_invisible; + /* * Check for conflicts related to generated columns. * @@ -3435,6 +3466,11 @@ MergeInheritedAttribute(List *inh_columns, errmsg("inherited column \"%s\" has a generation conflict", attributeName))); + /* + * Merge of INVISIBLE attribute = OR 'em together + */ + prevdef->is_invisible |= newdef->is_invisible; + /* * Default and other constraints are handled by the caller. */ @@ -4604,6 +4640,8 @@ AlterTableGetLockLevel(List *cmds) case AT_SetExpression: case AT_DropExpression: case AT_SetCompression: + case AT_DropInvisible: + case AT_SetInvisible: cmd_lockmode = AccessExclusiveLock; break; @@ -4888,6 +4926,16 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, cmd->recurse = true; pass = AT_PASS_DROP; break; + case AT_SetInvisible: + ATSimplePermissions(cmd->subtype, rel, ATT_TABLE); + /* No command-specific prep needed */ + pass = AT_PASS_MISC; + break; + case AT_DropInvisible: + ATSimplePermissions(cmd->subtype, rel, ATT_TABLE); + /* This command never recurses */ + pass = AT_PASS_DROP; + break; case AT_DropNotNull: /* ALTER COLUMN DROP NOT NULL */ ATSimplePermissions(cmd->subtype, rel, ATT_TABLE | ATT_FOREIGN_TABLE); /* Set up recursion for phase 2; no other prep needed */ @@ -5288,6 +5336,12 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, case AT_DropIdentity: address = ATExecDropIdentity(rel, cmd->name, cmd->missing_ok, lockmode, cmd->recurse, false); break; + case AT_SetInvisible: /* ALTER COLUMN SET INVISIBLE */ + address = ATExecSetInvisible(rel, cmd->name, lockmode); + break; + case AT_DropInvisible: /* ALTER COLUMN DROP INVISIBLE */ + address = ATExecDropInvisible(rel, cmd->name, lockmode); + break; case AT_DropNotNull: /* ALTER COLUMN DROP NOT NULL */ address = ATExecDropNotNull(rel, cmd->name, cmd->recurse, lockmode); break; @@ -6544,6 +6598,10 @@ alter_table_type_to_string(AlterTableType cmdtype) return "ALTER COLUMN ... DROP IDENTITY"; case AT_ReAddStatistics: return NULL; /* not real grammar */ + case AT_DropInvisible: + return "ALTER COLUMN ... DROP INVISIBLE"; + case AT_SetInvisible: + return "ALTER COLUMN ... SET INVISIBLE"; } return NULL; @@ -7505,6 +7563,185 @@ add_column_collation_dependency(Oid relid, int32 attnum, Oid collid) } } + +/* + * Return the address of the modified column. If the column was already + * part of star expansion, InvalidObjectAddress is returned. + */ +static ObjectAddress +ATExecDropInvisible(Relation rel, const char *colName, LOCKMODE lockmode) +{ + HeapTuple tuple; + Form_pg_attribute attTup; + AttrNumber attnum; + Relation attr_rel; + ObjectAddress address; + + /* + * lookup the attribute + */ + attr_rel = table_open(AttributeRelationId, RowExclusiveLock); + + tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName); + if (!HeapTupleIsValid(tuple)) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_COLUMN), + errmsg("column \"%s\" of relation \"%s\" does not exist", + colName, RelationGetRelationName(rel)))); + attTup = (Form_pg_attribute) GETSTRUCT(tuple); + attnum = attTup->attnum; + + /* Prevent them from altering a system attribute */ + if (attnum <= 0) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter system column \"%s\"", + colName))); + + /* If rel is partition, shouldn't drop INVISIBLE if parent has the same */ + if (rel->rd_rel->relispartition) + { + Oid parentId = get_partition_parent(RelationGetRelid(rel), false); + Relation parent = table_open(parentId, AccessShareLock); + TupleDesc tupDesc = RelationGetDescr(parent); + AttrNumber parent_attnum; + + parent_attnum = get_attnum(parentId, colName); + if (TupleDescAttr(tupDesc, parent_attnum - 1)->attisinvisible) + ereport(ERROR, + (errcode(ERRCODE_INVALID_TABLE_DEFINITION), + errmsg("column \"%s\" is marked INVISIBLE in parent table", + colName))); + table_close(parent, AccessShareLock); + } + + /* + * Okay, actually perform the catalog change ... if needed + */ + if (attTup->attisinvisible) + { + attTup->attisinvisible = false; + + CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple); + + ObjectAddressSubSet(address, RelationRelationId, + RelationGetRelid(rel), attnum); + } + else + address = InvalidObjectAddress; + + InvokeObjectPostAlterHook(RelationRelationId, + RelationGetRelid(rel), attnum); + + table_close(attr_rel, RowExclusiveLock); + + return address; +} + +/* + * Return the address of the modified column. If the column was already + * INVISIBLE, InvalidObjectAddress is returned. + */ +static ObjectAddress +ATExecSetInvisible(Relation rel, const char *colName, LOCKMODE lockmode) +{ + HeapTuple tuple; + AttrNumber attnum; + Relation attr_rel; + ObjectAddress address; + SysScanDesc scan; + + if (rel->rd_rel->reloftype) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot set INVISIBLE attribute on a column of a typed table"))); + + attr_rel = table_open(AttributeRelationId, RowExclusiveLock); + + /* + * lookup the attribute + */ + tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName); + + if (!HeapTupleIsValid(tuple)) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_COLUMN), + errmsg("column \"%s\" of relation \"%s\" does not exist", + colName, RelationGetRelationName(rel)))); + + attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum; + + /* Prevent them from altering a system attribute */ + if (attnum <= 0) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter system column \"%s\"", + colName))); + + /* + * Okay, actually perform the catalog change ... if needed + */ + if (!((Form_pg_attribute) GETSTRUCT(tuple))->attisinvisible) + { + bool has_visible_cols = false; + HeapTuple chk_tuple; + ScanKeyData key[1]; + ((Form_pg_attribute) GETSTRUCT(tuple))->attisinvisible = true; + + /* + * Look if we will have at least one other column that is + * visible, we do not allow all columns of a relation to + * be invisible. + */ + ScanKeyInit(&key[0], + Anum_pg_attribute_attrelid, + BTEqualStrategyNumber, F_OIDEQ, + ObjectIdGetDatum(rel->rd_rel->oid)); + + scan = systable_beginscan(attr_rel, AttributeRelidNumIndexId, true, + NULL, 1, key); + + while ((chk_tuple = systable_getnext(scan)) != NULL) + { + Form_pg_attribute attr = (Form_pg_attribute) GETSTRUCT(chk_tuple); + if (attr->attnum <= 0 || attr->attisdropped || attr->attnum == attnum) + continue; + if (!attr->attisinvisible) + { + has_visible_cols = true; + break; + } + + } + + /* Clean up after the scan */ + systable_endscan(scan); + + if (!has_visible_cols) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("relation \"%s\" can not have all columns invisible", + RelationGetRelationName(rel)))); + + + /* Now we can update the catalog */ + CatalogTupleUpdate(attr_rel, &tuple->t_self, tuple); + + ObjectAddressSubSet(address, RelationRelationId, + RelationGetRelid(rel), attnum); + } + else + address = InvalidObjectAddress; + + InvokeObjectPostAlterHook(RelationRelationId, + RelationGetRelid(rel), attnum); + + table_close(attr_rel, RowExclusiveLock); + + return address; +} + + /* * ALTER TABLE ALTER COLUMN DROP NOT NULL * diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c index dafd3f5271d..92c2dcfa9d2 100644 --- a/src/backend/nodes/makefuncs.c +++ b/src/backend/nodes/makefuncs.c @@ -508,6 +508,7 @@ makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid) n->constraints = NIL; n->fdwoptions = NIL; n->location = -1; + n->is_invisible = false; return n; } diff --git a/src/backend/oracle_parser/ora_gram.y b/src/backend/oracle_parser/ora_gram.y index 76a081fb5c6..06bb831a4ae 100644 --- a/src/backend/oracle_parser/ora_gram.y +++ b/src/backend/oracle_parser/ora_gram.y @@ -602,6 +602,7 @@ static void determineLanguage(List *options); %type TableConstraint TableLikeClause %type TableLikeOptionList TableLikeOption %type column_compression opt_column_compression column_storage opt_column_storage +%type column_invisible %type ColQualList %type ColConstraint ColConstraintElem ConstraintAttr %type key_match @@ -735,7 +736,7 @@ static void determineLanguage(List *options); IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE INCLUDING INCREMENT INDENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER - INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION + INTERSECT INTERVAL INTO INVISIBLE INVOKER IS ISNULL ISOLATION JOIN JSON JSON_ARRAY JSON_ARRAYAGG JSON_OBJECT JSON_OBJECTAGG JSON_SCALAR JSON_SERIALIZE @@ -787,7 +788,7 @@ static void determineLanguage(List *options); UNLISTEN UNLOGGED UNTIL UPDATE USER USERENV USING VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARCHAR2 VARIADIC VARYING - VERBOSE VERSION_P VIEW VIEWS VOLATILE + VERBOSE VERSION_P VIEW VIEWS VISIBLE VOLATILE WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE @@ -2493,6 +2494,36 @@ alter_table_cmd: n->name = $3; n->def = $4; $$ = (Node *) n; + } + /* ALTER TABLE ALTER [COLUMN] DROP INVISIBLE */ + | ALTER opt_column ColId DROP INVISIBLE + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropInvisible; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER TABLE ALTER [COLUMN] SET INVISIBLE */ + | ALTER opt_column ColId SET INVISIBLE + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetInvisible; + n->name = $3; + $$ = (Node *)n; + } + | MODIFY ColId INVISIBLE + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetInvisible; + n->name = $2; + $$ = (Node *)n; + } + | MODIFY ColId VISIBLE + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropInvisible; + n->name = $2; + $$ = (Node *)n; } /* ALTER TABLE ALTER [COLUMN] DROP NOT NULL */ | ALTER opt_column ColId DROP NOT NULL_P @@ -3889,7 +3920,7 @@ TypedTableElement: | TableConstraint { $$ = $1; } ; -columnDef: ColId Typename opt_column_storage opt_column_compression create_generic_options ColQualList +columnDef: ColId Typename opt_column_storage opt_column_compression create_generic_options ColQualList column_invisible { ColumnDef *n = makeNode(ColumnDef); @@ -3908,12 +3939,13 @@ columnDef: ColId Typename opt_column_storage opt_column_compression create_gener n->fdwoptions = $5; SplitColQualList($6, &n->constraints, &n->collClause, yyscanner); + n->is_invisible = $7; n->location = @1; $$ = (Node *) n; } ; -columnOptions: ColId ColQualList +columnOptions: ColId ColQualList column_invisible { ColumnDef *n = makeNode(ColumnDef); @@ -3929,6 +3961,7 @@ columnOptions: ColId ColQualList n->collOid = InvalidOid; SplitColQualList($2, &n->constraints, &n->collClause, yyscanner); + n->is_invisible = $3; n->location = @1; $$ = (Node *) n; } @@ -3953,6 +3986,12 @@ columnOptions: ColId ColQualList } ; +column_invisible: + INVISIBLE { $$ = $1; } + | VISIBLE { $$ = false; } + | /*EMPTY*/ { $$ = false; } + ; + column_compression: COMPRESSION ColId { $$ = $2; } | COMPRESSION DEFAULT { $$ = pstrdup("default"); } @@ -4237,6 +4276,7 @@ TableLikeOption: | INDEXES { $$ = CREATE_TABLE_LIKE_INDEXES; } | STATISTICS { $$ = CREATE_TABLE_LIKE_STATISTICS; } | STORAGE { $$ = CREATE_TABLE_LIKE_STORAGE; } + | INVISIBLE { $$ = CREATE_TABLE_LIKE_INVISIBLE; } | ALL { $$ = CREATE_TABLE_LIKE_ALL; } ; @@ -19198,6 +19238,7 @@ unreserved_keyword: | INSENSITIVE | INSERT | INSTEAD + | INVISIBLE | INVOKER | ISOLATION | IVYSQL @@ -19402,6 +19443,7 @@ unreserved_keyword: | VERSION_P | VIEW | VIEWS + | VISIBLE | VOLATILE | WHITESPACE_P | WITHIN @@ -19841,6 +19883,7 @@ bare_label_keyword: | INT_P | INTEGER | INTERVAL + | INVISIBLE | INVOKER | IS | ISOLATION @@ -20111,6 +20154,7 @@ bare_label_keyword: | VERSION_P | VIEW | VIEWS + | VISIBLE | VOLATILE | WHEN | WHITESPACE_P diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index b917a9da425..ac9ad25a88a 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -1326,6 +1326,12 @@ buildNSItemFromTupleDesc(RangeTblEntry *rte, Index rtindex, nscolumns[varattno].p_varcollid = attr->attcollation; nscolumns[varattno].p_varnosyn = rtindex; nscolumns[varattno].p_varattnosyn = varattno + 1; + /* + * For an invisible column, the entry will not + * be included in star expansion. + */ + if (attr->attisinvisible) + nscolumns[varattno].p_dontexpand = true; } /* ... and build the nsitem */ diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index a74e8d0a1bb..4412d5ab0f9 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -1019,7 +1019,7 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) attr = TupleDescAttr(pstate->p_target_relation->rd_att, i); - if (attr->attisdropped) + if (attr->attisdropped || attr->attisinvisible) continue; col = makeNode(ResTarget); @@ -1294,7 +1294,6 @@ ExpandAllTables(ParseState *pstate, int location) Assert(!nsitem->p_lateral_only); /* Remember we found a p_cols_visible item */ found_table = true; - target = list_concat(target, expandNSItemAttrs(pstate, nsitem, diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 0caa7fb64ee..4fa8afda334 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1174,6 +1174,12 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla else def->storage = 0; + /* Likewise, copy invisible if requested */ + if (table_like_clause->options & CREATE_TABLE_LIKE_INVISIBLE) + def->is_invisible = attribute->attisinvisible; + else + def->is_invisible = false; + /* Likewise, copy compression if requested */ if ((table_like_clause->options & CREATE_TABLE_LIKE_COMPRESSION) != 0 && CompressionMethodIsValid(attribute->attcompression)) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index c0340f50963..3d71582aac8 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -3579,6 +3579,7 @@ RelationBuildLocalRelation(const char *relname, datt->attidentity = satt->attidentity; datt->attgenerated = satt->attgenerated; datt->attnotnull = satt->attnotnull; + datt->attisinvisible = satt->attisinvisible; has_not_null |= satt->attnotnull; } diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 9bf521fefc4..432b98793fa 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -8621,6 +8621,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) int i_attoptions; int i_attcollation; int i_attcompression; + int i_attisinvisible; int i_attfdwoptions; int i_attmissingval; int i_atthasdef; @@ -8730,6 +8731,14 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) else appendPQExpBufferStr(q, "'' AS attcompression,\n"); + + if (fout->remoteVersion >= 170000) + appendPQExpBuffer(q, + "a.attisinvisible,\n"); + else + appendPQExpBuffer(q, + "'f' AS attisinvisible,\n"); + if (fout->remoteVersion >= 100000) appendPQExpBufferStr(q, @@ -8805,6 +8814,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) i_attoptions = PQfnumber(res, "attoptions"); i_attcollation = PQfnumber(res, "attcollation"); i_attcompression = PQfnumber(res, "attcompression"); + i_attisinvisible = PQfnumber(res, "attisinvisible"); i_attfdwoptions = PQfnumber(res, "attfdwoptions"); i_attmissingval = PQfnumber(res, "attmissingval"); i_atthasdef = PQfnumber(res, "atthasdef"); @@ -8867,6 +8877,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) tbinfo->attoptions = (char **) pg_malloc(numatts * sizeof(char *)); tbinfo->attcollation = (Oid *) pg_malloc(numatts * sizeof(Oid)); tbinfo->attcompression = (char *) pg_malloc(numatts * sizeof(char)); + tbinfo->attisinvisible = (bool *) pg_malloc(ntups * sizeof(bool)); tbinfo->attfdwoptions = (char **) pg_malloc(numatts * sizeof(char *)); tbinfo->attmissingval = (char **) pg_malloc(numatts * sizeof(char *)); tbinfo->notnull_constrs = (char **) pg_malloc(numatts * sizeof(char *)); @@ -9026,6 +9037,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) tbinfo->attoptions[j] = pg_strdup(PQgetvalue(res, r, i_attoptions)); tbinfo->attcollation[j] = atooid(PQgetvalue(res, r, i_attcollation)); tbinfo->attcompression[j] = *(PQgetvalue(res, r, i_attcompression)); + tbinfo->attisinvisible[j] = (PQgetvalue(res, j, i_attisinvisible)[0] == 't'); tbinfo->attfdwoptions[j] = pg_strdup(PQgetvalue(res, r, i_attfdwoptions)); tbinfo->attmissingval[j] = pg_strdup(PQgetvalue(res, r, i_attmissingval)); tbinfo->attrdefs[j] = NULL; /* fix below */ @@ -16478,6 +16490,13 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo) tbinfo->notnull_constrs[j], fmtId(tbinfo->attnames[j])); } + + /* + * Dump per-column invisible information. + */ + if (tbinfo->attisinvisible[j]) + appendPQExpBufferStr(q, " INVISIBLE"); + /* * Dump per-column statistics information. We only issue an ALTER diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 77db42e354b..bf374ad2c3d 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -344,6 +344,7 @@ typedef struct _tableInfo char **attoptions; /* per-attribute options */ Oid *attcollation; /* per-attribute collation selection */ char *attcompression; /* per-attribute compression method */ + bool *attisinvisible; /* invisible column */ char **attfdwoptions; /* per-attribute fdw options */ char **attmissingval; /* per attribute missing value */ char **notnull_constrs; /* NOT NULL constraint names. If null, diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 5f0904ae526..73dac1d554d 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -26,6 +26,7 @@ #include "fe_utils/mbprint.h" #include "fe_utils/print.h" #include "fe_utils/string_utils.h" +#include "oracle_fe_utils/ora_string_utils.h" #include "settings.h" #include "variables.h" @@ -1556,6 +1557,7 @@ describeOneTableDetails(const char *schemaname, atttype_col = -1, attrdef_col = -1, attnotnull_col = -1, + attisinvisible_col = -1, attcoll_col = -1, attidentity_col = -1, attgenerated_col = -1, @@ -1953,6 +1955,15 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n pg_catalog.col_description(a.attrelid, a.attnum)"); attdescr_col = cols++; } + + /* column visibility in a SELECT *, if relevant to relkind */ + if ((db_mode == DB_ORACLE) && + (tableinfo.relkind == RELKIND_RELATION || + tableinfo.relkind == RELKIND_PARTITIONED_TABLE)) + { + appendPQExpBufferStr(&buf, ",\n a.attisinvisible AS attisinvisible"); + attisinvisible_col = cols++; + } } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_attribute a"); @@ -2040,6 +2051,8 @@ describeOneTableDetails(const char *schemaname, headers[cols++] = gettext_noop("Nullable"); headers[cols++] = gettext_noop("Default"); } + if ((attisinvisible_col >= 0) && (db_mode == DB_ORACLE) ) + headers[cols++] = gettext_noop("Invisible"); if (isindexkey_col >= 0) headers[cols++] = gettext_noop("Key?"); if (indexdef_col >= 0) @@ -2072,7 +2085,7 @@ describeOneTableDetails(const char *schemaname, /* Type */ printTableAddCell(&cont, PQgetvalue(res, i, atttype_col), false, false); - /* Collation, Nullable, Default */ + /* Collation, Nullable, INVISIBLE, Default */ if (show_column_details) { char *identity; @@ -2085,7 +2098,6 @@ describeOneTableDetails(const char *schemaname, printTableAddCell(&cont, strcmp(PQgetvalue(res, i, attnotnull_col), "t") == 0 ? "not null" : "", false, false); - identity = PQgetvalue(res, i, attidentity_col); generated = PQgetvalue(res, i, attgenerated_col); @@ -2117,6 +2129,12 @@ describeOneTableDetails(const char *schemaname, if (fdwopts_col >= 0) printTableAddCell(&cont, PQgetvalue(res, i, fdwopts_col), false, false); + /* Column invisible in SELECT *, if relevant */ + if ((attisinvisible_col >= 0) && (db_mode == DB_ORACLE)) + printTableAddCell(&cont, + strcmp(PQgetvalue(res, i, attisinvisible_col), "t") == 0 ? "invisible" : "", + false, false); + /* Storage mode, if relevant */ if (attstorage_col >= 0) { diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 151a5211ee4..d7478df01de 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2350,7 +2350,17 @@ psql_completion(const char *text, int start, int end) "OWNER TO", "SET", "VALIDATE CONSTRAINT", "REPLICA IDENTITY", "ATTACH PARTITION", "DETACH PARTITION", "FORCE ROW LEVEL SECURITY", - "OF", "NOT OF"); + "OF", "NOT OF", "MODIFY"); + + /* + * Oracle Command + * ALTER TABLE xxx MODIFY + */ + else if (Matches("ALTER", "TABLE", MatchAny, "MODIFY", MatchAny)) + { + /* make sure to keep this list and the !Matches() below in sync */ + COMPLETE_WITH("INVISIBLE", "VISIBLE"); + } /* ALTER TABLE xxx ADD */ else if (Matches("ALTER", "TABLE", MatchAny, "ADD")) { @@ -2504,7 +2514,7 @@ psql_completion(const char *text, int start, int end) /* ALTER TABLE ALTER [COLUMN] SET */ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET") || Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET")) - COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "EXPRESSION", "GENERATED", "NOT NULL", "STATISTICS", "STORAGE", + COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "EXPRESSION", "GENERATED", "NOT NULL", "STATISTICS", "STORAGE", "INVISIBLE" /* a subset of ALTER SEQUENCE options */ "INCREMENT", "MINVALUE", "MAXVALUE", "START", "NO", "CACHE", "CYCLE"); /* ALTER TABLE ALTER [COLUMN] SET ( */ @@ -2544,7 +2554,7 @@ psql_completion(const char *text, int start, int end) /* ALTER TABLE ALTER [COLUMN] DROP */ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "DROP") || Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "DROP")) - COMPLETE_WITH("DEFAULT", "EXPRESSION", "IDENTITY", "NOT NULL"); + COMPLETE_WITH("DEFAULT", "EXPRESSION", "IDENTITY", "NOT NULL", "INVISIBLE"); else if (Matches("ALTER", "TABLE", MatchAny, "CLUSTER")) COMPLETE_WITH("ON"); else if (Matches("ALTER", "TABLE", MatchAny, "CLUSTER", "ON")) diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 7e5e09356a3..a97d7ffb2b1 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -158,6 +158,13 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75, /* Number of times inherited from direct parent relation(s) */ int16 attinhcount BKI_DEFAULT(0); + /* + * This flag specifies whether this column is visible in + * a SELECT *, an INSERT without column list, or not. It is true when + * a column is defined with the INVISIBLE attribute, false otherwise. + */ + bool attisinvisible BKI_DEFAULT(f); + /* attribute's collation, if any */ Oid attcollation BKI_LOOKUP_OPT(pg_collation); diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 4074390efdc..d761584a789 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -730,6 +730,8 @@ typedef struct ColumnDef List *constraints; /* other constraints on column */ List *fdwoptions; /* per-column FDW options */ int location; /* parse location, or -1 if none/unknown */ + bool is_invisible; /* column is not included in star expansion? + (invisible column) */ } ColumnDef; /* @@ -754,6 +756,7 @@ typedef enum TableLikeOption CREATE_TABLE_LIKE_INDEXES = 1 << 6, CREATE_TABLE_LIKE_STATISTICS = 1 << 7, CREATE_TABLE_LIKE_STORAGE = 1 << 8, + CREATE_TABLE_LIKE_INVISIBLE = 1 << 9, CREATE_TABLE_LIKE_ALL = PG_INT32_MAX } TableLikeOption; @@ -2253,6 +2256,8 @@ typedef enum AlterTableType AT_SetIdentity, /* SET identity column options */ AT_DropIdentity, /* DROP IDENTITY */ AT_ReAddStatistics, /* internal to commands/tablecmds.c */ + AT_DropInvisible, /* alter column drop invisible */ + AT_SetInvisible /* alter column set invisible */ } AlterTableType; typedef struct ReplicaIdentityStmt diff --git a/src/include/oracle_parser/ora_kwlist.h b/src/include/oracle_parser/ora_kwlist.h index f738b17cb25..ba0d04a7529 100644 --- a/src/include/oracle_parser/ora_kwlist.h +++ b/src/include/oracle_parser/ora_kwlist.h @@ -245,6 +245,7 @@ PG_KEYWORD("integer", INTEGER, COL_NAME_KEYWORD, BARE_LABEL) PG_KEYWORD("intersect", INTERSECT, RESERVED_KEYWORD, AS_LABEL) PG_KEYWORD("interval", INTERVAL, COL_NAME_KEYWORD, BARE_LABEL) PG_KEYWORD("into", INTO, RESERVED_KEYWORD, AS_LABEL) +PG_KEYWORD("invisible", INVISIBLE, UNRESERVED_KEYWORD, BARE_LABEL) PG_KEYWORD("invoker", INVOKER, UNRESERVED_KEYWORD, BARE_LABEL) PG_KEYWORD("is", IS, TYPE_FUNC_NAME_KEYWORD, BARE_LABEL) PG_KEYWORD("isnull", ISNULL, TYPE_FUNC_NAME_KEYWORD, AS_LABEL) @@ -532,6 +533,7 @@ PG_KEYWORD("verbose", VERBOSE, TYPE_FUNC_NAME_KEYWORD, BARE_LABEL) PG_KEYWORD("version", VERSION_P, UNRESERVED_KEYWORD, BARE_LABEL) PG_KEYWORD("view", VIEW, UNRESERVED_KEYWORD, BARE_LABEL) PG_KEYWORD("views", VIEWS, UNRESERVED_KEYWORD, BARE_LABEL) +PG_KEYWORD("visible", VISIBLE, UNRESERVED_KEYWORD, BARE_LABEL) PG_KEYWORD("volatile", VOLATILE, UNRESERVED_KEYWORD, BARE_LABEL) PG_KEYWORD("when", WHEN, RESERVED_KEYWORD, BARE_LABEL) PG_KEYWORD("where", WHERE, RESERVED_KEYWORD, AS_LABEL) diff --git a/src/oracle_test/regress/expected/alter_table.out b/src/oracle_test/regress/expected/alter_table.out index cfa85184a80..f65ad068e99 100644 --- a/src/oracle_test/regress/expected/alter_table.out +++ b/src/oracle_test/regress/expected/alter_table.out @@ -2287,12 +2287,12 @@ ERROR: column data type pg_catalog.int4 can only have storage PLAIN create index test_storage_idx on test_storage (b, a); alter table test_storage alter column a set storage external; \d+ test_storage - Table "public.test_storage" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------------------------+----------+--------------+------------- - a | text | | | | external | | - c | text | | | | plain | | - b | pg_catalog.int4 | | | random()::pg_catalog.int4 | plain | | + Table "public.test_storage" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------------------------+-----------+----------+--------------+------------- + a | text | | | | | external | | + c | text | | | | | plain | | + b | pg_catalog.int4 | | | random()::pg_catalog.int4 | | plain | | Indexes: "test_storage_idx" btree (b, a) @@ -3860,12 +3860,12 @@ ALTER TABLE atnotnull1 ADD COLUMN c INT, ADD PRIMARY KEY (c); \d+ atnotnull1 - Table "public.atnotnull1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | - b | pg_catalog.int4 | | not null | | plain | | - c | pg_catalog.int4 | | not null | | plain | | + Table "public.atnotnull1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | + c | pg_catalog.int4 | | not null | | | plain | | Indexes: "atnotnull1_pkey" PRIMARY KEY, btree (c) Not-null constraints: @@ -4340,10 +4340,10 @@ DROP TABLE part_rpd; -- works fine ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY; \d+ range_parted2 - Partitioned table "public.range_parted2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Partitioned table "public.range_parted2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Partition key: RANGE (a) Number of partitions: 0 @@ -4687,10 +4687,10 @@ create publication pub1 for table alter1.t1, tables in schema alter2; reset client_min_messages; alter table alter1.t1 set schema alter2; \d+ alter2.t1 - Table "alter2.t1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "alter2.t1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Publications: "pub1" diff --git a/src/oracle_test/regress/expected/compression.out b/src/oracle_test/regress/expected/compression.out index b7d9ef63cbd..681948ee9f2 100644 --- a/src/oracle_test/regress/expected/compression.out +++ b/src/oracle_test/regress/expected/compression.out @@ -6,20 +6,20 @@ CREATE TABLE cmdata(f1 text COMPRESSION pglz); CREATE INDEX idx ON cmdata(f1); INSERT INTO cmdata VALUES(repeat('1234567890', 1000)); \d+ cmdata - Table "public.cmdata" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | text | | | | extended | pglz | | + Table "public.cmdata" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | text | | | | | extended | pglz | | Indexes: "idx" btree (f1) CREATE TABLE cmdata1(f1 TEXT COMPRESSION lz4); INSERT INTO cmdata1 VALUES(repeat('1234567890', 1004)); \d+ cmdata1 - Table "public.cmdata1" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | text | | | | extended | lz4 | | + Table "public.cmdata1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | text | | | | | extended | lz4 | | -- verify stored compression method in the data SELECT pg_column_compression(f1) FROM cmdata; @@ -50,10 +50,10 @@ SELECT SUBSTR(f1, 2000, 50) FROM cmdata1; -- copy with table creation SELECT * INTO cmmove1 FROM cmdata; \d+ cmmove1 - Table "public.cmmove1" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | text | | | | extended | | | + Table "public.cmmove1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | text | | | | | extended | | | SELECT pg_column_compression(f1) FROM cmmove1; pg_column_compression @@ -75,15 +75,15 @@ SELECT pg_column_compression(f1) FROM cmmove3; -- test LIKE INCLUDING COMPRESSION CREATE TABLE cmdata2 (LIKE cmdata1 INCLUDING COMPRESSION); \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | text | | | | extended | lz4 | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | text | | | | | extended | lz4 | | DROP TABLE cmdata2; -- try setting compression for incompressible data type CREATE TABLE cmdata2 (f1 int COMPRESSION pglz); -ERROR: column data type integer does not support compression +ERROR: column data type pg_catalog.int4 does not support compression -- update using datum from different table CREATE TABLE cmmove2(f1 text COMPRESSION pglz); INSERT INTO cmmove2 VALUES (repeat('1234567890', 1004)); @@ -137,48 +137,48 @@ DROP TABLE cmdata2; --test column type update varlena/non-varlena CREATE TABLE cmdata2 (f1 int); \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+---------+-----------+----------+---------+---------+-------------+--------------+------------- - f1 | integer | | | | plain | | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+-------------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | | ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+-------------------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | character varying | | | | extended | | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+----------------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | varchar2(4000) | | | | | extended | | | ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::integer; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+---------+-----------+----------+---------+---------+-------------+--------------+------------- - f1 | integer | | | | plain | | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+-------------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | | --changing column storage should not impact the compression method --but the data should not be compressed ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar; ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION pglz; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+-------------------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | character varying | | | | extended | pglz | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+----------------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | varchar2(4000) | | | | | extended | pglz | | ALTER TABLE cmdata2 ALTER COLUMN f1 SET STORAGE plain; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+-------------------+-----------+----------+---------+---------+-------------+--------------+------------- - f1 | character varying | | | | plain | pglz | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+----------------+-----------+----------+---------+-----------+---------+-------------+--------------+------------- + f1 | varchar2(4000) | | | | | plain | pglz | | INSERT INTO cmdata2 VALUES (repeat('123456789', 800)); +ERROR: value too long for type varchar2(4000 byte) SELECT pg_column_compression(f1) FROM cmdata2; pg_column_compression ----------------------- - -(1 row) +(0 rows) -- test compression with materialized view CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1; @@ -246,10 +246,10 @@ SET default_toast_compression = 'pglz'; ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION lz4; INSERT INTO cmdata VALUES (repeat('123456789', 4004)); \d+ cmdata - Table "public.cmdata" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | text | | | | extended | lz4 | | + Table "public.cmdata" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | text | | | | | extended | lz4 | | Indexes: "idx" btree (f1) @@ -262,10 +262,10 @@ SELECT pg_column_compression(f1) FROM cmdata; ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION default; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+-------------------+-----------+----------+---------+---------+-------------+--------------+------------- - f1 | character varying | | | | plain | | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+----------------+-----------+----------+---------+-----------+---------+-------------+--------------+------------- + f1 | varchar2(4000) | | | | | plain | | | -- test alter compression method for materialized views ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4; diff --git a/src/oracle_test/regress/expected/compression_1.out b/src/oracle_test/regress/expected/compression_1.out index 7b972ba02a2..633fbf90931 100644 --- a/src/oracle_test/regress/expected/compression_1.out +++ b/src/oracle_test/regress/expected/compression_1.out @@ -6,10 +6,10 @@ CREATE TABLE cmdata(f1 text COMPRESSION pglz); CREATE INDEX idx ON cmdata(f1); INSERT INTO cmdata VALUES(repeat('1234567890', 1000)); \d+ cmdata - Table "public.cmdata" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | text | | | | extended | pglz | | + Table "public.cmdata" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | text | | | | | extended | pglz | | Indexes: "idx" btree (f1) @@ -46,10 +46,10 @@ LINE 1: SELECT SUBSTR(f1, 2000, 50) FROM cmdata1; -- copy with table creation SELECT * INTO cmmove1 FROM cmdata; \d+ cmmove1 - Table "public.cmmove1" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | text | | | | extended | | | + Table "public.cmmove1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | text | | | | | extended | | | SELECT pg_column_compression(f1) FROM cmmove1; pg_column_compression @@ -134,41 +134,41 @@ DROP TABLE cmdata2; --test column type update varlena/non-varlena CREATE TABLE cmdata2 (f1 int); \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+-------------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+-------------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | | ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+----------------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | varchar2(4000) | | | | extended | | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+----------------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | varchar2(4000) | | | | | extended | | | ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::integer; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+-------------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+-------------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | | --changing column storage should not impact the compression method --but the data should not be compressed ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar; ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION pglz; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+----------------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | varchar2(4000) | | | | extended | pglz | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+----------------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | varchar2(4000) | | | | | extended | pglz | | ALTER TABLE cmdata2 ALTER COLUMN f1 SET STORAGE plain; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+----------------+-----------+----------+---------+---------+-------------+--------------+------------- - f1 | varchar2(4000) | | | | plain | pglz | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+----------------+-----------+----------+---------+-----------+---------+-------------+--------------+------------- + f1 | varchar2(4000) | | | | | plain | pglz | | INSERT INTO cmdata2 VALUES (repeat('123456789', 800)); ERROR: value too long for type varchar2(4000 byte) @@ -241,10 +241,10 @@ ERROR: compression method lz4 not supported DETAIL: This functionality requires the server to be built with lz4 support. INSERT INTO cmdata VALUES (repeat('123456789', 4004)); \d+ cmdata - Table "public.cmdata" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+------+-----------+----------+---------+----------+-------------+--------------+------------- - f1 | text | | | | extended | pglz | | + Table "public.cmdata" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+-------------+--------------+------------- + f1 | text | | | | | extended | pglz | | Indexes: "idx" btree (f1) @@ -257,10 +257,10 @@ SELECT pg_column_compression(f1) FROM cmdata; ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION default; \d+ cmdata2 - Table "public.cmdata2" - Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---------+----------------+-----------+----------+---------+---------+-------------+--------------+------------- - f1 | varchar2(4000) | | | | plain | | | + Table "public.cmdata2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Compression | Stats target | Description +--------+----------------+-----------+----------+---------+-----------+---------+-------------+--------------+------------- + f1 | varchar2(4000) | | | | | plain | | | -- test alter compression method for materialized views ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4; diff --git a/src/oracle_test/regress/expected/constraints.out b/src/oracle_test/regress/expected/constraints.out index a84b6c7f8fd..e2bc5a2a70d 100644 --- a/src/oracle_test/regress/expected/constraints.out +++ b/src/oracle_test/regress/expected/constraints.out @@ -292,10 +292,10 @@ NOTICE: drop cascades to table atacc2 CREATE TABLE ATACC1 (a int, not null a no inherit); CREATE TABLE ATACC2 () INHERITS (ATACC1); \d+ ATACC2 - Table "public.atacc2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "public.atacc2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Inherits: atacc1 DROP TABLE ATACC1, ATACC2; @@ -303,10 +303,10 @@ CREATE TABLE ATACC1 (a int); ALTER TABLE ATACC1 ADD NOT NULL a NO INHERIT; CREATE TABLE ATACC2 () INHERITS (ATACC1); \d+ ATACC2 - Table "public.atacc2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "public.atacc2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Inherits: atacc1 DROP TABLE ATACC1, ATACC2; @@ -314,10 +314,10 @@ CREATE TABLE ATACC1 (a int); CREATE TABLE ATACC2 () INHERITS (ATACC1); ALTER TABLE ATACC1 ADD NOT NULL a NO INHERIT; \d+ ATACC2 - Table "public.atacc2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "public.atacc2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Inherits: atacc1 DROP TABLE ATACC1, ATACC2; @@ -790,10 +790,10 @@ DROP TABLE deferred_excl; -- verify constraints created for NOT NULL clauses CREATE TABLE notnull_tbl1 (a INTEGER NOT NULL NOT NULL); \d+ notnull_tbl1 - Table "public.notnull_tbl1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | + Table "public.notnull_tbl1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "notnull_tbl1_a_not_null" NOT NULL "a" @@ -806,10 +806,10 @@ select conname, contype, conkey from pg_constraint where conrelid = 'notnull_tbl -- no-op ALTER TABLE notnull_tbl1 ADD CONSTRAINT nn NOT NULL a; \d+ notnull_tbl1 - Table "public.notnull_tbl1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | + Table "public.notnull_tbl1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "notnull_tbl1_a_not_null" NOT NULL "a" @@ -908,22 +908,22 @@ NOTICE: merging multiple inherited definitions of column "a" NOTICE: merging multiple inherited definitions of column "b" ALTER TABLE cnn_parent ADD PRIMARY KEY (b); \d+ cnn_grandchild - Table "public.cnn_grandchild" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | not null | | plain | | + Table "public.cnn_grandchild" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "cnn_grandchild_b_not_null" NOT NULL "b" (local, inherited) Inherits: cnn_child Child tables: cnn_grandchild2 \d+ cnn_grandchild2 - Table "public.cnn_grandchild2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | not null | | plain | | + Table "public.cnn_grandchild2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "cnn_grandchild_b_not_null" NOT NULL "b" (inherited) Inherits: cnn_grandchild, @@ -945,22 +945,22 @@ NOTICE: merging multiple inherited definitions of column "b" ALTER TABLE cnn_parent ADD PRIMARY KEY (b); ERROR: multiple primary keys for table "cnn_parent" are not allowed \d+ cnn_grandchild - Table "public.cnn_grandchild" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | not null | | plain | | + Table "public.cnn_grandchild" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "cnn_grandchild_b_not_null" NOT NULL "b" (local, inherited) Inherits: cnn_child Child tables: cnn_grandchild2 \d+ cnn_grandchild2 - Table "public.cnn_grandchild2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | not null | | plain | | + Table "public.cnn_grandchild2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "cnn_grandchild_b_not_null" NOT NULL "b" (inherited) Inherits: cnn_grandchild, @@ -982,22 +982,22 @@ NOTICE: merging multiple inherited definitions of column "b" CREATE UNIQUE INDEX b_uq ON cnn_parent (b); ALTER TABLE cnn_parent ADD PRIMARY KEY USING INDEX b_uq; \d+ cnn_grandchild - Table "public.cnn_grandchild" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | not null | | plain | | + Table "public.cnn_grandchild" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "cnn_grandchild_b_not_null" NOT NULL "b" (local, inherited) Inherits: cnn_child Child tables: cnn_grandchild2 \d+ cnn_grandchild2 - Table "public.cnn_grandchild2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | not null | | plain | | + Table "public.cnn_grandchild2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "cnn_grandchild_b_not_null" NOT NULL "b" (inherited) Inherits: cnn_grandchild, diff --git a/src/oracle_test/regress/expected/copy2.out b/src/oracle_test/regress/expected/copy2.out index 3ef1768e9d5..71107fa84f1 100644 --- a/src/oracle_test/regress/expected/copy2.out +++ b/src/oracle_test/regress/expected/copy2.out @@ -593,10 +593,10 @@ end $$ language plpgsql immutable; / alter table check_con_tbl add check (check_con_function(check_con_tbl.*)); \d+ check_con_tbl - Table "public.check_con_tbl" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | + Table "public.check_con_tbl" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | Check constraints: "check_con_tbl_check" CHECK (check_con_function(check_con_tbl.*)) diff --git a/src/oracle_test/regress/expected/create_table.out b/src/oracle_test/regress/expected/create_table.out index 30e6c643609..4c4eef745b5 100644 --- a/src/oracle_test/regress/expected/create_table.out +++ b/src/oracle_test/regress/expected/create_table.out @@ -289,11 +289,11 @@ Partition key: RANGE (a oid_ops, plusone(b), c, d COLLATE "C") Number of partitions: 0 \d+ partitioned2 - Partitioned table "public.partitioned2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | text | | | | extended | | + Partitioned table "public.partitioned2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | text | | | | | extended | | Partition key: RANGE (((a + 1)), substr(b, 1, 5)) Number of partitions: 0 @@ -302,11 +302,11 @@ ERROR: no partition of relation "partitioned2" found for row DETAIL: Partition key of the failing row contains ((a + 1), substr(b, 1, 5)) = (2, hello). CREATE TABLE part2_1 PARTITION OF partitioned2 FOR VALUES FROM (-1, 'aaaaa') TO (100, 'ccccc'); \d+ part2_1 - Table "public.part2_1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | text | | | | extended | | + Table "public.part2_1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | text | | | | | extended | | Partition of: partitioned2 FOR VALUES FROM ('-1', 'aaaaa') TO (100, 'ccccc') Partition constraint: (((a + 1) IS NOT NULL) AND (substr(b, 1, 5) IS NOT NULL) AND (((a + 1) > '-1'::pg_catalog.int4) OR (((a + 1) = '-1'::pg_catalog.int4) AND (substr(b, 1, 5) >= 'aaaaa'::text))) AND (((a + 1) < 100) OR (((a + 1) = 100) AND (substr(b, 1, 5) < 'ccccc'::text)))) @@ -343,11 +343,11 @@ select * from partitioned where partitioned = '(1,2)'::partitioned; (2 rows) \d+ partitioned1 - Table "public.partitioned1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | + Table "public.partitioned1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | Partition of: partitioned FOR VALUES IN ('(1,2)') Partition constraint: (((partitioned1.*)::partitioned IS DISTINCT FROM NULL) AND ((partitioned1.*)::partitioned = '(1,2)'::partitioned)) @@ -400,10 +400,10 @@ CREATE TABLE part_p2 PARTITION OF list_parted FOR VALUES IN (2); CREATE TABLE part_p3 PARTITION OF list_parted FOR VALUES IN ((2+1)); CREATE TABLE part_null PARTITION OF list_parted FOR VALUES IN (null); \d+ list_parted - Partitioned table "public.list_parted" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Partitioned table "public.list_parted" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Partition key: LIST (a) Partitions: part_null FOR VALUES IN (NULL), part_p1 FOR VALUES IN (1), @@ -851,11 +851,11 @@ create table test_part_coll_cast2 partition of test_part_coll_posix for values f drop table test_part_coll_posix; -- Partition bound in describe output \d+ part_b - Table "public.part_b" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | not null | 1 | plain | | + Table "public.part_b" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | not null | 1 | | plain | | Partition of: parted FOR VALUES IN ('b') Partition constraint: ((a IS NOT NULL) AND (a = 'b'::text)) Not-null constraints: @@ -863,11 +863,11 @@ Not-null constraints: -- Both partition bound and partition key in describe output \d+ part_c - Partitioned table "public.part_c" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | not null | 0 | plain | | + Partitioned table "public.part_c" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | not null | 0 | | plain | | Partition of: parted FOR VALUES IN ('c') Partition constraint: ((a IS NOT NULL) AND (a = 'c'::text)) Partition key: RANGE (b) @@ -877,11 +877,11 @@ Partitions: part_c_1_10 FOR VALUES FROM (1) TO (10) -- a level-2 partition's constraint will include the parent's expressions \d+ part_c_1_10 - Table "public.part_c_1_10" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | not null | 0 | plain | | + Table "public.part_c_1_10" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | not null | 0 | | plain | | Partition of: part_c FOR VALUES FROM (1) TO (10) Partition constraint: ((a IS NOT NULL) AND (a = 'c'::text) AND (b IS NOT NULL) AND (b >= 1) AND (b < 10)) Not-null constraints: @@ -912,46 +912,46 @@ Number of partitions: 4 (Use \d+ to list them.) CREATE TABLE range_parted4 (a int, b int, c int) PARTITION BY RANGE (abs(a), abs(b), c); CREATE TABLE unbounded_range_part PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE); \d+ unbounded_range_part - Table "public.unbounded_range_part" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | - c | pg_catalog.int4 | | | | plain | | + Table "public.unbounded_range_part" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | + c | pg_catalog.int4 | | | | | plain | | Partition of: range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE) Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL)) DROP TABLE unbounded_range_part; CREATE TABLE range_parted4_1 PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE); \d+ range_parted4_1 - Table "public.range_parted4_1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | - c | pg_catalog.int4 | | | | plain | | + Table "public.range_parted4_1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | + c | pg_catalog.int4 | | | | | plain | | Partition of: range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE) Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND (abs(a) <= 1)) CREATE TABLE range_parted4_2 PARTITION OF range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE); \d+ range_parted4_2 - Table "public.range_parted4_2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | - c | pg_catalog.int4 | | | | plain | | + Table "public.range_parted4_2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | + c | pg_catalog.int4 | | | | | plain | | Partition of: range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE) Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND ((abs(a) > 3) OR ((abs(a) = 3) AND (abs(b) > 4)) OR ((abs(a) = 3) AND (abs(b) = 4) AND (c >= 5))) AND ((abs(a) < 6) OR ((abs(a) = 6) AND (abs(b) <= 7)))) CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE); \d+ range_parted4_3 - Table "public.range_parted4_3" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | - c | pg_catalog.int4 | | | | plain | | + Table "public.range_parted4_3" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | + c | pg_catalog.int4 | | | | | plain | | Partition of: range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE) Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND ((abs(a) > 6) OR ((abs(a) = 6) AND (abs(b) >= 8))) AND (abs(a) <= 9)) @@ -984,11 +984,11 @@ SELECT obj_description('parted_col_comment'::regclass); (1 row) \d+ parted_col_comment - Partitioned table "public.parted_col_comment" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+--------------- - a | pg_catalog.int4 | | | | plain | | Partition key - b | text | | | | extended | | + Partitioned table "public.parted_col_comment" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+--------------- + a | pg_catalog.int4 | | | | | plain | | Partition key + b | text | | | | | extended | | Partition key: LIST (a) Number of partitions: 0 @@ -1001,10 +1001,10 @@ HINT: Specify storage parameters for its leaf partitions instead. CREATE TABLE arrlp (a int[]) PARTITION BY LIST (a); CREATE TABLE arrlp12 PARTITION OF arrlp FOR VALUES IN ('{1}', '{2}'); \d+ arrlp12 - Table "public.arrlp12" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-------------------+-----------+----------+---------+----------+--------------+------------- - a | pg_catalog.int4[] | | | | extended | | + Table "public.arrlp12" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-------------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int4[] | | | | | extended | | Partition of: arrlp FOR VALUES IN ('{1}', '{2}') Partition constraint: ((a IS NOT NULL) AND ((a = '{1}'::pg_catalog.int4[]) OR (a = '{2}'::pg_catalog.int4[]))) @@ -1014,10 +1014,10 @@ create table boolspart (a bool) partition by list (a); create table boolspart_t partition of boolspart for values in (true); create table boolspart_f partition of boolspart for values in (false); \d+ boolspart - Partitioned table "public.boolspart" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.bool | | | | plain | | + Partitioned table "public.boolspart" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.bool | | | | | plain | | Partition key: LIST (a) Partitions: boolspart_f FOR VALUES IN (false), boolspart_t FOR VALUES IN (true) diff --git a/src/oracle_test/regress/expected/create_table_like.out b/src/oracle_test/regress/expected/create_table_like.out index c7b3883edb5..1e3fb24336e 100644 --- a/src/oracle_test/regress/expected/create_table_like.out +++ b/src/oracle_test/regress/expected/create_table_like.out @@ -280,23 +280,23 @@ CREATE TABLE ctlt4 (a text, c text); ALTER TABLE ctlt4 ALTER COLUMN c SET STORAGE EXTERNAL; CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING STORAGE); \d+ ctlt12_storage - Table "public.ctlt12_storage" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------+-----------+----------+---------+----------+--------------+------------- - a | text | | not null | | main | | - b | text | | | | extended | | - c | text | | | | external | | + Table "public.ctlt12_storage" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | not null | | | main | | + b | text | | | | | extended | | + c | text | | | | | external | | Not-null constraints: "ctlt12_storage_a_not_null" NOT NULL "a" CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS); \d+ ctlt12_comments - Table "public.ctlt12_comments" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------+-----------+----------+---------+----------+--------------+------------- - a | text | | not null | | extended | | A - b | text | | | | extended | | B - c | text | | | | extended | | C + Table "public.ctlt12_comments" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | not null | | | extended | | A + b | text | | | | | extended | | B + c | text | | | | | extended | | C Not-null constraints: "ctlt12_comments_a_not_null" NOT NULL "a" @@ -305,11 +305,11 @@ NOTICE: merging column "a" with inherited definition NOTICE: merging column "b" with inherited definition NOTICE: merging constraint "ctlt1_a_check" with inherited definition \d+ ctlt1_inh - Table "public.ctlt1_inh" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------+-----------+----------+---------+----------+--------------+------------- - a | text | | not null | | main | | A - b | text | | | | extended | | B + Table "public.ctlt1_inh" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | not null | | | main | | A + b | text | | | | | extended | | B Check constraints: "ctlt1_a_check" CHECK (length(a) > 2) Not-null constraints: @@ -325,12 +325,12 @@ SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_con CREATE TABLE ctlt13_inh () INHERITS (ctlt1, ctlt3); NOTICE: merging multiple inherited definitions of column "a" \d+ ctlt13_inh - Table "public.ctlt13_inh" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------+-----------+----------+---------+----------+--------------+------------- - a | text | | not null | | main | | - b | text | | | | extended | | - c | text | | | | external | | + Table "public.ctlt13_inh" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | not null | | | main | | + b | text | | | | | extended | | + c | text | | | | | external | | Check constraints: "ctlt1_a_check" CHECK (length(a) > 2) "ctlt3_a_check" CHECK (length(a) < 5) @@ -343,12 +343,12 @@ Inherits: ctlt1, CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING INDEXES INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1); NOTICE: merging column "a" with inherited definition \d+ ctlt13_like - Table "public.ctlt13_like" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------+-----------+----------+---------+----------+--------------+------------- - a | text | | not null | | main | | A3 - b | text | | | | extended | | - c | text | | | | external | | C + Table "public.ctlt13_like" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | not null | | | main | | A3 + b | text | | | | | extended | | + c | text | | | | | external | | C Indexes: "ctlt13_like_expr_idx" btree ((a || c)) Check constraints: @@ -367,11 +367,11 @@ SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_con CREATE TABLE ctlt_all (LIKE ctlt1 INCLUDING ALL); \d+ ctlt_all - Table "public.ctlt_all" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------+-----------+----------+---------+----------+--------------+------------- - a | text | | not null | | main | | A - b | text | | | | extended | | B + Table "public.ctlt_all" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | not null | | | main | | A + b | text | | | | | extended | | B Indexes: "ctlt_all_pkey" PRIMARY KEY, btree (a) "ctlt_all_b_idx" btree (b) @@ -407,11 +407,11 @@ DETAIL: MAIN versus EXTENDED -- Check that LIKE isn't confused by a system catalog of the same name CREATE TABLE pg_attrdef (LIKE ctlt1 INCLUDING ALL); \d+ public.pg_attrdef - Table "public.pg_attrdef" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------+-----------+----------+---------+----------+--------------+------------- - a | text | | not null | | main | | A - b | text | | | | extended | | B + Table "public.pg_attrdef" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | not null | | | main | | A + b | text | | | | | extended | | B Indexes: "pg_attrdef_pkey" PRIMARY KEY, btree (a) "pg_attrdef_b_idx" btree (b) @@ -429,11 +429,11 @@ CREATE SCHEMA ctl_schema; SET LOCAL search_path = ctl_schema, public; CREATE TABLE ctlt1 (LIKE ctlt1 INCLUDING ALL); \d+ ctlt1 - Table "ctl_schema.ctlt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------+-----------+----------+---------+----------+--------------+------------- - a | text | | not null | | main | | A - b | text | | | | extended | | B + Table "ctl_schema.ctlt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | not null | | | main | | A + b | text | | | | | extended | | B Indexes: "ctlt1_pkey" PRIMARY KEY, btree (a) "ctlt1_b_idx" btree (b) diff --git a/src/oracle_test/regress/expected/domain.out b/src/oracle_test/regress/expected/domain.out index 6c8f14e81aa..8aedb7118b6 100644 --- a/src/oracle_test/regress/expected/domain.out +++ b/src/oracle_test/regress/expected/domain.out @@ -316,10 +316,10 @@ explain (verbose, costs off) create rule silly as on delete to dcomptable do instead update dcomptable set d1.r = (d1).r - 1, d1.i = (d1).i + 1 where (d1).i > 0; \d+ dcomptable - Table "public.dcomptable" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------+-----------+----------+---------+----------+--------------+------------- - d1 | dcomptype | | | | extended | | + Table "public.dcomptable" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------+-----------+----------+---------+-----------+----------+--------------+------------- + d1 | dcomptype | | | | | extended | | Indexes: "dcomptable_d1_key" UNIQUE CONSTRAINT, btree (d1) Rules: @@ -475,10 +475,10 @@ create rule silly as on delete to dcomptable do instead update dcomptable set d1[1].r = d1[1].r - 1, d1[1].i = d1[1].i + 1 where d1[1].i > 0; \d+ dcomptable - Table "public.dcomptable" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+------------+-----------+----------+---------+----------+--------------+------------- - d1 | dcomptypea | | | | extended | | + Table "public.dcomptable" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+------------+-----------+----------+---------+-----------+----------+--------------+------------- + d1 | dcomptypea | | | | | extended | | Indexes: "dcomptable_d1_key" UNIQUE CONSTRAINT, btree (d1) Rules: diff --git a/src/oracle_test/regress/expected/foreign_data.out b/src/oracle_test/regress/expected/foreign_data.out index 61e6cdf9fab..49ddcd8a039 100644 --- a/src/oracle_test/regress/expected/foreign_data.out +++ b/src/oracle_test/regress/expected/foreign_data.out @@ -1407,12 +1407,12 @@ CREATE TABLE fd_pt1 ( CREATE FOREIGN TABLE ft2 () INHERITS (fd_pt1) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Not-null constraints: "fd_pt1_c1_not_null" NOT NULL "c1" Child tables: ft2, FOREIGN @@ -1432,12 +1432,12 @@ Inherits: fd_pt1 DROP FOREIGN TABLE ft2; \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Not-null constraints: "fd_pt1_c1_not_null" NOT NULL "c1" @@ -1460,12 +1460,12 @@ FDW options: (delimiter ',', quote '"', "be quoted" 'value') ALTER FOREIGN TABLE ft2 INHERIT fd_pt1; \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Not-null constraints: "fd_pt1_c1_not_null" NOT NULL "c1" Child tables: ft2, FOREIGN @@ -1509,12 +1509,12 @@ Child tables: ct3, ft3, FOREIGN \d+ ct3 - Table "public.ct3" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.ct3" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (inherited) Inherits: ft2 @@ -1538,17 +1538,17 @@ ALTER TABLE fd_pt1 ADD COLUMN c6 integer; ALTER TABLE fd_pt1 ADD COLUMN c7 integer NOT NULL; ALTER TABLE fd_pt1 ADD COLUMN c8 integer; \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | - c4 | pg_catalog.int4 | | | | plain | | - c5 | pg_catalog.int4 | | | 0 | plain | | - c6 | pg_catalog.int4 | | | | plain | | - c7 | pg_catalog.int4 | | not null | | plain | | - c8 | pg_catalog.int4 | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | + c4 | pg_catalog.int4 | | | | | plain | | + c5 | pg_catalog.int4 | | | 0 | | plain | | + c6 | pg_catalog.int4 | | | | | plain | | + c7 | pg_catalog.int4 | | not null | | | plain | | + c8 | pg_catalog.int4 | | | | | plain | | Not-null constraints: "fd_pt1_c1_not_null" NOT NULL "c1" "fd_pt1_c7_not_null" NOT NULL "c7" @@ -1576,17 +1576,17 @@ Child tables: ct3, ft3, FOREIGN \d+ ct3 - Table "public.ct3" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | - c4 | pg_catalog.int4 | | | | plain | | - c5 | pg_catalog.int4 | | | 0 | plain | | - c6 | pg_catalog.int4 | | | | plain | | - c7 | pg_catalog.int4 | | not null | | plain | | - c8 | pg_catalog.int4 | | | | plain | | + Table "public.ct3" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | + c4 | pg_catalog.int4 | | | | | plain | | + c5 | pg_catalog.int4 | | | 0 | | plain | | + c6 | pg_catalog.int4 | | | | | plain | | + c7 | pg_catalog.int4 | | not null | | | plain | | + c8 | pg_catalog.int4 | | | | | plain | | Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (inherited) "fd_pt1_c7_not_null" NOT NULL "c7" (inherited) @@ -1624,17 +1624,17 @@ ALTER TABLE fd_pt1 ALTER COLUMN c1 SET (n_distinct = 100); ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STATISTICS -1; ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STORAGE EXTERNAL; \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | 10000 | - c2 | text | | | | extended | | - c3 | date | | | | plain | | - c4 | pg_catalog.int4 | | | 0 | plain | | - c5 | pg_catalog.int4 | | | | plain | | - c6 | pg_catalog.int4 | | not null | | plain | | - c7 | pg_catalog.int4 | | | | plain | | - c8 | text | | | | external | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | 10000 | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | + c4 | pg_catalog.int4 | | | 0 | | plain | | + c5 | pg_catalog.int4 | | | | | plain | | + c6 | pg_catalog.int4 | | not null | | | plain | | + c7 | pg_catalog.int4 | | | | | plain | | + c8 | text | | | | | external | | Not-null constraints: "fd_pt1_c1_not_null" NOT NULL "c1" "fd_pt1_c6_not_null" NOT NULL "c6" @@ -1668,12 +1668,12 @@ ALTER TABLE fd_pt1 DROP COLUMN c6; ALTER TABLE fd_pt1 DROP COLUMN c7; ALTER TABLE fd_pt1 DROP COLUMN c8; \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | 10000 | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | 10000 | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Not-null constraints: "fd_pt1_c1_not_null" NOT NULL "c1" Child tables: ft2, FOREIGN @@ -1710,12 +1710,12 @@ SELECT relname, conname, contype, conislocal, coninhcount, connoinherit -- child does not inherit NO INHERIT constraints \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | 10000 | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | 10000 | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Check constraints: "fd_pt1chk1" CHECK (c1 > 0) NO INHERIT "fd_pt1chk2" CHECK (c2 <> ''::text) @@ -1761,12 +1761,12 @@ ALTER FOREIGN TABLE ft2 ADD CONSTRAINT fd_pt1chk2 CHECK (c2 <> ''); ALTER FOREIGN TABLE ft2 INHERIT fd_pt1; -- child does not inherit NO INHERIT constraints \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | 10000 | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | 10000 | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Check constraints: "fd_pt1chk1" CHECK (c1 > 0) NO INHERIT "fd_pt1chk2" CHECK (c2 <> ''::text) @@ -1796,12 +1796,12 @@ ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk2 CASCADE; INSERT INTO fd_pt1 VALUES (1, 'fd_pt1'::text, '1994-01-01'::date); ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk3 CHECK (c2 <> '') NOT VALID; \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | 10000 | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | 10000 | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Check constraints: "fd_pt1chk3" CHECK (c2 <> ''::text) NOT VALID Not-null constraints: @@ -1827,12 +1827,12 @@ Inherits: fd_pt1 -- VALIDATE CONSTRAINT need do nothing on foreign tables ALTER TABLE fd_pt1 VALIDATE CONSTRAINT fd_pt1chk3; \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | 10000 | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | 10000 | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Check constraints: "fd_pt1chk3" CHECK (c2 <> ''::text) Not-null constraints: @@ -1862,12 +1862,12 @@ ALTER TABLE fd_pt1 RENAME COLUMN c3 TO f3; -- changes name of a constraint recursively ALTER TABLE fd_pt1 RENAME CONSTRAINT fd_pt1chk3 TO f2_check; \d+ fd_pt1 - Table "public.fd_pt1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | 10000 | - f2 | text | | | | extended | | - f3 | date | | | | plain | | + Table "public.fd_pt1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | 10000 | + f2 | text | | | | | extended | | + f3 | date | | | | | plain | | Check constraints: "f2_check" CHECK (f2 <> ''::text) Not-null constraints: @@ -1925,12 +1925,12 @@ CREATE TABLE fd_pt2 ( CREATE FOREIGN TABLE fd_pt2_1 PARTITION OF fd_pt2 FOR VALUES IN (1) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); \d+ fd_pt2 - Partitioned table "public.fd_pt2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Partitioned table "public.fd_pt2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Partition key: LIST (c1) Not-null constraints: "fd_pt2_c1_not_null" NOT NULL "c1" @@ -1976,12 +1976,12 @@ ERROR: table "fd_pt2_1" contains column "c4" not found in parent "fd_pt2" DETAIL: The new partition may contain only the columns present in parent. DROP FOREIGN TABLE fd_pt2_1; \d+ fd_pt2 - Partitioned table "public.fd_pt2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Partitioned table "public.fd_pt2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Partition key: LIST (c1) Not-null constraints: "fd_pt2_c1_not_null" NOT NULL "c1" @@ -2007,12 +2007,12 @@ FDW options: (delimiter ',', quote '"', "be quoted" 'value') -- no attach partition validation occurs for foreign tables ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1); \d+ fd_pt2 - Partitioned table "public.fd_pt2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Partitioned table "public.fd_pt2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Partition key: LIST (c1) Not-null constraints: "fd_pt2_c1_not_null" NOT NULL "c1" @@ -2039,12 +2039,12 @@ ERROR: cannot add column to a partition ALTER TABLE fd_pt2_1 ALTER c3 SET NOT NULL; ALTER TABLE fd_pt2_1 ADD CONSTRAINT p21chk CHECK (c2 <> ''); \d+ fd_pt2 - Partitioned table "public.fd_pt2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | | | extended | | - c3 | date | | | | plain | | + Partitioned table "public.fd_pt2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | | | | extended | | + c3 | date | | | | | plain | | Partition key: LIST (c1) Not-null constraints: "fd_pt2_c1_not_null" NOT NULL "c1" @@ -2074,12 +2074,12 @@ ERROR: column "c1" is marked NOT NULL in parent table ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1; ALTER TABLE fd_pt2 ALTER c2 SET NOT NULL; \d+ fd_pt2 - Partitioned table "public.fd_pt2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | not null | | extended | | - c3 | date | | | | plain | | + Partitioned table "public.fd_pt2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | not null | | | extended | | + c3 | date | | | | | plain | | Partition key: LIST (c1) Not-null constraints: "fd_pt2_c1_not_null" NOT NULL "c1" @@ -2108,12 +2108,12 @@ ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1); ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1; ALTER TABLE fd_pt2 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0); \d+ fd_pt2 - Partitioned table "public.fd_pt2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - c1 | pg_catalog.int4 | | not null | | plain | | - c2 | text | | not null | | extended | | - c3 | date | | | | plain | | + Partitioned table "public.fd_pt2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + c1 | pg_catalog.int4 | | not null | | | plain | | + c2 | text | | not null | | | extended | | + c3 | date | | | | | plain | | Partition key: LIST (c1) Check constraints: "fd_pt2chk1" CHECK (c1 > 0) diff --git a/src/oracle_test/regress/expected/generated.out b/src/oracle_test/regress/expected/generated.out index d83851a1612..cdabe89999b 100644 --- a/src/oracle_test/regress/expected/generated.out +++ b/src/oracle_test/regress/expected/generated.out @@ -309,12 +309,12 @@ ERROR: column "b" inherits from generated column but specifies default CREATE TABLE gtestx (x int, b int GENERATED ALWAYS AS (a * 22) STORED) INHERITS (gtest1); -- ok, overrides parent NOTICE: merging column "b" with inherited definition \d+ gtestx - Table "public.gtestx" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+-------------------------------------+---------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | - b | pg_catalog.int4 | | | generated always as (a * 22) stored | plain | | - x | pg_catalog.int4 | | | | plain | | + Table "public.gtestx" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+-------------------------------------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | pg_catalog.int4 | | | generated always as (a * 22) stored | | plain | | + x | pg_catalog.int4 | | | | | plain | | Not-null constraints: "gtestx_a_not_null" NOT NULL "a" (inherited) Inherits: gtest1 diff --git a/src/oracle_test/regress/expected/inherit.out b/src/oracle_test/regress/expected/inherit.out index 6d8be608967..ba4d27734c3 100644 --- a/src/oracle_test/regress/expected/inherit.out +++ b/src/oracle_test/regress/expected/inherit.out @@ -1086,13 +1086,13 @@ ALTER TABLE inhts RENAME aa TO aaa; -- to be failed ERROR: cannot rename inherited column "aa" ALTER TABLE inhts RENAME d TO dd; \d+ inhts - Table "public.inhts" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - aa | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | - c | pg_catalog.int4 | | | | plain | | - dd | pg_catalog.int4 | | | | plain | | + Table "public.inhts" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + aa | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | + c | pg_catalog.int4 | | | | | plain | | + dd | pg_catalog.int4 | | | | | plain | | Inherits: inht1, inhs1 @@ -1106,10 +1106,10 @@ ALTER TABLE inhta ADD COLUMN i int; NOTICE: merging definition of column "i" for child "inhtd" NOTICE: merging definition of column "i" for child "inhtd" \d+ inhta - Table "public.inhta" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - i | pg_catalog.int4 | | | | plain | | + Table "public.inhta" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + i | pg_catalog.int4 | | | | | plain | | Child tables: inhtb, inhtd @@ -1122,14 +1122,14 @@ NOTICE: merging multiple inherited definitions of column "aa" NOTICE: merging multiple inherited definitions of column "b" ALTER TABLE inht1 RENAME aa TO aaa; \d+ inht4 - Table "public.inht4" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - aaa | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | - x | pg_catalog.int4 | | | | plain | | - y | pg_catalog.int4 | | | | plain | | - z | pg_catalog.int4 | | | | plain | | + Table "public.inht4" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + aaa | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | + x | pg_catalog.int4 | | | | | plain | | + y | pg_catalog.int4 | | | | | plain | | + z | pg_catalog.int4 | | | | | plain | | Inherits: inht2, inht3 @@ -1139,14 +1139,14 @@ ALTER TABLE inht1 RENAME aaa TO aaaa; ALTER TABLE inht1 RENAME b TO bb; -- to be failed ERROR: cannot rename inherited column "b" \d+ inhts - Table "public.inhts" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - aaaa | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | - x | pg_catalog.int4 | | | | plain | | - c | pg_catalog.int4 | | | | plain | | - d | pg_catalog.int4 | | | | plain | | + Table "public.inhts" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + aaaa | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | + x | pg_catalog.int4 | | | | | plain | | + c | pg_catalog.int4 | | | | | plain | | + d | pg_catalog.int4 | | | | | plain | | Inherits: inht2, inhs1 @@ -1186,33 +1186,33 @@ drop cascades to table inht4 CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2)); CREATE TABLE test_constraints_inh () INHERITS (test_constraints); \d+ test_constraints - Table "public.test_constraints" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - id | pg_catalog.int4 | | | | plain | | - val1 | varchar2(4000) | | | | extended | | - val2 | pg_catalog.int4 | | | | plain | | + Table "public.test_constraints" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | | | | plain | | + val1 | varchar2(4000) | | | | | extended | | + val2 | pg_catalog.int4 | | | | | plain | | Indexes: "test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2) Child tables: test_constraints_inh ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key; \d+ test_constraints - Table "public.test_constraints" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - id | pg_catalog.int4 | | | | plain | | - val1 | varchar2(4000) | | | | extended | | - val2 | pg_catalog.int4 | | | | plain | | + Table "public.test_constraints" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | | | | plain | | + val1 | varchar2(4000) | | | | | extended | | + val2 | pg_catalog.int4 | | | | | plain | | Child tables: test_constraints_inh \d+ test_constraints_inh - Table "public.test_constraints_inh" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - id | pg_catalog.int4 | | | | plain | | - val1 | varchar2(4000) | | | | extended | | - val2 | pg_catalog.int4 | | | | plain | | + Table "public.test_constraints_inh" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | | | | plain | | + val1 | varchar2(4000) | | | | | extended | | + val2 | pg_catalog.int4 | | | | | plain | | Inherits: test_constraints DROP TABLE test_constraints_inh; @@ -1223,27 +1223,27 @@ CREATE TABLE test_ex_constraints ( ); CREATE TABLE test_ex_constraints_inh () INHERITS (test_ex_constraints); \d+ test_ex_constraints - Table "public.test_ex_constraints" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+--------+-----------+----------+---------+---------+--------------+------------- - c | circle | | | | plain | | + Table "public.test_ex_constraints" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+--------+-----------+----------+---------+-----------+---------+--------------+------------- + c | circle | | | | | plain | | Indexes: "test_ex_constraints_c_excl" EXCLUDE USING gist (c WITH &&) Child tables: test_ex_constraints_inh ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl; \d+ test_ex_constraints - Table "public.test_ex_constraints" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+--------+-----------+----------+---------+---------+--------------+------------- - c | circle | | | | plain | | + Table "public.test_ex_constraints" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+--------+-----------+----------+---------+-----------+---------+--------------+------------- + c | circle | | | | | plain | | Child tables: test_ex_constraints_inh \d+ test_ex_constraints_inh - Table "public.test_ex_constraints_inh" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+--------+-----------+----------+---------+---------+--------------+------------- - c | circle | | | | plain | | + Table "public.test_ex_constraints_inh" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+--------+-----------+----------+---------+-----------+---------+--------------+------------- + c | circle | | | | | plain | | Inherits: test_ex_constraints DROP TABLE test_ex_constraints_inh; @@ -1253,37 +1253,37 @@ CREATE TABLE test_primary_constraints(id int PRIMARY KEY); CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id)); CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints); \d+ test_primary_constraints - Table "public.test_primary_constraints" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - id | pg_catalog.int4 | | not null | | plain | | + Table "public.test_primary_constraints" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + id | pg_catalog.int4 | | not null | | | plain | | Indexes: "test_primary_constraints_pkey" PRIMARY KEY, btree (id) Referenced by: TABLE "test_foreign_constraints" CONSTRAINT "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id) \d+ test_foreign_constraints - Table "public.test_foreign_constraints" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - id1 | pg_catalog.int4 | | | | plain | | + Table "public.test_foreign_constraints" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + id1 | pg_catalog.int4 | | | | | plain | | Foreign-key constraints: "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id) Child tables: test_foreign_constraints_inh ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey; \d+ test_foreign_constraints - Table "public.test_foreign_constraints" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - id1 | pg_catalog.int4 | | | | plain | | + Table "public.test_foreign_constraints" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + id1 | pg_catalog.int4 | | | | | plain | | Child tables: test_foreign_constraints_inh \d+ test_foreign_constraints_inh - Table "public.test_foreign_constraints_inh" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - id1 | pg_catalog.int4 | | | | plain | | + Table "public.test_foreign_constraints_inh" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + id1 | pg_catalog.int4 | | | | | plain | | Inherits: test_foreign_constraints DROP TABLE test_foreign_constraints_inh; @@ -2061,27 +2061,27 @@ Inherits: pp1, -- named NOT NULL constraint alter table cc1 add column a2 int constraint nn not null; \d+ cc1 - Table "public.cc1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | - f2 | text | | | | extended | | - f3 | pg_catalog.int4 | | | | plain | | - a2 | pg_catalog.int4 | | not null | | plain | | + Table "public.cc1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | + f2 | text | | | | | extended | | + f3 | pg_catalog.int4 | | | | | plain | | + a2 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "nn" NOT NULL "a2" Inherits: pp1 Child tables: cc2 \d+ cc2 - Table "public.cc2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-------------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | - f2 | text | | | | extended | | - f3 | pg_catalog.int4 | | | | plain | | - f4 | pg_catalog.float8 | | | | plain | | - a2 | pg_catalog.int4 | | not null | | plain | | + Table "public.cc2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-------------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | + f2 | text | | | | | extended | | + f3 | pg_catalog.int4 | | | | | plain | | + f4 | pg_catalog.float8 | | | | | plain | | + a2 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "nn" NOT NULL "a2" (inherited) Inherits: pp1, @@ -2089,23 +2089,23 @@ Inherits: pp1, alter table pp1 alter column f1 set not null; \d+ pp1 - Table "public.pp1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | + Table "public.pp1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" Child tables: cc1, cc2 \d+ cc1 - Table "public.cc1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | - f2 | text | | | | extended | | - f3 | pg_catalog.int4 | | | | plain | | - a2 | pg_catalog.int4 | | not null | | plain | | + Table "public.cc1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | + f2 | text | | | | | extended | | + f3 | pg_catalog.int4 | | | | | plain | | + a2 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) "nn" NOT NULL "a2" @@ -2113,14 +2113,14 @@ Inherits: pp1 Child tables: cc2 \d+ cc2 - Table "public.cc2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-------------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | - f2 | text | | | | extended | | - f3 | pg_catalog.int4 | | | | plain | | - f4 | pg_catalog.float8 | | | | plain | | - a2 | pg_catalog.int4 | | not null | | plain | | + Table "public.cc2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-------------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | + f2 | text | | | | | extended | | + f3 | pg_catalog.int4 | | | | | plain | | + f4 | pg_catalog.float8 | | | | | plain | | + a2 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) "nn" NOT NULL "a2" (inherited) @@ -2142,13 +2142,13 @@ ERROR: cannot drop inherited constraint "nn" of relation "cc2" -- remove constraint cc1, should succeed alter table cc1 alter column a2 drop not null; \d+ cc1 - Table "public.cc1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | - f2 | text | | | | extended | | - f3 | pg_catalog.int4 | | | | plain | | - a2 | pg_catalog.int4 | | | | plain | | + Table "public.cc1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | + f2 | text | | | | | extended | | + f3 | pg_catalog.int4 | | | | | plain | | + a2 | pg_catalog.int4 | | | | | plain | | Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) Inherits: pp1 @@ -2158,14 +2158,14 @@ Child tables: cc2 alter table cc2 alter column f1 drop not null; ERROR: cannot drop inherited constraint "pp1_f1_not_null" of relation "cc2" \d+ cc2 - Table "public.cc2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-------------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | - f2 | text | | | | extended | | - f3 | pg_catalog.int4 | | | | plain | | - f4 | pg_catalog.float8 | | | | plain | | - a2 | pg_catalog.int4 | | | | plain | | + Table "public.cc2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-------------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | + f2 | text | | | | | extended | | + f3 | pg_catalog.int4 | | | | | plain | | + f4 | pg_catalog.float8 | | | | | plain | | + a2 | pg_catalog.int4 | | | | | plain | | Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) Inherits: pp1, @@ -2177,10 +2177,10 @@ ERROR: cannot drop inherited constraint "pp1_f1_not_null" of relation "cc1" -- remove from pp1, should succeed alter table pp1 alter column f1 drop not null; \d+ pp1 - Table "public.pp1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | + Table "public.pp1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | Child tables: cc1, cc2 @@ -2191,11 +2191,11 @@ create table inh_parent1(a int constraint nn not null); create table inh_parent2(b int constraint nn not null); create table inh_child () inherits (inh_parent1, inh_parent2); \d+ inh_child - Table "public.inh_child" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | - b | pg_catalog.int4 | | not null | | plain | | + Table "public.inh_child" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "nn" NOT NULL "a" (inherited) "inh_child_b_not_null" NOT NULL "b" (inherited) @@ -2223,14 +2223,14 @@ select conrelid::regclass, conname, contype, conkey, (5 rows) \d+ inh_child - Table "public.inh_child" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | - b | pg_catalog.int4 | | not null | | plain | | - c | pg_catalog.int4 | | | | plain | | - d | pg_catalog.int4 | | not null | | plain | | - e | pg_catalog.int4 | | | | plain | | + Table "public.inh_child" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | pg_catalog.int4 | | not null | | | plain | | + c | pg_catalog.int4 | | | | | plain | | + d | pg_catalog.int4 | | not null | | | plain | | + e | pg_catalog.int4 | | | | | plain | | Not-null constraints: "inh_child_a_not_null" NOT NULL "a" (inherited) "inh_child_b_not_null" NOT NULL "b" (inherited) @@ -2256,22 +2256,22 @@ select conrelid::regclass, conname, contype, conkey, (1 row) \d+ inh_nn* - Table "public.inh_nn_child" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "public.inh_nn_child" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Inherits: inh_nn_parent - Table "public.inh_nn_child2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "public.inh_nn_child2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Inherits: inh_nn_parent - Table "public.inh_nn_parent" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | + Table "public.inh_nn_parent" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "inh_nn_parent_a_not_null" NOT NULL "a" NO INHERIT Child tables: inh_nn_child, @@ -2294,29 +2294,29 @@ alter table inh_child2 inherit inh_child1; -- add NOT NULL constraint recursively alter table inh_parent alter column f1 set not null; \d+ inh_parent - Table "public.inh_parent" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | + Table "public.inh_parent" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "inh_parent_f1_not_null" NOT NULL "f1" Child tables: inh_child1 \d+ inh_child1 - Table "public.inh_child1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | + Table "public.inh_child1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "inh_child1_f1_not_null" NOT NULL "f1" (local, inherited) Inherits: inh_parent Child tables: inh_child2 \d+ inh_child2 - Table "public.inh_child2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | + Table "public.inh_child2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "inh_child2_f1_not_null" NOT NULL "f1" (local, inherited) Inherits: inh_child1 @@ -2339,28 +2339,28 @@ select conrelid::regclass, conname, contype, coninhcount, conislocal create table inh_child3 () inherits (inh_child1); alter table inh_child1 no inherit inh_parent; \d+ inh_parent - Table "public.inh_parent" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | + Table "public.inh_parent" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "inh_parent_f1_not_null" NOT NULL "f1" \d+ inh_child1 - Table "public.inh_child1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | + Table "public.inh_child1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "inh_child1_f1_not_null" NOT NULL "f1" Child tables: inh_child2, inh_child3 \d+ inh_child2 - Table "public.inh_child2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | not null | | plain | | + Table "public.inh_child2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | not null | | | plain | | Not-null constraints: "inh_child2_f1_not_null" NOT NULL "f1" (local, inherited) Inherits: inh_child1 diff --git a/src/oracle_test/regress/expected/insert.out b/src/oracle_test/regress/expected/insert.out index 8acacbe8e3d..e073611b7d3 100644 --- a/src/oracle_test/regress/expected/insert.out +++ b/src/oracle_test/regress/expected/insert.out @@ -163,11 +163,11 @@ create rule irule3 as on insert to inserttest2 do also insert into inserttest (f4[1].if1, f4[1].if2[2]) select new.f1, new.f2; \d+ inserttest2 - Table "public.inserttest2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int8 | | | | plain | | - f2 | text | | | | extended | | + Table "public.inserttest2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int8 | | | | | plain | | + f2 | text | | | | | extended | | Rules: irule1 AS ON INSERT TO inserttest2 DO INSERT INTO inserttest (f3.if2[1], f3.if2[2]) @@ -447,11 +447,11 @@ from hash_parted order by part; -- test \d+ output on a table which has both partitioned and unpartitioned -- partitions \d+ list_parted - Partitioned table "public.list_parted" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Partitioned table "public.list_parted" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition key: LIST (lower(a)) Partitions: part_aa_bb FOR VALUES IN ('aa', 'bb'), part_cc_dd FOR VALUES IN ('cc', 'dd'), @@ -469,10 +469,10 @@ drop table hash_parted; create table list_parted (a int) partition by list (a); create table part_default partition of list_parted default; \d+ part_default - Table "public.part_default" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "public.part_default" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Partition of: list_parted DEFAULT No partition constraint @@ -856,11 +856,11 @@ create table mcrparted6_common_ge_10 partition of mcrparted for values from ('co create table mcrparted7_gt_common_lt_d partition of mcrparted for values from ('common', maxvalue) to ('d', minvalue); create table mcrparted8_ge_d partition of mcrparted for values from ('d', minvalue) to (maxvalue, maxvalue); \d+ mcrparted - Partitioned table "public.mcrparted" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Partitioned table "public.mcrparted" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition key: RANGE (a, b) Partitions: mcrparted1_lt_b FOR VALUES FROM (MINVALUE, MINVALUE) TO ('b', MINVALUE), mcrparted2_b FOR VALUES FROM ('b', MINVALUE) TO ('c', MINVALUE), @@ -872,74 +872,74 @@ Partitions: mcrparted1_lt_b FOR VALUES FROM (MINVALUE, MINVALUE) TO ('b', MINVAL mcrparted8_ge_d FOR VALUES FROM ('d', MINVALUE) TO (MAXVALUE, MAXVALUE) \d+ mcrparted1_lt_b - Table "public.mcrparted1_lt_b" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Table "public.mcrparted1_lt_b" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition of: mcrparted FOR VALUES FROM (MINVALUE, MINVALUE) TO ('b', MINVALUE) Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a < 'b'::text)) \d+ mcrparted2_b - Table "public.mcrparted2_b" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Table "public.mcrparted2_b" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition of: mcrparted FOR VALUES FROM ('b', MINVALUE) TO ('c', MINVALUE) Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'b'::text) AND (a < 'c'::text)) \d+ mcrparted3_c_to_common - Table "public.mcrparted3_c_to_common" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Table "public.mcrparted3_c_to_common" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition of: mcrparted FOR VALUES FROM ('c', MINVALUE) TO ('common', MINVALUE) Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'c'::text) AND (a < 'common'::text)) \d+ mcrparted4_common_lt_0 - Table "public.mcrparted4_common_lt_0" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Table "public.mcrparted4_common_lt_0" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition of: mcrparted FOR VALUES FROM ('common', MINVALUE) TO ('common', 0) Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b < 0)) \d+ mcrparted5_common_0_to_10 - Table "public.mcrparted5_common_0_to_10" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Table "public.mcrparted5_common_0_to_10" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition of: mcrparted FOR VALUES FROM ('common', 0) TO ('common', 10) Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b >= 0) AND (b < 10)) \d+ mcrparted6_common_ge_10 - Table "public.mcrparted6_common_ge_10" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Table "public.mcrparted6_common_ge_10" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition of: mcrparted FOR VALUES FROM ('common', 10) TO ('common', MAXVALUE) Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a = 'common'::text) AND (b >= 10)) \d+ mcrparted7_gt_common_lt_d - Table "public.mcrparted7_gt_common_lt_d" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Table "public.mcrparted7_gt_common_lt_d" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition of: mcrparted FOR VALUES FROM ('common', MAXVALUE) TO ('d', MINVALUE) Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a > 'common'::text) AND (a < 'd'::text)) \d+ mcrparted8_ge_d - Table "public.mcrparted8_ge_d" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int4 | | | | plain | | + Table "public.mcrparted8_ge_d" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int4 | | | | | plain | | Partition of: mcrparted FOR VALUES FROM ('d', MINVALUE) TO (MAXVALUE, MAXVALUE) Partition constraint: ((a IS NOT NULL) AND (b IS NOT NULL) AND (a >= 'd'::text)) diff --git a/src/oracle_test/regress/expected/invisible.out b/src/oracle_test/regress/expected/invisible.out new file mode 100644 index 00000000000..746bddac8a5 --- /dev/null +++ b/src/oracle_test/regress/expected/invisible.out @@ -0,0 +1,592 @@ +-- sanity check of system catalog +SELECT attrelid, attname, attisinvisible FROM pg_attribute WHERE attisinvisible; + attrelid | attname | attisinvisible +----------+---------+---------------- +(0 rows) + +CREATE TABLE htest0 (a int PRIMARY KEY, b text NOT NULL INVISIBLE); +INSERT INTO htest0 (a, b) VALUES (1, 'htest0 one'); +INSERT INTO htest0 (a, b) VALUES (2, 'htest0 two'); +-- we allow that all columns of a relation be invisible +ALTER TABLE htest0 MODIFY a INVISIBLE; +ERROR: relation "htest0" can not have all columns invisible +SELECT * FROM htest0; + a +--- + 1 + 2 +(2 rows) + +ALTER TABLE htest0 MODIFY a VISIBLE; +CREATE TABLE htest1 (a bigserial PRIMARY KEY INVISIBLE, b text); +ALTER TABLE htest1 MODIFY a INVISIBLE; +-- Insert without named column must not include the invisible column +INSERT INTO htest1 VALUES ('htest1 one'); +INSERT INTO htest1 VALUES ('htest1 two'); +-- INSERT + SELECT * should handle the invisible column +CREATE TABLE htest1_1 (a bigserial PRIMARY KEY, b text); +ALTER TABLE htest1_1 MODIFY a INVISIBLE; +INSERT INTO htest1_1 VALUES ('htest1 one'); +WITH cte AS ( + DELETE FROM htest1_1 RETURNING * +) SELECT * FROM cte; + b +------------ + htest1 one +(1 row) + +INSERT INTO htest1_1 SELECT * FROM htest0; +SELECT a, b FROM htest1_1; + a | b +---+--- + 2 | 1 + 3 | 2 +(2 rows) + +DROP TABLE htest1_1; +SELECT attrelid::regclass, attname, attisinvisible FROM pg_attribute WHERE attisinvisible; + attrelid | attname | attisinvisible +----------+---------+---------------- + htest0 | b | t + htest1 | a | t +(2 rows) + +\d+ htest1 + Table "public.htest1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+-----------------------------------+-----------+----------+--------------+------------- + a | pg_catalog.int8 | | not null | nextval('htest1_a_seq'::regclass) | invisible | plain | | + b | text | | | | | extended | | +Indexes: + "htest1_pkey" PRIMARY KEY, btree (a) +Not-null constraints: + "htest1_a_not_null" NOT NULL "a" + +-- DROP/SET invisible attribute +ALTER TABLE htest0 MODIFY b VISIBLE; +\d+ htest0 + Table "public.htest0" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | text | | not null | | | extended | | +Indexes: + "htest0_pkey" PRIMARY KEY, btree (a) +Not-null constraints: + "htest0_b_not_null" NOT NULL "b" + +ALTER TABLE htest0 MODIFY b INVISIBLE; +-- Hidden column are not expandable and must not be returned +SELECT * FROM htest0; -- return only column a + a +--- + 1 + 2 +(2 rows) + +SELECT t.* FROM htest1 t; -- return only column b + b +------------ + htest1 one + htest1 two +(2 rows) + +-- the whole-row syntax do not take care of the invisible attribute +SELECT t FROM htest1 t; -- return column a and b + t +------------------ + (1,"htest1 one") + (2,"htest1 two") +(2 rows) + +-- CTEs based on SELECT * only have visible column returned +WITH foo AS (SELECT * FROM htest1) SELECT * FROM foo; -- Only column b is returned here + b +------------ + htest1 one + htest1 two +(2 rows) + +-- Use of wildcard or whole-row in a function do not apply the invisible attribute +SELECT row_to_json(t.*) FROM htest0 t; + row_to_json +-------------------------- + {"a":1,"b":"htest0 one"} + {"a":2,"b":"htest0 two"} +(2 rows) + +SELECT row_to_json(t) FROM htest0 t; + row_to_json +-------------------------- + {"a":1,"b":"htest0 one"} + {"a":2,"b":"htest0 two"} +(2 rows) + +-- inheritance, the invisible attribute is inherited +CREATE TABLE htest1_1 () INHERITS (htest1); +SELECT * FROM htest1_1; + b +--- +(0 rows) + +\d htest1_1 + Table "public.htest1_1" + Column | Type | Collation | Nullable | Default +--------+-----------------+-----------+----------+----------------------------------- + a | pg_catalog.int8 | | not null | nextval('htest1_a_seq'::regclass) + b | text | | | +Inherits: htest1 + +INSERT INTO htest1_1 VALUES ('htest1 three'); +SELECT * FROM htest1_1; + b +-------------- + htest1 three +(1 row) + +SELECT * FROM htest1; + b +-------------- + htest1 one + htest1 two + htest1 three +(3 rows) + +-- invisible column must be explicitely named to be returned +SELECT a,b FROM htest1_1; + a | b +---+-------------- + 3 | htest1 three +(1 row) + +SELECT a,b FROM htest1; + a | b +---+-------------- + 1 | htest1 one + 2 | htest1 two + 3 | htest1 three +(3 rows) + +DROP TABLE htest1_1; +-- Default CREATE TABLE ... LIKE includes invisible columns, and they are not uinexpanded in the new table. +CREATE TABLE htest_like1 (LIKE htest1); +\d+ htest_like1 + Table "public.htest_like1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int8 | | not null | | | plain | | + b | text | | | | | extended | | +Not-null constraints: + "htest1_a_not_null" NOT NULL "a" + +-- CREATE TABLE ... LIKE includes invisible columns, and they are invisible if requested +CREATE TABLE htest_like2 (LIKE htest1 INCLUDING INVISIBLE); +\d+ htest_like2 + Table "public.htest_like2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int8 | | not null | | invisible | plain | | + b | text | | | | | extended | | +Not-null constraints: + "htest1_a_not_null" NOT NULL "a" + +CREATE TABLE htest_like3 (LIKE htest1 INCLUDING ALL); +\d+ htest_like3 + Table "public.htest_like3" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+-----------------------------------+-----------+----------+--------------+------------- + a | pg_catalog.int8 | | not null | nextval('htest1_a_seq'::regclass) | invisible | plain | | + b | text | | | | | extended | | +Indexes: + "htest_like3_pkey" PRIMARY KEY, btree (a) +Not-null constraints: + "htest1_a_not_null" NOT NULL "a" + +DROP TABLE htest_like1, htest_like2, htest_like3; +-- Insert without named column with and a not null invisible column must have a default value +INSERT INTO htest0 VALUES (3); -- error +ERROR: null value in column "b" of relation "htest0" violates not-null constraint +DETAIL: Failing row contains (3, null). +ALTER TABLE htest0 ALTER COLUMN b SET DEFAULT 'unknown'; +INSERT INTO htest0 VALUES (3); +-- Same with COPY +COPY htest0 TO stdout; +1 +2 +3 +COPY htest0 (a, b) TO stdout; +1 htest0 one +2 htest0 two +3 unknown +COPY htest0 FROM stdin; +SELECT a,b FROM htest0; + a | b +---+------------ + 1 | htest0 one + 2 | htest0 two + 3 | unknown + 4 | unknown + 5 | unknown +(5 rows) + +-- same but with drop/add the column between invisible columns (virtual columns can be made invisible) +CREATE TABLE htest2 (a serial, b int, c int GENERATED ALWAYS AS (a * 2) STORED); +ALTER TABLE htest2 MODIFY a INVISIBLE; +ALTER TABLE htest2 MODIFY c INVISIBLE; +SELECT * FROM htest2; + b +--- +(0 rows) + +INSERT INTO htest2 VALUES (2); +SELECT a,b,c FROM htest2; + a | b | c +---+---+--- + 1 | 2 | 2 +(1 row) + +ALTER TABLE htest2 DROP COLUMN b; +ALTER TABLE htest2 ADD COLUMN b int; +INSERT INTO htest2 VALUES (4); +SELECT a,b,c FROM htest2; + a | b | c +---+---+--- + 1 | | 2 + 2 | 4 | 4 +(2 rows) + +DROP TABLE htest2 CASCADE; +-- a table can NOT have all columns invisible +CREATE TABLE htest3 (a serial INVISIBLE, b int INVISIBLE); +ERROR: a table must have at least one visible column +CREATE TABLE htest3 (a serial, b int); +ALTER TABLE htest3 + ALTER COLUMN a SET INVISIBLE, + MODIFY b INVISIBLE; -- error +ERROR: relation "htest3" can not have all columns invisible +DROP TABLE htest3; +-- inheritance with an additional single invisible column is possible +CREATE TABLE htest3 (a serial INVISIBLE, b int); +SELECT * FROM htest3; + b +--- +(0 rows) + +CREATE TABLE htest3_1 (c int INVISIBLE) INHERITS (htest3); +SELECT * FROM htest3_1; + b +--- +(0 rows) + +\d+ htest3_1 + Table "public.htest3_1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+-----------------------------------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | nextval('htest3_a_seq'::regclass) | invisible | plain | | + b | pg_catalog.int4 | | | | | plain | | + c | pg_catalog.int4 | | | | invisible | plain | | +Not-null constraints: + "htest3_a_not_null" NOT NULL "a" (inherited) +Inherits: htest3 + +DROP TABLE htest3_1, htest3; +-- Ordering do not include the invisible column +CREATE TABLE t1 (col1 integer NOT NULL INVISIBLE, col2 integer); +INSERT INTO t1 (col1, col2) VALUES (1, 6), (3, 4); +SELECT * FROM t1 ORDER BY 1 DESC; + col2 +------ + 6 + 4 +(2 rows) + +SELECT col1,col2 FROM t1 ORDER BY 2 DESC; + col1 | col2 +------+------ + 1 | 6 + 3 | 4 +(2 rows) + +-- unless it is called explicitly +SELECT * FROM t1 ORDER BY col1 DESC; + col2 +------ + 4 + 6 +(2 rows) + +DROP TABLE t1; +-- A table can be partitioned by an invisible column +CREATE TABLE measurement ( + city_id int not null, + logdate date not null INVISIBLE, + peaktemp int, + unitsales int +) PARTITION BY RANGE (logdate); +CREATE TABLE measurement_y2006m02 PARTITION OF measurement + FOR VALUES FROM ('2021-01-01') TO ('2021-03-01'); +CREATE TABLE measurement_y2006m03 PARTITION OF measurement + FOR VALUES FROM ('2021-03-01') TO ('2021-05-01'); +INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-02-28', 34, 4); +INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-04-12', 42, 6); +EXPLAIN VERBOSE SELECT * FROM measurement; + QUERY PLAN +---------------------------------------------------------------------------------------------------- + Append (cost=0.00..71.00 rows=3400 width=12) + -> Seq Scan on public.measurement_y2006m02 measurement_1 (cost=0.00..27.00 rows=1700 width=12) + Output: measurement_1.city_id, measurement_1.peaktemp, measurement_1.unitsales + -> Seq Scan on public.measurement_y2006m03 measurement_2 (cost=0.00..27.00 rows=1700 width=12) + Output: measurement_2.city_id, measurement_2.peaktemp, measurement_2.unitsales +(5 rows) + +SELECT * FROM measurement; + city_id | peaktemp | unitsales +---------+----------+----------- + 1 | 34 | 4 + 1 | 42 | 6 +(2 rows) + +SELECT city_id, logdate, peaktemp, unitsales FROM measurement; + city_id | logdate | peaktemp | unitsales +---------+------------+----------+----------- + 1 | 2021-02-28 | 34 | 4 + 1 | 2021-04-12 | 42 | 6 +(2 rows) + +DROP TABLE measurement CASCADE; +-- Same but unitsales is invisible instead of the partition key +CREATE TABLE measurement ( + city_id int not null, + logdate date not null, + peaktemp int, + unitsales int INVISIBLE +) PARTITION BY RANGE (logdate); +CREATE TABLE measurement_y2006m02 PARTITION OF measurement + FOR VALUES FROM ('2021-01-01') TO ('2021-03-01'); +CREATE TABLE measurement_y2006m03 PARTITION OF measurement + FOR VALUES FROM ('2021-03-01') TO ('2021-05-01'); +INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-02-28', 34, 4); +INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-04-12', 42, 6); +EXPLAIN VERBOSE SELECT * FROM measurement; + QUERY PLAN +---------------------------------------------------------------------------------------------------- + Append (cost=0.00..71.00 rows=3400 width=16) + -> Seq Scan on public.measurement_y2006m02 measurement_1 (cost=0.00..27.00 rows=1700 width=16) + Output: measurement_1.city_id, measurement_1.logdate, measurement_1.peaktemp + -> Seq Scan on public.measurement_y2006m03 measurement_2 (cost=0.00..27.00 rows=1700 width=16) + Output: measurement_2.city_id, measurement_2.logdate, measurement_2.peaktemp +(5 rows) + +SELECT * FROM measurement; + city_id | logdate | peaktemp +---------+------------+---------- + 1 | 2021-02-28 | 34 + 1 | 2021-04-12 | 42 +(2 rows) + +SELECT city_id, logdate, peaktemp, unitsales FROM measurement; + city_id | logdate | peaktemp | unitsales +---------+------------+----------+----------- + 1 | 2021-02-28 | 34 | 4 + 1 | 2021-04-12 | 42 | 6 +(2 rows) + +SELECT * FROM measurement_y2006m03; + city_id | logdate | peaktemp +---------+------------+---------- + 1 | 2021-04-12 | 42 +(1 row) + +DROP TABLE measurement CASCADE; +-- Temporary tables can have invisible columns too. +CREATE TEMPORARY TABLE htest_tmp (col1 integer NOT NULL INVISIBLE, col2 integer); +ALTER TABLE htest_tmp MODIFY col1 INVISIBLE; +INSERT INTO htest_tmp (col1, col2) VALUES (1, 6), (3, 4); +SELECT * FROM htest_tmp ORDER BY 1 DESC; + col2 +------ + 6 + 4 +(2 rows) + +DROP TABLE htest_tmp; +-- A table can use a composite type as an invisible column +CREATE TYPE compfoo AS (f1 int, f2 text); +CREATE TABLE htest4 ( + a int, + b compfoo INVISIBLE +); +SELECT * FROM htest4; + a +--- +(0 rows) + +DROP TABLE htest4; +DROP TYPE compfoo; +-- Foreign key constraints can be defined on invisible columns, or invisible columns can be referenced. +CREATE TABLE t1 (col1 integer UNIQUE INVISIBLE, col2 integer); +CREATE TABLE t2 (col1 integer PRIMARY KEY INVISIBLE, col2 integer); +ALTER TABLE t1 ADD CONSTRAINT fk_t1_col1 FOREIGN KEY (col1) REFERENCES t2(col1); +ALTER TABLE t2 ADD CONSTRAINT fk_t2_col1 FOREIGN KEY (col1) REFERENCES t1(col1); +DROP TABLE t1, t2 CASCADE; +-- CHECK constraints can be defined on invisible columns. +CREATE TABLE t1 (col1 integer CHECK (col1 > 2) INVISIBLE, col2 integer NOT NULL); +ALTER TABLE t1 MODIFY col1 INVISIBLE; +INSERT INTO t1 (col1, col2) VALUES (1, 6); -- error +ERROR: new row for relation "t1" violates check constraint "t1_col1_check" +DETAIL: Failing row contains (1, 6). +INSERT INTO t1 (col1, col2) VALUES (3, 6); +-- An index can reference a invisible column +CREATE INDEX ON t1 (col1); +ALTER TABLE t1 + ALTER COLUMN col1 TYPE bigint, + ALTER COLUMN col1 DROP INVISIBLE, + MODIFY col2 INVISIBLE; +\d+ t1 + Table "public.t1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + col1 | pg_catalog.int8 | | | | | plain | | + col2 | pg_catalog.int4 | | not null | | invisible | plain | | +Indexes: + "t1_col1_idx" btree (col1) +Check constraints: + "t1_col1_check" CHECK (col1 > 2) +Not-null constraints: + "t1_col2_not_null" NOT NULL "col2" + +DROP TABLE t1; +-- View must not include the invisible column when not explicitly listed +CREATE VIEW viewt1 AS SELECT * FROM htest1; +\d viewt1 + View "public.viewt1" + Column | Type | Collation | Nullable | Default +--------+------+-----------+----------+--------- + b | text | | | + +SELECT * FROM viewt1; + b +------------ + htest1 one + htest1 two +(2 rows) + +-- If the invisible attribute on the column is removed the view result must not change +ALTER TABLE htest1 MODIFY a VISIBLE; +SELECT * FROM viewt1; + b +------------ + htest1 one + htest1 two +(2 rows) + +ALTER TABLE htest1 MODIFY a INVISIBLE; +DROP VIEW viewt1; +-- Materialized view must include the invisible column when explicitly listed +-- but the column is not invisible in the materialized view. +CREATE VIEW viewt1 AS SELECT a, b FROM htest1; +\d viewt1 + View "public.viewt1" + Column | Type | Collation | Nullable | Default +--------+-----------------+-----------+----------+--------- + a | pg_catalog.int8 | | | + b | text | | | + +SELECT * FROM viewt1; + a | b +---+------------ + 1 | htest1 one + 2 | htest1 two +(2 rows) + +-- Materialized view must not include the invisible column when not explicitly listed +CREATE MATERIALIZED VIEW mviewt1 AS SELECT * FROM htest1; +\d mviewt1 + Materialized view "public.mviewt1" + Column | Type | Collation | Nullable | Default +--------+------+-----------+----------+--------- + b | text | | | + +REFRESH MATERIALIZED VIEW mviewt1; +SELECT * FROM mviewt1; + b +------------ + htest1 one + htest1 two +(2 rows) + +DROP MATERIALIZED VIEW mviewt1; +-- Materialized view must include the invisible column when explicitly listed +-- but the column is not invisible in the materialized view. +CREATE MATERIALIZED VIEW mviewt1 AS SELECT a, b FROM htest1; +\d mviewt1 + Materialized view "public.mviewt1" + Column | Type | Collation | Nullable | Default +--------+-----------------+-----------+----------+--------- + a | pg_catalog.int8 | | | + b | text | | | + +REFRESH MATERIALIZED VIEW mviewt1; +SELECT * FROM mviewt1; + a | b +---+------------ + 1 | htest1 one + 2 | htest1 two +(2 rows) + +-- typed tables with invisible column is not supported +CREATE TYPE htest_type AS (f1 integer, f2 text, f3 bigint); +CREATE TABLE htest28 OF htest_type (f1 WITH OPTIONS DEFAULT 3); +ALTER TABLE htest28 MODIFY f1 INVISIBLE; -- error +ERROR: cannot set INVISIBLE attribute on a column of a typed table +DROP TYPE htest_type CASCADE; +NOTICE: drop cascades to table htest28 +-- Prepared statements +PREPARE q1 AS SELECT * FROM htest1 WHERE a > $1; +EXECUTE q1(0); + b +------------ + htest1 one + htest1 two +(2 rows) + +ALTER TABLE htest1 MODIFY a VISIBLE; +EXECUTE q1(0); -- error: cached plan change result type +ERROR: cached plan must not change result type +ALTER TABLE htest1 MODIFY a INVISIBLE; +EXECUTE q1(0); + b +------------ + htest1 one + htest1 two +(2 rows) + +DEALLOCATE q1; +-- SELECT * INTO and RETURNING * INTO has the same +-- behavior, the invisible column is not returned. +CREATE OR REPLACE PROCEDURE test_plpgsq_returning (p_a integer) +AS $$ +DECLARE + v_lbl text; +BEGIN + SELECT * INTO v_lbl FROM htest1 WHERE a = p_a; + RAISE NOTICE 'SELECT INTO Col b : %', v_lbl; + + DELETE FROM htest1 WHERE a = p_a + RETURNING * INTO v_lbl; + IF FOUND THEN + RAISE NOTICE 'RETURNING INTO Col b : %', v_lbl; + ELSE + RAISE NOTICE 'Noting found'; + END IF; +END +$$ +LANGUAGE plpgsql; +CALL test_plpgsq_returning(1); +-- Cleanup +DROP TABLE htest0, htest1 CASCADE; +NOTICE: SELECT INTO Col b : htest1 one +NOTICE: RETURNING INTO Col b : htest1 one +NOTICE: drop cascades to 2 other objects +DETAIL: drop cascades to view viewt1 +drop cascades to materialized view mviewt1 diff --git a/src/oracle_test/regress/expected/psql.out b/src/oracle_test/regress/expected/psql.out index 28c870c5788..0e4da64ecc7 100644 --- a/src/oracle_test/regress/expected/psql.out +++ b/src/oracle_test/regress/expected/psql.out @@ -2873,34 +2873,34 @@ CREATE TABLE tbl_heap(f1 int, f2 char(100)) using heap; CREATE VIEW view_heap_psql AS SELECT f1 from tbl_heap_psql; CREATE MATERIALIZED VIEW mat_view_heap_psql USING heap_psql AS SELECT f1 from tbl_heap_psql; \d+ tbl_heap_psql - Table "tableam_display.tbl_heap_psql" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | - f2 | char(100) | | | | extended | | + Table "tableam_display.tbl_heap_psql" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | + f2 | char(100) | | | | | extended | | \d+ tbl_heap - Table "tableam_display.tbl_heap" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | - f2 | char(100) | | | | extended | | + Table "tableam_display.tbl_heap" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | + f2 | char(100) | | | | | extended | | \set HIDE_TABLEAM off \d+ tbl_heap_psql - Table "tableam_display.tbl_heap_psql" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | - f2 | char(100) | | | | extended | | + Table "tableam_display.tbl_heap_psql" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | + f2 | char(100) | | | | | extended | | Access method: heap_psql \d+ tbl_heap - Table "tableam_display.tbl_heap" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | - f2 | char(100) | | | | extended | | + Table "tableam_display.tbl_heap" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | + f2 | char(100) | | | | | extended | | Access method: heap -- AM is displayed for tables, indexes and materialized views. diff --git a/src/oracle_test/regress/expected/publication.out b/src/oracle_test/regress/expected/publication.out index 36ef5179b6c..eeb1385d8d1 100644 --- a/src/oracle_test/regress/expected/publication.out +++ b/src/oracle_test/regress/expected/publication.out @@ -184,11 +184,11 @@ SELECT pubname, puballtables FROM pg_publication WHERE pubname = 'testpub_forall (1 row) \d+ testpub_tbl2 - Table "public.testpub_tbl2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+------------------------------------------+----------+--------------+------------- - id | pg_catalog.int4 | | not null | nextval('testpub_tbl2_id_seq'::regclass) | plain | | - data | text | | | | extended | | + Table "public.testpub_tbl2" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+------------------------------------------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | not null | nextval('testpub_tbl2_id_seq'::regclass) | | plain | | + data | text | | | | | extended | | Indexes: "testpub_tbl2_pkey" PRIMARY KEY, btree (id) Publications: @@ -748,12 +748,12 @@ UPDATE testpub_tbl6 SET a = 1; CREATE TABLE testpub_tbl7 (a int primary key, b text, c text); ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl7 (a, b); \d+ testpub_tbl7 - Table "public.testpub_tbl7" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | - b | text | | | | extended | | - c | text | | | | extended | | + Table "public.testpub_tbl7" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | text | | | | | extended | | + c | text | | | | | extended | | Indexes: "testpub_tbl7_pkey" PRIMARY KEY, btree (a) Publications: @@ -762,12 +762,12 @@ Publications: -- ok: the column list is the same, we should skip this table (or at least not fail) ALTER PUBLICATION testpub_fortable SET TABLE testpub_tbl7 (a, b); \d+ testpub_tbl7 - Table "public.testpub_tbl7" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | - b | text | | | | extended | | - c | text | | | | extended | | + Table "public.testpub_tbl7" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | text | | | | | extended | | + c | text | | | | | extended | | Indexes: "testpub_tbl7_pkey" PRIMARY KEY, btree (a) Publications: @@ -776,12 +776,12 @@ Publications: -- ok: the column list changes, make sure the catalog gets updated ALTER PUBLICATION testpub_fortable SET TABLE testpub_tbl7 (a, c); \d+ testpub_tbl7 - Table "public.testpub_tbl7" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+----------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | - b | text | | | | extended | | - c | text | | | | extended | | + Table "public.testpub_tbl7" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | text | | | | | extended | | + c | text | | | | | extended | | Indexes: "testpub_tbl7_pkey" PRIMARY KEY, btree (a) Publications: @@ -912,12 +912,12 @@ Tables: "public.testpub_tbl_both_filters" (a, c) WHERE (c <> 1) \d+ testpub_tbl_both_filters - Table "public.testpub_tbl_both_filters" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | not null | | plain | | - b | pg_catalog.int4 | | | | plain | | - c | pg_catalog.int4 | | not null | | plain | | + Table "public.testpub_tbl_both_filters" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | not null | | | plain | | + b | pg_catalog.int4 | | | | | plain | | + c | pg_catalog.int4 | | not null | | | plain | | Indexes: "testpub_tbl_both_filters_pkey" PRIMARY KEY, btree (a, c) REPLICA IDENTITY Publications: @@ -1129,22 +1129,22 @@ ALTER PUBLICATION testpub_default SET TABLE testpub_tbl1; ALTER PUBLICATION testpub_default ADD TABLE pub_test.testpub_nopk; ALTER PUBLICATION testpib_ins_trunct ADD TABLE pub_test.testpub_nopk, testpub_tbl1; \d+ pub_test.testpub_nopk - Table "pub_test.testpub_nopk" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - foo | pg_catalog.int4 | | | | plain | | - bar | pg_catalog.int4 | | | | plain | | + Table "pub_test.testpub_nopk" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + foo | pg_catalog.int4 | | | | | plain | | + bar | pg_catalog.int4 | | | | | plain | | Publications: "testpib_ins_trunct" "testpub_default" "testpub_fortbl" \d+ testpub_tbl1 - Table "public.testpub_tbl1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+------------------------------------------+----------+--------------+------------- - id | pg_catalog.int4 | | not null | nextval('testpub_tbl1_id_seq'::regclass) | plain | | - data | text | | | | extended | | + Table "public.testpub_tbl1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+------------------------------------------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | not null | nextval('testpub_tbl1_id_seq'::regclass) | | plain | | + data | text | | | | | extended | | Indexes: "testpub_tbl1_pkey" PRIMARY KEY, btree (id) Publications: @@ -1168,11 +1168,11 @@ ALTER PUBLICATION testpub_default DROP TABLE testpub_tbl1, pub_test.testpub_nopk ALTER PUBLICATION testpub_default DROP TABLE pub_test.testpub_nopk; ERROR: relation "testpub_nopk" is not part of the publication \d+ testpub_tbl1 - Table "public.testpub_tbl1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+------------------------------------------+----------+--------------+------------- - id | pg_catalog.int4 | | not null | nextval('testpub_tbl1_id_seq'::regclass) | plain | | - data | text | | | | extended | | + Table "public.testpub_tbl1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+------------------------------------------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | not null | nextval('testpub_tbl1_id_seq'::regclass) | | plain | | + data | text | | | | | extended | | Indexes: "testpub_tbl1_pkey" PRIMARY KEY, btree (id) Publications: diff --git a/src/oracle_test/regress/expected/replica_identity.out b/src/oracle_test/regress/expected/replica_identity.out index 740a72e162e..11ebac75346 100644 --- a/src/oracle_test/regress/expected/replica_identity.out +++ b/src/oracle_test/regress/expected/replica_identity.out @@ -153,13 +153,13 @@ SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass; (1 row) \d+ test_replica_identity - Table "public.test_replica_identity" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------------------------------------------------+----------+--------------+------------- - id | pg_catalog.int4 | | not null | nextval('test_replica_identity_id_seq'::regclass) | plain | | - keya | text | | not null | | extended | | - keyb | text | | not null | | extended | | - nonkey | text | | | | extended | | + Table "public.test_replica_identity" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------------------------------------------------+-----------+----------+--------------+------------- + id | pg_catalog.int4 | | not null | nextval('test_replica_identity_id_seq'::regclass) | | plain | | + keya | text | | not null | | | extended | | + keyb | text | | not null | | | extended | | + nonkey | text | | | | | extended | | Indexes: "test_replica_identity_pkey" PRIMARY KEY, btree (id) "test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3)) @@ -249,10 +249,10 @@ ALTER TABLE ONLY test_replica_identity4 ALTER TABLE ONLY test_replica_identity4_1 ADD CONSTRAINT test_replica_identity4_1_pkey PRIMARY KEY (id); \d+ test_replica_identity4 - Partitioned table "public.test_replica_identity4" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - id | pg_catalog.int4 | | not null | | plain | | + Partitioned table "public.test_replica_identity4" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + id | pg_catalog.int4 | | not null | | | plain | | Partition key: LIST (id) Indexes: "test_replica_identity4_pkey" PRIMARY KEY, btree (id) INVALID REPLICA IDENTITY @@ -263,10 +263,10 @@ Partitions: test_replica_identity4_1 FOR VALUES IN (1) ALTER INDEX test_replica_identity4_pkey ATTACH PARTITION test_replica_identity4_1_pkey; \d+ test_replica_identity4 - Partitioned table "public.test_replica_identity4" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - id | pg_catalog.int4 | | not null | | plain | | + Partitioned table "public.test_replica_identity4" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + id | pg_catalog.int4 | | not null | | | plain | | Partition key: LIST (id) Indexes: "test_replica_identity4_pkey" PRIMARY KEY, btree (id) REPLICA IDENTITY diff --git a/src/oracle_test/regress/expected/rowsecurity.out b/src/oracle_test/regress/expected/rowsecurity.out index 2c38b9393bb..7417b5e4e3f 100644 --- a/src/oracle_test/regress/expected/rowsecurity.out +++ b/src/oracle_test/regress/expected/rowsecurity.out @@ -939,14 +939,14 @@ CREATE POLICY pp1 ON part_document AS PERMISSIVE CREATE POLICY pp1r ON part_document AS RESTRICTIVE TO regress_rls_dave USING (cid < 55); \d+ part_document - Partitioned table "regress_rls_schema.part_document" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ----------+-----------------+-----------+----------+---------+----------+--------------+------------- - did | pg_catalog.int4 | | | | plain | | - cid | pg_catalog.int4 | | | | plain | | - dlevel | pg_catalog.int4 | | not null | | plain | | - dauthor | name | | | | plain | | - dtitle | text | | | | extended | | + Partitioned table "regress_rls_schema.part_document" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +---------+-----------------+-----------+----------+---------+-----------+----------+--------------+------------- + did | pg_catalog.int4 | | | | | plain | | + cid | pg_catalog.int4 | | | | | plain | | + dlevel | pg_catalog.int4 | | not null | | | plain | | + dauthor | name | | | | | plain | | + dtitle | text | | | | | extended | | Partition key: RANGE (cid) Policies: POLICY "pp1" diff --git a/src/oracle_test/regress/expected/rules.out b/src/oracle_test/regress/expected/rules.out index a64e889b47e..ac2ac855222 100644 --- a/src/oracle_test/regress/expected/rules.out +++ b/src/oracle_test/regress/expected/rules.out @@ -3064,11 +3064,11 @@ create rule r7 as on delete to rules_src do instead returning trgt.f1, trgt.f2; -- check display of all rules added above \d+ rules_src - Table "public.rules_src" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | - f2 | pg_catalog.int4 | | | 0 | plain | | + Table "public.rules_src" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | + f2 | pg_catalog.int4 | | | 0 | | plain | | Rules: r1 AS ON UPDATE TO rules_src DO INSERT INTO rules_log (f1, f2, tag, id) VALUES (old.f1,old.f2,'old'::text,DEFAULT), (new.f1,new.f2,'new'::text,DEFAULT) @@ -3117,11 +3117,11 @@ create rule rr as on update to rule_t1 do instead UPDATE rule_dest trgt SET (f2[1], f1, tag) = (SELECT new.f2, new.f1, 'updated'::varchar) WHERE trgt.f1 = new.f1 RETURNING new.*; \d+ rule_t1 - Table "public.rule_t1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - f1 | pg_catalog.int4 | | | | plain | | - f2 | pg_catalog.int4 | | | | plain | | + Table "public.rule_t1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + f1 | pg_catalog.int4 | | | | | plain | | + f2 | pg_catalog.int4 | | | | | plain | | Rules: rr AS ON UPDATE TO rule_t1 DO INSTEAD UPDATE rule_dest trgt SET (f2[1], f1, tag) = ( SELECT new.f2, diff --git a/src/oracle_test/regress/expected/stats_ext.out b/src/oracle_test/regress/expected/stats_ext.out index 870d277aa95..e32b676fdc6 100644 --- a/src/oracle_test/regress/expected/stats_ext.out +++ b/src/oracle_test/regress/expected/stats_ext.out @@ -151,11 +151,11 @@ SELECT stxname, stxdndistinct, stxddependencies, stxdmcv, stxdinherit ALTER STATISTICS ab1_a_b_stats SET STATISTICS -1; \d+ ab1 - Table "public.ab1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | - b | pg_catalog.int4 | | | | plain | | + Table "public.ab1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | + b | pg_catalog.int4 | | | | | plain | | Statistics objects: "public.ab1_a_b_stats" ON a, b FROM ab1 diff --git a/src/oracle_test/regress/expected/tablespace.out b/src/oracle_test/regress/expected/tablespace.out index b634635d268..a9d0674f6f5 100644 --- a/src/oracle_test/regress/expected/tablespace.out +++ b/src/oracle_test/regress/expected/tablespace.out @@ -349,10 +349,10 @@ Indexes: Number of partitions: 2 (Use \d+ to list them.) \d+ testschema.part - Partitioned table "testschema.part" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Partitioned table "testschema.part" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Partition key: LIST (a) Indexes: "part_a_idx" btree (a), tablespace "regress_tblspace" @@ -369,10 +369,10 @@ Indexes: "part1_a_idx" btree (a), tablespace "regress_tblspace" \d+ testschema.part1 - Table "testschema.part1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "testschema.part1" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Partition of: testschema.part FOR VALUES IN (1) Partition constraint: ((a IS NOT NULL) AND (a = 1)) Indexes: diff --git a/src/oracle_test/regress/expected/triggers.out b/src/oracle_test/regress/expected/triggers.out index de93b327c13..e767101fbcf 100644 --- a/src/oracle_test/regress/expected/triggers.out +++ b/src/oracle_test/regress/expected/triggers.out @@ -3751,10 +3751,10 @@ create trigger parenttrig after insert on child for each row execute procedure f(); alter trigger parenttrig on parent rename to anothertrig; \d+ child - Table "public.child" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+-----------------+-----------+----------+---------+---------+--------------+------------- - a | pg_catalog.int4 | | | | plain | | + Table "public.child" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+-----------------+-----------+----------+---------+-----------+---------+--------------+------------- + a | pg_catalog.int4 | | | | | plain | | Triggers: parenttrig AFTER INSERT ON child FOR EACH ROW EXECUTE FUNCTION f() Inherits: parent diff --git a/src/oracle_test/regress/expected/update.out b/src/oracle_test/regress/expected/update.out index 0d8e81d73f6..fa4cac33732 100644 --- a/src/oracle_test/regress/expected/update.out +++ b/src/oracle_test/regress/expected/update.out @@ -746,14 +746,14 @@ DROP TRIGGER d15_insert_trig ON part_d_15_20; :init_range_parted; create table part_def partition of range_parted default; \d+ part_def - Table "public.part_def" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+--------------------+-----------+----------+---------+----------+--------------+------------- - a | text | | | | extended | | - b | pg_catalog.int8 | | | | plain | | - c | pg_catalog.numeric | | | | main | | - d | pg_catalog.int4 | | | | plain | | - e | varchar2(4000) | | | | extended | | + Table "public.part_def" + Column | Type | Collation | Nullable | Default | Invisible | Storage | Stats target | Description +--------+--------------------+-----------+----------+---------+-----------+----------+--------------+------------- + a | text | | | | | extended | | + b | pg_catalog.int8 | | | | | plain | | + c | pg_catalog.numeric | | | | | main | | + d | pg_catalog.int4 | | | | | plain | | + e | varchar2(4000) | | | | | extended | | Partition of: range_parted DEFAULT Partition constraint: (NOT ((a IS NOT NULL) AND (b IS NOT NULL) AND (((a = 'a'::text) AND (b >= '1'::pg_catalog.int8) AND (b < '10'::pg_catalog.int8)) OR ((a = 'a'::text) AND (b >= '10'::pg_catalog.int8) AND (b < '20'::pg_catalog.int8)) OR ((a = 'b'::text) AND (b >= '1'::pg_catalog.int8) AND (b < '10'::pg_catalog.int8)) OR ((a = 'b'::text) AND (b >= '10'::pg_catalog.int8) AND (b < '20'::pg_catalog.int8)) OR ((a = 'b'::text) AND (b >= '20'::pg_catalog.int8) AND (b < '30'::pg_catalog.int8))))) diff --git a/src/oracle_test/regress/parallel_schedule b/src/oracle_test/regress/parallel_schedule index dc172efd38b..c1d403455bd 100644 --- a/src/oracle_test/regress/parallel_schedule +++ b/src/oracle_test/regress/parallel_schedule @@ -51,7 +51,7 @@ test: create_index create_index_spgist create_view index_including index_includi # ---------- # Another group of parallel tests # ---------- -test: create_aggregate create_function_sql create_cast constraints triggers select inherit typed_table vacuum drop_if_exists updatable_views roleattributes create_am hash_func errors infinite_recurse +test: create_aggregate create_function_sql create_cast constraints triggers select inherit typed_table vacuum drop_if_exists updatable_views roleattributes create_am hash_func errors infinite_recurse invisible # ---------- # sanity_check does a vacuum, affecting the sort order of SELECT * diff --git a/src/oracle_test/regress/sql/invisible.sql b/src/oracle_test/regress/sql/invisible.sql new file mode 100644 index 00000000000..547222d5bbd --- /dev/null +++ b/src/oracle_test/regress/sql/invisible.sql @@ -0,0 +1,271 @@ +-- sanity check of system catalog +SELECT attrelid, attname, attisinvisible FROM pg_attribute WHERE attisinvisible; + + +CREATE TABLE htest0 (a int PRIMARY KEY, b text NOT NULL INVISIBLE); +INSERT INTO htest0 (a, b) VALUES (1, 'htest0 one'); +INSERT INTO htest0 (a, b) VALUES (2, 'htest0 two'); +-- we allow that all columns of a relation be invisible +ALTER TABLE htest0 MODIFY a INVISIBLE; +SELECT * FROM htest0; +ALTER TABLE htest0 MODIFY a VISIBLE; + +CREATE TABLE htest1 (a bigserial PRIMARY KEY INVISIBLE, b text); +ALTER TABLE htest1 MODIFY a INVISIBLE; +-- Insert without named column must not include the invisible column +INSERT INTO htest1 VALUES ('htest1 one'); +INSERT INTO htest1 VALUES ('htest1 two'); +-- INSERT + SELECT * should handle the invisible column +CREATE TABLE htest1_1 (a bigserial PRIMARY KEY, b text); +ALTER TABLE htest1_1 MODIFY a INVISIBLE; +INSERT INTO htest1_1 VALUES ('htest1 one'); +WITH cte AS ( + DELETE FROM htest1_1 RETURNING * +) SELECT * FROM cte; +INSERT INTO htest1_1 SELECT * FROM htest0; +SELECT a, b FROM htest1_1; +DROP TABLE htest1_1; + +SELECT attrelid::regclass, attname, attisinvisible FROM pg_attribute WHERE attisinvisible; + +\d+ htest1 + +-- DROP/SET invisible attribute +ALTER TABLE htest0 MODIFY b VISIBLE; + +\d+ htest0 + +ALTER TABLE htest0 MODIFY b INVISIBLE; + +-- Hidden column are not expandable and must not be returned +SELECT * FROM htest0; -- return only column a +SELECT t.* FROM htest1 t; -- return only column b +-- the whole-row syntax do not take care of the invisible attribute +SELECT t FROM htest1 t; -- return column a and b + +-- CTEs based on SELECT * only have visible column returned +WITH foo AS (SELECT * FROM htest1) SELECT * FROM foo; -- Only column b is returned here + +-- Use of wildcard or whole-row in a function do not apply the invisible attribute +SELECT row_to_json(t.*) FROM htest0 t; +SELECT row_to_json(t) FROM htest0 t; + +-- inheritance, the invisible attribute is inherited +CREATE TABLE htest1_1 () INHERITS (htest1); +SELECT * FROM htest1_1; +\d htest1_1 +INSERT INTO htest1_1 VALUES ('htest1 three'); +SELECT * FROM htest1_1; +SELECT * FROM htest1; + +-- invisible column must be explicitely named to be returned +SELECT a,b FROM htest1_1; +SELECT a,b FROM htest1; +DROP TABLE htest1_1; + +-- Default CREATE TABLE ... LIKE includes invisible columns, and they are not uinexpanded in the new table. +CREATE TABLE htest_like1 (LIKE htest1); +\d+ htest_like1 +-- CREATE TABLE ... LIKE includes invisible columns, and they are invisible if requested +CREATE TABLE htest_like2 (LIKE htest1 INCLUDING INVISIBLE); +\d+ htest_like2 +CREATE TABLE htest_like3 (LIKE htest1 INCLUDING ALL); +\d+ htest_like3 +DROP TABLE htest_like1, htest_like2, htest_like3; + +-- Insert without named column with and a not null invisible column must have a default value +INSERT INTO htest0 VALUES (3); -- error +ALTER TABLE htest0 ALTER COLUMN b SET DEFAULT 'unknown'; +INSERT INTO htest0 VALUES (3); +-- Same with COPY +COPY htest0 TO stdout; +COPY htest0 (a, b) TO stdout; +COPY htest0 FROM stdin; +4 +5 +\. +SELECT a,b FROM htest0; + +-- same but with drop/add the column between invisible columns (virtual columns can be made invisible) +CREATE TABLE htest2 (a serial, b int, c int GENERATED ALWAYS AS (a * 2) STORED); +ALTER TABLE htest2 MODIFY a INVISIBLE; +ALTER TABLE htest2 MODIFY c INVISIBLE; +SELECT * FROM htest2; +INSERT INTO htest2 VALUES (2); +SELECT a,b,c FROM htest2; +ALTER TABLE htest2 DROP COLUMN b; +ALTER TABLE htest2 ADD COLUMN b int; +INSERT INTO htest2 VALUES (4); +SELECT a,b,c FROM htest2; +DROP TABLE htest2 CASCADE; + +-- a table can NOT have all columns invisible +CREATE TABLE htest3 (a serial INVISIBLE, b int INVISIBLE); + +CREATE TABLE htest3 (a serial, b int); +ALTER TABLE htest3 + ALTER COLUMN a SET INVISIBLE, + MODIFY b INVISIBLE; -- error +DROP TABLE htest3; + +-- inheritance with an additional single invisible column is possible +CREATE TABLE htest3 (a serial INVISIBLE, b int); +SELECT * FROM htest3; +CREATE TABLE htest3_1 (c int INVISIBLE) INHERITS (htest3); +SELECT * FROM htest3_1; +\d+ htest3_1 +DROP TABLE htest3_1, htest3; + +-- Ordering do not include the invisible column +CREATE TABLE t1 (col1 integer NOT NULL INVISIBLE, col2 integer); +INSERT INTO t1 (col1, col2) VALUES (1, 6), (3, 4); +SELECT * FROM t1 ORDER BY 1 DESC; +SELECT col1,col2 FROM t1 ORDER BY 2 DESC; +-- unless it is called explicitly +SELECT * FROM t1 ORDER BY col1 DESC; +DROP TABLE t1; + +-- A table can be partitioned by an invisible column +CREATE TABLE measurement ( + city_id int not null, + logdate date not null INVISIBLE, + peaktemp int, + unitsales int +) PARTITION BY RANGE (logdate); +CREATE TABLE measurement_y2006m02 PARTITION OF measurement + FOR VALUES FROM ('2021-01-01') TO ('2021-03-01'); +CREATE TABLE measurement_y2006m03 PARTITION OF measurement + FOR VALUES FROM ('2021-03-01') TO ('2021-05-01'); +INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-02-28', 34, 4); +INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-04-12', 42, 6); +EXPLAIN VERBOSE SELECT * FROM measurement; +SELECT * FROM measurement; +SELECT city_id, logdate, peaktemp, unitsales FROM measurement; +DROP TABLE measurement CASCADE; +-- Same but unitsales is invisible instead of the partition key +CREATE TABLE measurement ( + city_id int not null, + logdate date not null, + peaktemp int, + unitsales int INVISIBLE +) PARTITION BY RANGE (logdate); +CREATE TABLE measurement_y2006m02 PARTITION OF measurement + FOR VALUES FROM ('2021-01-01') TO ('2021-03-01'); +CREATE TABLE measurement_y2006m03 PARTITION OF measurement + FOR VALUES FROM ('2021-03-01') TO ('2021-05-01'); +INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-02-28', 34, 4); +INSERT INTO measurement (city_id, logdate, peaktemp, unitsales) VALUES (1, '2021-04-12', 42, 6); +EXPLAIN VERBOSE SELECT * FROM measurement; +SELECT * FROM measurement; +SELECT city_id, logdate, peaktemp, unitsales FROM measurement; +SELECT * FROM measurement_y2006m03; +DROP TABLE measurement CASCADE; + +-- Temporary tables can have invisible columns too. +CREATE TEMPORARY TABLE htest_tmp (col1 integer NOT NULL INVISIBLE, col2 integer); +ALTER TABLE htest_tmp MODIFY col1 INVISIBLE; +INSERT INTO htest_tmp (col1, col2) VALUES (1, 6), (3, 4); +SELECT * FROM htest_tmp ORDER BY 1 DESC; +DROP TABLE htest_tmp; + +-- A table can use a composite type as an invisible column +CREATE TYPE compfoo AS (f1 int, f2 text); +CREATE TABLE htest4 ( + a int, + b compfoo INVISIBLE +); +SELECT * FROM htest4; +DROP TABLE htest4; +DROP TYPE compfoo; + +-- Foreign key constraints can be defined on invisible columns, or invisible columns can be referenced. +CREATE TABLE t1 (col1 integer UNIQUE INVISIBLE, col2 integer); +CREATE TABLE t2 (col1 integer PRIMARY KEY INVISIBLE, col2 integer); +ALTER TABLE t1 ADD CONSTRAINT fk_t1_col1 FOREIGN KEY (col1) REFERENCES t2(col1); +ALTER TABLE t2 ADD CONSTRAINT fk_t2_col1 FOREIGN KEY (col1) REFERENCES t1(col1); +DROP TABLE t1, t2 CASCADE; + +-- CHECK constraints can be defined on invisible columns. +CREATE TABLE t1 (col1 integer CHECK (col1 > 2) INVISIBLE, col2 integer NOT NULL); +ALTER TABLE t1 MODIFY col1 INVISIBLE; +INSERT INTO t1 (col1, col2) VALUES (1, 6); -- error +INSERT INTO t1 (col1, col2) VALUES (3, 6); +-- An index can reference a invisible column +CREATE INDEX ON t1 (col1); +ALTER TABLE t1 + ALTER COLUMN col1 TYPE bigint, + ALTER COLUMN col1 DROP INVISIBLE, + MODIFY col2 INVISIBLE; +\d+ t1 +DROP TABLE t1; + +-- View must not include the invisible column when not explicitly listed +CREATE VIEW viewt1 AS SELECT * FROM htest1; +\d viewt1 +SELECT * FROM viewt1; +-- If the invisible attribute on the column is removed the view result must not change +ALTER TABLE htest1 MODIFY a VISIBLE; +SELECT * FROM viewt1; +ALTER TABLE htest1 MODIFY a INVISIBLE; +DROP VIEW viewt1; +-- Materialized view must include the invisible column when explicitly listed +-- but the column is not invisible in the materialized view. +CREATE VIEW viewt1 AS SELECT a, b FROM htest1; +\d viewt1 +SELECT * FROM viewt1; + +-- Materialized view must not include the invisible column when not explicitly listed +CREATE MATERIALIZED VIEW mviewt1 AS SELECT * FROM htest1; +\d mviewt1 +REFRESH MATERIALIZED VIEW mviewt1; +SELECT * FROM mviewt1; +DROP MATERIALIZED VIEW mviewt1; +-- Materialized view must include the invisible column when explicitly listed +-- but the column is not invisible in the materialized view. +CREATE MATERIALIZED VIEW mviewt1 AS SELECT a, b FROM htest1; +\d mviewt1 +REFRESH MATERIALIZED VIEW mviewt1; +SELECT * FROM mviewt1; + +-- typed tables with invisible column is not supported +CREATE TYPE htest_type AS (f1 integer, f2 text, f3 bigint); +CREATE TABLE htest28 OF htest_type (f1 WITH OPTIONS DEFAULT 3); +ALTER TABLE htest28 MODIFY f1 INVISIBLE; -- error +DROP TYPE htest_type CASCADE; + +-- Prepared statements +PREPARE q1 AS SELECT * FROM htest1 WHERE a > $1; +EXECUTE q1(0); +ALTER TABLE htest1 MODIFY a VISIBLE; +EXECUTE q1(0); -- error: cached plan change result type +ALTER TABLE htest1 MODIFY a INVISIBLE; +EXECUTE q1(0); +DEALLOCATE q1; + + +-- SELECT * INTO and RETURNING * INTO has the same +-- behavior, the invisible column is not returned. +CREATE OR REPLACE PROCEDURE test_plpgsq_returning (p_a integer) +AS $$ +DECLARE + v_lbl text; +BEGIN + SELECT * INTO v_lbl FROM htest1 WHERE a = p_a; + RAISE NOTICE 'SELECT INTO Col b : %', v_lbl; + + DELETE FROM htest1 WHERE a = p_a + RETURNING * INTO v_lbl; + IF FOUND THEN + RAISE NOTICE 'RETURNING INTO Col b : %', v_lbl; + ELSE + RAISE NOTICE 'Noting found'; + END IF; +END +$$ +LANGUAGE plpgsql; + +CALL test_plpgsq_returning(1); + +-- Cleanup +DROP TABLE htest0, htest1 CASCADE; +