Skip to content

Commit

Permalink
Add support for oracle invisible columns (IvorySQL#679)
Browse files Browse the repository at this point in the history
* Add support for oracle invisible columns

* Add ora invisible column support in describe

- Add invisible column support in psql extended describe command (\d+)

* Add regression for oracle invisible column

* Test Invisible columns in CREATE TABLE

* Fix failing regression for ivy_ddl

* Correct the pg_dump info for the Invisible Columns

* Refactor Invisible cols code for better understanding

* Add support for MODIFY column visibility

* Add tab-complete for invisible columns

* fix: Invalid version while dumping invisible cols

remoteVersion should be 170000 instead of 150000 in pg_dump.c
  • Loading branch information
imranzaheer612 authored Aug 16, 2024
1 parent fa4c4cf commit 510fd2a
Show file tree
Hide file tree
Showing 42 changed files with 2,035 additions and 810 deletions.
50 changes: 25 additions & 25 deletions contrib/test_decoding/expected/ivy_ddl.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/backend/access/common/tupdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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... */
}

Expand Down Expand Up @@ -665,6 +668,7 @@ TupleDescInitEntry(TupleDesc desc,
att->attstorage = typeForm->typstorage;
att->attcompression = InvalidCompressionMethod;
att->attcollation = typeForm->typcollation;
att->attisinvisible = false;

ReleaseSysCache(tuple);
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/backend/catalog/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/backend/commands/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 510fd2a

Please sign in to comment.