diff options
author | Andres Freund | 2018-11-20 23:36:57 +0000 |
---|---|---|
committer | Andres Freund | 2018-11-21 00:00:17 +0000 |
commit | 578b229718e8f15fa779e20f086c4b6bb3776106 (patch) | |
tree | 701869752158d27daa080d292befeb2e52f19037 /contrib | |
parent | 0999ac479292c12a7c373e612b15e1ff47077990 (diff) |
Remove WITH OIDS support, change oid catalog column visibility.
Previously tables declared WITH OIDS, including a significant fraction
of the catalog tables, stored the oid column not as a normal column,
but as part of the tuple header.
This special column was not shown by default, which was somewhat odd,
as it's often (consider e.g. pg_class.oid) one of the more important
parts of a row. Neither pg_dump nor COPY included the contents of the
oid column by default.
The fact that the oid column was not an ordinary column necessitated a
significant amount of special case code to support oid columns. That
already was painful for the existing, but upcoming work aiming to make
table storage pluggable, would have required expanding and duplicating
that "specialness" significantly.
WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0).
Remove it.
Removing includes:
- CREATE TABLE and ALTER TABLE syntax for declaring the table to be
WITH OIDS has been removed (WITH (oids[ = true]) will error out)
- pg_dump does not support dumping tables declared WITH OIDS and will
issue a warning when dumping one (and ignore the oid column).
- restoring an pg_dump archive with pg_restore will warn when
restoring a table with oid contents (and ignore the oid column)
- COPY will refuse to load binary dump that includes oids.
- pg_upgrade will error out when encountering tables declared WITH
OIDS, they have to be altered to remove the oid column first.
- Functionality to access the oid of the last inserted row (like
plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed.
The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false)
for CREATE TABLE) is still supported. While that requires a bit of
support code, it seems unnecessary to break applications / dumps that
do not use oids, and are explicit about not using them.
The biggest user of WITH OID columns was postgres' catalog. This
commit changes all 'magic' oid columns to be columns that are normally
declared and stored. To reduce unnecessary query breakage all the
newly added columns are still named 'oid', even if a table's column
naming scheme would indicate 'reloid' or such. This obviously
requires adapting a lot code, mostly replacing oid access via
HeapTupleGetOid() with access to the underlying Form_pg_*->oid column.
The bootstrap process now assigns oids for all oid columns in
genbki.pl that do not have an explicit value (starting at the largest
oid previously used), only oids assigned later by oids will be above
FirstBootstrapObjectId. As the oid column now is a normal column the
special bootstrap syntax for oids has been removed.
Oids are not automatically assigned during insertion anymore, all
backend code explicitly assigns oids with GetNewOidWithIndex(). For
the rare case that insertions into the catalog via SQL are called for
the new pg_nextoid() function can be used (which only works on catalog
tables).
The fact that oid columns on system tables are now normal columns
means that they will be included in the set of columns expanded
by * (i.e. SELECT * FROM pg_class will now include the table's oid,
previously it did not). It'd not technically be hard to hide oid
column by default, but that'd mean confusing behavior would either
have to be carried forward forever, or it'd cause breakage down the
line.
While it's not unlikely that further adjustments are needed, the
scope/invasiveness of the patch makes it worthwhile to get merge this
now. It's painful to maintain externally, too complicated to commit
after the code code freeze, and a dependency of a number of other
patches.
Catversion bump, for obvious reasons.
Author: Andres Freund, with contributions by John Naylor
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/adminpack/adminpack.c | 2 | ||||
-rw-r--r-- | contrib/btree_gist/expected/cash.out | 2 | ||||
-rw-r--r-- | contrib/btree_gist/expected/oid.out | 40 | ||||
-rw-r--r-- | contrib/btree_gist/sql/cash.sql | 2 | ||||
-rw-r--r-- | contrib/btree_gist/sql/oid.sql | 25 | ||||
-rw-r--r-- | contrib/dblink/dblink.c | 8 | ||||
-rw-r--r-- | contrib/file_fdw/file_fdw.c | 5 | ||||
-rw-r--r-- | contrib/pageinspect/heapfuncs.c | 17 | ||||
-rw-r--r-- | contrib/pg_buffercache/pg_buffercache_pages.c | 2 | ||||
-rw-r--r-- | contrib/pg_visibility/pg_visibility.c | 4 | ||||
-rw-r--r-- | contrib/postgres_fdw/deparse.c | 35 | ||||
-rw-r--r-- | contrib/postgres_fdw/expected/postgres_fdw.out | 41 | ||||
-rw-r--r-- | contrib/postgres_fdw/postgres_fdw.c | 34 | ||||
-rw-r--r-- | contrib/postgres_fdw/sql/postgres_fdw.sql | 11 | ||||
-rw-r--r-- | contrib/sepgsql/expected/alter.out | 18 | ||||
-rw-r--r-- | contrib/sepgsql/expected/ddl.out | 6 | ||||
-rw-r--r-- | contrib/sepgsql/label.c | 8 | ||||
-rw-r--r-- | contrib/sepgsql/sql/alter.sql | 4 | ||||
-rw-r--r-- | contrib/sepgsql/sql/ddl.sql | 3 | ||||
-rw-r--r-- | contrib/test_decoding/test_decoding.c | 7 | ||||
-rw-r--r-- | contrib/unaccent/unaccent.c | 3 |
21 files changed, 87 insertions, 190 deletions
diff --git a/contrib/adminpack/adminpack.c b/contrib/adminpack/adminpack.c index 0a27701e9c6..ea0ec201f0d 100644 --- a/contrib/adminpack/adminpack.c +++ b/contrib/adminpack/adminpack.c @@ -502,7 +502,7 @@ pg_logdir_ls_internal(FunctionCallInfo fcinfo) fctx = palloc(sizeof(directory_fctx)); - tupdesc = CreateTemplateTupleDesc(2, false); + tupdesc = CreateTemplateTupleDesc(2); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "starttime", TIMESTAMPOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 2, "filename", diff --git a/contrib/btree_gist/expected/cash.out b/contrib/btree_gist/expected/cash.out index cacbd718541..7fbc7355929 100644 --- a/contrib/btree_gist/expected/cash.out +++ b/contrib/btree_gist/expected/cash.out @@ -1,5 +1,5 @@ -- money check -CREATE TABLE moneytmp (a money) WITH OIDS; +CREATE TABLE moneytmp (a money); \copy moneytmp from 'data/cash.data' SET enable_seqscan=on; SELECT count(*) FROM moneytmp WHERE a < '22649.64'; diff --git a/contrib/btree_gist/expected/oid.out b/contrib/btree_gist/expected/oid.out index ffa90c3c3c7..776bbb10267 100644 --- a/contrib/btree_gist/expected/oid.out +++ b/contrib/btree_gist/expected/oid.out @@ -1,64 +1,66 @@ -- oid check SET enable_seqscan=on; -SELECT count(*) FROM moneytmp WHERE oid < ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +CREATE TEMPORARY TABLE oidtmp (oid oid); +INSERT INTO oidtmp SELECT g.i::oid FROM generate_series(1, 1000) g(i); +SELECT count(*) FROM oidtmp WHERE oid < 17; count ------- - 372 + 16 (1 row) -SELECT count(*) FROM moneytmp WHERE oid <= ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid <= 17; count ------- - 373 + 17 (1 row) -SELECT count(*) FROM moneytmp WHERE oid = ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid = 17; count ------- 1 (1 row) -SELECT count(*) FROM moneytmp WHERE oid >= ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid >= 17; count ------- - 228 + 984 (1 row) -SELECT count(*) FROM moneytmp WHERE oid > ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid > 17; count ------- - 227 + 983 (1 row) -CREATE INDEX oididx ON moneytmp USING gist ( oid ); +CREATE INDEX oididx ON oidtmp USING gist ( oid ); SET enable_seqscan=off; -SELECT count(*) FROM moneytmp WHERE oid < ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid < 17; count ------- - 372 + 16 (1 row) -SELECT count(*) FROM moneytmp WHERE oid <= ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid <= 17; count ------- - 373 + 17 (1 row) -SELECT count(*) FROM moneytmp WHERE oid = ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid = 17; count ------- 1 (1 row) -SELECT count(*) FROM moneytmp WHERE oid >= ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid >= 17; count ------- - 228 + 984 (1 row) -SELECT count(*) FROM moneytmp WHERE oid > ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid > 17; count ------- - 227 + 983 (1 row) diff --git a/contrib/btree_gist/sql/cash.sql b/contrib/btree_gist/sql/cash.sql index 0e037984e1b..4526cc4f0aa 100644 --- a/contrib/btree_gist/sql/cash.sql +++ b/contrib/btree_gist/sql/cash.sql @@ -1,6 +1,6 @@ -- money check -CREATE TABLE moneytmp (a money) WITH OIDS; +CREATE TABLE moneytmp (a money); \copy moneytmp from 'data/cash.data' diff --git a/contrib/btree_gist/sql/oid.sql b/contrib/btree_gist/sql/oid.sql index fd03b82bd44..c9358234ce9 100644 --- a/contrib/btree_gist/sql/oid.sql +++ b/contrib/btree_gist/sql/oid.sql @@ -2,26 +2,29 @@ SET enable_seqscan=on; -SELECT count(*) FROM moneytmp WHERE oid < ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +CREATE TEMPORARY TABLE oidtmp (oid oid); +INSERT INTO oidtmp SELECT g.i::oid FROM generate_series(1, 1000) g(i); -SELECT count(*) FROM moneytmp WHERE oid <= ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid < 17; -SELECT count(*) FROM moneytmp WHERE oid = ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid <= 17; -SELECT count(*) FROM moneytmp WHERE oid >= ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid = 17; -SELECT count(*) FROM moneytmp WHERE oid > ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid >= 17; -CREATE INDEX oididx ON moneytmp USING gist ( oid ); +SELECT count(*) FROM oidtmp WHERE oid > 17; + +CREATE INDEX oididx ON oidtmp USING gist ( oid ); SET enable_seqscan=off; -SELECT count(*) FROM moneytmp WHERE oid < ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid < 17; -SELECT count(*) FROM moneytmp WHERE oid <= ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid <= 17; -SELECT count(*) FROM moneytmp WHERE oid = ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid = 17; -SELECT count(*) FROM moneytmp WHERE oid >= ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid >= 17; -SELECT count(*) FROM moneytmp WHERE oid > ( SELECT oid FROM moneytmp WHERE a = '22649.64' ); +SELECT count(*) FROM oidtmp WHERE oid > 17; diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index c6460688486..3b73ff13f19 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -849,7 +849,7 @@ materializeResult(FunctionCallInfo fcinfo, PGconn *conn, PGresult *res) * need a tuple descriptor representing one TEXT column to return * the command status string as our result tuple */ - tupdesc = CreateTemplateTupleDesc(1, false); + tupdesc = CreateTemplateTupleDesc(1); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status", TEXTOID, -1, 0); ntuples = 1; @@ -1032,7 +1032,7 @@ materializeQueryResult(FunctionCallInfo fcinfo, * need a tuple descriptor representing one TEXT column to return * the command status string as our result tuple */ - tupdesc = CreateTemplateTupleDesc(1, false); + tupdesc = CreateTemplateTupleDesc(1); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status", TEXTOID, -1, 0); attinmeta = TupleDescGetAttInMetadata(tupdesc); @@ -1526,7 +1526,7 @@ dblink_get_pkey(PG_FUNCTION_ARGS) /* * need a tuple descriptor representing one INT and one TEXT column */ - tupdesc = CreateTemplateTupleDesc(2, false); + tupdesc = CreateTemplateTupleDesc(2); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "position", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 2, "colname", @@ -1904,7 +1904,7 @@ dblink_get_notify(PG_FUNCTION_ARGS) per_query_ctx = rsinfo->econtext->ecxt_per_query_memory; oldcontext = MemoryContextSwitchTo(per_query_ctx); - tupdesc = CreateTemplateTupleDesc(DBLINK_NOTIFY_COLS, false); + tupdesc = CreateTemplateTupleDesc(DBLINK_NOTIFY_COLS); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "notify_name", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 2, "be_pid", diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index 2cf09aecf6e..4368d920413 100644 --- a/contrib/file_fdw/file_fdw.c +++ b/contrib/file_fdw/file_fdw.c @@ -727,8 +727,7 @@ fileIterateForeignScan(ForeignScanState *node) */ ExecClearTuple(slot); found = NextCopyFrom(festate->cstate, NULL, - slot->tts_values, slot->tts_isnull, - NULL); + slot->tts_values, slot->tts_isnull); if (found) ExecStoreVirtualTuple(slot); @@ -1148,7 +1147,7 @@ file_acquire_sample_rows(Relation onerel, int elevel, MemoryContextReset(tupcontext); MemoryContextSwitchTo(tupcontext); - found = NextCopyFrom(cstate, NULL, values, nulls, NULL); + found = NextCopyFrom(cstate, NULL, values, nulls); MemoryContextSwitchTo(oldcontext); diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c index d96ba1e8b61..f7986572555 100644 --- a/contrib/pageinspect/heapfuncs.c +++ b/contrib/pageinspect/heapfuncs.c @@ -35,6 +35,19 @@ #include "utils/builtins.h" #include "utils/rel.h" +/* + * It's not supported to create tuples with oids anymore, but when pg_upgrade + * was used to upgrade from an older version, tuples might still have an + * oid. Seems worthwhile to display that. + */ +#define HeapTupleHeaderGetOidOld(tup) \ +( \ + ((tup)->t_infomask & HEAP_HASOID_OLD) ? \ + *((Oid *) ((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) \ + : \ + InvalidOid \ +) + /* * bits_to_text @@ -241,8 +254,8 @@ heap_page_items(PG_FUNCTION_ARGS) else nulls[11] = true; - if (tuphdr->t_infomask & HEAP_HASOID) - values[12] = HeapTupleHeaderGetOid(tuphdr); + if (tuphdr->t_infomask & HEAP_HASOID_OLD) + values[12] = HeapTupleHeaderGetOidOld(tuphdr); else nulls[12] = true; } diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c index b410aafa5a9..1bd579fcbb0 100644 --- a/contrib/pg_buffercache/pg_buffercache_pages.c +++ b/contrib/pg_buffercache/pg_buffercache_pages.c @@ -99,7 +99,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) elog(ERROR, "incorrect number of output arguments"); /* Construct a tuple descriptor for the result rows. */ - tupledesc = CreateTemplateTupleDesc(expected_tupledesc->natts, false); + tupledesc = CreateTemplateTupleDesc(expected_tupledesc->natts); TupleDescInitEntry(tupledesc, (AttrNumber) 1, "bufferid", INT4OID, -1, 0); TupleDescInitEntry(tupledesc, (AttrNumber) 2, "relfilenode", diff --git a/contrib/pg_visibility/pg_visibility.c b/contrib/pg_visibility/pg_visibility.c index 944dea66fc8..c1aae9d6551 100644 --- a/contrib/pg_visibility/pg_visibility.c +++ b/contrib/pg_visibility/pg_visibility.c @@ -292,7 +292,7 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS) ReleaseBuffer(vmbuffer); relation_close(rel, AccessShareLock); - tupdesc = CreateTemplateTupleDesc(2, false); + tupdesc = CreateTemplateTupleDesc(2); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "all_visible", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 2, "all_frozen", INT8OID, -1, 0); tupdesc = BlessTupleDesc(tupdesc); @@ -447,7 +447,7 @@ pg_visibility_tupdesc(bool include_blkno, bool include_pd) ++maxattr; if (include_pd) ++maxattr; - tupdesc = CreateTemplateTupleDesc(maxattr, false); + tupdesc = CreateTemplateTupleDesc(maxattr); if (include_blkno) TupleDescInitEntry(tupdesc, ++a, "blkno", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, ++a, "all_visible", BOOLOID, -1, 0); diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c index 6001f4d25ef..654323f1554 100644 --- a/contrib/postgres_fdw/deparse.c +++ b/contrib/postgres_fdw/deparse.c @@ -332,14 +332,13 @@ foreign_expr_walker(Node *node, /* Var belongs to foreign table */ /* - * System columns other than ctid and oid should not be - * sent to the remote, since we don't make any effort to - * ensure that local and remote values match (tableoid, in + * System columns other than ctid should not be sent to + * the remote, since we don't make any effort to ensure + * that local and remote values match (tableoid, in * particular, almost certainly doesn't match). */ if (var->varattno < 0 && - var->varattno != SelfItemPointerAttributeNumber && - var->varattno != ObjectIdAttributeNumber) + var->varattno != SelfItemPointerAttributeNumber) return false; /* Else check the collation */ @@ -1145,8 +1144,8 @@ deparseTargetList(StringInfo buf, } /* - * Add ctid and oid if needed. We currently don't support retrieving any - * other system columns. + * Add ctid if needed. We currently don't support retrieving any other + * system columns. */ if (bms_is_member(SelfItemPointerAttributeNumber - FirstLowInvalidHeapAttributeNumber, attrs_used)) @@ -1164,22 +1163,6 @@ deparseTargetList(StringInfo buf, *retrieved_attrs = lappend_int(*retrieved_attrs, SelfItemPointerAttributeNumber); } - if (bms_is_member(ObjectIdAttributeNumber - FirstLowInvalidHeapAttributeNumber, - attrs_used)) - { - if (!first) - appendStringInfoString(buf, ", "); - else if (is_returning) - appendStringInfoString(buf, " RETURNING "); - first = false; - - if (qualify_col) - ADD_REL_QUALIFIER(buf, rtindex); - appendStringInfoString(buf, "oid"); - - *retrieved_attrs = lappend_int(*retrieved_attrs, - ObjectIdAttributeNumber); - } /* Don't generate bad syntax if no undropped columns */ if (first && !is_returning) @@ -2079,12 +2062,6 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte, ADD_REL_QUALIFIER(buf, varno); appendStringInfoString(buf, "ctid"); } - else if (varattno == ObjectIdAttributeNumber) - { - if (qualify_col) - ADD_REL_QUALIFIER(buf, varno); - appendStringInfoString(buf, "oid"); - } else if (varattno < 0) { /* diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out index 21a2ef5ad3a..e653c302bec 100644 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@ -129,13 +129,6 @@ CREATE FOREIGN TABLE ft6 ( c2 int NOT NULL, c3 text ) SERVER loopback2 OPTIONS (schema_name 'S 1', table_name 'T 4'); --- A table with oids. CREATE FOREIGN TABLE doesn't support the --- WITH OIDS option, but ALTER does. -CREATE FOREIGN TABLE ft_pg_type ( - typname name, - typlen smallint -) SERVER loopback OPTIONS (schema_name 'pg_catalog', table_name 'pg_type'); -ALTER TABLE ft_pg_type SET WITH OIDS; -- =================================================================== -- tests for validator -- =================================================================== @@ -185,16 +178,15 @@ ALTER FOREIGN TABLE ft2 OPTIONS (schema_name 'S 1', table_name 'T 1'); ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); ALTER FOREIGN TABLE ft2 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); \det+ - List of foreign tables - Schema | Table | Server | FDW options | Description ---------+------------+-----------+--------------------------------------------------+------------- - public | ft1 | loopback | (schema_name 'S 1', table_name 'T 1') | - public | ft2 | loopback | (schema_name 'S 1', table_name 'T 1') | - public | ft4 | loopback | (schema_name 'S 1', table_name 'T 3') | - public | ft5 | loopback | (schema_name 'S 1', table_name 'T 4') | - public | ft6 | loopback2 | (schema_name 'S 1', table_name 'T 4') | - public | ft_pg_type | loopback | (schema_name 'pg_catalog', table_name 'pg_type') | -(6 rows) + List of foreign tables + Schema | Table | Server | FDW options | Description +--------+-------+-----------+---------------------------------------+------------- + public | ft1 | loopback | (schema_name 'S 1', table_name 'T 1') | + public | ft2 | loopback | (schema_name 'S 1', table_name 'T 1') | + public | ft4 | loopback | (schema_name 'S 1', table_name 'T 3') | + public | ft5 | loopback | (schema_name 'S 1', table_name 'T 4') | + public | ft6 | loopback2 | (schema_name 'S 1', table_name 'T 4') | +(5 rows) -- Test that alteration of server options causes reconnection -- Remote's errors might be non-English, so hide them to ensure stable results @@ -4048,21 +4040,6 @@ SELECT ctid, * FROM ft1 t1 LIMIT 1; (0,1) | 1 | 1 | 00001 | Fri Jan 02 00:00:00 1970 PST | Fri Jan 02 00:00:00 1970 | 1 | 1 | foo (1 row) -EXPLAIN (VERBOSE, COSTS OFF) -SELECT oid, * FROM ft_pg_type WHERE typname = 'int4'; - QUERY PLAN ----------------------------------------------------------------------------------------------------- - Foreign Scan on public.ft_pg_type - Output: oid, typname, typlen - Remote SQL: SELECT typname, typlen, oid FROM pg_catalog.pg_type WHERE ((typname = 'int4'::name)) -(3 rows) - -SELECT oid, * FROM ft_pg_type WHERE typname = 'int4'; - oid | typname | typlen ------+---------+-------- - 23 | int4 | 4 -(1 row) - -- =================================================================== -- used in PL/pgSQL function -- =================================================================== diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index 6f9c6e193fc..a5830bb89b3 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -3632,8 +3632,7 @@ build_remote_returning(Index rtindex, Relation rel, List *returningList) if (IsA(var, Var) && var->varno == rtindex && var->varattno <= InvalidAttrNumber && - var->varattno != SelfItemPointerAttributeNumber && - var->varattno != ObjectIdAttributeNumber) + var->varattno != SelfItemPointerAttributeNumber) continue; /* don't need it */ if (tlist_member((Expr *) var, tlist)) @@ -3864,8 +3863,6 @@ init_returning_filter(PgFdwDirectModifyState *dmstate, */ if (attrno == SelfItemPointerAttributeNumber) dmstate->ctidAttno = i; - else if (attrno == ObjectIdAttributeNumber) - dmstate->oidAttno = i; else Assert(false); dmstate->hasSystemCols = true; @@ -3963,15 +3960,6 @@ apply_returning_filter(PgFdwDirectModifyState *dmstate, resultTup->t_self = *ctid; } - /* oid */ - if (dmstate->oidAttno) - { - Oid oid = InvalidOid; - - oid = DatumGetObjectId(old_values[dmstate->oidAttno - 1]); - HeapTupleSetOid(resultTup, oid); - } - /* * And remaining columns * @@ -5556,7 +5544,6 @@ make_tuple_from_result_row(PGresult *res, Datum *values; bool *nulls; ItemPointer ctid = NULL; - Oid oid = InvalidOid; ConversionLocation errpos; ErrorContextCallback errcallback; MemoryContext oldcontext; @@ -5639,17 +5626,6 @@ make_tuple_from_result_row(PGresult *res, ctid = (ItemPointer) DatumGetPointer(datum); } } - else if (i == ObjectIdAttributeNumber) - { - /* oid */ - if (valstr != NULL) - { - Datum datum; - - datum = DirectFunctionCall1(oidin, CStringGetDatum(valstr)); - oid = DatumGetObjectId(datum); - } - } errpos.cur_attno = 0; j++; @@ -5693,12 +5669,6 @@ make_tuple_from_result_row(PGresult *res, HeapTupleHeaderSetXmin(tuple->t_data, InvalidTransactionId); HeapTupleHeaderSetCmin(tuple->t_data, InvalidTransactionId); - /* - * If we have an OID to return, install it. - */ - if (OidIsValid(oid)) - HeapTupleSetOid(tuple, oid); - /* Clean up */ MemoryContextReset(temp_context); @@ -5727,8 +5697,6 @@ conversion_error_callback(void *arg) attname = NameStr(attr->attname); else if (errpos->cur_attno == SelfItemPointerAttributeNumber) attname = "ctid"; - else if (errpos->cur_attno == ObjectIdAttributeNumber) - attname = "oid"; relname = RelationGetRelationName(errpos->rel); } diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql index 88c4cb4783f..6aa9a7f4d9b 100644 --- a/contrib/postgres_fdw/sql/postgres_fdw.sql +++ b/contrib/postgres_fdw/sql/postgres_fdw.sql @@ -142,14 +142,6 @@ CREATE FOREIGN TABLE ft6 ( c3 text ) SERVER loopback2 OPTIONS (schema_name 'S 1', table_name 'T 4'); --- A table with oids. CREATE FOREIGN TABLE doesn't support the --- WITH OIDS option, but ALTER does. -CREATE FOREIGN TABLE ft_pg_type ( - typname name, - typlen smallint -) SERVER loopback OPTIONS (schema_name 'pg_catalog', table_name 'pg_type'); -ALTER TABLE ft_pg_type SET WITH OIDS; - -- =================================================================== -- tests for validator -- =================================================================== @@ -1002,9 +994,6 @@ SELECT * FROM ft1 t1 WHERE t1.ctid = '(0,2)'; EXPLAIN (VERBOSE, COSTS OFF) SELECT ctid, * FROM ft1 t1 LIMIT 1; SELECT ctid, * FROM ft1 t1 LIMIT 1; -EXPLAIN (VERBOSE, COSTS OFF) -SELECT oid, * FROM ft_pg_type WHERE typname = 'int4'; -SELECT oid, * FROM ft_pg_type WHERE typname = 'int4'; -- =================================================================== -- used in PL/pgSQL function diff --git a/contrib/sepgsql/expected/alter.out b/contrib/sepgsql/expected/alter.out index e1d31e5b2fa..b27274d83ec 100644 --- a/contrib/sepgsql/expected/alter.out +++ b/contrib/sepgsql/expected/alter.out @@ -212,16 +212,6 @@ ALTER TABLE regtest_table ENABLE TRIGGER regtest_test_trig; -- not supported CREATE RULE regtest_test_rule AS ON INSERT TO regtest_table_3 DO ALSO NOTHING; ALTER TABLE regtest_table_3 DISABLE RULE regtest_test_rule; -- not supported ALTER TABLE regtest_table_3 ENABLE RULE regtest_test_rule; -- not supported -ALTER TABLE regtest_table SET WITH OIDS; -LOG: SELinux: allowed { create } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema_2.regtest_table.oid" -LOG: SELinux: allowed { create } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_table_2.oid" -ALTER TABLE regtest_table SET WITHOUT OIDS; -LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_table_2.oid" -LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema_2.regtest_table.oid" -ALTER TABLE regtest_table SET (fillfactor = 75); -LOG: SELinux: allowed { setattr } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_table name="regtest_schema_2.regtest_table" -ALTER TABLE regtest_table RESET (fillfactor); -LOG: SELinux: allowed { setattr } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_table name="regtest_schema_2.regtest_table" ALTER TABLE regtest_table_2 NO INHERIT regtest_table; -- not supported ALTER TABLE regtest_table_2 INHERIT regtest_table; -- not supported ALTER TABLE regtest_table SET TABLESPACE pg_default; @@ -265,14 +255,6 @@ LOG: SELinux: allowed { setattr } scontext=unconfined_u:unconfined_r:sepgsql_re LOG: SELinux: allowed { setattr } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_ptable_1_tens.p" ALTER TABLE regtest_ptable ADD CONSTRAINT test_ck CHECK (p like '%abc%') NOT VALID; -- not supported by sepgsql ALTER TABLE regtest_ptable DROP CONSTRAINT test_ck; -- not supported by sepgsql -ALTER TABLE regtest_ptable SET WITH OIDS; -LOG: SELinux: allowed { create } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema_2.regtest_ptable.oid" -LOG: SELinux: allowed { create } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema_2.regtest_table_part.oid" -LOG: SELinux: allowed { create } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_ptable_1_tens.oid" -ALTER TABLE regtest_ptable SET WITHOUT OIDS; -LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema_2.regtest_table_part.oid" -LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_ptable_1_tens.oid" -LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema_2.regtest_ptable.oid" ALTER TABLE regtest_ptable SET TABLESPACE pg_default; -- partitioned table child ALTER TABLE regtest_table_part ALTER p SET DEFAULT 'abcd'; -- not supported by sepgsql diff --git a/contrib/sepgsql/expected/ddl.out b/contrib/sepgsql/expected/ddl.out index 1c0409a7a65..9c5c6061390 100644 --- a/contrib/sepgsql/expected/ddl.out +++ b/contrib/sepgsql/expected/ddl.out @@ -61,9 +61,9 @@ LINE 1: ALTER TABLE regtest_table ADD COLUMN z int; ^ LOG: SELinux: allowed { search } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=system_u:object_r:sepgsql_schema_t:s0 tclass=db_schema name="pg_catalog" LOG: SELinux: allowed { create } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_table.z" -CREATE TABLE regtest_table_2 (a int) WITH OIDS; +CREATE TABLE regtest_table_2 (a int); LOG: SELinux: allowed { search } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=system_u:object_r:sepgsql_schema_t:s0 tclass=db_schema name="pg_catalog" -LINE 1: CREATE TABLE regtest_table_2 (a int) WITH OIDS; +LINE 1: CREATE TABLE regtest_table_2 (a int); ^ LOG: SELinux: allowed { search } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=system_u:object_r:sepgsql_schema_t:s0 tclass=db_schema name="pg_catalog" LOG: SELinux: allowed { add_name } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_schema_t:s0 tclass=db_schema name="regtest_schema" @@ -413,8 +413,6 @@ LOG: SELinux: allowed { remove_name } scontext=unconfined_u:unconfined_r:sepgsq LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_view_t:s0 tclass=db_view name="regtest_schema.regtest_view" ALTER TABLE regtest_table DROP COLUMN y; LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_table.y" -ALTER TABLE regtest_table_2 SET WITHOUT OIDS; -LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_table_2.oid" ALTER TABLE regtest_ptable DROP COLUMN q CASCADE; LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_ptable_ones.q" LOG: SELinux: allowed { drop } scontext=unconfined_u:unconfined_r:sepgsql_regtest_superuser_t:s0 tcontext=unconfined_u:object_r:sepgsql_table_t:s0 tclass=db_column name="regtest_schema.regtest_ptable_tens.q" diff --git a/contrib/sepgsql/label.c b/contrib/sepgsql/label.c index dba0986e02a..acffc468d28 100644 --- a/contrib/sepgsql/label.c +++ b/contrib/sepgsql/label.c @@ -758,7 +758,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) NULL, NULL, NULL); object.classId = DatabaseRelationId; - object.objectId = HeapTupleGetOid(tuple); + object.objectId = datForm->oid; object.objectSubId = 0; break; @@ -772,7 +772,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) NULL, NULL); object.classId = NamespaceRelationId; - object.objectId = HeapTupleGetOid(tuple); + object.objectId = nspForm->oid; object.objectSubId = 0; break; @@ -797,7 +797,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) pfree(namespace_name); object.classId = RelationRelationId; - object.objectId = HeapTupleGetOid(tuple); + object.objectId = relForm->oid; object.objectSubId = 0; break; @@ -838,7 +838,7 @@ exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId) pfree(namespace_name); object.classId = ProcedureRelationId; - object.objectId = HeapTupleGetOid(tuple); + object.objectId = proForm->oid; object.objectSubId = 0; break; diff --git a/contrib/sepgsql/sql/alter.sql b/contrib/sepgsql/sql/alter.sql index 14000eaaeeb..f1144492329 100644 --- a/contrib/sepgsql/sql/alter.sql +++ b/contrib/sepgsql/sql/alter.sql @@ -134,8 +134,6 @@ CREATE RULE regtest_test_rule AS ON INSERT TO regtest_table_3 DO ALSO NOTHING; ALTER TABLE regtest_table_3 DISABLE RULE regtest_test_rule; -- not supported ALTER TABLE regtest_table_3 ENABLE RULE regtest_test_rule; -- not supported -ALTER TABLE regtest_table SET WITH OIDS; -ALTER TABLE regtest_table SET WITHOUT OIDS; ALTER TABLE regtest_table SET (fillfactor = 75); ALTER TABLE regtest_table RESET (fillfactor); ALTER TABLE regtest_table_2 NO INHERIT regtest_table; -- not supported @@ -157,8 +155,6 @@ ALTER TABLE regtest_ptable ALTER p SET STORAGE PLAIN; ALTER TABLE regtest_ptable ADD CONSTRAINT test_ck CHECK (p like '%abc%') NOT VALID; -- not supported by sepgsql ALTER TABLE regtest_ptable DROP CONSTRAINT test_ck; -- not supported by sepgsql -ALTER TABLE regtest_ptable SET WITH OIDS; -ALTER TABLE regtest_ptable SET WITHOUT OIDS; ALTER TABLE regtest_ptable SET TABLESPACE pg_default; -- partitioned table child diff --git a/contrib/sepgsql/sql/ddl.sql b/contrib/sepgsql/sql/ddl.sql index ae431f6cd2a..3deadb62526 100644 --- a/contrib/sepgsql/sql/ddl.sql +++ b/contrib/sepgsql/sql/ddl.sql @@ -30,7 +30,7 @@ CREATE TABLE regtest_table (x serial primary key, y text); ALTER TABLE regtest_table ADD COLUMN z int; -CREATE TABLE regtest_table_2 (a int) WITH OIDS; +CREATE TABLE regtest_table_2 (a int); CREATE TABLE regtest_ptable (a int) PARTITION BY RANGE (a); CREATE TABLE regtest_ptable_ones PARTITION OF regtest_ptable FOR VALUES FROM ('0') TO ('10'); @@ -112,7 +112,6 @@ DROP SEQUENCE regtest_seq; DROP VIEW regtest_view; ALTER TABLE regtest_table DROP COLUMN y; -ALTER TABLE regtest_table_2 SET WITHOUT OIDS; ALTER TABLE regtest_ptable DROP COLUMN q CASCADE; diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c index 1c439b57b0e..f6e77fbda13 100644 --- a/contrib/test_decoding/test_decoding.c +++ b/contrib/test_decoding/test_decoding.c @@ -319,13 +319,6 @@ static void tuple_to_stringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool skip_nulls) { int natt; - Oid oid; - - /* print oid of tuple, it's not included in the TupleDesc */ - if ((oid = HeapTupleHeaderGetOid(tuple->t_data)) != InvalidOid) - { - appendStringInfo(s, " oid[oid]:%u", oid); - } /* print all columns individually */ for (natt = 0; natt < tupdesc->natts; natt++) diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c index dbf2bb9602f..8bce9b35e1d 100644 --- a/contrib/unaccent/unaccent.c +++ b/contrib/unaccent/unaccent.c @@ -14,6 +14,7 @@ #include "postgres.h" #include "catalog/namespace.h" +#include "catalog/pg_ts_dict.h" #include "commands/defrem.h" #include "lib/stringinfo.h" #include "tsearch/ts_cache.h" @@ -385,7 +386,7 @@ unaccent_dict(PG_FUNCTION_ARGS) Oid procnspid = get_func_namespace(fcinfo->flinfo->fn_oid); const char *dictname = "unaccent"; - dictOid = GetSysCacheOid2(TSDICTNAMENSP, + dictOid = GetSysCacheOid2(TSDICTNAMENSP, Anum_pg_ts_dict_oid, PointerGetDatum(dictname), ObjectIdGetDatum(procnspid)); if (!OidIsValid(dictOid)) |