Remove WITH OIDs support. oidnix
authorAndres Freund <[email protected]>
Tue, 20 Nov 2018 09:47:23 +0000 (01:47 -0800)
committerAndres Freund <[email protected]>
Tue, 20 Nov 2018 09:48:31 +0000 (01:48 -0800)
System table oids are now normal columns.

Author: Andres Freund
Discussion: https://postgr.es/m/20180930034810[email protected]

341 files changed:
contrib/adminpack/adminpack.c
contrib/btree_gist/expected/cash.out
contrib/btree_gist/expected/oid.out
contrib/btree_gist/sql/cash.sql
contrib/btree_gist/sql/oid.sql
contrib/dblink/dblink.c
contrib/file_fdw/file_fdw.c
contrib/pageinspect/heapfuncs.c
contrib/pg_buffercache/pg_buffercache_pages.c
contrib/pg_visibility/pg_visibility.c
contrib/postgres_fdw/deparse.c
contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/postgres_fdw.c
contrib/postgres_fdw/sql/postgres_fdw.sql
contrib/sepgsql/expected/alter.out
contrib/sepgsql/expected/ddl.out
contrib/sepgsql/label.c
contrib/sepgsql/sql/alter.sql
contrib/sepgsql/sql/ddl.sql
contrib/test_decoding/test_decoding.c
contrib/unaccent/unaccent.c
doc/src/sgml/catalogs.sgml
doc/src/sgml/config.sgml
doc/src/sgml/datatype.sgml
doc/src/sgml/ddl.sgml
doc/src/sgml/file-fdw.sgml
doc/src/sgml/plpgsql.sgml
doc/src/sgml/pltcl.sgml
doc/src/sgml/protocol.sgml
doc/src/sgml/ref/alter_foreign_table.sgml
doc/src/sgml/ref/alter_table.sgml
doc/src/sgml/ref/copy.sgml
doc/src/sgml/ref/create_materialized_view.sgml
doc/src/sgml/ref/create_table.sgml
doc/src/sgml/ref/create_table_as.sgml
doc/src/sgml/ref/pg_dump.sgml
doc/src/sgml/ref/select_into.sgml
doc/src/sgml/release-9.1.sgml
doc/src/sgml/release-9.2.sgml
doc/src/sgml/release-9.3.sgml
src/backend/access/brin/brin_tuple.c
src/backend/access/common/heaptuple.c
src/backend/access/common/reloptions.c
src/backend/access/common/tupconvert.c
src/backend/access/common/tupdesc.c
src/backend/access/gin/ginutil.c
src/backend/access/gist/gistscan.c
src/backend/access/heap/heapam.c
src/backend/access/heap/tuptoaster.c
src/backend/access/transam/commit_ts.c
src/backend/access/transam/multixact.c
src/backend/access/transam/twophase.c
src/backend/access/transam/varsup.c
src/backend/access/transam/xlogfuncs.c
src/backend/bootstrap/bootparse.y
src/backend/bootstrap/bootscanner.l
src/backend/bootstrap/bootstrap.c
src/backend/catalog/Catalog.pm
src/backend/catalog/aclchk.c
src/backend/catalog/catalog.c
src/backend/catalog/genbki.pl
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/indexing.c
src/backend/catalog/information_schema.sql
src/backend/catalog/namespace.c
src/backend/catalog/objectaddress.c
src/backend/catalog/pg_aggregate.c
src/backend/catalog/pg_collation.c
src/backend/catalog/pg_constraint.c
src/backend/catalog/pg_conversion.c
src/backend/catalog/pg_enum.c
src/backend/catalog/pg_largeobject.c
src/backend/catalog/pg_namespace.c
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_publication.c
src/backend/catalog/pg_subscription.c
src/backend/catalog/pg_type.c
src/backend/catalog/toasting.c
src/backend/commands/alter.c
src/backend/commands/amcmds.c
src/backend/commands/cluster.c
src/backend/commands/copy.c
src/backend/commands/createas.c
src/backend/commands/dbcommands.c
src/backend/commands/event_trigger.c
src/backend/commands/explain.c
src/backend/commands/extension.c
src/backend/commands/foreigncmds.c
src/backend/commands/functioncmds.c
src/backend/commands/indexcmds.c
src/backend/commands/matview.c
src/backend/commands/opclasscmds.c
src/backend/commands/policy.c
src/backend/commands/prepare.c
src/backend/commands/proclang.c
src/backend/commands/publicationcmds.c
src/backend/commands/schemacmds.c
src/backend/commands/sequence.c
src/backend/commands/statscmds.c
src/backend/commands/subscriptioncmds.c
src/backend/commands/tablecmds.c
src/backend/commands/tablespace.c
src/backend/commands/trigger.c
src/backend/commands/tsearchcmds.c
src/backend/commands/typecmds.c
src/backend/commands/user.c
src/backend/commands/vacuum.c
src/backend/commands/vacuumlazy.c
src/backend/commands/variable.c
src/backend/commands/view.c
src/backend/executor/execExpr.c
src/backend/executor/execJunk.c
src/backend/executor/execMain.c
src/backend/executor/execPartition.c
src/backend/executor/execSRF.c
src/backend/executor/execTuples.c
src/backend/executor/execUtils.c
src/backend/executor/functions.c
src/backend/executor/nodeAgg.c
src/backend/executor/nodeCustom.c
src/backend/executor/nodeForeignscan.c
src/backend/executor/nodeFunctionscan.c
src/backend/executor/nodeIndexonlyscan.c
src/backend/executor/nodeModifyTable.c
src/backend/executor/nodeSubplan.c
src/backend/executor/spi.c
src/backend/foreign/foreign.c
src/backend/optimizer/util/plancat.c
src/backend/parser/gram.y
src/backend/parser/parse_clause.c
src/backend/parser/parse_oper.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/backend/parser/parse_type.c
src/backend/parser/parse_utilcmd.c
src/backend/postmaster/autovacuum.c
src/backend/postmaster/pgstat.c
src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
src/backend/replication/logical/launcher.c
src/backend/replication/walsender.c
src/backend/rewrite/rewriteDefine.c
src/backend/rewrite/rewriteRemove.c
src/backend/rewrite/rewriteSupport.c
src/backend/statistics/extended_stats.c
src/backend/storage/large_object/inv_api.c
src/backend/tcop/pquery.c
src/backend/tsearch/wparser.c
src/backend/utils/adt/acl.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/enum.c
src/backend/utils/adt/expandedrecord.c
src/backend/utils/adt/genfile.c
src/backend/utils/adt/lockfuncs.c
src/backend/utils/adt/misc.c
src/backend/utils/adt/orderedsetaggs.c
src/backend/utils/adt/partitionfuncs.c
src/backend/utils/adt/pgstatfuncs.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/trigfuncs.c
src/backend/utils/adt/tsvector_op.c
src/backend/utils/cache/catcache.c
src/backend/utils/cache/inval.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/plancache.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/relfilenodemap.c
src/backend/utils/cache/syscache.c
src/backend/utils/cache/typcache.c
src/backend/utils/fmgr/fmgr.c
src/backend/utils/fmgr/funcapi.c
src/backend/utils/init/miscinit.c
src/backend/utils/init/postinit.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/pg_controldata.c
src/backend/utils/misc/postgresql.conf.sample
src/backend/utils/mmgr/portalmem.c
src/bin/initdb/initdb.c
src/bin/pg_dump/pg_backup.h
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.h
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/t/001_basic.pl
src/bin/pg_dump/t/002_pg_dump.pl
src/bin/pg_upgrade/check.c
src/bin/pgbench/t/001_pgbench_with_server.pl
src/bin/psql/describe.c
src/bin/psql/tab-complete.c
src/include/access/heapam.h
src/include/access/htup_details.h
src/include/access/reloptions.h
src/include/access/sysattr.h
src/include/access/tupdesc.h
src/include/catalog/catalog.h
src/include/catalog/catversion.h
src/include/catalog/genbki.h
src/include/catalog/heap.h
src/include/catalog/indexing.h
src/include/catalog/objectaddress.h
src/include/catalog/pg_aggregate.h
src/include/catalog/pg_am.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_attrdef.h
src/include/catalog/pg_attribute.h
src/include/catalog/pg_auth_members.h
src/include/catalog/pg_authid.h
src/include/catalog/pg_cast.h
src/include/catalog/pg_class.dat
src/include/catalog/pg_class.h
src/include/catalog/pg_collation.h
src/include/catalog/pg_constraint.h
src/include/catalog/pg_conversion.h
src/include/catalog/pg_database.h
src/include/catalog/pg_db_role_setting.h
src/include/catalog/pg_default_acl.h
src/include/catalog/pg_depend.h
src/include/catalog/pg_description.h
src/include/catalog/pg_enum.h
src/include/catalog/pg_event_trigger.h
src/include/catalog/pg_extension.h
src/include/catalog/pg_foreign_data_wrapper.h
src/include/catalog/pg_foreign_server.h
src/include/catalog/pg_foreign_table.h
src/include/catalog/pg_index.h
src/include/catalog/pg_inherits.h
src/include/catalog/pg_init_privs.h
src/include/catalog/pg_language.h
src/include/catalog/pg_largeobject.h
src/include/catalog/pg_largeobject_metadata.h
src/include/catalog/pg_namespace.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_opfamily.h
src/include/catalog/pg_partitioned_table.h
src/include/catalog/pg_pltemplate.h
src/include/catalog/pg_policy.h
src/include/catalog/pg_proc.dat
src/include/catalog/pg_proc.h
src/include/catalog/pg_publication.h
src/include/catalog/pg_publication_rel.h
src/include/catalog/pg_range.h
src/include/catalog/pg_replication_origin.h
src/include/catalog/pg_rewrite.h
src/include/catalog/pg_seclabel.h
src/include/catalog/pg_sequence.h
src/include/catalog/pg_shdepend.h
src/include/catalog/pg_shdescription.h
src/include/catalog/pg_shseclabel.h
src/include/catalog/pg_statistic.h
src/include/catalog/pg_statistic_ext.h
src/include/catalog/pg_subscription.h
src/include/catalog/pg_subscription_rel.h
src/include/catalog/pg_tablespace.h
src/include/catalog/pg_transform.h
src/include/catalog/pg_trigger.h
src/include/catalog/pg_ts_config.h
src/include/catalog/pg_ts_config_map.h
src/include/catalog/pg_ts_dict.h
src/include/catalog/pg_ts_parser.h
src/include/catalog/pg_ts_template.h
src/include/catalog/pg_type.h
src/include/catalog/pg_user_mapping.h
src/include/catalog/reformat_dat_file.pl
src/include/commands/copy.h
src/include/commands/event_trigger.h
src/include/executor/executor.h
src/include/executor/spi.h
src/include/executor/spi_priv.h
src/include/nodes/execnodes.h
src/include/nodes/parsenodes.h
src/include/parser/parse_clause.h
src/include/utils/guc.h
src/include/utils/rel.h
src/include/utils/relcache.h
src/include/utils/syscache.h
src/interfaces/ecpg/preproc/ecpg.addons
src/pl/plperl/plperl.c
src/pl/plpgsql/src/pl_comp.c
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/pl_funcs.c
src/pl/plpgsql/src/pl_gram.y
src/pl/plpgsql/src/pl_scanner.c
src/pl/plpgsql/src/plpgsql.h
src/pl/tcl/expected/pltcl_queries.out
src/pl/tcl/expected/pltcl_setup.out
src/pl/tcl/pltcl.c
src/pl/tcl/sql/pltcl_queries.sql
src/pl/tcl/sql/pltcl_setup.sql
src/test/modules/test_ddl_deparse/expected/create_table.out
src/test/modules/test_ddl_deparse/sql/create_table.sql
src/test/modules/test_ddl_deparse/test_ddl_deparse.c
src/test/modules/test_predtest/test_predtest.c
src/test/regress/expected/alter_table.out
src/test/regress/expected/copy2.out
src/test/regress/expected/create_index.out
src/test/regress/expected/create_table.out
src/test/regress/expected/create_table_like.out
src/test/regress/expected/enum.out
src/test/regress/expected/errors.out
src/test/regress/expected/foreign_data.out
src/test/regress/expected/inherit.out
src/test/regress/expected/insert_conflict.out
src/test/regress/expected/misc_sanity.out
src/test/regress/expected/opr_sanity.out
src/test/regress/expected/prepare.out
src/test/regress/expected/privileges.out
src/test/regress/expected/reloptions.out
src/test/regress/expected/replica_identity.out
src/test/regress/expected/roleattributes.out
src/test/regress/expected/rowsecurity.out
src/test/regress/expected/rowtypes.out
src/test/regress/expected/sanity_check.out
src/test/regress/expected/triggers.out
src/test/regress/expected/without_oid.out [deleted file]
src/test/regress/parallel_schedule
src/test/regress/serial_schedule
src/test/regress/sql/alter_table.sql
src/test/regress/sql/copy2.sql
src/test/regress/sql/create_index.sql
src/test/regress/sql/create_table.sql
src/test/regress/sql/create_table_like.sql
src/test/regress/sql/errors.sql
src/test/regress/sql/foreign_data.sql
src/test/regress/sql/inherit.sql
src/test/regress/sql/insert_conflict.sql
src/test/regress/sql/misc_sanity.sql
src/test/regress/sql/prepare.sql
src/test/regress/sql/privileges.sql
src/test/regress/sql/reloptions.sql
src/test/regress/sql/replica_identity.sql
src/test/regress/sql/roleattributes.sql
src/test/regress/sql/rowsecurity.sql
src/test/regress/sql/rowtypes.sql
src/test/regress/sql/sanity_check.sql
src/test/regress/sql/triggers.sql
src/test/regress/sql/without_oid.sql [deleted file]
src/tools/findoidjoins/findoidjoins.c

index 0a27701e9c6f19f0f5aa428d2110da6c618a5b69..ea0ec201f0d72cd545bed19b00bdf41a555b9312 100644 (file)
@@ -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",
index cacbd718541fd98769c5154491dc71f4099ce974..7fbc7355929a1b944ab9738e651b955ee99c29d0 100644 (file)
@@ -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';
index ffa90c3c3c7f2609e4ecbec931d56025cc6aede4..776bbb10267c4366d3a195a41dd818994a87700e 100644 (file)
@@ -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)
 
index 0e037984e1b6a90e00822888110cbfb5aed2beb2..4526cc4f0aa63248b852f105eb73139be5cfe696 100644 (file)
@@ -1,6 +1,6 @@
 -- money check
 
-CREATE TABLE moneytmp (a money) WITH OIDS;
+CREATE TABLE moneytmp (a money);
 
 \copy moneytmp from 'data/cash.data'
 
index fd03b82bd440114ebb69f012aca781a454d5c9a9..c9358234ce9f4af65a16a3cf0b8056c61d878819 100644 (file)
@@ -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;
index c6460688486544e006a6f31ebf6352a1274fce56..3b73ff13f19a7b293807fa0f37ac96decb0c42e1 100644 (file)
@@ -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",
index 2cf09aecf6eb76d6b4e499272d863e2909959316..4368d92041303e63d716f589a5bbe00fefebf5a8 100644 (file)
@@ -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);
 
index d96ba1e8b610db687a20f45fcc92db0b7b60fe91..f7986572555ea450a983f6d810fe8d6af97de5a2 100644 (file)
 #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;
            }
index b410aafa5a904ad61eeaf10b3978f3d10a4b0a33..1bd579fcbb0caeb0ddfe4277103da5474adacc5c 100644 (file)
@@ -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",
index 944dea66fc8641bb744fe7d520014116721da2a5..c1aae9d655121a10892c69f29689087173e7bc04 100644 (file)
@@ -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);
index 6001f4d25efdb6fbc56b80c8beb1df723964622f..654323f1554438cf031a002f0034b673fcf631e0 100644 (file)
@@ -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)
    {
        /*
index 21a2ef5ad3a8eb02c34d0e36c9962d0d0f888fce..e653c302becb985519a52ad6b588ce6b5fbeb482 100644 (file)
@@ -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
 -- ===================================================================
index 6f9c6e193fcce9035810b500636e15a59f85d3a9..a5830bb89b3ce109d541da4c91157e23872cbffd 100644 (file)
@@ -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);
    }
index 88c4cb4783f319fd21d91aa44b727f804f85d50b..6aa9a7f4d9bdf2db4679d4365959d65582357dde 100644 (file)
@@ -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
index e1d31e5b2fab47b9f12a57106596f87106614c98..b27274d83ec7312bee0a78dc4c9afd8af2d519fe 100644 (file)
@@ -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
index 1c0409a7a6532568a72d51b87faec439d0452945..9c5c6061390849463e3542446ec52d544521a756 100644 (file)
@@ -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"
index dba0986e02a85b9bae57d70bba65395534967f28..acffc468d284255f190b596ddec0f0a9b9ab766d 100644 (file)
@@ -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;
 
index 14000eaaeebcfa2a82994c3f4b1d73306906aec1..f1144492329b3fb678092cf52380a27f9aa2e26d 100644 (file)
@@ -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
index ae431f6cd2aa6c2556b56e9748bea88de1e77d50..3deadb625262900b837cbe446616f259fe3bb6e6 100644 (file)
@@ -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;
 
index 1c439b57b0ea7469a19ed29e4fb168d25709674e..f6e77fbda13828921bf5744ac5438658f25afa09 100644 (file)
@@ -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++)
index dbf2bb9602f50181cc6b4906356969ef05958c8f..8bce9b35e1da5db9a2639639e2dae111cbd7d44c 100644 (file)
@@ -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))
index 8b7f169d50c34d4d56ff69b7e3304dff586ba8b8..c134bca8096db5a8d2a3604bd842f95e136bca8a 100644 (file)
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
      <row>
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -1538,7 +1538,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -1661,7 +1661,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -1853,15 +1853,6 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       </entry>
      </row>
 
-     <row>
-      <entry><structfield>relhasoids</structfield></entry>
-      <entry><type>bool</type></entry>
-      <entry></entry>
-      <entry>
-       True if we generate an OID for each row of the relation
-      </entry>
-     </row>
-
      <row>
       <entry><structfield>relhasrules</structfield></entry>
       <entry><type>bool</type></entry>
@@ -2055,7 +2046,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -2193,7 +2184,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -2460,7 +2451,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -2560,7 +2551,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -2790,7 +2781,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -3188,7 +3179,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -3351,7 +3342,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -3454,7 +3445,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -3553,7 +3544,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -4106,7 +4097,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -4313,7 +4304,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -4373,7 +4364,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -4448,7 +4439,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -4553,7 +4544,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -4710,7 +4701,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -5120,7 +5111,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -5458,7 +5449,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -5734,7 +5725,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -6616,7 +6607,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -6797,7 +6788,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -6940,7 +6931,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -7149,7 +7140,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -7295,7 +7286,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -7378,7 +7369,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -7475,7 +7466,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -7549,7 +7540,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
@@ -8061,7 +8052,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       <entry><structfield>oid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry></entry>
-      <entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
+      <entry>Row identifier</entry>
      </row>
 
      <row>
index c4effa034c12e6d8831bbbc88635f612e3fa9282..2dad07e5729656d5e37ff001cdbdc20927611d4c 100644 (file)
@@ -7898,35 +7898,6 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
       </listitem>
      </varlistentry>
 
-     <varlistentry id="guc-default-with-oids" xreflabel="default_with_oids">
-      <term><varname>default_with_oids</varname> (<type>boolean</type>)
-      <indexterm>
-       <primary><varname>default_with_oids</varname> configuration parameter</primary>
-      </indexterm>
-      </term>
-      <listitem>
-       <para>
-        This controls whether <command>CREATE TABLE</command> and
-        <command>CREATE TABLE AS</command> include an OID column in
-        newly-created tables, if neither <literal>WITH OIDS</literal>
-        nor <literal>WITHOUT OIDS</literal> is specified. It also
-        determines whether OIDs will be included in tables created by
-        <command>SELECT INTO</command>. The parameter is <literal>off</literal>
-        by default; in <productname>PostgreSQL</productname> 8.0 and earlier, it
-        was <literal>on</literal> by default.
-       </para>
-
-       <para>
-        The use of OIDs in user tables is considered deprecated, so
-        most installations should leave this variable disabled.
-        Applications that require OIDs for a particular table should
-        specify <literal>WITH OIDS</literal> when creating the
-        table. This variable can be enabled for compatibility with old
-        applications that do not follow this behavior.
-       </para>
-      </listitem>
-     </varlistentry>
-
      <varlistentry id="guc-escape-string-warning" xreflabel="escape_string_warning">
       <term><varname>escape_string_warning</varname> (<type>boolean</type>)
       <indexterm><primary>strings</primary><secondary>escape warning</secondary></indexterm>
index 8c38dde8fb8b64e7bbcfd240b4eb8c96720bc428..cae3fa95a890cf019ad6995d4b25108e2d861d4a 100644 (file)
@@ -4497,25 +4497,22 @@ INSERT INTO mytable VALUES(-1);  -- fails
    <para>
     Object identifiers (OIDs) are used internally by
     <productname>PostgreSQL</productname> as primary keys for various
-    system tables.  OIDs are not added to user-created tables, unless
-    <literal>WITH OIDS</literal> is specified when the table is
-    created, or the <xref linkend="guc-default-with-oids"/>
-    configuration variable is enabled.  Type <type>oid</type> represents
-    an object identifier.  There are also several alias types for
-    <type>oid</type>: <type>regproc</type>, <type>regprocedure</type>,
-    <type>regoper</type>, <type>regoperator</type>, <type>regclass</type>,
-    <type>regtype</type>, <type>regrole</type>, <type>regnamespace</type>,
-    <type>regconfig</type>, and <type>regdictionary</type>.
-    <xref linkend="datatype-oid-table"/> shows an overview.
+    system tables.
+
+    Type <type>oid</type> represents an object identifier.  There are also
+    several alias types for <type>oid</type>: <type>regproc</type>,
+    <type>regprocedure</type>, <type>regoper</type>, <type>regoperator</type>,
+    <type>regclass</type>, <type>regtype</type>, <type>regrole</type>,
+    <type>regnamespace</type>, <type>regconfig</type>, and
+    <type>regdictionary</type>.  <xref linkend="datatype-oid-table"/> shows an
+    overview.
    </para>
 
    <para>
     The <type>oid</type> type is currently implemented as an unsigned
     four-byte integer.  Therefore, it is not large enough to provide
     database-wide uniqueness in large databases, or even in large
-    individual tables.  So, using a user-created table's OID column as
-    a primary key is discouraged.  OIDs are best used only for
-    references to system tables.
+    individual tables.
    </para>
 
    <para>
index c8268222af7ab3a066076183d3f7cfad001591dc..61c4a25460347b65b583ebec265288f16d7a816c 100644 (file)
@@ -938,24 +938,6 @@ CREATE TABLE circles (
   </indexterm>
 
   <variablelist>
-   <varlistentry>
-    <term><structfield>oid</structfield></term>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>OID</primary>
-       <secondary>column</secondary>
-      </indexterm>
-      The object identifier (object ID) of a row. This column is only
-      present if the table was created using <literal>WITH
-      OIDS</literal>, or if the <xref linkend="guc-default-with-oids"/>
-      configuration variable was set at the time. This column is of type
-      <type>oid</type> (same name as the column); see <xref
-      linkend="datatype-oid"/> for more information about the type.
-     </para>
-    </listitem>
-   </varlistentry>
-
    <varlistentry>
     <term><structfield>tableoid</structfield></term>
     <listitem>
@@ -1056,46 +1038,6 @@ CREATE TABLE circles (
    </varlistentry>
   </variablelist>
 
-   <para>
-    OIDs are 32-bit quantities and are assigned from a single
-    cluster-wide counter.  In a large or long-lived database, it is
-    possible for the counter to wrap around.  Hence, it is bad
-    practice to assume that OIDs are unique, unless you take steps to
-    ensure that this is the case.  If you need to identify the rows in
-    a table, using a sequence generator is strongly recommended.
-    However, OIDs can be used as well, provided that a few additional
-    precautions are taken:
-
-    <itemizedlist>
-     <listitem>
-      <para>
-       A unique constraint should be created on the OID column of each
-       table for which the OID will be used to identify rows.  When such
-       a unique constraint (or unique index) exists, the system takes
-       care not to generate an OID matching an already-existing row.
-       (Of course, this is only possible if the table contains fewer
-       than 2<superscript>32</superscript> (4 billion) rows, and in practice the
-       table size had better be much less than that, or performance
-       might suffer.)
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       OIDs should never be assumed to be unique across tables; use
-       the combination of <structfield>tableoid</structfield> and row OID if you
-       need a database-wide identifier.
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       Of course, the tables in question must be created <literal>WITH
-       OIDS</literal>.  As of <productname>PostgreSQL</productname> 8.1,
-       <literal>WITHOUT OIDS</literal> is the default.
-      </para>
-     </listitem>
-    </itemizedlist>
-   </para>
-
    <para>
     Transaction identifiers are also 32-bit quantities.  In a
     long-lived database it is possible for transaction IDs to wrap
index 955a13ab7d9eb0f128ec6302667b51c245334d9d..19be824b039170648edf54d95f0d0a085e49eab9 100644 (file)
  </variablelist>
 
  <para>
-  <command>COPY</command>'s <literal>OIDS</literal> and
-  <literal>FORCE_QUOTE</literal> options are currently not supported by
-  <literal>file_fdw</literal>.
+  <command>COPY</command>'s <literal>FORCE_QUOTE</literal> options is
+  currently not supported by <literal>file_fdw</literal>.
  </para>
 
  <para>
index beb7e03bbcfb181f04e5c3287544924b17d01985..60b0c72ff320cf2f64dee4e49e0754fecb73930b 100644 (file)
@@ -1485,14 +1485,6 @@ GET DIAGNOSTICS integer_var = ROW_COUNT;
          <entry>the number of rows processed by the most
           recent <acronym>SQL</acronym> command</entry>
         </row>
-        <row>
-         <entry><varname>RESULT_OID</varname></entry>
-         <entry><type>oid</type></entry>
-         <entry>the OID of the last row inserted by the most
-          recent <acronym>SQL</acronym> command (only useful after
-          an <command>INSERT</command> command into a table having
-          OIDs)</entry>
-        </row>
         <row>
          <entry><literal>PG_CONTEXT</literal></entry>
          <entry><type>text</type></entry>
index 4dd6fe434faecc9ca70d241e8c13915b0bbee23b..7ff828de70084f5eebb6895e3a18eac4876bd269 100644 (file)
@@ -470,24 +470,6 @@ $$ LANGUAGE pltcl;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
-      <term>
-       <function>spi_lastoid</function>
-       <indexterm>
-        <primary>spi_lastoid</primary>
-        <secondary>in PL/Tcl</secondary>
-       </indexterm>
-      </term>
-      <listitem>
-       <para>
-        Returns the OID of the row inserted by the last
-        <function>spi_exec</function> or <function>spi_execp</function>, if the
-        command was a single-row <command>INSERT</command> and the modified
-        table contained OIDs.  (If not, you get zero.)
-       </para>
-      </listitem>
-     </varlistentry>
-
      <varlistentry>
       <term><function>subtransaction</function> <replaceable>command</replaceable></term>
       <listitem>
index f0b21452084f88a34a8385c10697d6a884b42996..9f7fb0c1d04e41d85c50c22f7c2fa33cf3eb423d 100644 (file)
@@ -3837,10 +3837,11 @@ CommandComplete (B)
         <literal>INSERT <replaceable>oid</replaceable>
         <replaceable>rows</replaceable></literal>, where
         <replaceable>rows</replaceable> is the number of rows
-        inserted. <replaceable>oid</replaceable> is the object ID
-        of the inserted row if <replaceable>rows</replaceable> is 1
-        and the target table has OIDs;
-        otherwise <replaceable>oid</replaceable> is 0.
+        inserted. <replaceable>oid</replaceable> used to be the object ID
+        of the inserted row if <replaceable>rows</replaceable> was 1
+        and the target table had OIDs, but OIDs system columns are
+        not supported anymore; therefore <replaceable>oid</replaceable>
+        is always 0.
        </para>
 
        <para>
index f266be0c37b29a8cb43012be96b5301c344cda19..b27eb6f2aae0047e0fcc75b72beaa87e8eef3268 100644 (file)
@@ -50,7 +50,6 @@ ALTER FOREIGN TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceab
     ENABLE TRIGGER [ <replaceable class="parameter">trigger_name</replaceable> | ALL | USER ]
     ENABLE REPLICA TRIGGER <replaceable class="parameter">trigger_name</replaceable>
     ENABLE ALWAYS TRIGGER <replaceable class="parameter">trigger_name</replaceable>
-    SET WITH OIDS
     SET WITHOUT OIDS
     INHERIT <replaceable class="parameter">parent_table</replaceable>
     NO INHERIT <replaceable class="parameter">parent_table</replaceable>
@@ -223,34 +222,13 @@ ALTER FOREIGN TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceab
     </listitem>
    </varlistentry>
 
-   <varlistentry>
-    <term><literal>SET WITH OIDS</literal></term>
-    <listitem>
-     <para>
-      This form adds an <literal>oid</literal> system column to the
-      table (see <xref linkend="ddl-system-columns"/>).
-      It does nothing if the table already has OIDs.
-      Unless the table's foreign-data wrapper supports OIDs, this column
-      will simply read as zeroes.
-     </para>
-
-     <para>
-      Note that this is not equivalent to <literal>ADD COLUMN oid oid</literal>;
-      that would add a normal column that happened to be named
-      <literal>oid</literal>, not a system column.
-     </para>
-    </listitem>
-   </varlistentry>
-
    <varlistentry>
     <term><literal>SET WITHOUT OIDS</literal></term>
     <listitem>
      <para>
-      This form removes the <literal>oid</literal> system column from the
-      table.  This is exactly equivalent to
-      <literal>DROP COLUMN oid RESTRICT</literal>,
-      except that it will not complain if there is already no
-      <literal>oid</literal> column.
+      Backward compatibility syntax for removing the <literal>oid</literal>
+      system column. As oid system columns cannot be added anymore, this never
+      has an effect.
      </para>
     </listitem>
    </varlistentry>
index f13a6cd944df57278fc289fa79425a649675f032..be1647937dc3fb02291d866719368f95a50f69a9 100644 (file)
@@ -72,7 +72,6 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     NO FORCE ROW LEVEL SECURITY
     CLUSTER ON <replaceable class="parameter">index_name</replaceable>
     SET WITHOUT CLUSTER
-    SET WITH OIDS
     SET WITHOUT OIDS
     SET TABLESPACE <replaceable class="parameter">new_tablespace</replaceable>
     SET { LOGGED | UNLOGGED }
@@ -613,32 +612,13 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
-    <term><literal>SET WITH OIDS</literal></term>
-    <listitem>
-     <para>
-      This form adds an <literal>oid</literal> system column to the
-      table (see <xref linkend="ddl-system-columns"/>).
-      It does nothing if the table already has OIDs.
-     </para>
-
-     <para>
-      Note that this is not equivalent to <literal>ADD COLUMN oid oid</literal>;
-      that would add a normal column that happened to be named
-      <literal>oid</literal>, not a system column.
-     </para>
-    </listitem>
-   </varlistentry>
-
    <varlistentry>
     <term><literal>SET WITHOUT OIDS</literal></term>
     <listitem>
      <para>
-      This form removes the <literal>oid</literal> system column from the
-      table.  This is exactly equivalent to
-      <literal>DROP COLUMN oid RESTRICT</literal>,
-      except that it will not complain if there is already no
-      <literal>oid</literal> column.
+      Backward compatibility syntax for removing the <literal>oid</literal>
+      system column. As oid system columns cannot be added anymore, this never
+      has an effect.
      </para>
     </listitem>
    </varlistentry>
@@ -704,17 +684,6 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       <varname>effective_io_concurrency</varname>, <varname>parallel_workers</varname>, <varname>seq_page_cost</varname>,
       <varname>random_page_cost</varname>, <varname>n_distinct</varname> and <varname>n_distinct_inherited</varname>.
      </para>
-
-     <note>
-      <para>
-       While <command>CREATE TABLE</command> allows <literal>OIDS</literal> to be specified
-       in the <literal>WITH (<replaceable
-       class="parameter">storage_parameter</replaceable>)</literal> syntax,
-       <command>ALTER TABLE</command> does not treat <literal>OIDS</literal> as a
-       storage parameter.  Instead use the <literal>SET WITH OIDS</literal>
-       and <literal>SET WITHOUT OIDS</literal> forms to change OID status.
-      </para>
-     </note>
     </listitem>
    </varlistentry>
 
index 9f3c85bf7f9f649d98833d0f7ae7a49129adf657..411941ed31f17df504ed7ed59c45d33912fa0b3e 100644 (file)
@@ -33,7 +33,6 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
 <phrase>where <replaceable class="parameter">option</replaceable> can be one of:</phrase>
 
     FORMAT <replaceable class="parameter">format_name</replaceable>
-    OIDS [ <replaceable class="parameter">boolean</replaceable> ]
     FREEZE [ <replaceable class="parameter">boolean</replaceable> ]
     DELIMITER '<replaceable class="parameter">delimiter_character</replaceable>'
     NULL '<replaceable class="parameter">null_string</replaceable>'
@@ -203,18 +202,6 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
     </listitem>
    </varlistentry>
 
-   <varlistentry>
-    <term><literal>OIDS</literal></term>
-    <listitem>
-     <para>
-      Specifies copying the OID for each row.  (An error is raised if
-      <literal>OIDS</literal> is specified for a table that does not
-      have OIDs, or in the case of copying a <replaceable
-      class="parameter">query</replaceable>.)
-     </para>
-    </listitem>
-   </varlistentry>
-
    <varlistentry>
     <term><literal>FREEZE</literal></term>
     <listitem>
@@ -549,8 +536,6 @@ COPY <replaceable class="parameter">count</replaceable>
     place of columns that are null.
     <command>COPY FROM</command> will raise an error if any line of the
     input file contains more or fewer columns than are expected.
-    If <literal>OIDS</literal> is specified, the OID is read or written as the first column,
-    preceding the user data columns.
    </para>
 
    <para>
@@ -824,7 +809,9 @@ only one flag bit is defined, and the rest must be zero:
           <term>Bit 16</term>
           <listitem>
            <para>
-            if 1, OIDs are included in the data; if 0, not
+            If 1, OIDs are included in the data; if 0, not. Oid system columns
+            are not supported in <productname>PostgreSQL</productname>
+            anymore, but the format still contains the indicator.
            </para>
           </listitem>
          </varlistentry>
@@ -895,10 +882,9 @@ distribution).
 
     <para>
 If OIDs are included in the file, the OID field immediately follows the
-field-count word.  It is a normal field except that it's not included
-in the field-count.  In particular it has a length word &mdash; this will allow
-handling of 4-byte vs. 8-byte OIDs without too much pain, and will allow
-OIDs to be shown as null if that ever proves desirable.
+field-count word.  It is a normal field except that it's not included in the
+field-count.  Note that oid system columns are not supported in current
+versions of <productname>PostgreSQL</productname>.
     </para>
    </refsect3>
 
@@ -1001,7 +987,6 @@ COPY <replaceable class="parameter">table_name</replaceable> [ ( <replaceable cl
     FROM { '<replaceable class="parameter">filename</replaceable>' | STDIN }
     [ [ WITH ]
           [ BINARY ]
-          [ OIDS ]
           [ DELIMITER [ AS ] '<replaceable class="parameter">delimiter</replaceable>' ]
           [ NULL [ AS ] '<replaceable class="parameter">null string</replaceable>' ]
           [ CSV [ HEADER ]
@@ -1013,7 +998,6 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
     TO { '<replaceable class="parameter">filename</replaceable>' | STDOUT }
     [ [ WITH ]
           [ BINARY ]
-          [ OIDS ]
           [ DELIMITER [ AS ] '<replaceable class="parameter">delimiter</replaceable>' ]
           [ NULL [ AS ] '<replaceable class="parameter">null string</replaceable>' ]
           [ CSV [ HEADER ]
@@ -1032,12 +1016,12 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
    version 7.3 and is still supported:
 
 <synopsis>
-COPY [ BINARY ] <replaceable class="parameter">table_name</replaceable> [ WITH OIDS ]
+COPY [ BINARY ] <replaceable class="parameter">table_name</replaceable>
     FROM { '<replaceable class="parameter">filename</replaceable>' | STDIN }
     [ [USING] DELIMITERS '<replaceable class="parameter">delimiter</replaceable>' ]
     [ WITH NULL AS '<replaceable class="parameter">null string</replaceable>' ]
 
-COPY [ BINARY ] <replaceable class="parameter">table_name</replaceable> [ WITH OIDS ]
+COPY [ BINARY ] <replaceable class="parameter">table_name</replaceable>
     TO { '<replaceable class="parameter">filename</replaceable>' | STDOUT }
     [ [USING] DELIMITERS '<replaceable class="parameter">delimiter</replaceable>' ]
     [ WITH NULL AS '<replaceable class="parameter">null string</replaceable>' ]
index eed4273c4b4dd76808bb95caa1818cce891f927b..7f31ab4d26df93d5357f03876cd631d48895f522 100644 (file)
@@ -45,8 +45,7 @@ CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] <replaceable>table_name</replaceable>
    <command>CREATE TABLE AS</command>, except that it also remembers the query used
    to initialize the view, so that it can be refreshed later upon demand.
    A materialized view has many of the same properties as a table, but there
-   is no support for temporary materialized views or automatic generation of
-   OIDs.
+   is no support for temporary materialized views.
   </para>
  </refsect1>
 
@@ -95,7 +94,7 @@ CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] <replaceable>table_name</replaceable>
       endterm="sql-createtable-storage-parameters-title"/> for more
       information.  All parameters supported for <literal>CREATE
       TABLE</literal> are also supported for <literal>CREATE MATERIALIZED
-      VIEW</literal> with the exception of <literal>OIDS</literal>.
+      VIEW</literal>.
       See <xref linkend="sql-createtable"/> for more information.
      </para>
     </listitem>
index 4b9c8a78017135bbbfe4c1fa0262e71eb3e28955..50d55970020f6fd143d642b0444bc055d159e3cd 100644 (file)
@@ -29,7 +29,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
 ] )
 [ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ]
 [ PARTITION BY { RANGE | LIST | HASH } ( { <replaceable class="parameter">column_name</replaceable> | ( <replaceable class="parameter">expression</replaceable> ) } [ COLLATE <replaceable class="parameter">collation</replaceable> ] [ <replaceable class="parameter">opclass</replaceable> ] [, ... ] ) ]
-[ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
+[ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) | WITHOUT OIDS ]
 [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
 [ TABLESPACE <replaceable class="parameter">tablespace_name</replaceable> ]
 
@@ -40,7 +40,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
     [, ... ]
 ) ]
 [ PARTITION BY { RANGE | LIST | HASH } ( { <replaceable class="parameter">column_name</replaceable> | ( <replaceable class="parameter">expression</replaceable> ) } [ COLLATE <replaceable class="parameter">collation</replaceable> ] [ <replaceable class="parameter">opclass</replaceable> ] [, ... ] ) ]
-[ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
+[ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) | WITHOUT OIDS ]
 [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
 [ TABLESPACE <replaceable class="parameter">tablespace_name</replaceable> ]
 
@@ -51,7 +51,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
     [, ... ]
 ) ] { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }
 [ PARTITION BY { RANGE | LIST | HASH } ( { <replaceable class="parameter">column_name</replaceable> | ( <replaceable class="parameter">expression</replaceable> ) } [ COLLATE <replaceable class="parameter">collation</replaceable> ] [ <replaceable class="parameter">opclass</replaceable> ] [, ... ] ) ]
-[ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
+[ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) | WITHOUT OIDS ]
 [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
 [ TABLESPACE <replaceable class="parameter">tablespace_name</replaceable> ]
 
@@ -531,17 +531,13 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
 
      <para>
       A partition must have the same column names and types as the partitioned
-      table to which it belongs.  If the parent is specified <literal>WITH
-      OIDS</literal> then all partitions must have OIDs; the parent's OID
-      column will be inherited by all partitions just like any other column.
-      Modifications to the column names or types of a partitioned table, or
-      the addition or removal of an OID column, will automatically propagate
-      to all partitions.  <literal>CHECK</literal> constraints will be inherited
-      automatically by every partition, but an individual partition may specify
-      additional <literal>CHECK</literal> constraints; additional constraints with
-      the same name and condition as in the parent will be merged with the
-      parent constraint.  Defaults may be specified separately for each
-      partition.
+      table to which it belongs. Modifications to the column names or types of
+      a partitioned table will automatically propagate to all partitions.
+      <literal>CHECK</literal> constraints will be inherited automatically by
+      every partition, but an individual partition may specify additional
+      <literal>CHECK</literal> constraints; additional constraints with the
+      same name and condition as in the parent will be merged with the parent
+      constraint.  Defaults may be specified separately for each partition.
      </para>
 
      <para>
@@ -1145,46 +1141,21 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       This clause specifies optional storage parameters for a table or index;
       see <xref linkend="sql-createtable-storage-parameters"
       endterm="sql-createtable-storage-parameters-title"/> for more
-      information.  The <literal>WITH</literal> clause for a
-      table can also include <literal>OIDS=TRUE</literal> (or just <literal>OIDS</literal>)
-      to specify that rows of the new table
-      should have OIDs (object identifiers) assigned to them, or
-      <literal>OIDS=FALSE</literal> to specify that the rows should not have OIDs.
-      If <literal>OIDS</literal> is not specified, the default setting depends upon
-      the <xref linkend="guc-default-with-oids"/> configuration parameter.
-      (If the new table inherits from any tables that have OIDs, then
-      <literal>OIDS=TRUE</literal> is forced even if the command says
-      <literal>OIDS=FALSE</literal>.)
-     </para>
-
-     <para>
-      If <literal>OIDS=FALSE</literal> is specified or implied, the new
-      table does not store OIDs and no OID will be assigned for a row inserted
-      into it. This is generally considered worthwhile, since it
-      will reduce OID consumption and thereby postpone the wraparound
-      of the 32-bit OID counter. Once the counter wraps around, OIDs
-      can no longer be assumed to be unique, which makes them
-      considerably less useful. In addition, excluding OIDs from a
-      table reduces the space required to store the table on disk by
-      4 bytes per row (on most machines), slightly improving performance.
-     </para>
-
-     <para>
-      To remove OIDs from a table after it has been created, use <xref
-      linkend="sql-altertable"/>.
+      information.  For backward-compatibility the <literal>WITH</literal>
+      clause for a table can also include <literal>OIDS=FALSE</literal> to
+      specify that rows of the new table should not contain OIDs (object
+      identifiers), <literal>OIDS=TRUE</literal> is not supported anymore.
      </para>
     </listitem>
    </varlistentry>
 
    <varlistentry>
-    <term><literal>WITH OIDS</literal></term>
     <term><literal>WITHOUT OIDS</literal></term>
     <listitem>
      <para>
-      These are obsolescent syntaxes equivalent to <literal>WITH (OIDS)</literal>
-      and <literal>WITH (OIDS=FALSE)</literal>, respectively.  If you wish to give
-      both an <literal>OIDS</literal> setting and storage parameters, you must use
-      the <literal>WITH ( ... )</literal> syntax; see above.
+      This is backward-compatible syntax for declaring a table
+      <literal>WITHOUT OIDS</literal>, creating a table <literal>WITH
+      OIDS</literal> is not supported anymore.
      </para>
     </listitem>
    </varlistentry>
@@ -1528,29 +1499,6 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
 
  <refsect1 id="sql-createtable-notes">
   <title>Notes</title>
-
-    <para>
-     Using OIDs in new applications is not recommended: where
-     possible, using an identity column or other sequence
-     generator as the table's primary key is preferred. However, if
-     your application does make use of OIDs to identify specific
-     rows of a table, it is recommended to create a unique constraint
-     on the <structfield>oid</structfield> column of that table, to ensure that
-     OIDs in the table will indeed uniquely identify rows even after
-     counter wraparound.  Avoid assuming that OIDs are unique across
-     tables; if you need a database-wide unique identifier, use the
-     combination of <structfield>tableoid</structfield> and row OID for the
-     purpose.
-    </para>
-
-    <tip>
-     <para>
-      The use of <literal>OIDS=FALSE</literal> is not recommended
-      for tables with no primary key, since without either an OID or a
-      unique data key, it is difficult to identify specific rows.
-     </para>
-    </tip>
-
     <para>
      <productname>PostgreSQL</productname> automatically creates an
      index for each unique constraint and primary key constraint to
@@ -2089,7 +2037,7 @@ CREATE TABLE cities_partdef
 
    <para>
     The <literal>WITH</literal> clause is a <productname>PostgreSQL</productname>
-    extension; neither storage parameters nor OIDs are in the standard.
+    extension; storage parameters are not in the standard.
    </para>
   </refsect2>
 
index 527138e7872339e2d49479a85736e4737ee128f9..679e8f521ed7625c349f57e1777cafadfd8d7ea9 100644 (file)
@@ -23,7 +23,7 @@ PostgreSQL documentation
 <synopsis>
 CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] <replaceable>table_name</replaceable>
     [ (<replaceable>column_name</replaceable> [, ...] ) ]
-    [ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
+    [ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) | WITHOUT OIDS ]
     [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
     [ TABLESPACE <replaceable class="parameter">tablespace_name</replaceable> ]
     AS <replaceable>query</replaceable>
@@ -127,25 +127,22 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
       This clause specifies optional storage parameters for the new table;
       see <xref linkend="sql-createtable-storage-parameters"
       endterm="sql-createtable-storage-parameters-title"/> for more
-      information.  The <literal>WITH</literal> clause
-      can also include <literal>OIDS=TRUE</literal> (or just <literal>OIDS</literal>)
-      to specify that rows of the new table
-      should have OIDs (object identifiers) assigned to them, or
-      <literal>OIDS=FALSE</literal> to specify that the rows should not have OIDs.
-      See <xref linkend="sql-createtable"/> for more information.
+      information.   For backward-compatibility the <literal>WITH</literal>
+      clause for a table can also include <literal>OIDS=FALSE</literal> to
+      specify that rows of the new table should contain no OIDs (object
+      identifiers), <literal>OIDS=TRUE</literal> is not supported anymore.
+      OIDs.
      </para>
     </listitem>
    </varlistentry>
 
    <varlistentry>
-    <term><literal>WITH OIDS</literal></term>
     <term><literal>WITHOUT OIDS</literal></term>
     <listitem>
      <para>
-      These are obsolescent syntaxes equivalent to <literal>WITH (OIDS)</literal>
-      and <literal>WITH (OIDS=FALSE)</literal>, respectively.  If you wish to give
-      both an <literal>OIDS</literal> setting and storage parameters, you must use
-      the <literal>WITH ( ... )</literal> syntax; see above.
+      This is backward-compatible syntax for declaring a table
+      <literal>WITHOUT OIDS</literal>, creating a table <literal>WITH
+      OIDS</literal> is not supported anymore.
      </para>
     </listitem>
    </varlistentry>
@@ -245,14 +242,6 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
    TABLE AS</command> offers a superset of the functionality offered
    by <command>SELECT INTO</command>.
   </para>
-
-  <para>
-   The <command>CREATE TABLE AS</command> command allows the user to
-   explicitly specify whether OIDs should be included. If the
-   presence of OIDs is not explicitly specified,
-   the <xref linkend="guc-default-with-oids"/> configuration variable is
-   used.
-  </para>
  </refsect1>
 
  <refsect1>
@@ -281,12 +270,12 @@ CREATE TABLE films2 AS
   <para>
    Create a new temporary table <literal>films_recent</literal>, consisting of
    only recent entries from the table <literal>films</literal>, using a
-   prepared statement.  The new table has OIDs and will be dropped at commit:
+   prepared statement.  The new table will be dropped at commit:
 
 <programlisting>
 PREPARE recentfilms(date) AS
   SELECT * FROM films WHERE date_prod &gt; $1;
-CREATE TEMP TABLE films_recent WITH (OIDS) ON COMMIT DROP AS
+CREATE TEMP TABLE films_recent ON COMMIT DROP AS
   EXECUTE recentfilms('2002-01-01');
 </programlisting></para>
  </refsect1>
@@ -325,7 +314,7 @@ CREATE TEMP TABLE films_recent WITH (OIDS) ON COMMIT DROP AS
     <listitem>
      <para>
       The <literal>WITH</literal> clause is a <productname>PostgreSQL</productname>
-      extension; neither storage parameters nor OIDs are in the standard.
+      extension; storage parameters are not in the standard.
      </para>
     </listitem>
 
index b5fa4fb85ccc66e358ff882735e105d5d6bc9ce5..2015410a421940cde03315393f381856d5cb705f 100644 (file)
@@ -438,20 +438,6 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
-      <term><option>-o</option></term>
-      <term><option>--oids</option></term>
-      <listitem>
-       <para>
-        Dump object identifiers (<acronym>OID</acronym>s) as part of the
-        data for every table.  Use this option if your application references
-        the <acronym>OID</acronym>
-        columns in some way (e.g., in a foreign key constraint).
-        Otherwise, this option should not be used.
-       </para>
-      </listitem>
-     </varlistentry>
-
      <varlistentry>
       <term><option>-O</option></term>
       <term><option>--no-owner</option></term>
index 6c1a25f5ed59818fc859f30bbba424070e823f42..462e37238192b911e680e19ee56e44dc3981a4da 100644 (file)
@@ -104,13 +104,6 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="parameter">expression</replac
    <command>CREATE TABLE AS</command> offers a superset of the
    functionality provided by <command>SELECT INTO</command>.
   </para>
-
-  <para>
-   To add OIDs to the table created by <command>SELECT INTO</command>,
-   enable the <xref linkend="guc-default-with-oids"/> configuration
-   variable.  Alternatively, <command>CREATE TABLE AS</command> can be
-   used with the <literal>WITH OIDS</literal> clause.
-  </para>
  </refsect1>
 
  <refsect1>
index e6ce80032fd5c19cea67545bb4168f3080924172..3407d8ad7398a363ff7d2eade9147bda4c81ef42 100644 (file)
@@ -3654,7 +3654,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
     <listitem>
      <para>
       Prevent foreign tables from being created with OIDS
-      when <xref linkend="guc-default-with-oids"/> is true
+      when <literal>default_with_oids"</literal> is true
       (Etsuro Fujita)
      </para>
     </listitem>
index 3494ddb5cefe0a99109d7d4f6674a87172a53d11..1e5f4e04c331d94686bc6292944355f30afc8564 100644 (file)
@@ -5650,7 +5650,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
     <listitem>
      <para>
       Prevent foreign tables from being created with OIDS
-      when <xref linkend="guc-default-with-oids"/> is true
+      when <literal>default_with_oids"</literal> is true
       (Etsuro Fujita)
      </para>
     </listitem>
index 0c1498015ba63aecfcd361a5e0dd4b63f6c81782..23868d65d8e0461899f3813ee9f3b8e9838a8581 100644 (file)
@@ -9237,7 +9237,7 @@ Branch: REL9_1_STABLE [dd1a5b09b] 2014-06-24 13:30:41 +0300
     <listitem>
      <para>
       Prevent foreign tables from being created with OIDS
-      when <xref linkend="guc-default-with-oids"/> is true
+      when <literal>default_with_oids"</literal> is true
       (Etsuro Fujita)
      </para>
     </listitem>
index 00316b899c883567e5a7d7cf3165f23d34e85367..c82bbbaa7f851f09b99b038b289c8a00d6c670ff 100644 (file)
@@ -62,7 +62,7 @@ brtuple_disk_tupdesc(BrinDesc *brdesc)
        /* make sure it's in the bdesc's context */
        oldcxt = MemoryContextSwitchTo(brdesc->bd_context);
 
-       tupdesc = CreateTemplateTupleDesc(brdesc->bd_totalstored, false);
+       tupdesc = CreateTemplateTupleDesc(brdesc->bd_totalstored);
 
        for (i = 0; i < brdesc->bd_tupdesc->natts; i++)
        {
index ccb69bdd616e9f1b5a064ed41513f00b6b1654c2..06dd628a5bc6a5ae2656bd54c6185fdafe7bbe49 100644 (file)
@@ -384,7 +384,6 @@ heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
    {
        case TableOidAttributeNumber:
        case SelfItemPointerAttributeNumber:
-       case ObjectIdAttributeNumber:
        case MinTransactionIdAttributeNumber:
        case MinCommandIdAttributeNumber:
        case MaxTransactionIdAttributeNumber:
@@ -642,9 +641,6 @@ heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
            /* pass-by-reference datatype */
            result = PointerGetDatum(&(tup->t_self));
            break;
-       case ObjectIdAttributeNumber:
-           result = ObjectIdGetDatum(HeapTupleGetOid(tup));
-           break;
        case MinTransactionIdAttributeNumber:
            result = TransactionIdGetDatum(HeapTupleHeaderGetRawXmin(tup->t_data));
            break;
@@ -839,9 +835,6 @@ expand_tuple(HeapTuple *targetHeapTuple,
    else
        targetNullLen = 0;
 
-   if (tupleDesc->tdhasoid)
-       len += sizeof(Oid);
-
    /*
     * Allocate and zero the space needed.  Note that the tuple body and
     * HeapTupleData management structure are allocated in one chunk.
@@ -1065,9 +1058,6 @@ heap_form_tuple(TupleDesc tupleDescriptor,
    if (hasnull)
        len += BITMAPLEN(numberOfAttributes);
 
-   if (tupleDescriptor->tdhasoid)
-       len += sizeof(Oid);
-
    hoff = len = MAXALIGN(len); /* align user data safely */
 
    data_len = heap_compute_data_size(tupleDescriptor, values, isnull);
@@ -1099,9 +1089,6 @@ heap_form_tuple(TupleDesc tupleDescriptor,
    HeapTupleHeaderSetNatts(td, numberOfAttributes);
    td->t_hoff = hoff;
 
-   if (tupleDescriptor->tdhasoid)  /* else leave infomask = 0 */
-       td->t_infomask = HEAP_HASOID;
-
    heap_fill_tuple(tupleDescriptor,
                    values,
                    isnull,
@@ -1171,14 +1158,11 @@ heap_modify_tuple(HeapTuple tuple,
    pfree(isnull);
 
    /*
-    * copy the identification info of the old tuple: t_ctid, t_self, and OID
-    * (if any)
+    * copy the identification info of the old tuple: t_ctid, t_self
     */
    newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
    newTuple->t_self = tuple->t_self;
    newTuple->t_tableOid = tuple->t_tableOid;
-   if (tupleDesc->tdhasoid)
-       HeapTupleSetOid(newTuple, HeapTupleGetOid(tuple));
 
    return newTuple;
 }
@@ -1237,14 +1221,11 @@ heap_modify_tuple_by_cols(HeapTuple tuple,
    pfree(isnull);
 
    /*
-    * copy the identification info of the old tuple: t_ctid, t_self, and OID
-    * (if any)
+    * copy the identification info of the old tuple: t_ctid, t_self
     */
    newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
    newTuple->t_self = tuple->t_self;
    newTuple->t_tableOid = tuple->t_tableOid;
-   if (tupleDesc->tdhasoid)
-       HeapTupleSetOid(newTuple, HeapTupleGetOid(tuple));
 
    return newTuple;
 }
@@ -1412,9 +1393,6 @@ heap_form_minimal_tuple(TupleDesc tupleDescriptor,
    if (hasnull)
        len += BITMAPLEN(numberOfAttributes);
 
-   if (tupleDescriptor->tdhasoid)
-       len += sizeof(Oid);
-
    hoff = len = MAXALIGN(len); /* align user data safely */
 
    data_len = heap_compute_data_size(tupleDescriptor, values, isnull);
@@ -1433,9 +1411,6 @@ heap_form_minimal_tuple(TupleDesc tupleDescriptor,
    HeapTupleHeaderSetNatts(tuple, numberOfAttributes);
    tuple->t_hoff = hoff + MINIMAL_TUPLE_OFFSET;
 
-   if (tupleDescriptor->tdhasoid)  /* else leave infomask = 0 */
-       tuple->t_infomask = HEAP_HASOID;
-
    heap_fill_tuple(tupleDescriptor,
                    values,
                    isnull,
index db84da06789ca8b9f6afdca319d70dd37f8cdd0b..eece89aa21f08778a3b68042fc574fa7122c6f60 100644 (file)
@@ -757,8 +757,8 @@ add_string_reloption(bits32 kinds, const char *name, const char *desc, const cha
  * reloptions value (possibly NULL), and we replace or remove entries
  * as needed.
  *
- * If ignoreOids is true, then we should ignore any occurrence of "oids"
- * in the list (it will be or has been handled by interpretOidsOption()).
+ * If acceptOidsOff is true, then we allow oids = false, but throw error when
+ * on. This is solely needed for backwards compatibility.
  *
  * Note that this is not responsible for determining whether the options
  * are valid, but it does check that namespaces for all the options given are
@@ -771,7 +771,7 @@ add_string_reloption(bits32 kinds, const char *name, const char *desc, const cha
  */
 Datum
 transformRelOptions(Datum oldOptions, List *defList, const char *namspace,
-                   char *validnsps[], bool ignoreOids, bool isReset)
+                   char *validnsps[], bool acceptOidsOff, bool isReset)
 {
    Datum       result;
    ArrayBuildState *astate;
@@ -882,9 +882,6 @@ transformRelOptions(Datum oldOptions, List *defList, const char *namspace,
                                    def->defnamespace)));
            }
 
-           if (ignoreOids && strcmp(def->defname, "oids") == 0)
-               continue;
-
            /* ignore if not in the same namespace */
            if (namspace == NULL)
            {
@@ -905,6 +902,24 @@ transformRelOptions(Datum oldOptions, List *defList, const char *namspace,
                value = defGetString(def);
            else
                value = "true";
+
+           /*
+            * This is not a great place for this test, but there's no other
+            * convenient place to filter the option out. As WITH (oids =
+            * false) will be removed someday, this seems like an acceptable
+            * amount of ugly.
+            */
+           if (acceptOidsOff && def->defnamespace == NULL &&
+               strcmp(def->defname, "oids") == 0)
+           {
+               if (defGetBoolean(def))
+                   ereport(ERROR,
+                           (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                            errmsg("tables declared WITH OIDS are not supported")));
+               /* skip over option, reloptions machinery doesn't know it */
+               continue;
+           }
+
            len = VARHDRSZ + strlen(def->defname) + 1 + strlen(value);
            /* +1 leaves room for sprintf's trailing null */
            t = (text *) palloc(len + 1);
index 21fe8ae490982189dbc213b5ab30e4ec1bf06067..fc88aa376ac5263b1375eb9d8ac01711253f617c 100644 (file)
@@ -138,13 +138,9 @@ convert_tuples_by_position(TupleDesc indesc,
 
    /*
     * Check to see if the map is one-to-one, in which case we need not do a
-    * tuple conversion.  We must also insist that both tupdescs either
-    * specify or don't specify an OID column, else we need a conversion to
-    * add/remove space for that.  (For some callers, presence or absence of
-    * an OID column perhaps would not really matter, but let's be safe.)
+    * tuple conversion.
     */
-   if (indesc->natts == outdesc->natts &&
-       indesc->tdhasoid == outdesc->tdhasoid)
+   if (indesc->natts == outdesc->natts)
    {
        for (i = 0; i < n; i++)
        {
@@ -344,13 +340,9 @@ convert_tuples_by_name_map_if_req(TupleDesc indesc,
 
    /*
     * Check to see if the map is one-to-one, in which case we need not do a
-    * tuple conversion.  We must also insist that both tupdescs either
-    * specify or don't specify an OID column, else we need a conversion to
-    * add/remove space for that.  (For some callers, presence or absence of
-    * an OID column perhaps would not really matter, but let's be safe.)
+    * tuple conversion.
     */
-   if (indesc->natts == outdesc->natts &&
-       indesc->tdhasoid == outdesc->tdhasoid)
+   if (indesc->natts == outdesc->natts)
    {
        same = true;
        for (i = 0; i < n; i++)
index b0434b467208bc19e2a3bd76453a3a1cedc31235..5354a04639b5fd55849333b32ad863a42c68d2f2 100644 (file)
@@ -42,7 +42,7 @@
  * caller can overwrite this if needed.
  */
 TupleDesc
-CreateTemplateTupleDesc(int natts, bool hasoid)
+CreateTemplateTupleDesc(int natts)
 {
    TupleDesc   desc;
 
@@ -73,7 +73,6 @@ CreateTemplateTupleDesc(int natts, bool hasoid)
    desc->constr = NULL;
    desc->tdtypeid = RECORDOID;
    desc->tdtypmod = -1;
-   desc->tdhasoid = hasoid;
    desc->tdrefcount = -1;      /* assume not reference-counted */
 
    return desc;
@@ -88,12 +87,12 @@ CreateTemplateTupleDesc(int natts, bool hasoid)
  * caller can overwrite this if needed.
  */
 TupleDesc
-CreateTupleDesc(int natts, bool hasoid, Form_pg_attribute *attrs)
+CreateTupleDesc(int natts, Form_pg_attribute *attrs)
 {
    TupleDesc   desc;
    int         i;
 
-   desc = CreateTemplateTupleDesc(natts, hasoid);
+   desc = CreateTemplateTupleDesc(natts);
 
    for (i = 0; i < natts; ++i)
        memcpy(TupleDescAttr(desc, i), attrs[i], ATTRIBUTE_FIXED_PART_SIZE);
@@ -114,7 +113,7 @@ CreateTupleDescCopy(TupleDesc tupdesc)
    TupleDesc   desc;
    int         i;
 
-   desc = CreateTemplateTupleDesc(tupdesc->natts, tupdesc->tdhasoid);
+   desc = CreateTemplateTupleDesc(tupdesc->natts);
 
    /* Flat-copy the attribute array */
    memcpy(TupleDescAttr(desc, 0),
@@ -154,7 +153,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
    TupleConstr *constr = tupdesc->constr;
    int         i;
 
-   desc = CreateTemplateTupleDesc(tupdesc->natts, tupdesc->tdhasoid);
+   desc = CreateTemplateTupleDesc(tupdesc->natts);
 
    /* Flat-copy the attribute array */
    memcpy(TupleDescAttr(desc, 0),
@@ -416,8 +415,6 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
        return false;
    if (tupdesc1->tdtypeid != tupdesc2->tdtypeid)
        return false;
-   if (tupdesc1->tdhasoid != tupdesc2->tdhasoid)
-       return false;
 
    for (i = 0; i < tupdesc1->natts; i++)
    {
@@ -574,7 +571,6 @@ hashTupleDesc(TupleDesc desc)
 
    s = hash_combine(0, hash_uint32(desc->natts));
    s = hash_combine(s, hash_uint32(desc->tdtypeid));
-   s = hash_combine(s, hash_uint32(desc->tdhasoid));
    for (i = 0; i < desc->natts; ++i)
        s = hash_combine(s, hash_uint32(TupleDescAttr(desc, i)->atttypid));
 
@@ -800,7 +796,7 @@ BuildDescForRelation(List *schema)
     * allocate a new tuple descriptor
     */
    natts = list_length(schema);
-   desc = CreateTemplateTupleDesc(natts, false);
+   desc = CreateTemplateTupleDesc(natts);
    has_not_null = false;
 
    attnum = 0;
@@ -900,7 +896,7 @@ BuildDescFromLists(List *names, List *types, List *typmods, List *collations)
    /*
     * allocate a new tuple descriptor
     */
-   desc = CreateTemplateTupleDesc(natts, false);
+   desc = CreateTemplateTupleDesc(natts);
 
    attnum = 0;
 
index 0a32182dd7fbafbedb4548a458f37b7286be9a37..d7696a1ad03cff536d2bc48a5a59d106905d7a7d 100644 (file)
@@ -104,7 +104,7 @@ initGinState(GinState *state, Relation index)
            state->tupdesc[i] = state->origTupdesc;
        else
        {
-           state->tupdesc[i] = CreateTemplateTupleDesc(2, false);
+           state->tupdesc[i] = CreateTemplateTupleDesc(2);
 
            TupleDescInitEntry(state->tupdesc[i], (AttrNumber) 1, NULL,
                               INT2OID, -1, 0);
index 4d97ff1d5d21b41ff103785e2e16494f39a82be1..6b18bd3afb8a8e84cea59df2f71369e010bec5a2 100644 (file)
@@ -167,7 +167,7 @@ gistrescan(IndexScanDesc scan, ScanKey key, int nkeys,
         * types.
         */
        natts = RelationGetNumberOfAttributes(scan->indexRelation);
-       so->giststate->fetchTupdesc = CreateTemplateTupleDesc(natts, false);
+       so->giststate->fetchTupdesc = CreateTemplateTupleDesc(natts);
        for (attno = 1; attno <= natts; attno++)
        {
            TupleDescInitEntry(so->giststate->fetchTupdesc, attno, NULL,
index da2a8f34c20145d49123f5ecff9473a590b11820..9650145642209bfcc8493dbabc385d2545860be5 100644 (file)
@@ -2454,7 +2454,7 @@ ReleaseBulkInsertStatePin(BulkInsertState bistate)
  * TID where the tuple was stored.  But note that any toasting of fields
  * within the tuple data is NOT reflected into *tup.
  */
-Oid
+void
 heap_insert(Relation relation, HeapTuple tup, CommandId cid,
            int options, BulkInsertState bistate)
 {
@@ -2628,8 +2628,6 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
        tup->t_self = heaptup->t_self;
        heap_freetuple(heaptup);
    }
-
-   return HeapTupleGetOid(tup);
 }
 
 /*
@@ -2656,30 +2654,6 @@ heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid,
                (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
                 errmsg("cannot insert tuples in a parallel worker")));
 
-   if (relation->rd_rel->relhasoids)
-   {
-#ifdef NOT_USED
-       /* this is redundant with an Assert in HeapTupleSetOid */
-       Assert(tup->t_data->t_infomask & HEAP_HASOID);
-#endif
-
-       /*
-        * If the object id of this tuple has already been assigned, trust the
-        * caller.  There are a couple of ways this can happen.  At initial db
-        * creation, the backend program sets oids for tuples. When we define
-        * an index, we set the oid.  Finally, in the future, we may allow
-        * users to set their own object ids in order to support a persistent
-        * object store (objects need to contain pointers to one another).
-        */
-       if (!OidIsValid(HeapTupleGetOid(tup)))
-           HeapTupleSetOid(tup, GetNewOid(relation));
-   }
-   else
-   {
-       /* check there is not space for an OID */
-       Assert(!(tup->t_data->t_infomask & HEAP_HASOID));
-   }
-
    tup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
    tup->t_data->t_infomask2 &= ~(HEAP2_XACT_MASK);
    tup->t_data->t_infomask |= HEAP_XMAX_INVALID;
@@ -2995,10 +2969,10 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
  * This should be used rather than using heap_insert directly in most places
  * where we are modifying system catalogs.
  */
-Oid
+void
 simple_heap_insert(Relation relation, HeapTuple tup)
 {
-   return heap_insert(relation, tup, GetCurrentCommandId(true), 0, NULL);
+   heap_insert(relation, tup, GetCurrentCommandId(true), 0, NULL);
 }
 
 /*
@@ -3656,21 +3630,6 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
    /* the new tuple is ready, except for this: */
    newtup->t_tableOid = RelationGetRelid(relation);
 
-   /* Fill in OID for newtup */
-   if (relation->rd_rel->relhasoids)
-   {
-#ifdef NOT_USED
-       /* this is redundant with an Assert in HeapTupleSetOid */
-       Assert(newtup->t_data->t_infomask & HEAP_HASOID);
-#endif
-       HeapTupleSetOid(newtup, HeapTupleGetOid(&oldtup));
-   }
-   else
-   {
-       /* check there is not space for an OID */
-       Assert(!(newtup->t_data->t_infomask & HEAP_HASOID));
-   }
-
    /* Determine columns modified by the update. */
    modified_attrs = HeapDetermineModifiedColumns(relation, interesting_attrs,
                                                  &oldtup, newtup);
@@ -4437,13 +4396,12 @@ heap_tuple_attr_equals(TupleDesc tupdesc, int attrnum,
 
    /*
     * Likewise, automatically say "not equal" for any system attribute other
-    * than OID and tableOID; we cannot expect these to be consistent in a HOT
-    * chain, or even to be set correctly yet in the new tuple.
+    * than tableOID; we cannot expect these to be consistent in a HOT chain,
+    * or even to be set correctly yet in the new tuple.
     */
    if (attrnum < 0)
    {
-       if (attrnum != ObjectIdAttributeNumber &&
-           attrnum != TableOidAttributeNumber)
+       if (attrnum != TableOidAttributeNumber)
            return false;
    }
 
@@ -8123,16 +8081,7 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool *
        int         attno = idx_rel->rd_index->indkey.values[natt];
 
        if (attno < 0)
-       {
-           /*
-            * The OID column can appear in an index definition, but that's
-            * OK, because we always copy the OID if present (see below).
-            * Other system columns may not.
-            */
-           if (attno == ObjectIdAttributeNumber)
-               continue;
            elog(ERROR, "system column in index");
-       }
        nulls[attno - 1] = false;
    }
 
@@ -8140,14 +8089,6 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool *
    *copy = true;
    RelationClose(idx_rel);
 
-   /*
-    * Always copy oids if the table has them, even if not included in the
-    * index. The space in the logged tuple is used anyway, so there's little
-    * point in not including the information.
-    */
-   if (relation->rd_rel->relhasoids)
-       HeapTupleSetOid(key_tuple, HeapTupleGetOid(tp));
-
    /*
     * If the tuple, which by here only contains indexed columns, still has
     * toasted columns, force them to be inlined. This is somewhat unlikely
index cd42c50b09c8a2ac468118b83be9eb8e0348d352..fdbaf38126d99d0c3ba554fc01063a2f44634277 100644 (file)
@@ -723,8 +723,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
    hoff = SizeofHeapTupleHeader;
    if (has_nulls)
        hoff += BITMAPLEN(numAttrs);
-   if (newtup->t_data->t_infomask & HEAP_HASOID)
-       hoff += sizeof(Oid);
    hoff = MAXALIGN(hoff);
    /* now convert to a limit on the tuple data size */
    maxDataLen = RelationGetToastTupleTarget(rel, TOAST_TUPLE_TARGET) - hoff;
@@ -1013,8 +1011,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
        new_header_len = SizeofHeapTupleHeader;
        if (has_nulls)
            new_header_len += BITMAPLEN(numAttrs);
-       if (olddata->t_infomask & HEAP_HASOID)
-           new_header_len += sizeof(Oid);
        new_header_len = MAXALIGN(new_header_len);
        new_data_len = heap_compute_data_size(tupleDesc,
                                              toast_values, toast_isnull);
@@ -1036,8 +1032,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
        memcpy(new_data, olddata, SizeofHeapTupleHeader);
        HeapTupleHeaderSetNatts(new_data, numAttrs);
        new_data->t_hoff = new_header_len;
-       if (olddata->t_infomask & HEAP_HASOID)
-           HeapTupleHeaderSetOid(new_data, HeapTupleHeaderGetOid(olddata));
 
        /* Copy over the data, and fill the null bitmap if needed */
        heap_fill_tuple(tupleDesc,
@@ -1124,13 +1118,10 @@ toast_flatten_tuple(HeapTuple tup, TupleDesc tupleDesc)
    new_tuple = heap_form_tuple(tupleDesc, toast_values, toast_isnull);
 
    /*
-    * Be sure to copy the tuple's OID and identity fields.  We also make a
-    * point of copying visibility info, just in case anybody looks at those
-    * fields in a syscache entry.
+    * Be sure to copy the tuple's identity fields.  We also make a point of
+    * copying visibility info, just in case anybody looks at those fields in
+    * a syscache entry.
     */
-   if (tupleDesc->tdhasoid)
-       HeapTupleSetOid(new_tuple, HeapTupleGetOid(tup));
-
    new_tuple->t_self = tup->t_self;
    new_tuple->t_tableOid = tup->t_tableOid;
 
@@ -1244,8 +1235,6 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
    new_header_len = SizeofHeapTupleHeader;
    if (has_nulls)
        new_header_len += BITMAPLEN(numAttrs);
-   if (tup->t_infomask & HEAP_HASOID)
-       new_header_len += sizeof(Oid);
    new_header_len = MAXALIGN(new_header_len);
    new_data_len = heap_compute_data_size(tupleDesc,
                                          toast_values, toast_isnull);
@@ -1259,8 +1248,6 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
    memcpy(new_data, tup, SizeofHeapTupleHeader);
    HeapTupleHeaderSetNatts(new_data, numAttrs);
    new_data->t_hoff = new_header_len;
-   if (tup->t_infomask & HEAP_HASOID)
-       HeapTupleHeaderSetOid(new_data, HeapTupleHeaderGetOid(tup));
 
    /* Set the composite-Datum header fields correctly */
    HeapTupleHeaderSetDatumLength(new_data, new_tuple_len);
@@ -1796,7 +1783,7 @@ toast_delete_datum(Relation rel, Datum value, bool is_speculative)
  *
  * Test whether a toast value with the given ID exists in the toast relation.
  * For safety, we consider a value to exist if there are either live or dead
- * toast rows with that ID; see notes for GetNewOid().
+ * toast rows with that ID; see notes for GetNewOidWithIndex().
  * ----------
  */
 static bool
index 599203c96ce8f09598955764a9cfad11a9395504..66b940c66ccba0b76c7a9c50559e163a7f9c70b3 100644 (file)
@@ -434,7 +434,7 @@ pg_last_committed_xact(PG_FUNCTION_ARGS)
     * Construct a tuple descriptor for the result row.  This must match this
     * function's pg_proc entry!
     */
-   tupdesc = CreateTemplateTupleDesc(2, false);
+   tupdesc = CreateTemplateTupleDesc(2);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, "xid",
                       XIDOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 2, "timestamp",
index 365daf153abe55f1e4f8d9d1b17869c9cbe2fcae..82346f1000d3f2e3f6a9f5f604ebb4b37e711ad9 100644 (file)
@@ -3368,7 +3368,7 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
                                                false);
        multi->iter = 0;
 
-       tupdesc = CreateTemplateTupleDesc(2, false);
+       tupdesc = CreateTemplateTupleDesc(2);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1, "xid",
                           XIDOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 2, "mode",
index 3942734e5ae66659a6c6ef3c831269b1ed9ad76f..e65dccc6a2c54e23919a639d66944860a6fc271c 100644 (file)
@@ -734,7 +734,7 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
 
        /* build tupdesc for result tuples */
        /* this had better match pg_prepared_xacts view in system_views.sql */
-       tupdesc = CreateTemplateTupleDesc(5, false);
+       tupdesc = CreateTemplateTupleDesc(5);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1, "transaction",
                           XIDOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 2, "gid",
index 664735b38146af3887aaa011608444c9b2137d0c..a5eb29e01acaf91e81152db01a7720ffe6ee7571 100644 (file)
@@ -451,8 +451,8 @@ ForceTransactionIdLimitUpdate(void)
  * OIDs are generated by a cluster-wide counter.  Since they are only 32 bits
  * wide, counter wraparound will occur eventually, and therefore it is unwise
  * to assume they are unique unless precautions are taken to make them so.
- * Hence, this routine should generally not be used directly.  The only
- * direct callers should be GetNewOid() and GetNewRelFileNode() in
+ * Hence, this routine should generally not be used directly.  The only direct
+ * callers should be GetNewOidWithIndex() and GetNewRelFileNode() in
  * catalog/catalog.c.
  */
 Oid
index a31adcca5ebf0e1a368a86293164c546a1203459..bd18f496af1a72e4b05a209b1c9e320edb312b0a 100644 (file)
@@ -471,7 +471,7 @@ pg_walfile_name_offset(PG_FUNCTION_ARGS)
     * Construct a tuple descriptor for the result row.  This must match this
     * function's pg_proc entry!
     */
-   resultTupleDesc = CreateTemplateTupleDesc(2, false);
+   resultTupleDesc = CreateTemplateTupleDesc(2);
    TupleDescInitEntry(resultTupleDesc, (AttrNumber) 1, "file_name",
                       TEXTOID, -1, 0);
    TupleDescInitEntry(resultTupleDesc, (AttrNumber) 2, "file_offset",
index 4c72989cc25e74ae563d671b95579bf82455eb19..f49c808eeb7a3831276c34ae8facde8c869177ff 100644 (file)
@@ -113,7 +113,7 @@ static int num_columns_read = 0;
 %type <list>  boot_index_params
 %type <ielem> boot_index_param
 %type <str>   boot_ident
-%type <ival>  optbootstrap optsharedrelation optwithoutoids boot_column_nullness
+%type <ival>  optbootstrap optsharedrelation boot_column_nullness
 %type <oidval> oidspec optoideq optrowtypeoid
 
 %token <str> ID
@@ -123,7 +123,7 @@ static int num_columns_read = 0;
 /* All the rest are unreserved, and should be handled in boot_ident! */
 %token <kw> OPEN XCLOSE XCREATE INSERT_TUPLE
 %token <kw> XDECLARE INDEX ON USING XBUILD INDICES UNIQUE XTOAST
-%token <kw> OBJ_ID XBOOTSTRAP XSHARED_RELATION XWITHOUT_OIDS XROWTYPE_OID
+%token <kw> OBJ_ID XBOOTSTRAP XSHARED_RELATION XROWTYPE_OID
 %token <kw> XFORCE XNOT XNULL
 
 %start TopLevel
@@ -170,7 +170,7 @@ Boot_CloseStmt:
        ;
 
 Boot_CreateStmt:
-         XCREATE boot_ident oidspec optbootstrap optsharedrelation optwithoutoids optrowtypeoid LPAREN
+         XCREATE boot_ident oidspec optbootstrap optsharedrelation optrowtypeoid LPAREN
                {
                    do_start();
                    numattr = 0;
@@ -192,7 +192,7 @@ Boot_CreateStmt:
 
                    do_start();
 
-                   tupdesc = CreateTupleDesc(numattr, !($6), attrtypes);
+                   tupdesc = CreateTupleDesc(numattr, attrtypes);
 
                    shared_relation = $5;
 
@@ -236,7 +236,7 @@ Boot_CreateStmt:
                                                      PG_CATALOG_NAMESPACE,
                                                      shared_relation ? GLOBALTABLESPACE_OID : 0,
                                                      $3,
-                                                     $7,
+                                                     $6,
                                                      InvalidOid,
                                                      BOOTSTRAP_SUPERUSERID,
                                                      tupdesc,
@@ -245,8 +245,6 @@ Boot_CreateStmt:
                                                      RELPERSISTENCE_PERMANENT,
                                                      shared_relation,
                                                      mapped_relation,
-                                                     true,
-                                                     0,
                                                      ONCOMMIT_NOOP,
                                                      (Datum) 0,
                                                      false,
@@ -432,11 +430,6 @@ optsharedrelation:
        |                       { $$ = 0; }
        ;
 
-optwithoutoids:
-           XWITHOUT_OIDS   { $$ = 1; }
-       |                   { $$ = 0; }
-       ;
-
 optrowtypeoid:
            XROWTYPE_OID oidspec    { $$ = $2; }
        |                           { $$ = InvalidOid; }
@@ -501,7 +494,6 @@ boot_ident:
        | OBJ_ID        { $$ = pstrdup($1); }
        | XBOOTSTRAP    { $$ = pstrdup($1); }
        | XSHARED_RELATION  { $$ = pstrdup($1); }
-       | XWITHOUT_OIDS { $$ = pstrdup($1); }
        | XROWTYPE_OID  { $$ = pstrdup($1); }
        | XFORCE        { $$ = pstrdup($1); }
        | XNOT          { $$ = pstrdup($1); }
index 739087b786f306ee6a9ff2013a2de70142030205..14bc0888979fc94c0355344ea0d635bf50698eb3 100644 (file)
@@ -91,7 +91,6 @@ create            { yylval.kw = "create"; return XCREATE; }
 OID                { yylval.kw = "OID"; return OBJ_ID; }
 bootstrap      { yylval.kw = "bootstrap"; return XBOOTSTRAP; }
 shared_relation    { yylval.kw = "shared_relation"; return XSHARED_RELATION; }
-without_oids   { yylval.kw = "without_oids"; return XWITHOUT_OIDS; }
 rowtype_oid        { yylval.kw = "rowtype_oid"; return XROWTYPE_OID; }
 
 insert         { yylval.kw = "insert"; return INSERT_TUPLE; }
index 578af2e66d8c982ad7bc31b083aaf46a95294096..8e2cf7df562abfdbba06f0d8dd6b9d177e785d7e 100644 (file)
@@ -616,7 +616,7 @@ boot_openrel(char *relname)
        app = Typ;
        while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
        {
-           (*app)->am_oid = HeapTupleGetOid(tup);
+           (*app)->am_oid = ((Form_pg_type) GETSTRUCT(tup))->oid;
            memcpy((char *) &(*app)->am_typ,
                   (char *) GETSTRUCT(tup),
                   sizeof((*app)->am_typ));
@@ -807,12 +807,8 @@ InsertOneTuple(Oid objectid)
 
    elog(DEBUG4, "inserting row oid %u, %d columns", objectid, numattr);
 
-   tupDesc = CreateTupleDesc(numattr,
-                             RelationGetForm(boot_reldesc)->relhasoids,
-                             attrtypes);
+   tupDesc = CreateTupleDesc(numattr, attrtypes);
    tuple = heap_form_tuple(tupDesc, values, Nulls);
-   if (objectid != (Oid) 0)
-       HeapTupleSetOid(tuple, objectid);
    pfree(tupDesc);             /* just free's tupDesc, not the attrtypes */
 
    simple_heap_insert(boot_reldesc, tuple);
@@ -946,7 +942,7 @@ gettype(char *type)
        app = Typ;
        while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
        {
-           (*app)->am_oid = HeapTupleGetOid(tup);
+           (*app)->am_oid = ((Form_pg_type) GETSTRUCT(tup))->oid;
            memmove((char *) &(*app++)->am_typ,
                    (char *) GETSTRUCT(tup),
                    sizeof((*app)->am_typ));
index 9699dfd8d52a6303f0677ab90ba15a1343628c0d..d5c096f7d1b5bc244200c8db28f262713dac116d 100644 (file)
@@ -111,8 +111,6 @@ sub ParseHeader
            $catalog{bootstrap} = /BKI_BOOTSTRAP/ ? ' bootstrap' : '';
            $catalog{shared_relation} =
              /BKI_SHARED_RELATION/ ? ' shared_relation' : '';
-           $catalog{without_oids} =
-             /BKI_WITHOUT_OIDS/ ? ' without_oids' : '';
            if (/BKI_ROWTYPE_OID\((\d+),(\w+)\)/)
            {
                $catalog{rowtype_oid}        = $1;
@@ -337,6 +335,10 @@ sub AddDefaultValues
        {
            ;
        }
+       elsif ($attname eq 'oid')
+       {
+           ;
+       }
        elsif (defined $column->{default})
        {
            $row->{$attname} = $column->{default};
index bd147752ef90ba86de844a20933fb2c276a127c7..1dd70bb9c693e9a9516ead77020cd09e9f0bbab2 100644 (file)
@@ -848,7 +848,9 @@ objectsInSchemaToOids(ObjectType objtype, List *nspnames)
 
                    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
                    {
-                       objects = lappend_oid(objects, HeapTupleGetOid(tuple));
+                       Oid     oid = ((Form_pg_proc) GETSTRUCT(tuple))->oid;
+
+                       objects = lappend_oid(objects, oid);
                    }
 
                    heap_endscan(scan);
@@ -893,7 +895,9 @@ getRelationsInNamespace(Oid namespaceId, char relkind)
 
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
-       relations = lappend_oid(relations, HeapTupleGetOid(tuple));
+       Oid     oid  = ((Form_pg_class) GETSTRUCT(tuple))->oid;
+
+       relations = lappend_oid(relations, oid);
    }
 
    heap_endscan(scan);
@@ -1299,7 +1303,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
             * there shouldn't be anything depending on this entry.
             */
            myself.classId = DefaultAclRelationId;
-           myself.objectId = HeapTupleGetOid(tuple);
+           myself.objectId = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
            myself.objectSubId = 0;
 
            performDeletion(&myself, DROP_RESTRICT, 0);
@@ -1307,6 +1311,8 @@ SetDefaultACL(InternalDefaultACL *iacls)
    }
    else
    {
+       Oid     defAclOid;
+
        /* Prepare to insert or update pg_default_acl entry */
        MemSet(values, 0, sizeof(values));
        MemSet(nulls, false, sizeof(nulls));
@@ -1315,6 +1321,9 @@ SetDefaultACL(InternalDefaultACL *iacls)
        if (isNew)
        {
            /* insert new entry */
+           defAclOid = GetNewOidWithIndex(rel, DefaultAclOidIndexId,
+                                          Anum_pg_default_acl_oid);
+           values[Anum_pg_default_acl_oid - 1] = ObjectIdGetDatum(defAclOid);
            values[Anum_pg_default_acl_defaclrole - 1] = ObjectIdGetDatum(iacls->roleid);
            values[Anum_pg_default_acl_defaclnamespace - 1] = ObjectIdGetDatum(iacls->nspid);
            values[Anum_pg_default_acl_defaclobjtype - 1] = CharGetDatum(objtype);
@@ -1325,6 +1334,8 @@ SetDefaultACL(InternalDefaultACL *iacls)
        }
        else
        {
+           defAclOid = ((Form_pg_default_acl) GETSTRUCT(tuple))->oid;
+
            /* update existing entry */
            values[Anum_pg_default_acl_defaclacl - 1] = PointerGetDatum(new_acl);
            replaces[Anum_pg_default_acl_defaclacl - 1] = true;
@@ -1338,8 +1349,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
        if (isNew)
        {
            /* dependency on role */
-           recordDependencyOnOwner(DefaultAclRelationId,
-                                   HeapTupleGetOid(newtuple),
+           recordDependencyOnOwner(DefaultAclRelationId, defAclOid,
                                    iacls->roleid);
 
            /* dependency on namespace */
@@ -1349,7 +1359,7 @@ SetDefaultACL(InternalDefaultACL *iacls)
                            referenced;
 
                myself.classId = DefaultAclRelationId;
-               myself.objectId = HeapTupleGetOid(newtuple);
+               myself.objectId = defAclOid;
                myself.objectSubId = 0;
 
                referenced.classId = NamespaceRelationId;
@@ -1366,17 +1376,15 @@ SetDefaultACL(InternalDefaultACL *iacls)
        nnewmembers = aclmembers(new_acl, &newmembers);
 
        updateAclDependencies(DefaultAclRelationId,
-                             HeapTupleGetOid(newtuple), 0,
+                             defAclOid, 0,
                              iacls->roleid,
                              noldmembers, oldmembers,
                              nnewmembers, newmembers);
 
        if (isNew)
-           InvokeObjectPostCreateHook(DefaultAclRelationId,
-                                      HeapTupleGetOid(newtuple), 0);
+           InvokeObjectPostCreateHook(DefaultAclRelationId, defAclOid, 0);
        else
-           InvokeObjectPostAlterHook(DefaultAclRelationId,
-                                     HeapTupleGetOid(newtuple), 0);
+           InvokeObjectPostAlterHook(DefaultAclRelationId,  defAclOid, 0);
    }
 
    if (HeapTupleIsValid(tuple))
@@ -1407,7 +1415,7 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
        rel = heap_open(DefaultAclRelationId, AccessShareLock);
 
        ScanKeyInit(&skey[0],
-                   ObjectIdAttributeNumber,
+                   Anum_pg_default_acl_oid,
                    BTEqualStrategyNumber, F_OIDEQ,
                    ObjectIdGetDatum(objid));
 
@@ -1530,7 +1538,7 @@ RemoveDefaultACLById(Oid defaclOid)
    rel = heap_open(DefaultAclRelationId, RowExclusiveLock);
 
    ScanKeyInit(&skey[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_default_acl_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(defaclOid));
 
@@ -1608,10 +1616,6 @@ expand_all_col_privileges(Oid table_oid, Form_pg_class classForm,
        if (curr_att == InvalidAttrNumber)
            continue;
 
-       /* Skip OID column if it doesn't exist */
-       if (curr_att == ObjectIdAttributeNumber && !classForm->relhasoids)
-           continue;
-
        /* Views don't have any system columns at all */
        if (classForm->relkind == RELKIND_VIEW && curr_att < 0)
            continue;
@@ -2223,7 +2227,7 @@ ExecGrant_Database(InternalGrant *istmt)
        CatalogTupleUpdate(relation, &newtuple->t_self, newtuple);
 
        /* Update the shared dependency ACL info */
-       updateAclDependencies(DatabaseRelationId, HeapTupleGetOid(tuple), 0,
+       updateAclDependencies(DatabaseRelationId, pg_database_tuple->oid, 0,
                              ownerId,
                              noldmembers, oldmembers,
                              nnewmembers, newmembers);
@@ -2350,7 +2354,7 @@ ExecGrant_Fdw(InternalGrant *istmt)
 
        /* Update the shared dependency ACL info */
        updateAclDependencies(ForeignDataWrapperRelationId,
-                             HeapTupleGetOid(tuple), 0,
+                             pg_fdw_tuple->oid, 0,
                              ownerId,
                              noldmembers, oldmembers,
                              nnewmembers, newmembers);
@@ -2475,7 +2479,7 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
 
        /* Update the shared dependency ACL info */
        updateAclDependencies(ForeignServerRelationId,
-                             HeapTupleGetOid(tuple), 0,
+                             pg_server_tuple->oid, 0,
                              ownerId,
                              noldmembers, oldmembers,
                              nnewmembers, newmembers);
@@ -2729,7 +2733,7 @@ ExecGrant_Language(InternalGrant *istmt)
        recordExtensionInitPriv(langId, LanguageRelationId, 0, new_acl);
 
        /* Update the shared dependency ACL info */
-       updateAclDependencies(LanguageRelationId, HeapTupleGetOid(tuple), 0,
+       updateAclDependencies(LanguageRelationId, pg_language_tuple->oid, 0,
                              ownerId,
                              noldmembers, oldmembers,
                              nnewmembers, newmembers);
@@ -2784,7 +2788,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
 
        /* There's no syscache for pg_largeobject_metadata */
        ScanKeyInit(&entry[0],
-                   ObjectIdAttributeNumber,
+                   Anum_pg_largeobject_metadata_oid,
                    BTEqualStrategyNumber, F_OIDEQ,
                    ObjectIdGetDatum(loid));
 
@@ -2869,7 +2873,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
 
        /* Update the shared dependency ACL info */
        updateAclDependencies(LargeObjectRelationId,
-                             HeapTupleGetOid(tuple), 0,
+                             form_lo_meta->oid, 0,
                              ownerId,
                              noldmembers, oldmembers,
                              nnewmembers, newmembers);
@@ -2993,7 +2997,7 @@ ExecGrant_Namespace(InternalGrant *istmt)
        recordExtensionInitPriv(nspid, NamespaceRelationId, 0, new_acl);
 
        /* Update the shared dependency ACL info */
-       updateAclDependencies(NamespaceRelationId, HeapTupleGetOid(tuple), 0,
+       updateAclDependencies(NamespaceRelationId, pg_namespace_tuple->oid, 0,
                              ownerId,
                              noldmembers, oldmembers,
                              nnewmembers, newmembers);
@@ -4116,7 +4120,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
                           AccessShareLock);
 
    ScanKeyInit(&entry[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_largeobject_metadata_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(lobj_oid));
 
@@ -4898,7 +4902,7 @@ pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
                           AccessShareLock);
 
    ScanKeyInit(&entry[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_largeobject_metadata_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(lobj_oid));
 
@@ -5260,7 +5264,7 @@ pg_extension_ownercheck(Oid ext_oid, Oid roleid)
    pg_extension = heap_open(ExtensionRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_extension_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(ext_oid));
 
@@ -5726,7 +5730,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
 
        /* There's no syscache for pg_largeobject_metadata */
        ScanKeyInit(&entry[0],
-                   ObjectIdAttributeNumber,
+                   Anum_pg_largeobject_metadata_oid,
                    BTEqualStrategyNumber, F_OIDEQ,
                    ObjectIdGetDatum(objoid));
 
index 6061428bccd401cd84e94645de9a077d7d26fbba..54b0cf17a9310ce3d59cf1c9a54a90a87375f0eb 100644 (file)
@@ -21,6 +21,8 @@
 #include <unistd.h>
 
 #include "access/genam.h"
+#include "access/heapam.h"
+#include "access/htup_details.h"
 #include "access/sysattr.h"
 #include "access/transam.h"
 #include "catalog/catalog.h"
@@ -43,7 +45,9 @@
 #include "miscadmin.h"
 #include "storage/fd.h"
 #include "utils/fmgroids.h"
+#include "utils/fmgrprotos.h"
 #include "utils/rel.h"
+#include "utils/syscache.h"
 #include "utils/tqual.h"
 
 
@@ -277,17 +281,8 @@ IsSharedRelation(Oid relationId)
 
 
 /*
- * GetNewOid
- *     Generate a new OID that is unique within the given relation.
- *
- * Caller must have a suitable lock on the relation.
- *
- * Uniqueness is promised only if the relation has a unique index on OID.
- * This is true for all system catalogs that have OIDs, but might not be
- * true for user tables.  Note that we are effectively assuming that the
- * table has a relatively small number of entries (much less than 2^32)
- * and there aren't very long runs of consecutive existing OIDs.  Again,
- * this is reasonable for system catalogs but less so for user tables.
+ * GetNewOidWithIndex
+ *     Generate a new OID that is unique within the system relation.
  *
  * Since the OID is not immediately inserted into the table, there is a
  * race condition here; but a problem could occur only if someone else
@@ -300,44 +295,11 @@ IsSharedRelation(Oid relationId)
  * of transient conflicts for as long as our own MVCC snapshots think a
  * recently-deleted row is live.  The risk is far higher when selecting TOAST
  * OIDs, because SnapshotToast considers dead rows as active indefinitely.)
- */
-Oid
-GetNewOid(Relation relation)
-{
-   Oid         oidIndex;
-
-   /* If relation doesn't have OIDs at all, caller is confused */
-   Assert(relation->rd_rel->relhasoids);
-
-   /* In bootstrap mode, we don't have any indexes to use */
-   if (IsBootstrapProcessingMode())
-       return GetNewObjectId();
-
-   /* The relcache will cache the identity of the OID index for us */
-   oidIndex = RelationGetOidIndex(relation);
-
-   /* If no OID index, just hand back the next OID counter value */
-   if (!OidIsValid(oidIndex))
-   {
-       /*
-        * System catalogs that have OIDs should *always* have a unique OID
-        * index; we should only take this path for user tables. Give a
-        * warning if it looks like somebody forgot an index.
-        */
-       if (IsSystemRelation(relation))
-           elog(WARNING, "generating possibly-non-unique OID for \"%s\"",
-                RelationGetRelationName(relation));
-
-       return GetNewObjectId();
-   }
-
-   /* Otherwise, use the index to find a nonconflicting OID */
-   return GetNewOidWithIndex(relation, oidIndex, ObjectIdAttributeNumber);
-}
-
-/*
- * GetNewOidWithIndex
- *     Guts of GetNewOid: use the supplied index
+ *
+ * Note that we are effectively assuming that the table has a relatively small
+ * number of entries (much less than 2^32) and there aren't very long runs of
+ * consecutive existing OIDs.  This is a mostly reasonable assumption for
+ * system catalogs.
  *
  * This is exported separately because there are cases where we want to use
  * an index that will not be recognized by RelationGetOidIndex: TOAST tables
@@ -356,6 +318,13 @@ GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
    ScanKeyData key;
    bool        collides;
 
+   /* Only system relations are supported */
+   Assert(IsSystemRelation(relation));
+
+   /* In bootstrap mode, we don't have any indexes to use */
+   if (IsBootstrapProcessingMode())
+       return GetNewObjectId();
+
    /*
     * We should never be asked to generate a new pg_type OID during
     * pg_upgrade; doing so would risk collisions with the OIDs it wants to
@@ -450,7 +419,8 @@ GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
 
        /* Generate the OID */
        if (pg_class)
-           rnode.node.relNode = GetNewOid(pg_class);
+           rnode.node.relNode = GetNewOidWithIndex(pg_class, ClassOidIndexId,
+                                                   Anum_pg_class_oid);
        else
            rnode.node.relNode = GetNewObjectId();
 
@@ -479,3 +449,82 @@ GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
 
    return rnode.node.relNode;
 }
+
+/*
+ * SQL callable interface for GetNewOidWithIndex().  Outside of initdb's
+ * direct insertions into catalog tables, and recovering from corruption, this
+ * should rarely be needed.
+ *
+ * Function is intentionally not documented in the user facing docs.
+ */
+Datum
+pg_nextoid(PG_FUNCTION_ARGS)
+{
+   Oid     reloid = PG_GETARG_OID(0);
+   Name    attname = PG_GETARG_NAME(1);
+   Oid     idxoid = PG_GETARG_OID(2);
+   Relation rel;
+   Relation idx;
+   HeapTuple atttuple;
+   Form_pg_attribute attform;
+   AttrNumber attno;
+   Oid     newoid;
+
+   /*
+    * As this function is not intended to be used during normal running, and
+    * only supports system catalogs (which require superuser permissions to
+    * modify), just checking for superuser ought to not obstruct valid
+    * usecases.
+    */
+   if (!superuser())
+       ereport(ERROR,
+               (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+                errmsg("must be superuser to call pg_nextoid")));
+
+   rel = heap_open(reloid, RowExclusiveLock);
+   idx = index_open(idxoid, RowExclusiveLock);
+
+   if (!IsSystemRelation(rel))
+       ereport(ERROR,
+               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                errmsg("pg_nextoid() can only be used on system relation")));
+
+   if (idx->rd_index->indrelid != RelationGetRelid(rel))
+       ereport(ERROR,
+               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                errmsg("index %s does not belong to table %s",
+                       RelationGetRelationName(idx),
+                       RelationGetRelationName(rel))));
+
+   atttuple = SearchSysCacheAttName(reloid, NameStr(*attname));
+   if (!HeapTupleIsValid(atttuple))
+       ereport(ERROR,
+               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                errmsg("attribute %s does not exists",
+                       NameStr(*attname))));
+
+   attform = ((Form_pg_attribute) GETSTRUCT(atttuple));
+   attno = attform->attnum;
+
+   if (attform->atttypid != OIDOID)
+       ereport(ERROR,
+               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                errmsg("attribute %s is not of type oid",
+                       NameStr(*attname))));
+
+   if (IndexRelationGetNumberOfKeyAttributes(idx) != 1 ||
+       idx->rd_index->indkey.values[0] != attno)
+       ereport(ERROR,
+               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                errmsg("index %s is not the index for attribute %s",
+                       RelationGetRelationName(idx),
+                       NameStr(*attname))));
+
+   newoid = GetNewOidWithIndex(rel, idxoid, attno);
+
+   ReleaseSysCache(atttuple);
+   heap_close(rel, RowExclusiveLock);
+   index_close(idx, RowExclusiveLock);
+
+   return newoid;
+}
index 649200260a4e0d36d2c377190301852a7eef1b02..9c56f386c4299e9c7ad5696b579b77bde26f87c9 100644 (file)
@@ -133,9 +133,17 @@ foreach my $header (@input_files)
 # While duplicate OIDs would only cause a failure if they appear in
 # the same catalog, our project policy is that manually assigned OIDs
 # should be globally unique, to avoid confusion.
+#
+# Also use the loop to determine the maximum explicitly assigned oid
+# found in the data file, we'll use that for default oid assignments.
 my $found = 0;
+my $maxoid = 0;
 foreach my $oid (keys %oidcounts)
 {
+   if ($oid > $maxoid)
+   {
+       $maxoid = $oid;
+   }
    next unless $oidcounts{$oid} > 1;
    print STDERR "Duplicate OIDs detected:\n" if !$found;
    print STDERR "$oid\n";
@@ -320,7 +328,6 @@ EOM
    print $bki "create $catname $catalog->{relation_oid}"
      . $catalog->{shared_relation}
      . $catalog->{bootstrap}
-     . $catalog->{without_oids}
      . $catalog->{rowtype_oid_clause};
 
    my $first = 1;
@@ -392,8 +399,7 @@ EOM
        foreach my $key (keys %bki_values)
        {
            next
-             if $key eq "oid"
-             || $key eq "oid_symbol"
+             if $key eq "oid_symbol"
              || $key eq "array_type_oid"
              || $key eq "descr"
              || $key eq "autogenerated"
@@ -409,6 +415,13 @@ EOM
            my $attname = $column->{name};
            my $atttype = $column->{type};
 
+           # Assign oid if oid column exists and no explicit assignment in row
+           if ($attname eq "oid" and not defined $bki_values{$attname})
+           {
+               $bki_values{$attname} = $maxoid;
+               $maxoid++;
+           }
+
            # Substitute constant values we acquired above.
            # (It's intentional that this can apply to parts of a field).
            $bki_values{$attname} =~ s/\bPGUID\b/$BOOTSTRAP_SUPERUSERID/g;
@@ -627,7 +640,6 @@ sub gen_pg_attribute
            $attnum = 0;
            my @SYS_ATTRS = (
                { name => 'ctid',     type => 'tid' },
-               { name => 'oid',      type => 'oid' },
                { name => 'xmin',     type => 'xid' },
                { name => 'cmin',     type => 'cid' },
                { name => 'xmax',     type => 'xid' },
@@ -641,11 +653,6 @@ sub gen_pg_attribute
                $row{attrelid}      = $table->{relation_oid};
                $row{attstattarget} = '0';
 
-               # Omit the oid column if the catalog doesn't have them
-               next
-                 if $table->{without_oids}
-                 && $attr->{name} eq 'oid';
-
                morph_row_for_pgattr(\%row, $schema, $attr, 1);
                print_bki_insert(\%row, $schema);
            }
index bd4c439ef356f2e1c459ab819675299a69ae4ae3..11debaa780e7f3c47f90ba19dd003352c49324b6 100644 (file)
@@ -159,20 +159,6 @@ static const FormData_pg_attribute a1 = {
 };
 
 static const FormData_pg_attribute a2 = {
-   .attname = {"oid"},
-   .atttypid = OIDOID,
-   .attlen = sizeof(Oid),
-   .attnum = ObjectIdAttributeNumber,
-   .attcacheoff = -1,
-   .atttypmod = -1,
-   .attbyval = true,
-   .attstorage = 'p',
-   .attalign = 'i',
-   .attnotnull = true,
-   .attislocal = true,
-};
-
-static const FormData_pg_attribute a3 = {
    .attname = {"xmin"},
    .atttypid = XIDOID,
    .attlen = sizeof(TransactionId),
@@ -186,7 +172,7 @@ static const FormData_pg_attribute a3 = {
    .attislocal = true,
 };
 
-static const FormData_pg_attribute a4 = {
+static const FormData_pg_attribute a3 = {
    .attname = {"cmin"},
    .atttypid = CIDOID,
    .attlen = sizeof(CommandId),
@@ -200,7 +186,7 @@ static const FormData_pg_attribute a4 = {
    .attislocal = true,
 };
 
-static const FormData_pg_attribute a5 = {
+static const FormData_pg_attribute a4 = {
    .attname = {"xmax"},
    .atttypid = XIDOID,
    .attlen = sizeof(TransactionId),
@@ -214,7 +200,7 @@ static const FormData_pg_attribute a5 = {
    .attislocal = true,
 };
 
-static const FormData_pg_attribute a6 = {
+static const FormData_pg_attribute a5 = {
    .attname = {"cmax"},
    .atttypid = CIDOID,
    .attlen = sizeof(CommandId),
@@ -234,7 +220,7 @@ static const FormData_pg_attribute a6 = {
  * table of a particular class/type. In any case table is still the word
  * used in SQL.
  */
-static const FormData_pg_attribute a7 = {
+static const FormData_pg_attribute a6 = {
    .attname = {"tableoid"},
    .atttypid = OIDOID,
    .attlen = sizeof(Oid),
@@ -248,7 +234,7 @@ static const FormData_pg_attribute a7 = {
    .attislocal = true,
 };
 
-static const FormData_pg_attribute *SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
+static const FormData_pg_attribute *SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6};
 
 /*
  * This function returns a Form_pg_attribute pointer for a system attribute.
@@ -256,12 +242,10 @@ static const FormData_pg_attribute *SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a
  * happen if there's a problem upstream.
  */
 const FormData_pg_attribute *
-SystemAttributeDefinition(AttrNumber attno, bool relhasoids)
+SystemAttributeDefinition(AttrNumber attno)
 {
    if (attno >= 0 || attno < -(int) lengthof(SysAtt))
        elog(ERROR, "invalid system attribute number %d", attno);
-   if (attno == ObjectIdAttributeNumber && !relhasoids)
-       elog(ERROR, "invalid system attribute number %d", attno);
    return SysAtt[-attno - 1];
 }
 
@@ -270,7 +254,7 @@ SystemAttributeDefinition(AttrNumber attno, bool relhasoids)
  * pointer for a prototype definition.  If not, return NULL.
  */
 const FormData_pg_attribute *
-SystemAttributeByName(const char *attname, bool relhasoids)
+SystemAttributeByName(const char *attname)
 {
    int         j;
 
@@ -278,11 +262,8 @@ SystemAttributeByName(const char *attname, bool relhasoids)
    {
        const FormData_pg_attribute *att = SysAtt[j];
 
-       if (relhasoids || att->attnum != ObjectIdAttributeNumber)
-       {
-           if (strcmp(NameStr(att->attname), attname) == 0)
-               return att;
-       }
+       if (strcmp(NameStr(att->attname), attname) == 0)
+           return att;
    }
 
    return NULL;
@@ -501,8 +482,7 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
        {
            Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
 
-           if (SystemAttributeByName(NameStr(attr->attname),
-                                     tupdesc->tdhasoid) != NULL)
+           if (SystemAttributeByName(NameStr(attr->attname)) != NULL)
                ereport(ERROR,
                        (errcode(ERRCODE_DUPLICATE_COLUMN),
                         errmsg("column name \"%s\" conflicts with a system column name",
@@ -725,9 +705,7 @@ InsertPgAttributeTuple(Relation pg_attribute_rel,
 static void
 AddNewAttributeTuples(Oid new_rel_oid,
                      TupleDesc tupdesc,
-                     char relkind,
-                     bool oidislocal,
-                     int oidinhcount)
+                     char relkind)
 {
    Form_pg_attribute attr;
    int         i;
@@ -789,23 +767,11 @@ AddNewAttributeTuples(Oid new_rel_oid,
        {
            FormData_pg_attribute attStruct;
 
-           /* skip OID where appropriate */
-           if (!tupdesc->tdhasoid &&
-               SysAtt[i]->attnum == ObjectIdAttributeNumber)
-               continue;
-
            memcpy(&attStruct, (char *) SysAtt[i], sizeof(FormData_pg_attribute));
 
            /* Fill in the correct relation OID in the copied tuple */
            attStruct.attrelid = new_rel_oid;
 
-           /* Fill in correct inheritance info for the OID column */
-           if (attStruct.attnum == ObjectIdAttributeNumber)
-           {
-               attStruct.attislocal = oidislocal;
-               attStruct.attinhcount = oidinhcount;
-           }
-
            InsertPgAttributeTuple(rel, &attStruct, indstate);
        }
    }
@@ -847,6 +813,7 @@ InsertPgClassTuple(Relation pg_class_desc,
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   values[Anum_pg_class_oid - 1] = ObjectIdGetDatum(new_rel_oid);
    values[Anum_pg_class_relname - 1] = NameGetDatum(&rd_rel->relname);
    values[Anum_pg_class_relnamespace - 1] = ObjectIdGetDatum(rd_rel->relnamespace);
    values[Anum_pg_class_reltype - 1] = ObjectIdGetDatum(rd_rel->reltype);
@@ -865,7 +832,6 @@ InsertPgClassTuple(Relation pg_class_desc,
    values[Anum_pg_class_relkind - 1] = CharGetDatum(rd_rel->relkind);
    values[Anum_pg_class_relnatts - 1] = Int16GetDatum(rd_rel->relnatts);
    values[Anum_pg_class_relchecks - 1] = Int16GetDatum(rd_rel->relchecks);
-   values[Anum_pg_class_relhasoids - 1] = BoolGetDatum(rd_rel->relhasoids);
    values[Anum_pg_class_relhasrules - 1] = BoolGetDatum(rd_rel->relhasrules);
    values[Anum_pg_class_relhastriggers - 1] = BoolGetDatum(rd_rel->relhastriggers);
    values[Anum_pg_class_relrowsecurity - 1] = BoolGetDatum(rd_rel->relrowsecurity);
@@ -891,12 +857,6 @@ InsertPgClassTuple(Relation pg_class_desc,
 
    tup = heap_form_tuple(RelationGetDescr(pg_class_desc), values, nulls);
 
-   /*
-    * The new tuple must have the oid already chosen for the rel.  Sure would
-    * be embarrassing to do this sort of thing in polite company.
-    */
-   HeapTupleSetOid(tup, new_rel_oid);
-
    /* finally insert the new tuple, update the indexes, and clean up */
    CatalogTupleInsert(pg_class_desc, tup);
 
@@ -1071,8 +1031,6 @@ AddNewRelationType(const char *typeName,
  * relpersistence: rel's persistence status (permanent, temp, or unlogged)
  * shared_relation: true if it's to be a shared relation
  * mapped_relation: true if the relation will use the relfilenode map
- * oidislocal: true if oid column (if any) should be marked attislocal
- * oidinhcount: attinhcount to assign to oid column (if any)
  * oncommit: ON COMMIT marking (only relevant if it's a temp table)
  * reloptions: reloptions in Datum form, or (Datum) 0 if none
  * use_user_acl: true if should look for user-defined default permissions;
@@ -1100,8 +1058,6 @@ heap_create_with_catalog(const char *relname,
                         char relpersistence,
                         bool shared_relation,
                         bool mapped_relation,
-                        bool oidislocal,
-                        int oidinhcount,
                         OnCommitAction oncommit,
                         Datum reloptions,
                         bool use_user_acl,
@@ -1144,7 +1100,7 @@ heap_create_with_catalog(const char *relname,
     * autogenerated array, we can rename it out of the way; otherwise we can
     * at least give a good error message.
     */
-   old_type_oid = GetSysCacheOid2(TYPENAMENSP,
+   old_type_oid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
                                   CStringGetDatum(relname),
                                   ObjectIdGetDatum(relnamespace));
    if (OidIsValid(old_type_oid))
@@ -1347,8 +1303,7 @@ heap_create_with_catalog(const char *relname,
    /*
     * now add tuples to pg_attribute for the attributes in our new relation.
     */
-   AddNewAttributeTuples(relid, new_rel_desc->rd_att, relkind,
-                         oidislocal, oidinhcount);
+   AddNewAttributeTuples(relid, new_rel_desc->rd_att, relkind);
 
    /*
     * Make a dependency link to force the relation to be deleted if its
@@ -1741,9 +1696,10 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
    while (HeapTupleIsValid(tuple = systable_getnext(scan)))
    {
        ObjectAddress object;
+       Form_pg_attrdef attrtuple = (Form_pg_attrdef) GETSTRUCT(tuple);
 
        object.classId = AttrDefaultRelationId;
-       object.objectId = HeapTupleGetOid(tuple);
+       object.objectId = attrtuple->oid;
        object.objectSubId = 0;
 
        performDeletion(&object, behavior,
@@ -1784,7 +1740,7 @@ RemoveAttrDefaultById(Oid attrdefId)
 
    /* Find the pg_attrdef tuple */
    ScanKeyInit(&scankeys[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_attrdef_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(attrdefId));
 
@@ -2162,6 +2118,8 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
    ObjectAddress colobject,
                defobject;
 
+   adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
+
    /*
     * Flatten expression to string form for storage.
     */
@@ -2170,14 +2128,15 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
    /*
     * Make the pg_attrdef entry.
     */
+   attrdefOid = GetNewOidWithIndex(adrel, AttrDefaultOidIndexId,
+                                   Anum_pg_attrdef_oid);
+   values[Anum_pg_attrdef_oid - 1] = ObjectIdGetDatum(attrdefOid);
    values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel);
    values[Anum_pg_attrdef_adnum - 1] = attnum;
    values[Anum_pg_attrdef_adbin - 1] = CStringGetTextDatum(adbin);
 
-   adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
-
    tuple = heap_form_tuple(adrel->rd_att, values, nulls);
-   attrdefOid = CatalogTupleInsert(adrel, tuple);
+   CatalogTupleInsert(adrel, tuple);
 
    defobject.classId = AttrDefaultRelationId;
    defobject.objectId = attrdefOid;
index a980202a7b11f0b82b933021c4097b03aa744a26..8709e8c22c77edaf3ffbd2c677a5e22cb8231bff 100644 (file)
@@ -322,7 +322,7 @@ ConstructTupleDescriptor(Relation heapRelation,
    /*
     * allocate the new tuple descriptor
     */
-   indexTupDesc = CreateTemplateTupleDesc(numatts, false);
+   indexTupDesc = CreateTemplateTupleDesc(numatts);
 
    /*
     * Fill in the pg_attribute row.
@@ -354,24 +354,12 @@ ConstructTupleDescriptor(Relation heapRelation,
            /* Simple index column */
            const FormData_pg_attribute *from;
 
-           if (atnum < 0)
-           {
-               /*
-                * here we are indexing on a system attribute (-1...-n)
-                */
-               from = SystemAttributeDefinition(atnum,
-                                                heapRelation->rd_rel->relhasoids);
-           }
-           else
-           {
-               /*
-                * here we are indexing on a normal attribute (1...n)
-                */
-               if (atnum > natts)  /* safety check */
-                   elog(ERROR, "invalid column number %d", atnum);
-               from = TupleDescAttr(heapTupDesc,
-                                    AttrNumberGetAttrOffset(atnum));
-           }
+           Assert(atnum > 0); /* should've been caught above */
+
+           if (atnum > natts)  /* safety check */
+               elog(ERROR, "invalid column number %d", atnum);
+           from = TupleDescAttr(heapTupDesc,
+                                AttrNumberGetAttrOffset(atnum));
 
            namecpy(&to->attname, &from->attname);
            to->atttypid = from->atttypid;
@@ -945,7 +933,6 @@ index_create(Relation heapRelation,
     */
    indexRelation->rd_rel->relowner = heapRelation->rd_rel->relowner;
    indexRelation->rd_rel->relam = accessMethodObjectId;
-   indexRelation->rd_rel->relhasoids = false;
    indexRelation->rd_rel->relispartition = OidIsValid(parentIndexRelid);
 
    /*
@@ -2147,7 +2134,7 @@ index_update_stats(Relation rel,
        ScanKeyData key[1];
 
        ScanKeyInit(&key[0],
-                   ObjectIdAttributeNumber,
+                   Anum_pg_class_oid,
                    BTEqualStrategyNumber, F_OIDEQ,
                    ObjectIdGetDatum(relid));
 
@@ -3910,11 +3897,6 @@ reindex_relation(Oid relid, int flags, int options)
     * have index entries.  Also, a new pg_class index will be created with a
     * correct entry for its own pg_class row because we do
     * RelationSetNewRelfilenode() before we do index_build().
-    *
-    * Note that we also clear pg_class's rd_oidindex until the loop is done,
-    * so that that index can't be accessed either.  This means we cannot
-    * safely generate new relation OIDs while in the loop; shouldn't be a
-    * problem.
     */
    is_pg_class = (RelationGetRelid(rel) == RelationRelationId);
 
@@ -3958,7 +3940,7 @@ reindex_relation(Oid relid, int flags, int options)
            Oid         indexOid = lfirst_oid(indexId);
 
            if (is_pg_class)
-               RelationSetIndexList(rel, doneIndexes, InvalidOid);
+               RelationSetIndexList(rel, doneIndexes);
 
            reindex_index(indexOid, !(flags & REINDEX_REL_CHECK_CONSTRAINTS),
                          persistence, options);
@@ -3982,7 +3964,7 @@ reindex_relation(Oid relid, int flags, int options)
    ResetReindexPending();
 
    if (is_pg_class)
-       RelationSetIndexList(rel, indexIds, ClassOidIndexId);
+       RelationSetIndexList(rel, indexIds);
 
    /*
     * Close rel, but continue to hold the lock.
index c5f6efba2b628b026ec5db494fd0c83da61e2079..52a2ccb40fc6b9aec78a9c34da14739fc71edfb7 100644 (file)
@@ -160,20 +160,17 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
  * and building the index info structures is moderately expensive.
  * (Use CatalogTupleInsertWithInfo in such cases.)
  */
-Oid
+void
 CatalogTupleInsert(Relation heapRel, HeapTuple tup)
 {
    CatalogIndexState indstate;
-   Oid         oid;
 
    indstate = CatalogOpenIndexes(heapRel);
 
-   oid = simple_heap_insert(heapRel, tup);
+   simple_heap_insert(heapRel, tup);
 
    CatalogIndexInsert(indstate, tup);
    CatalogCloseIndexes(indstate);
-
-   return oid;
 }
 
 /*
@@ -184,17 +181,13 @@ CatalogTupleInsert(Relation heapRel, HeapTuple tup)
  * might cache the CatalogIndexState data somewhere (perhaps in the relcache)
  * so that callers needn't trouble over this ... but we don't do so today.
  */
-Oid
+void
 CatalogTupleInsertWithInfo(Relation heapRel, HeapTuple tup,
                           CatalogIndexState indstate)
 {
-   Oid         oid;
-
-   oid = simple_heap_insert(heapRel, tup);
+   simple_heap_insert(heapRel, tup);
 
    CatalogIndexInsert(indstate, tup);
-
-   return oid;
 }
 
 /*
index f4e69f4a264c4c68d18425eb16090703e956dccc..a3479afa1044f5e8924676ee9e18c3d6435b1f98 100644 (file)
@@ -1583,7 +1583,7 @@ CREATE TABLE sql_features (
     is_supported        yes_or_no,
     is_verified_by      character_data,
     comments            character_data
-) WITHOUT OIDS;
+);
 
 -- Will be filled with external data by initdb.
 
@@ -1604,7 +1604,7 @@ CREATE TABLE sql_implementation_info (
     integer_value               cardinal_number,
     character_value             character_data,
     comments                    character_data
-) WITHOUT OIDS;
+);
 
 INSERT INTO sql_implementation_info VALUES ('10003', 'CATALOG NAME', NULL, 'Y', NULL);
 INSERT INTO sql_implementation_info VALUES ('10004', 'COLLATING SEQUENCE', NULL, (SELECT default_collate_name FROM character_sets), NULL);
@@ -1635,7 +1635,7 @@ CREATE TABLE sql_languages (
     sql_language_implementation character_data,
     sql_language_binding_style  character_data,
     sql_language_programming_language character_data
-) WITHOUT OIDS;
+);
 
 INSERT INTO sql_languages VALUES ('ISO 9075', '1999', 'CORE', NULL, NULL, 'DIRECT', NULL);
 INSERT INTO sql_languages VALUES ('ISO 9075', '1999', 'CORE', NULL, NULL, 'EMBEDDED', 'C');
@@ -1656,7 +1656,7 @@ CREATE TABLE sql_packages (
     is_supported    yes_or_no,
     is_verified_by  character_data,
     comments        character_data
-) WITHOUT OIDS;
+);
 
 INSERT INTO sql_packages VALUES ('PKG000', 'Core', 'NO', NULL, '');
 INSERT INTO sql_packages VALUES ('PKG001', 'Enhanced datetime facilities', 'YES', NULL, '');
@@ -1683,7 +1683,7 @@ CREATE TABLE sql_parts (
     is_supported    yes_or_no,
     is_verified_by  character_data,
     comments        character_data
-) WITHOUT OIDS;
+);
 
 INSERT INTO sql_parts VALUES ('1', 'Framework (SQL/Framework)', 'NO', NULL, '');
 INSERT INTO sql_parts VALUES ('2', 'Foundation (SQL/Foundation)', 'NO', NULL, '');
@@ -1708,7 +1708,7 @@ CREATE TABLE sql_sizing (
     sizing_name     character_data,
     supported_value cardinal_number,
     comments        character_data
-) WITHOUT OIDS;
+);
 
 INSERT INTO sql_sizing VALUES (34,    'MAXIMUM CATALOG NAME LENGTH', 63, NULL);
 INSERT INTO sql_sizing VALUES (30,    'MAXIMUM COLUMN NAME LENGTH', 63, NULL);
@@ -1757,7 +1757,7 @@ CREATE TABLE sql_sizing_profiles (
     profile_id      character_data,
     required_value  cardinal_number,
     comments        character_data
-) WITHOUT OIDS;
+);
 
 GRANT SELECT ON sql_sizing_profiles TO PUBLIC;
 
index 5d13e6a3d70142016f5219c86fc5f4fc1c67c8f6..13a24631fcd12acc7ef21e4d9ba7617457b0c440 100644 (file)
@@ -775,7 +775,7 @@ TypenameGetTypid(const char *typname)
    {
        Oid         namespaceId = lfirst_oid(l);
 
-       typid = GetSysCacheOid2(TYPENAMENSP,
+       typid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
                                PointerGetDatum(typname),
                                ObjectIdGetDatum(namespaceId));
        if (OidIsValid(typid))
@@ -1084,7 +1084,7 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames,
            palloc(offsetof(struct _FuncCandidateList, args) +
                   effective_nargs * sizeof(Oid));
        newResult->pathpos = pathpos;
-       newResult->oid = HeapTupleGetOid(proctup);
+       newResult->oid = procform->oid;
        newResult->nargs = effective_nargs;
        newResult->argnumbers = argnumbers;
        if (argnumbers)
@@ -1488,7 +1488,8 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
                                      ObjectIdGetDatum(namespaceId));
            if (HeapTupleIsValid(opertup))
            {
-               Oid         result = HeapTupleGetOid(opertup);
+               Form_pg_operator operclass = (Form_pg_operator) GETSTRUCT(opertup);
+               Oid         result = operclass->oid;
 
                ReleaseSysCache(opertup);
                return result;
@@ -1533,7 +1534,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
 
            if (operform->oprnamespace == namespaceId)
            {
-               Oid         result = HeapTupleGetOid(opertup);
+               Oid         result = operform->oid;
 
                ReleaseSysCacheList(catlist);
                return result;
@@ -1687,7 +1688,7 @@ OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
                        continue;   /* keep previous result */
                    /* replace previous result */
                    prevResult->pathpos = pathpos;
-                   prevResult->oid = HeapTupleGetOid(opertup);
+                   prevResult->oid = operform->oid;
                    continue;   /* args are same, of course */
                }
            }
@@ -1700,7 +1701,7 @@ OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
        nextResult += SPACE_PER_OP;
 
        newResult->pathpos = pathpos;
-       newResult->oid = HeapTupleGetOid(opertup);
+       newResult->oid = operform->oid;
        newResult->nargs = 2;
        newResult->nvargs = 0;
        newResult->ndargs = 0;
@@ -1790,7 +1791,7 @@ OpclassnameGetOpcid(Oid amid, const char *opcname)
        if (namespaceId == myTempNamespace)
            continue;           /* do not look in temp namespace */
 
-       opcid = GetSysCacheOid3(CLAAMNAMENSP,
+       opcid = GetSysCacheOid3(CLAAMNAMENSP, Anum_pg_opclass_oid,
                                ObjectIdGetDatum(amid),
                                PointerGetDatum(opcname),
                                ObjectIdGetDatum(namespaceId));
@@ -1873,7 +1874,7 @@ OpfamilynameGetOpfid(Oid amid, const char *opfname)
        if (namespaceId == myTempNamespace)
            continue;           /* do not look in temp namespace */
 
-       opfid = GetSysCacheOid3(OPFAMILYAMNAMENSP,
+       opfid = GetSysCacheOid3(OPFAMILYAMNAMENSP, Anum_pg_opfamily_oid,
                                ObjectIdGetDatum(amid),
                                PointerGetDatum(opfname),
                                ObjectIdGetDatum(namespaceId));
@@ -1946,7 +1947,7 @@ lookup_collation(const char *collname, Oid collnamespace, int32 encoding)
    Form_pg_collation collform;
 
    /* Check for encoding-specific entry (exact match) */
-   collid = GetSysCacheOid3(COLLNAMEENCNSP,
+   collid = GetSysCacheOid3(COLLNAMEENCNSP, Anum_pg_collation_oid,
                             PointerGetDatum(collname),
                             Int32GetDatum(encoding),
                             ObjectIdGetDatum(collnamespace));
@@ -1969,13 +1970,13 @@ lookup_collation(const char *collname, Oid collnamespace, int32 encoding)
    if (collform->collprovider == COLLPROVIDER_ICU)
    {
        if (is_encoding_supported_by_icu(encoding))
-           collid = HeapTupleGetOid(colltup);
+           collid = collform->oid;
        else
            collid = InvalidOid;
    }
    else
    {
-       collid = HeapTupleGetOid(colltup);
+       collid = collform->oid;
    }
    ReleaseSysCache(colltup);
    return collid;
@@ -2089,7 +2090,7 @@ ConversionGetConid(const char *conname)
        if (namespaceId == myTempNamespace)
            continue;           /* do not look in temp namespace */
 
-       conid = GetSysCacheOid2(CONNAMENSP,
+       conid = GetSysCacheOid2(CONNAMENSP, Anum_pg_conversion_oid,
                                PointerGetDatum(conname),
                                ObjectIdGetDatum(namespaceId));
        if (OidIsValid(conid))
@@ -2172,7 +2173,7 @@ get_statistics_object_oid(List *names, bool missing_ok)
        if (missing_ok && !OidIsValid(namespaceId))
            stats_oid = InvalidOid;
        else
-           stats_oid = GetSysCacheOid2(STATEXTNAMENSP,
+           stats_oid = GetSysCacheOid2(STATEXTNAMENSP, Anum_pg_statistic_ext_oid,
                                        PointerGetDatum(stats_name),
                                        ObjectIdGetDatum(namespaceId));
    }
@@ -2187,7 +2188,7 @@ get_statistics_object_oid(List *names, bool missing_ok)
 
            if (namespaceId == myTempNamespace)
                continue;       /* do not look in temp namespace */
-           stats_oid = GetSysCacheOid2(STATEXTNAMENSP,
+           stats_oid = GetSysCacheOid2(STATEXTNAMENSP, Anum_pg_statistic_ext_oid,
                                        PointerGetDatum(stats_name),
                                        ObjectIdGetDatum(namespaceId));
            if (OidIsValid(stats_oid))
@@ -2294,7 +2295,7 @@ get_ts_parser_oid(List *names, bool missing_ok)
        if (missing_ok && !OidIsValid(namespaceId))
            prsoid = InvalidOid;
        else
-           prsoid = GetSysCacheOid2(TSPARSERNAMENSP,
+           prsoid = GetSysCacheOid2(TSPARSERNAMENSP, Anum_pg_ts_parser_oid,
                                     PointerGetDatum(parser_name),
                                     ObjectIdGetDatum(namespaceId));
    }
@@ -2310,7 +2311,7 @@ get_ts_parser_oid(List *names, bool missing_ok)
            if (namespaceId == myTempNamespace)
                continue;       /* do not look in temp namespace */
 
-           prsoid = GetSysCacheOid2(TSPARSERNAMENSP,
+           prsoid = GetSysCacheOid2(TSPARSERNAMENSP, Anum_pg_ts_parser_oid,
                                     PointerGetDatum(parser_name),
                                     ObjectIdGetDatum(namespaceId));
            if (OidIsValid(prsoid))
@@ -2420,7 +2421,7 @@ get_ts_dict_oid(List *names, bool missing_ok)
        if (missing_ok && !OidIsValid(namespaceId))
            dictoid = InvalidOid;
        else
-           dictoid = GetSysCacheOid2(TSDICTNAMENSP,
+           dictoid = GetSysCacheOid2(TSDICTNAMENSP, Anum_pg_ts_dict_oid,
                                      PointerGetDatum(dict_name),
                                      ObjectIdGetDatum(namespaceId));
    }
@@ -2436,7 +2437,7 @@ get_ts_dict_oid(List *names, bool missing_ok)
            if (namespaceId == myTempNamespace)
                continue;       /* do not look in temp namespace */
 
-           dictoid = GetSysCacheOid2(TSDICTNAMENSP,
+           dictoid = GetSysCacheOid2(TSDICTNAMENSP, Anum_pg_ts_dict_oid,
                                      PointerGetDatum(dict_name),
                                      ObjectIdGetDatum(namespaceId));
            if (OidIsValid(dictoid))
@@ -2547,7 +2548,7 @@ get_ts_template_oid(List *names, bool missing_ok)
        if (missing_ok && !OidIsValid(namespaceId))
            tmploid = InvalidOid;
        else
-           tmploid = GetSysCacheOid2(TSTEMPLATENAMENSP,
+           tmploid = GetSysCacheOid2(TSTEMPLATENAMENSP, Anum_pg_ts_template_oid,
                                      PointerGetDatum(template_name),
                                      ObjectIdGetDatum(namespaceId));
    }
@@ -2563,7 +2564,7 @@ get_ts_template_oid(List *names, bool missing_ok)
            if (namespaceId == myTempNamespace)
                continue;       /* do not look in temp namespace */
 
-           tmploid = GetSysCacheOid2(TSTEMPLATENAMENSP,
+           tmploid = GetSysCacheOid2(TSTEMPLATENAMENSP, Anum_pg_ts_template_oid,
                                      PointerGetDatum(template_name),
                                      ObjectIdGetDatum(namespaceId));
            if (OidIsValid(tmploid))
@@ -2673,7 +2674,7 @@ get_ts_config_oid(List *names, bool missing_ok)
        if (missing_ok && !OidIsValid(namespaceId))
            cfgoid = InvalidOid;
        else
-           cfgoid = GetSysCacheOid2(TSCONFIGNAMENSP,
+           cfgoid = GetSysCacheOid2(TSCONFIGNAMENSP, Anum_pg_ts_config_oid,
                                     PointerGetDatum(config_name),
                                     ObjectIdGetDatum(namespaceId));
    }
@@ -2689,7 +2690,7 @@ get_ts_config_oid(List *names, bool missing_ok)
            if (namespaceId == myTempNamespace)
                continue;       /* do not look in temp namespace */
 
-           cfgoid = GetSysCacheOid2(TSCONFIGNAMENSP,
+           cfgoid = GetSysCacheOid2(TSCONFIGNAMENSP, Anum_pg_ts_config_oid,
                                     PointerGetDatum(config_name),
                                     ObjectIdGetDatum(namespaceId));
            if (OidIsValid(cfgoid))
@@ -3025,7 +3026,8 @@ get_namespace_oid(const char *nspname, bool missing_ok)
 {
    Oid         oid;
 
-   oid = GetSysCacheOid1(NAMESPACENAME, CStringGetDatum(nspname));
+   oid = GetSysCacheOid1(NAMESPACENAME, Anum_pg_namespace_oid,
+                         CStringGetDatum(nspname));
    if (!OidIsValid(oid) && !missing_ok)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_SCHEMA),
@@ -3621,7 +3623,7 @@ get_conversion_oid(List *name, bool missing_ok)
        if (missing_ok && !OidIsValid(namespaceId))
            conoid = InvalidOid;
        else
-           conoid = GetSysCacheOid2(CONNAMENSP,
+           conoid = GetSysCacheOid2(CONNAMENSP, Anum_pg_conversion_oid,
                                     PointerGetDatum(conversion_name),
                                     ObjectIdGetDatum(namespaceId));
    }
@@ -3637,7 +3639,7 @@ get_conversion_oid(List *name, bool missing_ok)
            if (namespaceId == myTempNamespace)
                continue;       /* do not look in temp namespace */
 
-           conoid = GetSysCacheOid2(CONNAMENSP,
+           conoid = GetSysCacheOid2(CONNAMENSP, Anum_pg_conversion_oid,
                                     PointerGetDatum(conversion_name),
                                     ObjectIdGetDatum(namespaceId));
            if (OidIsValid(conoid))
index 593e6f7022d9047bc6025796753d1839d637938c..d5e30649ff064eceed68379eece21fa30953126a 100644 (file)
@@ -27,6 +27,7 @@
 #include "catalog/pg_authid.h"
 #include "catalog/pg_cast.h"
 #include "catalog/pg_default_acl.h"
+#include "catalog/pg_enum.h"
 #include "catalog/pg_event_trigger.h"
 #include "catalog/pg_collation.h"
 #include "catalog/pg_constraint.h"
@@ -99,6 +100,7 @@ typedef struct
    int         name_catcache_id;   /* id of catcache on (name,namespace), or
                                     * (name) if the object does not live in a
                                     * namespace */
+   AttrNumber  attnum_oid;     /* attribute number of oid column */
    AttrNumber  attnum_name;    /* attnum of name field */
    AttrNumber  attnum_namespace;   /* attnum of namespace field */
    AttrNumber  attnum_owner;   /* attnum of owner field */
@@ -117,6 +119,7 @@ static const ObjectPropertyType ObjectProperty[] =
        AmOidIndexId,
        AMOID,
        AMNAME,
+       Anum_pg_am_oid,
        Anum_pg_am_amname,
        InvalidAttrNumber,
        InvalidAttrNumber,
@@ -129,6 +132,7 @@ static const ObjectPropertyType ObjectProperty[] =
        CastOidIndexId,
        -1,
        -1,
+       Anum_pg_cast_oid,
        InvalidAttrNumber,
        InvalidAttrNumber,
        InvalidAttrNumber,
@@ -141,6 +145,7 @@ static const ObjectPropertyType ObjectProperty[] =
        CollationOidIndexId,
        COLLOID,
        -1,                     /* COLLNAMEENCNSP also takes encoding */
+       Anum_pg_collation_oid,
        Anum_pg_collation_collname,
        Anum_pg_collation_collnamespace,
        Anum_pg_collation_collowner,
@@ -153,6 +158,7 @@ static const ObjectPropertyType ObjectProperty[] =
        ConstraintOidIndexId,
        CONSTROID,
        -1,
+       Anum_pg_constraint_oid,
        Anum_pg_constraint_conname,
        Anum_pg_constraint_connamespace,
        InvalidAttrNumber,
@@ -165,6 +171,7 @@ static const ObjectPropertyType ObjectProperty[] =
        ConversionOidIndexId,
        CONVOID,
        CONNAMENSP,
+       Anum_pg_conversion_oid,
        Anum_pg_conversion_conname,
        Anum_pg_conversion_connamespace,
        Anum_pg_conversion_conowner,
@@ -177,6 +184,7 @@ static const ObjectPropertyType ObjectProperty[] =
        DatabaseOidIndexId,
        DATABASEOID,
        -1,
+       Anum_pg_database_oid,
        Anum_pg_database_datname,
        InvalidAttrNumber,
        Anum_pg_database_datdba,
@@ -189,6 +197,7 @@ static const ObjectPropertyType ObjectProperty[] =
        ExtensionOidIndexId,
        -1,
        -1,
+       Anum_pg_extension_oid,
        Anum_pg_extension_extname,
        InvalidAttrNumber,      /* extension doesn't belong to extnamespace */
        Anum_pg_extension_extowner,
@@ -201,6 +210,7 @@ static const ObjectPropertyType ObjectProperty[] =
        ForeignDataWrapperOidIndexId,
        FOREIGNDATAWRAPPEROID,
        FOREIGNDATAWRAPPERNAME,
+       Anum_pg_foreign_data_wrapper_oid,
        Anum_pg_foreign_data_wrapper_fdwname,
        InvalidAttrNumber,
        Anum_pg_foreign_data_wrapper_fdwowner,
@@ -213,6 +223,7 @@ static const ObjectPropertyType ObjectProperty[] =
        ForeignServerOidIndexId,
        FOREIGNSERVEROID,
        FOREIGNSERVERNAME,
+       Anum_pg_foreign_server_oid,
        Anum_pg_foreign_server_srvname,
        InvalidAttrNumber,
        Anum_pg_foreign_server_srvowner,
@@ -225,6 +236,7 @@ static const ObjectPropertyType ObjectProperty[] =
        ProcedureOidIndexId,
        PROCOID,
        -1,                     /* PROCNAMEARGSNSP also takes argument types */
+       Anum_pg_proc_oid,
        Anum_pg_proc_proname,
        Anum_pg_proc_pronamespace,
        Anum_pg_proc_proowner,
@@ -237,6 +249,7 @@ static const ObjectPropertyType ObjectProperty[] =
        LanguageOidIndexId,
        LANGOID,
        LANGNAME,
+       Anum_pg_language_oid,
        Anum_pg_language_lanname,
        InvalidAttrNumber,
        Anum_pg_language_lanowner,
@@ -249,6 +262,7 @@ static const ObjectPropertyType ObjectProperty[] =
        LargeObjectMetadataOidIndexId,
        -1,
        -1,
+       Anum_pg_largeobject_metadata_oid,
        InvalidAttrNumber,
        InvalidAttrNumber,
        Anum_pg_largeobject_metadata_lomowner,
@@ -261,6 +275,7 @@ static const ObjectPropertyType ObjectProperty[] =
        OpclassOidIndexId,
        CLAOID,
        -1,                     /* CLAAMNAMENSP also takes opcmethod */
+       Anum_pg_opclass_oid,
        Anum_pg_opclass_opcname,
        Anum_pg_opclass_opcnamespace,
        Anum_pg_opclass_opcowner,
@@ -273,6 +288,7 @@ static const ObjectPropertyType ObjectProperty[] =
        OperatorOidIndexId,
        OPEROID,
        -1,                     /* OPERNAMENSP also takes left and right type */
+       Anum_pg_operator_oid,
        Anum_pg_operator_oprname,
        Anum_pg_operator_oprnamespace,
        Anum_pg_operator_oprowner,
@@ -285,6 +301,7 @@ static const ObjectPropertyType ObjectProperty[] =
        OpfamilyOidIndexId,
        OPFAMILYOID,
        -1,                     /* OPFAMILYAMNAMENSP also takes opfmethod */
+       Anum_pg_opfamily_oid,
        Anum_pg_opfamily_opfname,
        Anum_pg_opfamily_opfnamespace,
        Anum_pg_opfamily_opfowner,
@@ -297,6 +314,7 @@ static const ObjectPropertyType ObjectProperty[] =
        AuthIdOidIndexId,
        AUTHOID,
        AUTHNAME,
+       Anum_pg_authid_oid,
        Anum_pg_authid_rolname,
        InvalidAttrNumber,
        InvalidAttrNumber,
@@ -309,6 +327,7 @@ static const ObjectPropertyType ObjectProperty[] =
        RewriteOidIndexId,
        -1,
        -1,
+       Anum_pg_rewrite_oid,
        Anum_pg_rewrite_rulename,
        InvalidAttrNumber,
        InvalidAttrNumber,
@@ -321,6 +340,7 @@ static const ObjectPropertyType ObjectProperty[] =
        NamespaceOidIndexId,
        NAMESPACEOID,
        NAMESPACENAME,
+       Anum_pg_namespace_oid,
        Anum_pg_namespace_nspname,
        InvalidAttrNumber,
        Anum_pg_namespace_nspowner,
@@ -333,6 +353,7 @@ static const ObjectPropertyType ObjectProperty[] =
        ClassOidIndexId,
        RELOID,
        RELNAMENSP,
+       Anum_pg_class_oid,
        Anum_pg_class_relname,
        Anum_pg_class_relnamespace,
        Anum_pg_class_relowner,
@@ -345,6 +366,7 @@ static const ObjectPropertyType ObjectProperty[] =
        TablespaceOidIndexId,
        TABLESPACEOID,
        -1,
+       Anum_pg_tablespace_oid,
        Anum_pg_tablespace_spcname,
        InvalidAttrNumber,
        Anum_pg_tablespace_spcowner,
@@ -356,13 +378,15 @@ static const ObjectPropertyType ObjectProperty[] =
        TransformRelationId,
        TransformOidIndexId,
        TRFOID,
-       InvalidAttrNumber
+       InvalidAttrNumber,
+       Anum_pg_transform_oid
    },
    {
        TriggerRelationId,
        TriggerOidIndexId,
        -1,
        -1,
+       Anum_pg_trigger_oid,
        Anum_pg_trigger_tgname,
        InvalidAttrNumber,
        InvalidAttrNumber,
@@ -375,6 +399,7 @@ static const ObjectPropertyType ObjectProperty[] =
        PolicyOidIndexId,
        -1,
        -1,
+       Anum_pg_policy_oid,
        Anum_pg_policy_polname,
        InvalidAttrNumber,
        InvalidAttrNumber,
@@ -387,6 +412,7 @@ static const ObjectPropertyType ObjectProperty[] =
        EventTriggerOidIndexId,
        EVENTTRIGGEROID,
        EVENTTRIGGERNAME,
+       Anum_pg_event_trigger_oid,
        Anum_pg_event_trigger_evtname,
        InvalidAttrNumber,
        Anum_pg_event_trigger_evtowner,
@@ -399,6 +425,7 @@ static const ObjectPropertyType ObjectProperty[] =
        TSConfigOidIndexId,
        TSCONFIGOID,
        TSCONFIGNAMENSP,
+       Anum_pg_ts_config_oid,
        Anum_pg_ts_config_cfgname,
        Anum_pg_ts_config_cfgnamespace,
        Anum_pg_ts_config_cfgowner,
@@ -411,6 +438,7 @@ static const ObjectPropertyType ObjectProperty[] =
        TSDictionaryOidIndexId,
        TSDICTOID,
        TSDICTNAMENSP,
+       Anum_pg_ts_dict_oid,
        Anum_pg_ts_dict_dictname,
        Anum_pg_ts_dict_dictnamespace,
        Anum_pg_ts_dict_dictowner,
@@ -423,6 +451,7 @@ static const ObjectPropertyType ObjectProperty[] =
        TSParserOidIndexId,
        TSPARSEROID,
        TSPARSERNAMENSP,
+       Anum_pg_ts_parser_oid,
        Anum_pg_ts_parser_prsname,
        Anum_pg_ts_parser_prsnamespace,
        InvalidAttrNumber,
@@ -435,6 +464,7 @@ static const ObjectPropertyType ObjectProperty[] =
        TSTemplateOidIndexId,
        TSTEMPLATEOID,
        TSTEMPLATENAMENSP,
+       Anum_pg_ts_template_oid,
        Anum_pg_ts_template_tmplname,
        Anum_pg_ts_template_tmplnamespace,
        InvalidAttrNumber,
@@ -447,6 +477,7 @@ static const ObjectPropertyType ObjectProperty[] =
        TypeOidIndexId,
        TYPEOID,
        TYPENAMENSP,
+       Anum_pg_type_oid,
        Anum_pg_type_typname,
        Anum_pg_type_typnamespace,
        Anum_pg_type_typowner,
@@ -459,6 +490,7 @@ static const ObjectPropertyType ObjectProperty[] =
        PublicationObjectIndexId,
        PUBLICATIONOID,
        PUBLICATIONNAME,
+       Anum_pg_publication_oid,
        Anum_pg_publication_pubname,
        InvalidAttrNumber,
        Anum_pg_publication_pubowner,
@@ -471,6 +503,7 @@ static const ObjectPropertyType ObjectProperty[] =
        SubscriptionObjectIndexId,
        SUBSCRIPTIONOID,
        SUBSCRIPTIONNAME,
+       Anum_pg_subscription_oid,
        Anum_pg_subscription_subname,
        InvalidAttrNumber,
        Anum_pg_subscription_subowner,
@@ -483,6 +516,7 @@ static const ObjectPropertyType ObjectProperty[] =
        StatisticExtOidIndexId,
        STATEXTOID,
        STATEXTNAMENSP,
+       Anum_pg_statistic_ext_oid,
        Anum_pg_statistic_ext_stxname,
        Anum_pg_statistic_ext_stxnamespace,
        Anum_pg_statistic_ext_stxowner,
@@ -1459,7 +1493,11 @@ get_object_address_attrdef(ObjectType objtype, List *object,
        scan = systable_beginscan(attrdef, AttrDefaultIndexId, true,
                                  NULL, 2, keys);
        if (HeapTupleIsValid(tup = systable_getnext(scan)))
-           defoid = HeapTupleGetOid(tup);
+       {
+           Form_pg_attrdef atdform = (Form_pg_attrdef) GETSTRUCT(tup);
+
+           defoid = atdform->oid;
+       }
 
        systable_endscan(scan);
        relation_close(attrdef, AccessShareLock);
@@ -1633,7 +1671,7 @@ get_object_address_opf_member(ObjectType objtype,
                }
                else
                {
-                   address.objectId = HeapTupleGetOid(tp);
+                   address.objectId = ((Form_pg_amop) GETSTRUCT(tp))->oid;
                    ReleaseSysCache(tp);
                }
            }
@@ -1664,7 +1702,7 @@ get_object_address_opf_member(ObjectType objtype,
                }
                else
                {
-                   address.objectId = HeapTupleGetOid(tp);
+                   address.objectId = ((Form_pg_amproc) GETSTRUCT(tp))->oid;
                    ReleaseSysCache(tp);
                }
            }
@@ -1711,7 +1749,7 @@ get_object_address_usermapping(List *object, bool missing_ok)
                                username, servername)));
            return address;
        }
-       userid = HeapTupleGetOid(tp);
+       userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
        ReleaseSysCache(tp);
    }
 
@@ -1738,7 +1776,7 @@ get_object_address_usermapping(List *object, bool missing_ok)
        return address;
    }
 
-   address.objectId = HeapTupleGetOid(tp);
+   address.objectId = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
 
    ReleaseSysCache(tp);
 
@@ -1781,7 +1819,7 @@ get_object_address_publication_rel(List *object,
 
    /* Find the publication relation mapping in syscache. */
    address.objectId =
-       GetSysCacheOid2(PUBLICATIONRELMAP,
+       GetSysCacheOid2(PUBLICATIONRELMAP, Anum_pg_publication_rel_oid,
                        ObjectIdGetDatum(RelationGetRelid(relation)),
                        ObjectIdGetDatum(pub->oid));
    if (!OidIsValid(address.objectId))
@@ -1868,7 +1906,7 @@ get_object_address_defacl(List *object, bool missing_ok)
                         CStringGetDatum(username));
    if (!HeapTupleIsValid(tp))
        goto not_found;
-   userid = HeapTupleGetOid(tp);
+   userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
    ReleaseSysCache(tp);
 
    /*
@@ -1892,7 +1930,7 @@ get_object_address_defacl(List *object, bool missing_ok)
    if (!HeapTupleIsValid(tp))
        goto not_found;
 
-   address.objectId = HeapTupleGetOid(tp);
+   address.objectId = ((Form_pg_default_acl) GETSTRUCT(tp))->oid;
    ReleaseSysCache(tp);
 
    return address;
@@ -2202,7 +2240,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
    if (relation)
        relation_close(relation, AccessShareLock);
 
-   tupdesc = CreateTemplateTupleDesc(3, false);
+   tupdesc = CreateTemplateTupleDesc(3);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, "classid",
                       OIDOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 2, "objid",
@@ -2510,6 +2548,14 @@ get_object_catcache_name(Oid class_id)
    return prop->name_catcache_id;
 }
 
+AttrNumber
+get_object_attnum_oid(Oid class_id)
+{
+   const ObjectPropertyType *prop = get_object_property_data(class_id);
+
+   return prop->attnum_oid;
+}
+
 AttrNumber
 get_object_attnum_name(Oid class_id)
 {
@@ -2625,7 +2671,7 @@ get_object_property_data(Oid class_id)
  * We try a syscache first, if available.
  */
 HeapTuple
-get_catalog_object_by_oid(Relation catalog, Oid objectId)
+get_catalog_object_by_oid(Relation catalog, AttrNumber oidcol, Oid objectId)
 {
    HeapTuple   tuple;
    Oid         classId = RelationGetRelid(catalog);
@@ -2646,7 +2692,7 @@ get_catalog_object_by_oid(Relation catalog, Oid objectId)
        Assert(OidIsValid(oidIndexId));
 
        ScanKeyInit(&skey,
-                   ObjectIdAttributeNumber,
+                   oidcol,
                    BTEqualStrategyNumber, F_OIDEQ,
                    ObjectIdGetDatum(objectId));
 
@@ -2721,7 +2767,7 @@ getObjectDescription(const ObjectAddress *object)
                castDesc = heap_open(CastRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_cast_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -2842,7 +2888,7 @@ getObjectDescription(const ObjectAddress *object)
                attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_attrdef_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -2955,7 +3001,7 @@ getObjectDescription(const ObjectAddress *object)
                                     AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_amop_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -3005,7 +3051,7 @@ getObjectDescription(const ObjectAddress *object)
                                       AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_amproc_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -3054,7 +3100,7 @@ getObjectDescription(const ObjectAddress *object)
                ruleDesc = heap_open(RewriteRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_rewrite_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -3092,7 +3138,7 @@ getObjectDescription(const ObjectAddress *object)
                trigDesc = heap_open(TriggerRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_trigger_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -3352,7 +3398,7 @@ getObjectDescription(const ObjectAddress *object)
                defaclrel = heap_open(DefaultAclRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_default_acl_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -3479,7 +3525,7 @@ getObjectDescription(const ObjectAddress *object)
                policy_rel = heap_open(PolicyRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_policy_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -3753,7 +3799,7 @@ pg_identify_object(PG_FUNCTION_ARGS)
     * Construct a tuple descriptor for the result row.  This must match this
     * function's pg_proc entry!
     */
-   tupdesc = CreateTemplateTupleDesc(4, false);
+   tupdesc = CreateTemplateTupleDesc(4);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, "type",
                       TEXTOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 2, "schema",
@@ -3770,7 +3816,9 @@ pg_identify_object(PG_FUNCTION_ARGS)
        HeapTuple   objtup;
        Relation    catalog = heap_open(address.classId, AccessShareLock);
 
-       objtup = get_catalog_object_by_oid(catalog, address.objectId);
+       objtup = get_catalog_object_by_oid(catalog,
+                                          get_object_attnum_oid(address.classId),
+                                          address.objectId);
        if (objtup != NULL)
        {
            bool        isnull;
@@ -3870,7 +3918,7 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
     * Construct a tuple descriptor for the result row.  This must match this
     * function's pg_proc entry!
     */
-   tupdesc = CreateTemplateTupleDesc(3, false);
+   tupdesc = CreateTemplateTupleDesc(3);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, "type",
                       TEXTOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 2, "object_names",
@@ -4147,7 +4195,8 @@ getConstraintTypeDescription(StringInfo buffer, Oid constroid)
    Form_pg_constraint constrForm;
 
    constrRel = heap_open(ConstraintRelationId, AccessShareLock);
-   constrTup = get_catalog_object_by_oid(constrRel, constroid);
+   constrTup = get_catalog_object_by_oid(constrRel, Anum_pg_constraint_oid,
+                                         constroid);
    if (!HeapTupleIsValid(constrTup))
        elog(ERROR, "cache lookup failed for constraint %u", constroid);
 
@@ -4158,7 +4207,7 @@ getConstraintTypeDescription(StringInfo buffer, Oid constroid)
    else if (OidIsValid(constrForm->contypid))
        appendStringInfoString(buffer, "domain constraint");
    else
-       elog(ERROR, "invalid constraint %u", HeapTupleGetOid(constrTup));
+       elog(ERROR, "invalid constraint %u", constrForm->oid);
 
    heap_close(constrRel, AccessShareLock);
 }
@@ -4271,7 +4320,8 @@ getObjectIdentityParts(const ObjectAddress *object,
 
                castRel = heap_open(CastRelationId, AccessShareLock);
 
-               tup = get_catalog_object_by_oid(castRel, object->objectId);
+               tup = get_catalog_object_by_oid(castRel, Anum_pg_cast_oid,
+                                               object->objectId);
 
                if (!HeapTupleIsValid(tup))
                    elog(ERROR, "could not find tuple for cast %u",
@@ -4393,7 +4443,7 @@ getObjectIdentityParts(const ObjectAddress *object,
                attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_attrdef_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -4523,7 +4573,7 @@ getObjectIdentityParts(const ObjectAddress *object,
                                     AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_amop_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -4577,7 +4627,7 @@ getObjectIdentityParts(const ObjectAddress *object,
                                       AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_amproc_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -4624,7 +4674,8 @@ getObjectIdentityParts(const ObjectAddress *object,
 
                ruleDesc = heap_open(RewriteRelationId, AccessShareLock);
 
-               tup = get_catalog_object_by_oid(ruleDesc, object->objectId);
+               tup = get_catalog_object_by_oid(ruleDesc, Anum_pg_rewrite_oid,
+                                               object->objectId);
 
                if (!HeapTupleIsValid(tup))
                    elog(ERROR, "could not find tuple for rule %u",
@@ -4650,7 +4701,8 @@ getObjectIdentityParts(const ObjectAddress *object,
 
                trigDesc = heap_open(TriggerRelationId, AccessShareLock);
 
-               tup = get_catalog_object_by_oid(trigDesc, object->objectId);
+               tup = get_catalog_object_by_oid(trigDesc, Anum_pg_trigger_oid,
+                                               object->objectId);
 
                if (!HeapTupleIsValid(tup))
                    elog(ERROR, "could not find tuple for trigger %u",
@@ -4912,7 +4964,7 @@ getObjectIdentityParts(const ObjectAddress *object,
                defaclrel = heap_open(DefaultAclRelationId, AccessShareLock);
 
                ScanKeyInit(&skey[0],
-                           ObjectIdAttributeNumber,
+                           Anum_pg_default_acl_oid,
                            BTEqualStrategyNumber, F_OIDEQ,
                            ObjectIdGetDatum(object->objectId));
 
@@ -5022,7 +5074,8 @@ getObjectIdentityParts(const ObjectAddress *object,
 
                polDesc = heap_open(PolicyRelationId, AccessShareLock);
 
-               tup = get_catalog_object_by_oid(polDesc, object->objectId);
+               tup = get_catalog_object_by_oid(polDesc, Anum_pg_policy_oid,
+                                               object->objectId);
 
                if (!HeapTupleIsValid(tup))
                    elog(ERROR, "could not find tuple for policy %u",
@@ -5099,7 +5152,9 @@ getObjectIdentityParts(const ObjectAddress *object,
 
                transformDesc = heap_open(TransformRelationId, AccessShareLock);
 
-               tup = get_catalog_object_by_oid(transformDesc, object->objectId);
+               tup = get_catalog_object_by_oid(transformDesc,
+                                               Anum_pg_transform_oid,
+                                               object->objectId);
 
                if (!HeapTupleIsValid(tup))
                    elog(ERROR, "could not find tuple for transform %u",
index 246776093eceae45e1a2ca535f56bddf720bd5de..4b12e9f2748d6864c210ed8bb93713ec5793a554 100644 (file)
@@ -639,6 +639,8 @@ AggregateCreate(const char *aggName,
    /*
     * Okay to create the pg_aggregate entry.
     */
+   aggdesc = heap_open(AggregateRelationId, RowExclusiveLock);
+   tupDesc = aggdesc->rd_att;
 
    /* initialize nulls and values */
    for (i = 0; i < Natts_pg_aggregate; i++)
@@ -675,9 +677,6 @@ AggregateCreate(const char *aggName,
    else
        nulls[Anum_pg_aggregate_aggminitval - 1] = true;
 
-   aggdesc = heap_open(AggregateRelationId, RowExclusiveLock);
-   tupDesc = aggdesc->rd_att;
-
    tup = heap_form_tuple(tupDesc, values, nulls);
    CatalogTupleInsert(aggdesc, tup);
 
index ce7e5fb5cc18f03fe99965c48ac648a3629fe788..d4543b511ef017a62d927a84f8aad2ed34158d67 100644 (file)
@@ -18,6 +18,7 @@
 #include "access/heapam.h"
 #include "access/htup_details.h"
 #include "access/sysattr.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -153,6 +154,9 @@ CollationCreate(const char *collname, Oid collnamespace,
    memset(nulls, 0, sizeof(nulls));
 
    namestrcpy(&name_name, collname);
+   oid = GetNewOidWithIndex(rel, CollationOidIndexId,
+                            Anum_pg_collation_oid);
+   values[Anum_pg_collation_oid - 1] = ObjectIdGetDatum(oid);
    values[Anum_pg_collation_collname - 1] = NameGetDatum(&name_name);
    values[Anum_pg_collation_collnamespace - 1] = ObjectIdGetDatum(collnamespace);
    values[Anum_pg_collation_collowner - 1] = ObjectIdGetDatum(collowner);
@@ -170,7 +174,7 @@ CollationCreate(const char *collname, Oid collnamespace,
    tup = heap_form_tuple(tupDesc, values, nulls);
 
    /* insert a new tuple */
-   oid = CatalogTupleInsert(rel, tup);
+   CatalogTupleInsert(rel, tup);
    Assert(OidIsValid(oid));
 
    /* set up dependencies for the new collation */
@@ -185,8 +189,7 @@ CollationCreate(const char *collname, Oid collnamespace,
    recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
 
    /* create dependency on owner */
-   recordDependencyOnOwner(CollationRelationId, HeapTupleGetOid(tup),
-                           collowner);
+   recordDependencyOnOwner(CollationRelationId, oid, collowner);
 
    /* dependency on extension */
    recordDependencyOnCurrentExtension(&myself, false);
@@ -217,7 +220,7 @@ RemoveCollationById(Oid collationOid)
    rel = heap_open(CollationRelationId, RowExclusiveLock);
 
    ScanKeyInit(&scanKeyData,
-               ObjectIdAttributeNumber,
+               Anum_pg_collation_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(collationOid));
 
index 1c235b4b296dbb0f609cee84e5bd1fbd52eb32ed..a8194b02fa2877ec4bd4329f8902012bd825e27e 100644 (file)
@@ -20,6 +20,7 @@
 #include "access/sysattr.h"
 #include "access/tupconvert.h"
 #include "access/xact.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -169,6 +170,9 @@ CreateConstraintEntry(const char *constraintName,
        values[i] = (Datum) NULL;
    }
 
+   conOid = GetNewOidWithIndex(conDesc, ConstraintOidIndexId,
+                               Anum_pg_constraint_oid);
+   values[Anum_pg_constraint_oid - 1] = ObjectIdGetDatum(conOid);
    values[Anum_pg_constraint_conname - 1] = NameGetDatum(&cname);
    values[Anum_pg_constraint_connamespace - 1] = ObjectIdGetDatum(constraintNamespace);
    values[Anum_pg_constraint_contype - 1] = CharGetDatum(constraintType);
@@ -224,7 +228,7 @@ CreateConstraintEntry(const char *constraintName,
 
    tup = heap_form_tuple(RelationGetDescr(conDesc), values, nulls);
 
-   conOid = CatalogTupleInsert(conDesc, tup);
+   CatalogTupleInsert(conDesc, tup);
 
    conobject.classId = ConstraintRelationId;
    conobject.objectId = conOid;
@@ -408,7 +412,11 @@ CloneForeignKeyConstraints(Oid parentId, Oid relationId, List **cloned)
    scan = systable_beginscan(pg_constraint, ConstraintRelidTypidNameIndexId, true,
                              NULL, 1, &key);
    while ((tuple = systable_getnext(scan)) != NULL)
-       clone = lappend_oid(clone, HeapTupleGetOid(tuple));
+   {
+       Oid     oid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
+
+       clone = lappend_oid(clone, oid);
+   }
    systable_endscan(scan);
 
    /* Do the actual work, recursing to partitions as needed */
@@ -647,8 +655,7 @@ clone_fk_constraints(Relation pg_constraint, Relation parentRel,
            ReleaseSysCache(partcontup);
 
            /* looks good!  Attach this constraint */
-           ConstraintSetParentConstraint(fk->conoid,
-                                         HeapTupleGetOid(tuple));
+           ConstraintSetParentConstraint(fk->conoid, constrForm->oid);
            CommandCounterIncrement();
            attach_it = true;
            break;
@@ -672,7 +679,7 @@ clone_fk_constraints(Relation pg_constraint, Relation parentRel,
                                  constrForm->condeferrable,
                                  constrForm->condeferred,
                                  constrForm->convalidated,
-                                 HeapTupleGetOid(tuple),
+                                 constrForm->oid,
                                  RelationGetRelid(partRel),
                                  mapped_conkey,
                                  nelem,
@@ -1111,7 +1118,7 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
        ObjectAddress thisobj;
 
        thisobj.classId = ConstraintRelationId;
-       thisobj.objectId = HeapTupleGetOid(tup);
+       thisobj.objectId = conform->oid;
        thisobj.objectSubId = 0;
 
        if (object_address_present(&thisobj, objsMoved))
@@ -1232,7 +1239,7 @@ get_relation_constraint_oid(Oid relid, const char *conname, bool missing_ok)
 
    /* There can be at most one matching row */
    if (HeapTupleIsValid(tuple = systable_getnext(scan)))
-       conOid = HeapTupleGetOid(tuple);
+       conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
 
    systable_endscan(scan);
 
@@ -1297,7 +1304,7 @@ get_relation_constraint_attnos(Oid relid, const char *conname,
        Datum       adatum;
        bool        isNull;
 
-       *constraintOid = HeapTupleGetOid(tuple);
+       *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
 
        /* Extract the conkey array, ie, attnums of constrained columns */
        adatum = heap_getattr(tuple, Anum_pg_constraint_conkey,
@@ -1370,7 +1377,7 @@ get_relation_idx_constraint_oid(Oid relationId, Oid indexId)
        constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
        if (constrForm->conindid == indexId)
        {
-           constraintId = HeapTupleGetOid(tuple);
+           constraintId = constrForm->oid;
            break;
        }
    }
@@ -1414,7 +1421,7 @@ get_domain_constraint_oid(Oid typid, const char *conname, bool missing_ok)
 
    /* There can be at most one matching row */
    if (HeapTupleIsValid(tuple = systable_getnext(scan)))
-       conOid = HeapTupleGetOid(tuple);
+       conOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
 
    systable_endscan(scan);
 
@@ -1494,7 +1501,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
                              RelationGetDescr(pg_constraint), &isNull);
        if (isNull)
            elog(ERROR, "null conkey for constraint %u",
-                HeapTupleGetOid(tuple));
+                ((Form_pg_constraint) GETSTRUCT(tuple))->oid);
        arr = DatumGetArrayTypeP(adatum);   /* ensure not toasted */
        numkeys = ARR_DIMS(arr)[0];
        if (ARR_NDIM(arr) != 1 ||
@@ -1510,7 +1517,7 @@ get_primary_key_attnos(Oid relid, bool deferrableOk, Oid *constraintOid)
            pkattnos = bms_add_member(pkattnos,
                                      attnums[i] - FirstLowInvalidHeapAttributeNumber);
        }
-       *constraintOid = HeapTupleGetOid(tuple);
+       *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
 
        /* No need to search further */
        break;
index fd5c18426bfc80119eb4925d40178074fda0d5a5..c692958d917188a341281b84661a05e80986f1c1 100644 (file)
@@ -17,6 +17,7 @@
 #include "access/heapam.h"
 #include "access/htup_details.h"
 #include "access/sysattr.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -46,6 +47,7 @@ ConversionCreate(const char *conname, Oid connamespace,
    Relation    rel;
    TupleDesc   tupDesc;
    HeapTuple   tup;
+   Oid         oid;
    bool        nulls[Natts_pg_conversion];
    Datum       values[Natts_pg_conversion];
    NameData    cname;
@@ -93,6 +95,9 @@ ConversionCreate(const char *conname, Oid connamespace,
 
    /* form a tuple */
    namestrcpy(&cname, conname);
+   oid = GetNewOidWithIndex(rel, ConversionOidIndexId,
+                            Anum_pg_conversion_oid);
+   values[Anum_pg_conversion_oid - 1] = ObjectIdGetDatum(oid);
    values[Anum_pg_conversion_conname - 1] = NameGetDatum(&cname);
    values[Anum_pg_conversion_connamespace - 1] = ObjectIdGetDatum(connamespace);
    values[Anum_pg_conversion_conowner - 1] = ObjectIdGetDatum(conowner);
@@ -107,7 +112,7 @@ ConversionCreate(const char *conname, Oid connamespace,
    CatalogTupleInsert(rel, tup);
 
    myself.classId = ConversionRelationId;
-   myself.objectId = HeapTupleGetOid(tup);
+   myself.objectId = oid;
    myself.objectSubId = 0;
 
    /* create dependency on conversion procedure */
@@ -123,14 +128,13 @@ ConversionCreate(const char *conname, Oid connamespace,
    recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
 
    /* create dependency on owner */
-   recordDependencyOnOwner(ConversionRelationId, HeapTupleGetOid(tup),
-                           conowner);
+   recordDependencyOnOwner(ConversionRelationId, oid, conowner);
 
    /* dependency on extension */
    recordDependencyOnCurrentExtension(&myself, false);
 
    /* Post creation hook for new conversion */
-   InvokeObjectPostCreateHook(ConversionRelationId, HeapTupleGetOid(tup), 0);
+   InvokeObjectPostCreateHook(ConversionRelationId, oid, 0);
 
    heap_freetuple(tup);
    heap_close(rel, RowExclusiveLock);
@@ -153,7 +157,7 @@ RemoveConversionById(Oid conversionOid)
    ScanKeyData scanKeyData;
 
    ScanKeyInit(&scanKeyData,
-               ObjectIdAttributeNumber,
+               Anum_pg_conversion_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(conversionOid));
 
index ece65587bbaca8f6299453683086f16b2badcae7..bcb184ccbb11457f818bdf1c0f1bd854b0e961aa 100644 (file)
@@ -102,7 +102,8 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
 
        do
        {
-           new_oid = GetNewOid(pg_enum);
+           new_oid = GetNewOidWithIndex(pg_enum, EnumOidIndexId,
+                                        Anum_pg_enum_oid);
        } while (new_oid & 1);
        oids[elemno] = new_oid;
    }
@@ -129,13 +130,13 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
                     errdetail("Labels must be %d characters or less.",
                               NAMEDATALEN - 1)));
 
+       values[Anum_pg_enum_oid - 1] = ObjectIdGetDatum(oids[elemno]);
        values[Anum_pg_enum_enumtypid - 1] = ObjectIdGetDatum(enumTypeOid);
        values[Anum_pg_enum_enumsortorder - 1] = Float4GetDatum(elemno + 1);
        namestrcpy(&enumlabel, lab);
        values[Anum_pg_enum_enumlabel - 1] = NameGetDatum(&enumlabel);
 
        tup = heap_form_tuple(RelationGetDescr(pg_enum), values, nulls);
-       HeapTupleSetOid(tup, oids[elemno]);
 
        CatalogTupleInsert(pg_enum, tup);
        heap_freetuple(tup);
@@ -406,7 +407,8 @@ restart:
            bool        sorts_ok;
 
            /* Get a new OID (different from all existing pg_enum tuples) */
-           newOid = GetNewOid(pg_enum);
+           newOid = GetNewOidWithIndex(pg_enum, EnumOidIndexId,
+                                       Anum_pg_enum_oid);
 
            /*
             * Detect whether it sorts correctly relative to existing
@@ -419,7 +421,7 @@ restart:
            {
                HeapTuple   exists_tup = existing[i];
                Form_pg_enum exists_en = (Form_pg_enum) GETSTRUCT(exists_tup);
-               Oid         exists_oid = HeapTupleGetOid(exists_tup);
+               Oid         exists_oid = exists_en->oid;
 
                if (exists_oid & 1)
                    continue;   /* ignore odd Oids */
@@ -480,12 +482,12 @@ restart:
 
    /* Create the new pg_enum entry */
    memset(nulls, false, sizeof(nulls));
+   values[Anum_pg_enum_oid - 1] = ObjectIdGetDatum(newOid);
    values[Anum_pg_enum_enumtypid - 1] = ObjectIdGetDatum(enumTypeOid);
    values[Anum_pg_enum_enumsortorder - 1] = Float4GetDatum(newelemorder);
    namestrcpy(&enumlabel, newVal);
    values[Anum_pg_enum_enumlabel - 1] = NameGetDatum(&enumlabel);
    enum_tup = heap_form_tuple(RelationGetDescr(pg_enum), values, nulls);
-   HeapTupleSetOid(enum_tup, newOid);
    CatalogTupleInsert(pg_enum, enum_tup);
    heap_freetuple(enum_tup);
 
index a876473976a2a35ee0e46f01fd51b7f3ddf33008..d5cde9ecf181c06c0e3181e9dea474a2a1d7acb6 100644 (file)
@@ -18,6 +18,7 @@
 #include "access/heapam.h"
 #include "access/htup_details.h"
 #include "access/sysattr.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/pg_largeobject.h"
@@ -54,17 +55,22 @@ LargeObjectCreate(Oid loid)
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   if (OidIsValid(loid))
+       loid_new = loid;
+   else
+       loid_new = GetNewOidWithIndex(pg_lo_meta,
+                                     LargeObjectMetadataOidIndexId,
+                                     Anum_pg_largeobject_metadata_oid);
+
+   values[Anum_pg_largeobject_metadata_oid - 1] = ObjectIdGetDatum(loid_new);
    values[Anum_pg_largeobject_metadata_lomowner - 1]
        = ObjectIdGetDatum(GetUserId());
    nulls[Anum_pg_largeobject_metadata_lomacl - 1] = true;
 
    ntup = heap_form_tuple(RelationGetDescr(pg_lo_meta),
                           values, nulls);
-   if (OidIsValid(loid))
-       HeapTupleSetOid(ntup, loid);
 
-   loid_new = CatalogTupleInsert(pg_lo_meta, ntup);
-   Assert(!OidIsValid(loid) || loid == loid_new);
+   CatalogTupleInsert(pg_lo_meta, ntup);
 
    heap_freetuple(ntup);
 
@@ -96,7 +102,7 @@ LargeObjectDrop(Oid loid)
     * Delete an entry from pg_largeobject_metadata
     */
    ScanKeyInit(&skey[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_largeobject_metadata_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(loid));
 
@@ -159,7 +165,7 @@ LargeObjectExists(Oid loid)
    bool        retval = false;
 
    ScanKeyInit(&skey[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_largeobject_metadata_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(loid));
 
index 0538e31b3b31f5048f78fc7048726afba3c5eea1..73319b07470f8a6cefdda10133248eb7f3d8d277 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "access/heapam.h"
 #include "access/htup_details.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -68,12 +69,19 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
    else
        nspacl = NULL;
 
+   nspdesc = heap_open(NamespaceRelationId, RowExclusiveLock);
+   tupDesc = nspdesc->rd_att;
+
    /* initialize nulls and values */
    for (i = 0; i < Natts_pg_namespace; i++)
    {
        nulls[i] = false;
        values[i] = (Datum) NULL;
    }
+
+   nspoid = GetNewOidWithIndex(nspdesc, NamespaceOidIndexId,
+                               Anum_pg_namespace_oid);
+   values[Anum_pg_namespace_oid - 1] = ObjectIdGetDatum(nspoid);
    namestrcpy(&nname, nspName);
    values[Anum_pg_namespace_nspname - 1] = NameGetDatum(&nname);
    values[Anum_pg_namespace_nspowner - 1] = ObjectIdGetDatum(ownerId);
@@ -82,12 +90,10 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
    else
        nulls[Anum_pg_namespace_nspacl - 1] = true;
 
-   nspdesc = heap_open(NamespaceRelationId, RowExclusiveLock);
-   tupDesc = nspdesc->rd_att;
 
    tup = heap_form_tuple(tupDesc, values, nulls);
 
-   nspoid = CatalogTupleInsert(nspdesc, tup);
+   CatalogTupleInsert(nspdesc, tup);
    Assert(OidIsValid(nspoid));
 
    heap_close(nspdesc, RowExclusiveLock);
index 6dde75ed2520f8e0422418eeb54fb6527aac758d..43533c5836a2da7e8783df119c8933360092c353 100644 (file)
@@ -20,6 +20,7 @@
 #include "access/heapam.h"
 #include "access/htup_details.h"
 #include "access/xact.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/namespace.h"
@@ -142,10 +143,10 @@ OperatorGet(const char *operatorName,
                          ObjectIdGetDatum(operatorNamespace));
    if (HeapTupleIsValid(tup))
    {
-       RegProcedure oprcode = ((Form_pg_operator) GETSTRUCT(tup))->oprcode;
+       Form_pg_operator oprform = (Form_pg_operator) GETSTRUCT(tup);
 
-       operatorObjectId = HeapTupleGetOid(tup);
-       *defined = RegProcedureIsValid(oprcode);
+       operatorObjectId = oprform->oid;
+       *defined = RegProcedureIsValid(oprform->oprcode);
        ReleaseSysCache(tup);
    }
    else
@@ -218,6 +219,12 @@ OperatorShellMake(const char *operatorName,
                 errmsg("\"%s\" is not a valid operator name",
                        operatorName)));
 
+   /*
+    * open pg_operator
+    */
+   pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
+   tupDesc = pg_operator_desc->rd_att;
+
    /*
     * initialize our *nulls and *values arrays
     */
@@ -231,6 +238,9 @@ OperatorShellMake(const char *operatorName,
     * initialize values[] with the operator name and input data types. Note
     * that oprcode is set to InvalidOid, indicating it's a shell.
     */
+   operatorObjectId = GetNewOidWithIndex(pg_operator_desc, OperatorOidIndexId,
+                                         Anum_pg_operator_oid);
+   values[Anum_pg_operator_oid - 1] = ObjectIdGetDatum(operatorObjectId);
    namestrcpy(&oname, operatorName);
    values[Anum_pg_operator_oprname - 1] = NameGetDatum(&oname);
    values[Anum_pg_operator_oprnamespace - 1] = ObjectIdGetDatum(operatorNamespace);
@@ -247,12 +257,6 @@ OperatorShellMake(const char *operatorName,
    values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(InvalidOid);
    values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(InvalidOid);
 
-   /*
-    * open pg_operator
-    */
-   pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);
-   tupDesc = pg_operator_desc->rd_att;
-
    /*
     * create a new operator tuple
     */
@@ -261,7 +265,7 @@ OperatorShellMake(const char *operatorName,
    /*
     * insert our "shell" operator tuple
     */
-   operatorObjectId = CatalogTupleInsert(pg_operator_desc, tup);
+   CatalogTupleInsert(pg_operator_desc, tup);
 
    /* Add dependencies for the entry */
    makeOperatorDependencies(tup, false);
@@ -517,6 +521,7 @@ OperatorCreate(const char *operatorName,
            elog(ERROR, "cache lookup failed for operator %u",
                 operatorObjectId);
 
+       replaces[Anum_pg_operator_oid - 1] = false;
        tup = heap_modify_tuple(tup,
                                RelationGetDescr(pg_operator_desc),
                                values,
@@ -529,10 +534,15 @@ OperatorCreate(const char *operatorName,
    {
        isUpdate = false;
 
+       operatorObjectId = GetNewOidWithIndex(pg_operator_desc,
+                                             OperatorOidIndexId,
+                                             Anum_pg_operator_oid);
+       values[Anum_pg_operator_oid - 1] = ObjectIdGetDatum(operatorObjectId);
+
        tup = heap_form_tuple(RelationGetDescr(pg_operator_desc),
                              values, nulls);
 
-       operatorObjectId = CatalogTupleInsert(pg_operator_desc, tup);
+       CatalogTupleInsert(pg_operator_desc, tup);
    }
 
    /* Add dependencies for the entry */
@@ -767,7 +777,7 @@ makeOperatorDependencies(HeapTuple tuple, bool isUpdate)
                referenced;
 
    myself.classId = OperatorRelationId;
-   myself.objectId = HeapTupleGetOid(tuple);
+   myself.objectId = oper->oid;
    myself.objectSubId = 0;
 
    /*
@@ -853,7 +863,7 @@ makeOperatorDependencies(HeapTuple tuple, bool isUpdate)
    }
 
    /* Dependency on owner */
-   recordDependencyOnOwner(OperatorRelationId, HeapTupleGetOid(tuple),
+   recordDependencyOnOwner(OperatorRelationId, oper->oid,
                            oper->oprowner);
 
    /* Dependency on extension */
index e367da7dba5a8919e7ae5933151f736224fd53a4..74ee309c799538290c0e9fce5d392a858b0226b3 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "access/htup_details.h"
 #include "access/xact.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -382,7 +383,7 @@ ProcedureCreate(const char *procedureName,
                    (errcode(ERRCODE_DUPLICATE_FUNCTION),
                     errmsg("function \"%s\" already exists with same argument types",
                            procedureName)));
-       if (!pg_proc_ownercheck(HeapTupleGetOid(oldtup), proowner))
+       if (!pg_proc_ownercheck(oldproc->oid, proowner))
            aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
                           procedureName);
 
@@ -421,7 +422,7 @@ ProcedureCreate(const char *procedureName,
                     /* translator: first %s is DROP FUNCTION or DROP PROCEDURE */
                     errhint("Use %s %s first.",
                             dropcmd,
-                            format_procedure(HeapTupleGetOid(oldtup)))));
+                            format_procedure(oldproc->oid))));
 
        /*
         * If it returns RECORD, check for possible change of record type
@@ -448,7 +449,7 @@ ProcedureCreate(const char *procedureName,
                         /* translator: first %s is DROP FUNCTION or DROP PROCEDURE */
                         errhint("Use %s %s first.",
                                 dropcmd,
-                                format_procedure(HeapTupleGetOid(oldtup)))));
+                                format_procedure(oldproc->oid))));
        }
 
        /*
@@ -493,7 +494,7 @@ ProcedureCreate(const char *procedureName,
                             /* translator: first %s is DROP FUNCTION or DROP PROCEDURE */
                             errhint("Use %s %s first.",
                                     dropcmd,
-                                    format_procedure(HeapTupleGetOid(oldtup)))));
+                                    format_procedure(oldproc->oid))));
            }
        }
 
@@ -519,7 +520,7 @@ ProcedureCreate(const char *procedureName,
                         /* translator: first %s is DROP FUNCTION or DROP PROCEDURE */
                         errhint("Use %s %s first.",
                                 dropcmd,
-                                format_procedure(HeapTupleGetOid(oldtup)))));
+                                format_procedure(oldproc->oid))));
 
            proargdefaults = SysCacheGetAttr(PROCNAMEARGSNSP, oldtup,
                                             Anum_pg_proc_proargdefaults,
@@ -547,15 +548,16 @@ ProcedureCreate(const char *procedureName,
                             /* translator: first %s is DROP FUNCTION or DROP PROCEDURE */
                             errhint("Use %s %s first.",
                                     dropcmd,
-                                    format_procedure(HeapTupleGetOid(oldtup)))));
+                                    format_procedure(oldproc->oid))));
                newlc = lnext(newlc);
            }
        }
 
        /*
-        * Do not change existing ownership or permissions, either.  Note
+        * Do not change existing oid, ownership or permissions, either.  Note
         * dependency-update code below has to agree with this decision.
         */
+       replaces[Anum_pg_proc_oid - 1] = false;
        replaces[Anum_pg_proc_proowner - 1] = false;
        replaces[Anum_pg_proc_proacl - 1] = false;
 
@@ -569,6 +571,7 @@ ProcedureCreate(const char *procedureName,
    else
    {
        /* Creating a new procedure */
+       Oid     newOid;
 
        /* First, get default permissions and set up proacl */
        proacl = get_user_default_acl(OBJECT_FUNCTION, proowner,
@@ -578,13 +581,16 @@ ProcedureCreate(const char *procedureName,
        else
            nulls[Anum_pg_proc_proacl - 1] = true;
 
+       newOid = GetNewOidWithIndex(rel, ProcedureOidIndexId,
+                                   Anum_pg_proc_oid);
+       values[Anum_pg_proc_oid - 1] = ObjectIdGetDatum(newOid);
        tup = heap_form_tuple(tupDesc, values, nulls);
        CatalogTupleInsert(rel, tup);
        is_update = false;
    }
 
 
-   retval = HeapTupleGetOid(tup);
+   retval = ((Form_pg_proc) GETSTRUCT(tup))->oid;
 
    /*
     * Create dependencies for the new function.  If we are updating an
index 3ecf6d57bf06e481ff00ce04c86631ec03806405..a9fbb731654eb069e0e5c3e0a9426991c64d11a4 100644 (file)
@@ -182,6 +182,9 @@ publication_add_relation(Oid pubid, Relation targetrel,
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   prrelid = GetNewOidWithIndex(rel, PublicationRelObjectIndexId,
+                                Anum_pg_publication_rel_oid);
+   values[Anum_pg_publication_rel_oid - 1] = ObjectIdGetDatum(prrelid);
    values[Anum_pg_publication_rel_prpubid - 1] =
        ObjectIdGetDatum(pubid);
    values[Anum_pg_publication_rel_prrelid - 1] =
@@ -190,7 +193,7 @@ publication_add_relation(Oid pubid, Relation targetrel,
    tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
 
    /* Insert tuple into catalog. */
-   prrelid = CatalogTupleInsert(rel, tup);
+   CatalogTupleInsert(rel, tup);
    heap_freetuple(tup);
 
    ObjectAddressSet(myself, PublicationRelRelationId, prrelid);
@@ -306,7 +309,11 @@ GetAllTablesPublications(void)
 
    result = NIL;
    while (HeapTupleIsValid(tup = systable_getnext(scan)))
-       result = lappend_oid(result, HeapTupleGetOid(tup));
+   {
+       Oid     oid = ((Form_pg_publication) GETSTRUCT(tup))->oid;
+
+       result = lappend_oid(result, oid);
+   }
 
    systable_endscan(scan);
    heap_close(rel, AccessShareLock);
@@ -337,8 +344,8 @@ GetAllTablesPublicationRelations(void)
 
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
-       Oid         relid = HeapTupleGetOid(tuple);
        Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+       Oid         relid = relForm->oid;
 
        if (is_publishable_class(relid, relForm))
            result = lappend_oid(result, relid);
@@ -392,7 +399,8 @@ GetPublicationByName(const char *pubname, bool missing_ok)
 {
    Oid         oid;
 
-   oid = GetSysCacheOid1(PUBLICATIONNAME, CStringGetDatum(pubname));
+   oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
+                         CStringGetDatum(pubname));
    if (!OidIsValid(oid))
    {
        if (missing_ok)
@@ -417,7 +425,8 @@ get_publication_oid(const char *pubname, bool missing_ok)
 {
    Oid         oid;
 
-   oid = GetSysCacheOid1(PUBLICATIONNAME, CStringGetDatum(pubname));
+   oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
+                         CStringGetDatum(pubname));
    if (!OidIsValid(oid) && !missing_ok)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
index f891ff8054384672f75e968e2f6ae36ada43f587..e136aa6a0b22de2e4575a63b418f9704406e433c 100644 (file)
@@ -168,8 +168,8 @@ get_subscription_oid(const char *subname, bool missing_ok)
 {
    Oid         oid;
 
-   oid = GetSysCacheOid2(SUBSCRIPTIONNAME, MyDatabaseId,
-                         CStringGetDatum(subname));
+   oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+                         MyDatabaseId, CStringGetDatum(subname));
    if (!OidIsValid(oid) && !missing_ok)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -236,13 +236,12 @@ textarray_to_stringlist(ArrayType *textarray)
 /*
  * Add new state record for a subscription table.
  */
-Oid
+void
 AddSubscriptionRelState(Oid subid, Oid relid, char state,
                        XLogRecPtr sublsn)
 {
    Relation    rel;
    HeapTuple   tup;
-   Oid         subrelid;
    bool        nulls[Natts_pg_subscription_rel];
    Datum       values[Natts_pg_subscription_rel];
 
@@ -272,26 +271,23 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
    tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
 
    /* Insert tuple into catalog. */
-   subrelid = CatalogTupleInsert(rel, tup);
+   CatalogTupleInsert(rel, tup);
 
    heap_freetuple(tup);
 
    /* Cleanup. */
    heap_close(rel, NoLock);
-
-   return subrelid;
 }
 
 /*
  * Update the state of a subscription table.
  */
-Oid
+void
 UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
                           XLogRecPtr sublsn)
 {
    Relation    rel;
    HeapTuple   tup;
-   Oid         subrelid;
    bool        nulls[Natts_pg_subscription_rel];
    Datum       values[Natts_pg_subscription_rel];
    bool        replaces[Natts_pg_subscription_rel];
@@ -328,12 +324,8 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
    /* Update the catalog. */
    CatalogTupleUpdate(rel, &tup->t_self, tup);
 
-   subrelid = HeapTupleGetOid(tup);
-
    /* Cleanup. */
    heap_close(rel, NoLock);
-
-   return subrelid;
 }
 
 /*
index b729e7ec95d21927e2ad874c9ddb44c7723b1251..fb3d012c7159ddc120ee775d1e5ac3914305233c 100644 (file)
@@ -17,6 +17,7 @@
 #include "access/heapam.h"
 #include "access/htup_details.h"
 #include "access/xact.h"
+#include "catalog/catalog.h"
 #include "catalog/binary_upgrade.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
@@ -121,11 +122,6 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
    nulls[Anum_pg_type_typdefault - 1] = true;
    nulls[Anum_pg_type_typacl - 1] = true;
 
-   /*
-    * create a new type tuple
-    */
-   tup = heap_form_tuple(tupDesc, values, nulls);
-
    /* Use binary-upgrade override for pg_type.oid? */
    if (IsBinaryUpgrade)
    {
@@ -134,14 +130,26 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                     errmsg("pg_type OID value not set when in binary upgrade mode")));
 
-       HeapTupleSetOid(tup, binary_upgrade_next_pg_type_oid);
+       typoid = binary_upgrade_next_pg_type_oid;
        binary_upgrade_next_pg_type_oid = InvalidOid;
    }
+   else
+   {
+       typoid = GetNewOidWithIndex(pg_type_desc, TypeOidIndexId,
+                                   Anum_pg_type_oid);
+   }
+
+   values[Anum_pg_type_oid - 1] = ObjectIdGetDatum(typoid);
+
+   /*
+    * create a new type tuple
+    */
+   tup = heap_form_tuple(tupDesc, values, nulls);
 
    /*
     * insert the tuple in the relation and get the tuple's oid.
     */
-   typoid = CatalogTupleInsert(pg_type_desc, tup);
+   CatalogTupleInsert(pg_type_desc, tup);
 
    /*
     * Create dependencies.  We can/must skip this in bootstrap mode.
@@ -407,11 +415,13 @@ TypeCreate(Oid newTypeOid,
                              ObjectIdGetDatum(typeNamespace));
    if (HeapTupleIsValid(tup))
    {
+       Form_pg_type typform = (Form_pg_type) GETSTRUCT(tup);
+
        /*
         * check that the type is not already defined.  It may exist as a
         * shell type, however.
         */
-       if (((Form_pg_type) GETSTRUCT(tup))->typisdefined)
+       if (typform->typisdefined)
            ereport(ERROR,
                    (errcode(ERRCODE_DUPLICATE_OBJECT),
                     errmsg("type \"%s\" already exists", typeName)));
@@ -419,13 +429,15 @@ TypeCreate(Oid newTypeOid,
        /*
         * shell type must have been created by same owner
         */
-       if (((Form_pg_type) GETSTRUCT(tup))->typowner != ownerId)
+       if (typform->typowner != ownerId)
            aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TYPE, typeName);
 
        /* trouble if caller wanted to force the OID */
        if (OidIsValid(newTypeOid))
            elog(ERROR, "cannot assign new OID to existing shell type");
 
+       replaces[Anum_pg_type_oid - 1] = false;
+
        /*
         * Okay to update existing shell type tuple
         */
@@ -437,19 +449,15 @@ TypeCreate(Oid newTypeOid,
 
        CatalogTupleUpdate(pg_type_desc, &tup->t_self, tup);
 
-       typeObjectId = HeapTupleGetOid(tup);
+       typeObjectId = typform->oid;
 
        rebuildDeps = true;     /* get rid of shell type's dependencies */
    }
    else
    {
-       tup = heap_form_tuple(RelationGetDescr(pg_type_desc),
-                             values,
-                             nulls);
-
        /* Force the OID if requested by caller */
        if (OidIsValid(newTypeOid))
-           HeapTupleSetOid(tup, newTypeOid);
+           typeObjectId = newTypeOid;
        /* Use binary-upgrade override for pg_type.oid, if supplied. */
        else if (IsBinaryUpgrade)
        {
@@ -458,12 +466,21 @@ TypeCreate(Oid newTypeOid,
                        (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                         errmsg("pg_type OID value not set when in binary upgrade mode")));
 
-           HeapTupleSetOid(tup, binary_upgrade_next_pg_type_oid);
+           typeObjectId = binary_upgrade_next_pg_type_oid;
            binary_upgrade_next_pg_type_oid = InvalidOid;
        }
-       /* else allow system to assign oid */
+       else
+       {
+           typeObjectId = GetNewOidWithIndex(pg_type_desc, TypeOidIndexId,
+                                             Anum_pg_type_oid);
+       }
+
+       values[Anum_pg_type_oid - 1] = ObjectIdGetDatum(typeObjectId);
+
+       tup = heap_form_tuple(RelationGetDescr(pg_type_desc),
+                             values, nulls);
 
-       typeObjectId = CatalogTupleInsert(pg_type_desc, tup);
+       CatalogTupleInsert(pg_type_desc, tup);
    }
 
    /*
@@ -710,7 +727,7 @@ RenameTypeInternal(Oid typeOid, const char *newTypeName, Oid typeNamespace)
    arrayOid = typ->typarray;
 
    /* Check for a conflicting type name. */
-   oldTypeOid = GetSysCacheOid2(TYPENAMENSP,
+   oldTypeOid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
                                 CStringGetDatum(newTypeName),
                                 ObjectIdGetDatum(typeNamespace));
 
index 3baaa0823815cc887cc83ab9baba571201144e48..462969a83843c2021340427a812c58f805774c79 100644 (file)
@@ -216,7 +216,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
             "pg_toast_%u_index", relOid);
 
    /* this is pretty painful...  need a tuple descriptor */
-   tupdesc = CreateTemplateTupleDesc(3, false);
+   tupdesc = CreateTemplateTupleDesc(3);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1,
                       "chunk_id",
                       OIDOID,
@@ -272,8 +272,6 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
                                           rel->rd_rel->relpersistence,
                                           shared_relation,
                                           mapped_relation,
-                                          true,
-                                          0,
                                           ONCOMMIT_NOOP,
                                           reloptions,
                                           false,
index eff325cc7d00286c7259d0cbc688f3a6c4cf5ae3..21e9d3916a1e81d309a02cd27df3639a287da798 100644 (file)
@@ -903,6 +903,7 @@ void
 AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
 {
    Oid         classId = RelationGetRelid(rel);
+   AttrNumber  Anum_oid = get_object_attnum_oid(classId);
    AttrNumber  Anum_owner = get_object_attnum_owner(classId);
    AttrNumber  Anum_namespace = get_object_attnum_namespace(classId);
    AttrNumber  Anum_acl = get_object_attnum_acl(classId);
@@ -913,7 +914,7 @@ AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
    Oid         old_ownerId;
    Oid         namespaceId = InvalidOid;
 
-   oldtup = get_catalog_object_by_oid(rel, objectId);
+   oldtup = get_catalog_object_by_oid(rel, Anum_oid, objectId);
    if (oldtup == NULL)
        elog(ERROR, "cache lookup failed for object %u of catalog \"%s\"",
             objectId, RelationGetRelationName(rel));
@@ -959,8 +960,7 @@ AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
                }
                else
                {
-                   snprintf(namebuf, sizeof(namebuf), "%u",
-                            HeapTupleGetOid(oldtup));
+                   snprintf(namebuf, sizeof(namebuf), "%u", objectId);
                    objname = namebuf;
                }
                aclcheck_error(ACLCHECK_NOT_OWNER, objtype, objname);
@@ -1017,7 +1017,7 @@ AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
        /* Update owner dependency reference */
        if (classId == LargeObjectMetadataRelationId)
            classId = LargeObjectRelationId;
-       changeDependencyOnOwner(classId, HeapTupleGetOid(newtup), new_ownerId);
+       changeDependencyOnOwner(classId, objectId, new_ownerId);
 
        /* Release memory */
        pfree(values);
index f2173450ad3b950a57d9d8e3d263bdfe7c2593ed..4367290a27cab24103f60d3cf643f4c55f7938c4 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "access/heapam.h"
 #include "access/htup_details.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/pg_am.h"
@@ -60,7 +61,8 @@ CreateAccessMethod(CreateAmStmt *stmt)
                 errhint("Must be superuser to create an access method.")));
 
    /* Check if name is used */
-   amoid = GetSysCacheOid1(AMNAME, CStringGetDatum(stmt->amname));
+   amoid = GetSysCacheOid1(AMNAME,  Anum_pg_am_oid,
+                           CStringGetDatum(stmt->amname));
    if (OidIsValid(amoid))
    {
        ereport(ERROR,
@@ -80,6 +82,8 @@ CreateAccessMethod(CreateAmStmt *stmt)
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   amoid = GetNewOidWithIndex(rel, AmOidIndexId, Anum_pg_am_oid);
+   values[Anum_pg_am_oid - 1] = ObjectIdGetDatum(amoid);
    values[Anum_pg_am_amname - 1] =
        DirectFunctionCall1(namein, CStringGetDatum(stmt->amname));
    values[Anum_pg_am_amhandler - 1] = ObjectIdGetDatum(amhandler);
@@ -87,7 +91,7 @@ CreateAccessMethod(CreateAmStmt *stmt)
 
    tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
 
-   amoid = CatalogTupleInsert(rel, tup);
+   CatalogTupleInsert(rel, tup);
    heap_freetuple(tup);
 
    myself.classId = AccessMethodRelationId;
@@ -164,7 +168,7 @@ get_am_type_oid(const char *amname, char amtype, bool missing_ok)
                            NameStr(amform->amname),
                            get_am_type_string(amtype))));
 
-       oid = HeapTupleGetOid(tup);
+       oid = amform->oid;
        ReleaseSysCache(tup);
    }
 
index 5ecd2565b4d870f003ac4b4ead6ce6954ad484cc..610e425a566d5621784ff386df024fdc84959f56 100644 (file)
@@ -75,7 +75,7 @@ static List *get_tables_to_cluster(MemoryContext cluster_context);
 static void reform_and_rewrite_tuple(HeapTuple tuple,
                         TupleDesc oldTupDesc, TupleDesc newTupDesc,
                         Datum *values, bool *isnull,
-                        bool newRelHasOids, RewriteState rwstate);
+                        RewriteState rwstate);
 
 
 /*---------------------------------------------------------------------------
@@ -688,8 +688,6 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, char relpersistence,
                                          relpersistence,
                                          false,
                                          RelationIsMapped(OldHeap),
-                                         true,
-                                         0,
                                          ONCOMMIT_NOOP,
                                          reloptions,
                                          false,
@@ -1061,7 +1059,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
            reform_and_rewrite_tuple(tuple,
                                     oldTupDesc, newTupDesc,
                                     values, isnull,
-                                    NewHeap->rd_rel->relhasoids, rwstate);
+                                    rwstate);
    }
 
    if (indexScan != NULL)
@@ -1090,7 +1088,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
            reform_and_rewrite_tuple(tuple,
                                     oldTupDesc, newTupDesc,
                                     values, isnull,
-                                    NewHeap->rd_rel->relhasoids, rwstate);
+                                    rwstate);
        }
 
        tuplesort_end(tuplesort);
@@ -1755,7 +1753,7 @@ get_tables_to_cluster(MemoryContext cluster_context)
  *
  * 2. The tuple might not even be legal for the new table; this is
  * currently only known to happen as an after-effect of ALTER TABLE
- * SET WITHOUT OIDS.
+ * SET WITHOUT OIDS (in an older version, via pg_upgrade).
  *
  * So, we must reconstruct the tuple from component Datums.
  */
@@ -1763,7 +1761,7 @@ static void
 reform_and_rewrite_tuple(HeapTuple tuple,
                         TupleDesc oldTupDesc, TupleDesc newTupDesc,
                         Datum *values, bool *isnull,
-                        bool newRelHasOids, RewriteState rwstate)
+                        RewriteState rwstate)
 {
    HeapTuple   copiedTuple;
    int         i;
@@ -1779,10 +1777,6 @@ reform_and_rewrite_tuple(HeapTuple tuple,
 
    copiedTuple = heap_form_tuple(newTupDesc, values, isnull);
 
-   /* Preserve OID, if any */
-   if (newRelHasOids)
-       HeapTupleSetOid(copiedTuple, HeapTupleGetOid(tuple));
-
    /* The heap rewrite module does the rest */
    rewrite_heap_tuple(rwstate, tuple, copiedTuple);
 
index a283fcb33adda8c0915ca8c35b789e816d291f94..4aa8890fe816b2a50c91f73acb66435f3dfded00 100644 (file)
@@ -131,7 +131,6 @@ typedef struct CopyStateData
    bool        is_program;     /* is 'filename' a program to popen? */
    copy_data_source_cb data_source_cb; /* function for reading data */
    bool        binary;         /* binary format? */
-   bool        oids;           /* include OIDs? */
    bool        freeze;         /* freeze rows on loading? */
    bool        csv_mode;       /* Comma Separated Value format? */
    bool        header_line;    /* CSV header line? */
@@ -173,7 +172,6 @@ typedef struct CopyStateData
     * Working state for COPY FROM
     */
    AttrNumber  num_defaults;
-   bool        file_has_oids;
    FmgrInfo    oid_in_function;
    Oid         oid_typioparam;
    FmgrInfo   *in_functions;   /* array of input functions for each attrs */
@@ -313,7 +311,7 @@ static CopyState BeginCopyTo(ParseState *pstate, Relation rel, RawStmt *query,
 static void EndCopyTo(CopyState cstate);
 static uint64 DoCopyTo(CopyState cstate);
 static uint64 CopyTo(CopyState cstate);
-static void CopyOneRowTo(CopyState cstate, Oid tupleOid,
+static void CopyOneRowTo(CopyState cstate,
             Datum *values, bool *nulls);
 static void CopyFromInsertBatch(CopyState cstate, EState *estate,
                    CommandId mycid, int hi_options,
@@ -1086,15 +1084,6 @@ ProcessCopyOptions(ParseState *pstate,
                         errmsg("COPY format \"%s\" not recognized", fmt),
                         parser_errposition(pstate, defel->location)));
        }
-       else if (strcmp(defel->defname, "oids") == 0)
-       {
-           if (cstate->oids)
-               ereport(ERROR,
-                       (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("conflicting or redundant options"),
-                        parser_errposition(pstate, defel->location)));
-           cstate->oids = defGetBoolean(defel);
-       }
        else if (strcmp(defel->defname, "freeze") == 0)
        {
            if (cstate->freeze)
@@ -1440,13 +1429,6 @@ BeginCopy(ParseState *pstate,
        cstate->rel = rel;
 
        tupDesc = RelationGetDescr(cstate->rel);
-
-       /* Don't allow COPY w/ OIDs to or from a table without them */
-       if (cstate->oids && !cstate->rel->rd_rel->relhasoids)
-           ereport(ERROR,
-                   (errcode(ERRCODE_UNDEFINED_COLUMN),
-                    errmsg("table \"%s\" does not have OIDs",
-                           RelationGetRelationName(cstate->rel))));
    }
    else
    {
@@ -1458,12 +1440,6 @@ BeginCopy(ParseState *pstate,
        Assert(!is_from);
        cstate->rel = NULL;
 
-       /* Don't allow COPY w/ OIDs from a query */
-       if (cstate->oids)
-           ereport(ERROR,
-                   (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                    errmsg("COPY (query) WITH OIDS is not supported")));
-
        /*
         * Run parse analysis and rewrite.  Note this also acquires sufficient
         * locks on the source table(s).
@@ -2028,8 +2004,6 @@ CopyTo(CopyState cstate)
        CopySendData(cstate, BinarySignature, 11);
        /* Flags field */
        tmp = 0;
-       if (cstate->oids)
-           tmp |= (1 << 16);
        CopySendInt32(cstate, tmp);
        /* No header extension */
        tmp = 0;
@@ -2091,7 +2065,7 @@ CopyTo(CopyState cstate)
            heap_deform_tuple(tuple, tupDesc, values, nulls);
 
            /* Format and send the data */
-           CopyOneRowTo(cstate, HeapTupleGetOid(tuple), values, nulls);
+           CopyOneRowTo(cstate, values, nulls);
            processed++;
        }
 
@@ -2124,7 +2098,7 @@ CopyTo(CopyState cstate)
  * Emit one row during CopyTo().
  */
 static void
-CopyOneRowTo(CopyState cstate, Oid tupleOid, Datum *values, bool *nulls)
+CopyOneRowTo(CopyState cstate, Datum *values, bool *nulls)
 {
    bool        need_delim = false;
    FmgrInfo   *out_functions = cstate->out_functions;
@@ -2139,25 +2113,6 @@ CopyOneRowTo(CopyState cstate, Oid tupleOid, Datum *values, bool *nulls)
    {
        /* Binary per-tuple header */
        CopySendInt16(cstate, list_length(cstate->attnumlist));
-       /* Send OID if wanted --- note attnumlist doesn't include it */
-       if (cstate->oids)
-       {
-           /* Hack --- assume Oid is same size as int32 */
-           CopySendInt32(cstate, sizeof(int32));
-           CopySendInt32(cstate, tupleOid);
-       }
-   }
-   else
-   {
-       /* Text format has no per-tuple header, but send OID if wanted */
-       /* Assume digits don't need any quoting or encoding conversion */
-       if (cstate->oids)
-       {
-           string = DatumGetCString(DirectFunctionCall1(oidout,
-                                                        ObjectIdGetDatum(tupleOid)));
-           CopySendString(cstate, string);
-           need_delim = true;
-       }
    }
 
    foreach(cur, cstate->attnumlist)
@@ -2689,7 +2644,6 @@ CopyFrom(CopyState cstate)
    {
        TupleTableSlot *slot;
        bool        skip_tuple;
-       Oid         loaded_oid = InvalidOid;
 
        CHECK_FOR_INTERRUPTS();
 
@@ -2706,15 +2660,12 @@ CopyFrom(CopyState cstate)
        /* Switch into its memory context */
        MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
 
-       if (!NextCopyFrom(cstate, econtext, values, nulls, &loaded_oid))
+       if (!NextCopyFrom(cstate, econtext, values, nulls))
            break;
 
        /* And now we can form the input tuple. */
        tuple = heap_form_tuple(tupDesc, values, nulls);
 
-       if (loaded_oid != InvalidOid)
-           HeapTupleSetOid(tuple, loaded_oid);
-
        /*
         * Constraints might reference the tableoid column, so initialize
         * t_tableOid before evaluating them.
@@ -3368,12 +3319,7 @@ BeginCopyFrom(ParseState *pstate,
        }
    }
 
-   if (!cstate->binary)
-   {
-       /* must rely on user to tell us... */
-       cstate->file_has_oids = cstate->oids;
-   }
-   else
+   if (cstate->binary)
    {
        /* Read and verify binary header */
        char        readSig[11];
@@ -3390,7 +3336,10 @@ BeginCopyFrom(ParseState *pstate,
            ereport(ERROR,
                    (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
                     errmsg("invalid COPY file header (missing flags)")));
-       cstate->file_has_oids = (tmp & (1 << 16)) != 0;
+       if ((tmp & (1 << 16)) != 0)
+           ereport(ERROR,
+                   (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
+                    errmsg("invalid COPY file header (WITH OIDS)")));
        tmp &= ~(1 << 16);
        if ((tmp >> 16) != 0)
            ereport(ERROR,
@@ -3412,21 +3361,13 @@ BeginCopyFrom(ParseState *pstate,
        }
    }
 
-   if (cstate->file_has_oids && cstate->binary)
-   {
-       getTypeBinaryInputInfo(OIDOID,
-                              &in_func_oid, &cstate->oid_typioparam);
-       fmgr_info(in_func_oid, &cstate->oid_in_function);
-   }
-
    /* create workspace for CopyReadAttributes results */
    if (!cstate->binary)
    {
        AttrNumber  attr_count = list_length(cstate->attnumlist);
-       int         nfields = cstate->file_has_oids ? (attr_count + 1) : attr_count;
 
-       cstate->max_fields = nfields;
-       cstate->raw_fields = (char **) palloc(nfields * sizeof(char *));
+       cstate->max_fields = attr_count;
+       cstate->raw_fields = (char **) palloc(attr_count * sizeof(char *));
    }
 
    MemoryContextSwitchTo(oldcontext);
@@ -3499,7 +3440,7 @@ NextCopyFromRawFields(CopyState cstate, char ***fields, int *nfields)
  */
 bool
 NextCopyFrom(CopyState cstate, ExprContext *econtext,
-            Datum *values, bool *nulls, Oid *tupleOid)
+            Datum *values, bool *nulls)
 {
    TupleDesc   tupDesc;
    AttrNumber  num_phys_attrs,
@@ -3508,16 +3449,12 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
    FmgrInfo   *in_functions = cstate->in_functions;
    Oid        *typioparams = cstate->typioparams;
    int         i;
-   int         nfields;
-   bool        isnull;
-   bool        file_has_oids = cstate->file_has_oids;
    int        *defmap = cstate->defmap;
    ExprState **defexprs = cstate->defexprs;
 
    tupDesc = RelationGetDescr(cstate->rel);
    num_phys_attrs = tupDesc->natts;
    attr_count = list_length(cstate->attnumlist);
-   nfields = file_has_oids ? (attr_count + 1) : attr_count;
 
    /* Initialize all values for row to NULL */
    MemSet(values, 0, num_phys_attrs * sizeof(Datum));
@@ -3536,41 +3473,13 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
            return false;
 
        /* check for overflowing fields */
-       if (nfields > 0 && fldct > nfields)
+       if (attr_count > 0 && fldct > attr_count)
            ereport(ERROR,
                    (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
                     errmsg("extra data after last expected column")));
 
        fieldno = 0;
 
-       /* Read the OID field if present */
-       if (file_has_oids)
-       {
-           if (fieldno >= fldct)
-               ereport(ERROR,
-                       (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
-                        errmsg("missing data for OID column")));
-           string = field_strings[fieldno++];
-
-           if (string == NULL)
-               ereport(ERROR,
-                       (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
-                        errmsg("null OID in COPY data")));
-           else if (cstate->oids && tupleOid != NULL)
-           {
-               cstate->cur_attname = "oid";
-               cstate->cur_attval = string;
-               *tupleOid = DatumGetObjectId(DirectFunctionCall1(oidin,
-                                                                CStringGetDatum(string)));
-               if (*tupleOid == InvalidOid)
-                   ereport(ERROR,
-                           (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
-                            errmsg("invalid OID in COPY data")));
-               cstate->cur_attname = NULL;
-               cstate->cur_attval = NULL;
-           }
-       }
-
        /* Loop to read the user attributes on the line. */
        foreach(cur, cstate->attnumlist)
        {
@@ -3628,7 +3537,7 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
            cstate->cur_attval = NULL;
        }
 
-       Assert(fieldno == nfields);
+       Assert(fieldno == attr_count);
    }
    else
    {
@@ -3674,27 +3583,6 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
                     errmsg("row field count is %d, expected %d",
                            (int) fld_count, attr_count)));
 
-       if (file_has_oids)
-       {
-           Oid         loaded_oid;
-
-           cstate->cur_attname = "oid";
-           loaded_oid =
-               DatumGetObjectId(CopyReadBinaryAttribute(cstate,
-                                                        0,
-                                                        &cstate->oid_in_function,
-                                                        cstate->oid_typioparam,
-                                                        -1,
-                                                        &isnull));
-           if (isnull || loaded_oid == InvalidOid)
-               ereport(ERROR,
-                       (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
-                        errmsg("invalid OID in COPY data")));
-           cstate->cur_attname = NULL;
-           if (cstate->oids && tupleOid != NULL)
-               *tupleOid = loaded_oid;
-       }
-
        i = 0;
        foreach(cur, cstate->attnumlist)
        {
@@ -5022,7 +4910,7 @@ copy_dest_receive(TupleTableSlot *slot, DestReceiver *self)
    slot_getallattrs(slot);
 
    /* And send the data */
-   CopyOneRowTo(cstate, InvalidOid, slot->tts_values, slot->tts_isnull);
+   CopyOneRowTo(cstate, slot->tts_values, slot->tts_isnull);
    myState->processed++;
 
    return true;
index 7b60aa9e282ccf79370bd20f5b7ef7006b5c5c07..d01b258b65444a47ff23773e07fe73a14ade567b 100644 (file)
@@ -391,20 +391,7 @@ ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
 int
 GetIntoRelEFlags(IntoClause *intoClause)
 {
-   int         flags;
-
-   /*
-    * We need to tell the executor whether it has to produce OIDs or not,
-    * because it doesn't have enough information to do so itself (since we
-    * can't build the target relation until after ExecutorStart).
-    *
-    * Disallow the OIDS option for materialized views.
-    */
-   if (interpretOidsOption(intoClause->options,
-                           (intoClause->viewQuery == NULL)))
-       flags = EXEC_FLAG_WITH_OIDS;
-   else
-       flags = EXEC_FLAG_WITHOUT_OIDS;
+   int         flags = 0;
 
    if (intoClause->skipData)
        flags |= EXEC_FLAG_WITH_NO_DATA;
@@ -591,12 +578,6 @@ intorel_receive(TupleTableSlot *slot, DestReceiver *self)
     */
    tuple = ExecCopySlotHeapTuple(slot);
 
-   /*
-    * force assignment of new OID (see comments in ExecInsert)
-    */
-   if (myState->rel->rd_rel->relhasoids)
-       HeapTupleSetOid(tuple, InvalidOid);
-
    heap_insert(myState->rel,
                tuple,
                myState->output_cid,
index 5342f217c028da722d3918022d629fae5e793b6c..f640f4697294563bd35890d0f346eaab16a97e44 100644 (file)
@@ -504,7 +504,8 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
 
    do
    {
-       dboid = GetNewOid(pg_database_rel);
+       dboid = GetNewOidWithIndex(pg_database_rel, DatabaseOidIndexId,
+                                  Anum_pg_database_oid);
    } while (check_db_file_conflict(dboid));
 
    /*
@@ -517,6 +518,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
    MemSet(new_record, 0, sizeof(new_record));
    MemSet(new_record_nulls, false, sizeof(new_record_nulls));
 
+   new_record[Anum_pg_database_oid - 1] = ObjectIdGetDatum(dboid);
    new_record[Anum_pg_database_datname - 1] =
        DirectFunctionCall1(namein, CStringGetDatum(dbname));
    new_record[Anum_pg_database_datdba - 1] = ObjectIdGetDatum(datdba);
@@ -543,8 +545,6 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
    tuple = heap_form_tuple(RelationGetDescr(pg_database_rel),
                            new_record, new_record_nulls);
 
-   HeapTupleSetOid(tuple, dboid);
-
    CatalogTupleInsert(pg_database_rel, tuple);
 
    /*
@@ -593,7 +593,8 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
        scan = heap_beginscan_catalog(rel, 0, NULL);
        while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
        {
-           Oid         srctablespace = HeapTupleGetOid(tuple);
+           Form_pg_tablespace spaceform = (Form_pg_tablespace) GETSTRUCT(tuple);
+           Oid         srctablespace = spaceform->oid;
            Oid         dsttablespace;
            char       *srcpath;
            char       *dstpath;
@@ -1301,8 +1302,7 @@ movedb(const char *dbname, const char *tblspcname)
                                     new_record_nulls, new_record_repl);
        CatalogTupleUpdate(pgdbrel, &oldtuple->t_self, newtuple);
 
-       InvokeObjectPostAlterHook(DatabaseRelationId,
-                                 HeapTupleGetOid(newtuple), 0);
+       InvokeObjectPostAlterHook(DatabaseRelationId, db_id, 0);
 
        systable_endscan(sysscan);
 
@@ -1400,6 +1400,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
    Oid         dboid;
    HeapTuple   tuple,
                newtuple;
+   Form_pg_database datform;
    ScanKeyData scankey;
    SysScanDesc scan;
    ListCell   *option;
@@ -1512,9 +1513,10 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
                (errcode(ERRCODE_UNDEFINED_DATABASE),
                 errmsg("database \"%s\" does not exist", stmt->dbname)));
 
-   dboid = HeapTupleGetOid(tuple);
+   datform = (Form_pg_database) GETSTRUCT(tuple);
+   dboid = datform->oid;
 
-   if (!pg_database_ownercheck(HeapTupleGetOid(tuple), GetUserId()))
+   if (!pg_database_ownercheck(dboid, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
                       stmt->dbname);
 
@@ -1556,8 +1558,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
                                 new_record_nulls, new_record_repl);
    CatalogTupleUpdate(rel, &tuple->t_self, newtuple);
 
-   InvokeObjectPostAlterHook(DatabaseRelationId,
-                             HeapTupleGetOid(newtuple), 0);
+   InvokeObjectPostAlterHook(DatabaseRelationId, dboid, 0);
 
    systable_endscan(scan);
 
@@ -1626,8 +1627,8 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
                (errcode(ERRCODE_UNDEFINED_DATABASE),
                 errmsg("database \"%s\" does not exist", dbname)));
 
-   db_id = HeapTupleGetOid(tuple);
    datForm = (Form_pg_database) GETSTRUCT(tuple);
+   db_id = datForm->oid;
 
    /*
     * If the new owner is the same as the existing owner, consider the
@@ -1645,7 +1646,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
        HeapTuple   newtuple;
 
        /* Otherwise, must be owner of the existing object */
-       if (!pg_database_ownercheck(HeapTupleGetOid(tuple), GetUserId()))
+       if (!pg_database_ownercheck(db_id, GetUserId()))
            aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
                           dbname);
 
@@ -1694,11 +1695,10 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
        heap_freetuple(newtuple);
 
        /* Update owner dependency reference */
-       changeDependencyOnOwner(DatabaseRelationId, HeapTupleGetOid(tuple),
-                               newOwnerId);
+       changeDependencyOnOwner(DatabaseRelationId, db_id, newOwnerId);
    }
 
-   InvokeObjectPostAlterHook(DatabaseRelationId, HeapTupleGetOid(tuple), 0);
+   InvokeObjectPostAlterHook(DatabaseRelationId, db_id, 0);
 
    ObjectAddressSet(address, DatabaseRelationId, db_id);
 
@@ -1770,7 +1770,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
            break;
        }
 
-       dbOid = HeapTupleGetOid(tuple);
+       dbOid = ((Form_pg_database) GETSTRUCT(tuple))->oid;
 
        systable_endscan(scan);
 
@@ -1878,7 +1878,8 @@ remove_dbtablespaces(Oid db_id)
    scan = heap_beginscan_catalog(rel, 0, NULL);
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
-       Oid         dsttablespace = HeapTupleGetOid(tuple);
+       Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+       Oid         dsttablespace = spcform->oid;
        char       *dstpath;
        struct stat st;
 
@@ -1945,7 +1946,8 @@ check_db_file_conflict(Oid db_id)
    scan = heap_beginscan_catalog(rel, 0, NULL);
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
-       Oid         dsttablespace = HeapTupleGetOid(tuple);
+       Form_pg_tablespace spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+       Oid         dsttablespace = spcform->oid;
        char       *dstpath;
        struct stat st;
 
@@ -2030,7 +2032,7 @@ get_database_oid(const char *dbname, bool missing_ok)
 
    /* We assume that there can be at most one matching tuple */
    if (HeapTupleIsValid(dbtuple))
-       oid = HeapTupleGetOid(dbtuple);
+       oid = ((Form_pg_database)GETSTRUCT(dbtuple))->oid;
    else
        oid = InvalidOid;
 
index 20a3a786929c77cda81e8fe2e4192b9ac63527e0..3e7c1067d8e0b150c629d8cebd38f97777dd8aee 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "access/htup_details.h"
 #include "access/xact.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -391,6 +392,9 @@ insert_event_trigger_tuple(const char *trigname, const char *eventname, Oid evtO
    tgrel = heap_open(EventTriggerRelationId, RowExclusiveLock);
 
    /* Build the new pg_trigger tuple. */
+   trigoid = GetNewOidWithIndex(tgrel, EventTriggerOidIndexId,
+                                Anum_pg_event_trigger_oid);
+   values[Anum_pg_event_trigger_oid - 1] = ObjectIdGetDatum(trigoid);
    memset(nulls, false, sizeof(nulls));
    namestrcpy(&evtnamedata, trigname);
    values[Anum_pg_event_trigger_evtname - 1] = NameGetDatum(&evtnamedata);
@@ -408,7 +412,7 @@ insert_event_trigger_tuple(const char *trigname, const char *eventname, Oid evtO
 
    /* Insert heap tuple. */
    tuple = heap_form_tuple(tgrel->rd_att, values, nulls);
-   trigoid = CatalogTupleInsert(tgrel, tuple);
+   CatalogTupleInsert(tgrel, tuple);
    heap_freetuple(tuple);
 
    /* Depend on owner. */
@@ -516,14 +520,14 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
                 errmsg("event trigger \"%s\" does not exist",
                        stmt->trigname)));
 
-   trigoid = HeapTupleGetOid(tup);
+   evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+   trigoid = evtForm->oid;
 
    if (!pg_event_trigger_ownercheck(trigoid, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EVENT_TRIGGER,
                       stmt->trigname);
 
    /* tuple is a copy, so we can modify it below */
-   evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
    evtForm->evtenabled = tgenabled;
 
    CatalogTupleUpdate(tgrel, &tup->t_self, tup);
@@ -546,6 +550,7 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId)
 {
    Oid         evtOid;
    HeapTuple   tup;
+   Form_pg_event_trigger evtForm;
    Relation    rel;
    ObjectAddress address;
 
@@ -558,7 +563,8 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId)
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("event trigger \"%s\" does not exist", name)));
 
-   evtOid = HeapTupleGetOid(tup);
+   evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
+   evtOid = evtForm->oid;
 
    AlterEventTriggerOwner_internal(rel, tup, newOwnerId);
 
@@ -609,7 +615,7 @@ AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
    if (form->evtowner == newOwnerId)
        return;
 
-   if (!pg_event_trigger_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+   if (!pg_event_trigger_ownercheck(form->oid, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EVENT_TRIGGER,
                       NameStr(form->evtname));
 
@@ -626,11 +632,11 @@ AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
 
    /* Update owner dependency reference */
    changeDependencyOnOwner(EventTriggerRelationId,
-                           HeapTupleGetOid(tup),
+                           form->oid,
                            newOwnerId);
 
    InvokeObjectPostAlterHook(EventTriggerRelationId,
-                             HeapTupleGetOid(tup), 0);
+                             form->oid, 0);
 }
 
 /*
@@ -644,7 +650,8 @@ get_event_trigger_oid(const char *trigname, bool missing_ok)
 {
    Oid         oid;
 
-   oid = GetSysCacheOid1(EVENTTRIGGERNAME, CStringGetDatum(trigname));
+   oid = GetSysCacheOid1(EVENTTRIGGERNAME, Anum_pg_event_trigger_oid,
+                         CStringGetDatum(trigname));
    if (!OidIsValid(oid) && !missing_ok)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1357,7 +1364,9 @@ EventTriggerSQLDropAddObject(const ObjectAddress *object, bool original, bool no
        HeapTuple   tuple;
 
        catalog = heap_open(obj->address.classId, AccessShareLock);
-       tuple = get_catalog_object_by_oid(catalog, obj->address.objectId);
+       tuple = get_catalog_object_by_oid(catalog,
+                                         get_object_attnum_oid(object->classId),
+                                         obj->address.objectId);
 
        if (tuple)
        {
@@ -2106,6 +2115,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
 
                            catalog = heap_open(addr.classId, AccessShareLock);
                            objtup = get_catalog_object_by_oid(catalog,
+                                                              get_object_attnum_oid(addr.classId),
                                                               addr.objectId);
                            if (!HeapTupleIsValid(objtup))
                                elog(ERROR, "cache lookup failed for object %u/%u",
index ab2c84ff98a1c13bf8aa466d7e848b1bcc9644c7..de09ded65b90630e6ca4351cfe457eefcf5a144e 100644 (file)
@@ -324,7 +324,7 @@ ExplainResultDesc(ExplainStmt *stmt)
    }
 
    /* Need a tuple descriptor representing a single TEXT or XML column */
-   tupdesc = CreateTemplateTupleDesc(1, false);
+   tupdesc = CreateTemplateTupleDesc(1);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, "QUERY PLAN",
                       result_type, -1, 0);
    return tupdesc;
index 560064d3e1fe74e8febf6e10d93ff17ceba8844b..a587a1bc03eb5c8e7a880297ed114f3a9cb85fcf 100644 (file)
@@ -32,6 +32,7 @@
 #include "access/htup_details.h"
 #include "access/sysattr.h"
 #include "access/xact.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/namespace.h"
@@ -154,7 +155,7 @@ get_extension_oid(const char *extname, bool missing_ok)
 
    /* We assume that there can be at most one matching tuple */
    if (HeapTupleIsValid(tuple))
-       result = HeapTupleGetOid(tuple);
+       result = ((Form_pg_extension) GETSTRUCT(tuple))->oid;
    else
        result = InvalidOid;
 
@@ -188,7 +189,7 @@ get_extension_name(Oid ext_oid)
    rel = heap_open(ExtensionRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_extension_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(ext_oid));
 
@@ -227,7 +228,7 @@ get_extension_schema(Oid ext_oid)
    rel = heap_open(ExtensionRelationId, AccessShareLock);
 
    ScanKeyInit(&entry[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_extension_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(ext_oid));
 
@@ -1758,6 +1759,9 @@ InsertExtensionTuple(const char *extName, Oid extOwner,
    memset(values, 0, sizeof(values));
    memset(nulls, 0, sizeof(nulls));
 
+   extensionOid = GetNewOidWithIndex(rel, ExtensionOidIndexId,
+                                     Anum_pg_extension_oid);
+   values[Anum_pg_extension_oid - 1] = ObjectIdGetDatum(extensionOid);
    values[Anum_pg_extension_extname - 1] =
        DirectFunctionCall1(namein, CStringGetDatum(extName));
    values[Anum_pg_extension_extowner - 1] = ObjectIdGetDatum(extOwner);
@@ -1777,7 +1781,7 @@ InsertExtensionTuple(const char *extName, Oid extOwner,
 
    tuple = heap_form_tuple(rel->rd_att, values, nulls);
 
-   extensionOid = CatalogTupleInsert(rel, tuple);
+   CatalogTupleInsert(rel, tuple);
 
    heap_freetuple(tuple);
    heap_close(rel, RowExclusiveLock);
@@ -1848,7 +1852,7 @@ RemoveExtensionById(Oid extId)
    rel = heap_open(ExtensionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&entry[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_extension_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(extId));
    scandesc = systable_beginscan(rel, ExtensionOidIndexId, true,
@@ -2376,7 +2380,7 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
    extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_extension_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(CurrentExtensionObject));
 
@@ -2524,7 +2528,7 @@ extension_config_remove(Oid extensionoid, Oid tableoid)
    extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_extension_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(extensionoid));
 
@@ -2723,7 +2727,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
    extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
 
    ScanKeyInit(&key[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_extension_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(extensionOid));
 
@@ -2903,7 +2907,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
                 errmsg("extension \"%s\" does not exist",
                        stmt->extname)));
 
-   extensionOid = HeapTupleGetOid(extTup);
+   extensionOid = ((Form_pg_extension) GETSTRUCT(extTup))->oid;
 
    /*
     * Determine the existing version we are updating from
@@ -3045,7 +3049,7 @@ ApplyExtensionUpdates(Oid extensionOid,
        extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
 
        ScanKeyInit(&key[0],
-                   ObjectIdAttributeNumber,
+                   Anum_pg_extension_oid,
                    BTEqualStrategyNumber, F_OIDEQ,
                    ObjectIdGetDatum(extensionOid));
 
index e5dd9958a4cb5cc064911d7d0b4f0619553c4b06..10e9d7f5629bd633a0d5c62b137cfda0ef5cefcf 100644 (file)
@@ -17,6 +17,7 @@
 #include "access/htup_details.h"
 #include "access/reloptions.h"
 #include "access/xact.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -260,12 +261,12 @@ AlterForeignDataWrapperOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerI
 
        /* Update owner dependency reference */
        changeDependencyOnOwner(ForeignDataWrapperRelationId,
-                               HeapTupleGetOid(tup),
+                               form->oid,
                                newOwnerId);
    }
 
    InvokeObjectPostAlterHook(ForeignDataWrapperRelationId,
-                             HeapTupleGetOid(tup), 0);
+                             form->oid, 0);
 }
 
 /*
@@ -280,6 +281,8 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
    HeapTuple   tup;
    Relation    rel;
    ObjectAddress address;
+   Form_pg_foreign_data_wrapper form;
+
 
    rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
 
@@ -290,7 +293,8 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("foreign-data wrapper \"%s\" does not exist", name)));
 
-   fdwId = HeapTupleGetOid(tup);
+   form = (Form_pg_foreign_data_wrapper) GETSTRUCT(tup);
+   fdwId = form->oid;
 
    AlterForeignDataWrapperOwner_internal(rel, tup, newOwnerId);
 
@@ -354,7 +358,7 @@ AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
            Oid         srvId;
            AclResult   aclresult;
 
-           srvId = HeapTupleGetOid(tup);
+           srvId = form->oid;
 
            /* Must be owner */
            if (!pg_foreign_server_ownercheck(srvId, GetUserId()))
@@ -399,12 +403,12 @@ AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
        CatalogTupleUpdate(rel, &tup->t_self, tup);
 
        /* Update owner dependency reference */
-       changeDependencyOnOwner(ForeignServerRelationId, HeapTupleGetOid(tup),
+       changeDependencyOnOwner(ForeignServerRelationId, form->oid,
                                newOwnerId);
    }
 
    InvokeObjectPostAlterHook(ForeignServerRelationId,
-                             HeapTupleGetOid(tup), 0);
+                             form->oid, 0);
 }
 
 /*
@@ -417,6 +421,7 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
    HeapTuple   tup;
    Relation    rel;
    ObjectAddress address;
+   Form_pg_foreign_server form;
 
    rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
 
@@ -427,7 +432,8 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("server \"%s\" does not exist", name)));
 
-   servOid = HeapTupleGetOid(tup);
+   form = (Form_pg_foreign_server) GETSTRUCT(tup);
+   servOid = form->oid;
 
    AlterForeignServerOwner_internal(rel, tup, newOwnerId);
 
@@ -601,6 +607,9 @@ CreateForeignDataWrapper(CreateFdwStmt *stmt)
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   fdwId = GetNewOidWithIndex(rel, ForeignDataWrapperOidIndexId,
+                              Anum_pg_foreign_data_wrapper_oid);
+   values[Anum_pg_foreign_data_wrapper_oid - 1] = ObjectIdGetDatum(fdwId);
    values[Anum_pg_foreign_data_wrapper_fdwname - 1] =
        DirectFunctionCall1(namein, CStringGetDatum(stmt->fdwname));
    values[Anum_pg_foreign_data_wrapper_fdwowner - 1] = ObjectIdGetDatum(ownerId);
@@ -627,7 +636,7 @@ CreateForeignDataWrapper(CreateFdwStmt *stmt)
 
    tuple = heap_form_tuple(rel->rd_att, values, nulls);
 
-   fdwId = CatalogTupleInsert(rel, tuple);
+   CatalogTupleInsert(rel, tuple);
 
    heap_freetuple(tuple);
 
@@ -706,7 +715,7 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt)
                 errmsg("foreign-data wrapper \"%s\" does not exist", stmt->fdwname)));
 
    fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tp);
-   fdwId = HeapTupleGetOid(tp);
+   fdwId = fdwForm->oid;
 
    memset(repl_val, 0, sizeof(repl_val));
    memset(repl_null, false, sizeof(repl_null));
@@ -915,6 +924,9 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   srvId = GetNewOidWithIndex(rel, ForeignServerOidIndexId,
+                              Anum_pg_foreign_server_oid);
+   values[Anum_pg_foreign_server_oid - 1] = ObjectIdGetDatum(srvId);
    values[Anum_pg_foreign_server_srvname - 1] =
        DirectFunctionCall1(namein, CStringGetDatum(stmt->servername));
    values[Anum_pg_foreign_server_srvowner - 1] = ObjectIdGetDatum(ownerId);
@@ -950,7 +962,7 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
 
    tuple = heap_form_tuple(rel->rd_att, values, nulls);
 
-   srvId = CatalogTupleInsert(rel, tuple);
+   CatalogTupleInsert(rel, tuple);
 
    heap_freetuple(tuple);
 
@@ -1003,8 +1015,8 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("server \"%s\" does not exist", stmt->servername)));
 
-   srvId = HeapTupleGetOid(tp);
    srvForm = (Form_pg_foreign_server) GETSTRUCT(tp);
+   srvId = srvForm->oid;
 
    /*
     * Only owner or a superuser can ALTER a SERVER.
@@ -1162,7 +1174,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
    /*
     * Check that the user mapping is unique within server.
     */
-   umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
+   umId = GetSysCacheOid2(USERMAPPINGUSERSERVER, Anum_pg_user_mapping_oid,
                           ObjectIdGetDatum(useId),
                           ObjectIdGetDatum(srv->serverid));
 
@@ -1195,6 +1207,9 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   umId = GetNewOidWithIndex(rel, UserMappingOidIndexId,
+                             Anum_pg_user_mapping_oid);
+   values[Anum_pg_user_mapping_oid - 1] = ObjectIdGetDatum(umId);
    values[Anum_pg_user_mapping_umuser - 1] = ObjectIdGetDatum(useId);
    values[Anum_pg_user_mapping_umserver - 1] = ObjectIdGetDatum(srv->serverid);
 
@@ -1211,7 +1226,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
 
    tuple = heap_form_tuple(rel->rd_att, values, nulls);
 
-   umId = CatalogTupleInsert(rel, tuple);
+   CatalogTupleInsert(rel, tuple);
 
    heap_freetuple(tuple);
 
@@ -1273,7 +1288,7 @@ AlterUserMapping(AlterUserMappingStmt *stmt)
 
    srv = GetForeignServerByName(stmt->servername, false);
 
-   umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
+   umId = GetSysCacheOid2(USERMAPPINGUSERSERVER, Anum_pg_user_mapping_oid,
                           ObjectIdGetDatum(useId),
                           ObjectIdGetDatum(srv->serverid));
    if (!OidIsValid(umId))
@@ -1385,7 +1400,7 @@ RemoveUserMapping(DropUserMappingStmt *stmt)
        return InvalidOid;
    }
 
-   umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
+   umId = GetSysCacheOid2(USERMAPPINGUSERSERVER, Anum_pg_user_mapping_oid,
                           ObjectIdGetDatum(useId),
                           ObjectIdGetDatum(srv->serverid));
 
index f6e12a33532720d4992801d764664c37071f551e..ebece4d1d7eeb7924630215dcec753041116f779 100644 (file)
@@ -36,6 +36,7 @@
 #include "access/heapam.h"
 #include "access/htup_details.h"
 #include "access/sysattr.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -938,8 +939,8 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
                 (PLTemplateExists(language) ?
                  errhint("Use CREATE EXTENSION to load the language into the database.") : 0)));
 
-   languageOid = HeapTupleGetOid(languageTuple);
    languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+   languageOid = languageStruct->oid;
 
    if (languageStruct->lanpltrusted)
    {
@@ -1668,6 +1669,8 @@ CreateCast(CreateCastStmt *stmt)
                        format_type_be(targettypeid))));
 
    /* ready to go */
+   castid = GetNewOidWithIndex(relation, CastOidIndexId, Anum_pg_cast_oid);
+   values[Anum_pg_cast_oid - 1] = ObjectIdGetDatum(castid);
    values[Anum_pg_cast_castsource - 1] = ObjectIdGetDatum(sourcetypeid);
    values[Anum_pg_cast_casttarget - 1] = ObjectIdGetDatum(targettypeid);
    values[Anum_pg_cast_castfunc - 1] = ObjectIdGetDatum(funcid);
@@ -1678,7 +1681,7 @@ CreateCast(CreateCastStmt *stmt)
 
    tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls);
 
-   castid = CatalogTupleInsert(relation, tuple);
+   CatalogTupleInsert(relation, tuple);
 
    /* make dependency entries */
    myself.classId = CastRelationId;
@@ -1730,7 +1733,7 @@ get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok)
 {
    Oid         oid;
 
-   oid = GetSysCacheOid2(CASTSOURCETARGET,
+   oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
                          ObjectIdGetDatum(sourcetypeid),
                          ObjectIdGetDatum(targettypeid));
    if (!OidIsValid(oid) && !missing_ok)
@@ -1753,7 +1756,7 @@ DropCastById(Oid castOid)
    relation = heap_open(CastRelationId, RowExclusiveLock);
 
    ScanKeyInit(&scankey,
-               ObjectIdAttributeNumber,
+               Anum_pg_cast_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(castOid));
    scan = systable_beginscan(relation, CastOidIndexId, true,
@@ -1925,6 +1928,8 @@ CreateTransform(CreateTransformStmt *stmt)
                            ObjectIdGetDatum(langid));
    if (HeapTupleIsValid(tuple))
    {
+       Form_pg_transform form = (Form_pg_transform) GETSTRUCT(tuple);
+
        if (!stmt->replace)
            ereport(ERROR,
                    (errcode(ERRCODE_DUPLICATE_OBJECT),
@@ -1939,14 +1944,17 @@ CreateTransform(CreateTransformStmt *stmt)
        newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values, nulls, replaces);
        CatalogTupleUpdate(relation, &newtuple->t_self, newtuple);
 
-       transformid = HeapTupleGetOid(tuple);
+       transformid = form->oid;
        ReleaseSysCache(tuple);
        is_replace = true;
    }
    else
    {
+       transformid = GetNewOidWithIndex(relation, TransformOidIndexId,
+                                        Anum_pg_transform_oid);
+       values[Anum_pg_transform_oid - 1] = ObjectIdGetDatum(transformid);
        newtuple = heap_form_tuple(RelationGetDescr(relation), values, nulls);
-       transformid = CatalogTupleInsert(relation, newtuple);
+       CatalogTupleInsert(relation, newtuple);
        is_replace = false;
    }
 
@@ -2011,7 +2019,7 @@ get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok)
 {
    Oid         oid;
 
-   oid = GetSysCacheOid2(TRFTYPELANG,
+   oid = GetSysCacheOid2(TRFTYPELANG, Anum_pg_transform_oid,
                          ObjectIdGetDatum(type_id),
                          ObjectIdGetDatum(lang_id));
    if (!OidIsValid(oid) && !missing_ok)
@@ -2035,7 +2043,7 @@ DropTransformById(Oid transformOid)
    relation = heap_open(TransformRelationId, RowExclusiveLock);
 
    ScanKeyInit(&scankey,
-               ObjectIdAttributeNumber,
+               Anum_pg_transform_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(transformOid));
    scan = systable_beginscan(relation, TransformOidIndexId, true,
@@ -2140,8 +2148,8 @@ ExecuteDoStmt(DoStmt *stmt, bool atomic)
                 (PLTemplateExists(language) ?
                  errhint("Use CREATE EXTENSION to load the language into the database.") : 0)));
 
-   codeblock->langOid = HeapTupleGetOid(languageTuple);
    languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
+   codeblock->langOid = languageStruct->oid;
    codeblock->langIsTrusted = languageStruct->lanpltrusted;
    codeblock->atomic = atomic;
 
index 906d7113781d1426d5de772e013fd929fbd1e72a..73656d8cc8466bf60272904ca76f1b7f83121e13 100644 (file)
@@ -172,8 +172,8 @@ CheckIndexCompatible(Oid oldId,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("access method \"%s\" does not exist",
                        accessMethodName)));
-   accessMethodId = HeapTupleGetOid(tuple);
    accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+   accessMethodId = accessMethodForm->oid;
    amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler);
    ReleaseSysCache(tuple);
 
@@ -583,8 +583,8 @@ DefineIndex(Oid relationId,
                     errmsg("access method \"%s\" does not exist",
                            accessMethodName)));
    }
-   accessMethodId = HeapTupleGetOid(tuple);
    accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+   accessMethodId = accessMethodForm->oid;
    amRoutine = GetIndexAmRoutine(accessMethodForm->amhandler);
 
    if (stmt->unique && !amRoutine->amcanunique)
@@ -748,14 +748,14 @@ DefineIndex(Oid relationId,
 
 
    /*
-    * We disallow indexes on system columns other than OID.  They would not
-    * necessarily get updated correctly, and they don't seem useful anyway.
+    * We disallow indexes on system columns.  They would not necessarily get
+    * updated correctly, and they don't seem useful anyway.
     */
    for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
    {
        AttrNumber  attno = indexInfo->ii_IndexAttrNumbers[i];
 
-       if (attno < 0 && attno != ObjectIdAttributeNumber)
+       if (attno < 0)
            ereport(ERROR,
                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                     errmsg("index creation on system columns is not supported")));
@@ -773,8 +773,7 @@ DefineIndex(Oid relationId,
 
        for (i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
        {
-           if (i != ObjectIdAttributeNumber &&
-               bms_is_member(i - FirstLowInvalidHeapAttributeNumber,
+           if (bms_is_member(i - FirstLowInvalidHeapAttributeNumber,
                              indexattrs))
                ereport(ERROR,
                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -1712,6 +1711,7 @@ ResolveOpClass(List *opclass, Oid attrType,
    char       *schemaname;
    char       *opcname;
    HeapTuple   tuple;
+   Form_pg_opclass opform;
    Oid         opClassId,
                opInputType;
 
@@ -1796,8 +1796,9 @@ ResolveOpClass(List *opclass, Oid attrType,
     * Verify that the index operator class accepts this datatype.  Note we
     * will accept binary compatibility.
     */
-   opClassId = HeapTupleGetOid(tuple);
-   opInputType = ((Form_pg_opclass) GETSTRUCT(tuple))->opcintype;
+   opform = (Form_pg_opclass) GETSTRUCT(tuple);
+   opClassId = opform->oid;
+   opInputType = opform->opcintype;
 
    if (!IsBinaryCoercible(attrType, opInputType))
        ereport(ERROR,
@@ -1866,7 +1867,7 @@ GetDefaultOpClass(Oid type_id, Oid am_id)
        if (opclass->opcintype == type_id)
        {
            nexact++;
-           result = HeapTupleGetOid(tup);
+           result = opclass->oid;
        }
        else if (nexact == 0 &&
                 IsBinaryCoercible(type_id, opclass->opcintype))
@@ -1874,12 +1875,12 @@ GetDefaultOpClass(Oid type_id, Oid am_id)
            if (IsPreferredType(tcategory, opclass->opcintype))
            {
                ncompatiblepreferred++;
-               result = HeapTupleGetOid(tup);
+               result = opclass->oid;
            }
            else if (ncompatiblepreferred == 0)
            {
                ncompatible++;
-               result = HeapTupleGetOid(tup);
+               result = opclass->oid;
            }
        }
    }
@@ -2405,7 +2406,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
        Form_pg_class classtuple = (Form_pg_class) GETSTRUCT(tuple);
-       Oid         relid = HeapTupleGetOid(tuple);
+       Oid         relid = classtuple->oid;
 
        /*
         * Only regular tables and matviews can have indexes, so ignore any
index fd12288cbe3dd778b40ba0ef4e42fbc163b7d205..a171ebabf8fb6d12ad5be4e6ebe77392133b3817 100644 (file)
@@ -184,9 +184,6 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
                (errcode(ERRCODE_SYNTAX_ERROR),
                 errmsg("CONCURRENTLY and WITH NO DATA options cannot be used together")));
 
-   /* We don't allow an oid column for a materialized view. */
-   Assert(!matviewRel->rd_rel->relhasoids);
-
    /*
     * Check that everything is correct for a refresh. Problems at this point
     * are internal errors, so elog is sufficient.
@@ -408,7 +405,7 @@ refresh_matview_datafill(DestReceiver *dest, Query *query,
                                dest, NULL, NULL, 0);
 
    /* call ExecutorStart to prepare the plan for execution */
-   ExecutorStart(queryDesc, EXEC_FLAG_WITHOUT_OIDS);
+   ExecutorStart(queryDesc, 0);
 
    /* run the plan */
    ExecutorRun(queryDesc, ForwardScanDirection, 0L, true);
index 3b5c90e3f41ffe896672e16c874c17cbfb3d04e7..93ef3bd17cad3e2194a02a38e77781f880757f2d 100644 (file)
@@ -23,6 +23,7 @@
 #include "access/nbtree.h"
 #include "access/htup_details.h"
 #include "access/sysattr.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -142,12 +143,14 @@ Oid
 get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok)
 {
    HeapTuple   htup;
+   Form_pg_opfamily opfamform;
    Oid         opfID;
 
    htup = OpFamilyCacheLookup(amID, opfamilyname, missing_ok);
    if (!HeapTupleIsValid(htup))
        return InvalidOid;
-   opfID = HeapTupleGetOid(htup);
+   opfamform = (Form_pg_opfamily) GETSTRUCT(htup);
+   opfID = opfamform->oid;
    ReleaseSysCache(htup);
 
    return opfID;
@@ -221,12 +224,14 @@ Oid
 get_opclass_oid(Oid amID, List *opclassname, bool missing_ok)
 {
    HeapTuple   htup;
+   Form_pg_opclass opcform;
    Oid         opcID;
 
    htup = OpClassCacheLookup(amID, opclassname, missing_ok);
    if (!HeapTupleIsValid(htup))
        return InvalidOid;
-   opcID = HeapTupleGetOid(htup);
+   opcform = (Form_pg_opclass) GETSTRUCT(htup);
+   opcID = opcform->oid;
    ReleaseSysCache(htup);
 
    return opcID;
@@ -271,6 +276,9 @@ CreateOpFamily(const char *amname, const char *opfname, Oid namespaceoid, Oid am
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   opfamilyoid = GetNewOidWithIndex(rel, OpfamilyOidIndexId,
+                                    Anum_pg_opfamily_oid);
+   values[Anum_pg_opfamily_oid - 1] = ObjectIdGetDatum(opfamilyoid);
    values[Anum_pg_opfamily_opfmethod - 1] = ObjectIdGetDatum(amoid);
    namestrcpy(&opfName, opfname);
    values[Anum_pg_opfamily_opfname - 1] = NameGetDatum(&opfName);
@@ -279,7 +287,7 @@ CreateOpFamily(const char *amname, const char *opfname, Oid namespaceoid, Oid am
 
    tup = heap_form_tuple(rel->rd_att, values, nulls);
 
-   opfamilyoid = CatalogTupleInsert(rel, tup);
+   CatalogTupleInsert(rel, tup);
 
    heap_freetuple(tup);
 
@@ -338,6 +346,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
    ListCell   *l;
    Relation    rel;
    HeapTuple   tup;
+   Form_pg_am  amform;
    IndexAmRoutine *amroutine;
    Datum       values[Natts_pg_opclass];
    bool        nulls[Natts_pg_opclass];
@@ -364,7 +373,8 @@ DefineOpClass(CreateOpClassStmt *stmt)
                 errmsg("access method \"%s\" does not exist",
                        stmt->amname)));
 
-   amoid = HeapTupleGetOid(tup);
+   amform = (Form_pg_am) GETSTRUCT(tup);
+   amoid = amform->oid;
    amroutine = GetIndexAmRoutineByAmId(amoid, false);
    ReleaseSysCache(tup);
 
@@ -429,7 +439,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
                              ObjectIdGetDatum(namespaceoid));
        if (HeapTupleIsValid(tup))
        {
-           opfamilyoid = HeapTupleGetOid(tup);
+           opfamilyoid = ((Form_pg_opfamily) GETSTRUCT(tup))->oid;
 
            /*
             * XXX given the superuser check above, there's no need for an
@@ -633,6 +643,9 @@ DefineOpClass(CreateOpClassStmt *stmt)
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   opclassoid = GetNewOidWithIndex(rel, OpclassOidIndexId,
+                                   Anum_pg_opclass_oid);
+   values[Anum_pg_opclass_oid - 1] = ObjectIdGetDatum(opclassoid);
    values[Anum_pg_opclass_opcmethod - 1] = ObjectIdGetDatum(amoid);
    namestrcpy(&opcName, opcname);
    values[Anum_pg_opclass_opcname - 1] = NameGetDatum(&opcName);
@@ -645,7 +658,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
 
    tup = heap_form_tuple(rel->rd_att, values, nulls);
 
-   opclassoid = CatalogTupleInsert(rel, tup);
+   CatalogTupleInsert(rel, tup);
 
    heap_freetuple(tup);
 
@@ -768,6 +781,7 @@ AlterOpFamily(AlterOpFamilyStmt *stmt)
    int         maxOpNumber,    /* amstrategies value */
                maxProcNumber;  /* amsupport value */
    HeapTuple   tup;
+   Form_pg_am  amform;
    IndexAmRoutine *amroutine;
 
    /* Get necessary info about access method */
@@ -778,7 +792,8 @@ AlterOpFamily(AlterOpFamilyStmt *stmt)
                 errmsg("access method \"%s\" does not exist",
                        stmt->amname)));
 
-   amoid = HeapTupleGetOid(tup);
+   amform = (Form_pg_am) GETSTRUCT(tup);
+   amoid = amform->oid;
    amroutine = GetIndexAmRoutineByAmId(amoid, false);
    ReleaseSysCache(tup);
 
@@ -1333,6 +1348,9 @@ storeOperators(List *opfamilyname, Oid amoid,
        memset(values, 0, sizeof(values));
        memset(nulls, false, sizeof(nulls));
 
+       entryoid = GetNewOidWithIndex(rel, AccessMethodOperatorOidIndexId,
+                                     Anum_pg_amop_oid);
+       values[Anum_pg_amop_oid - 1] = ObjectIdGetDatum(entryoid);
        values[Anum_pg_amop_amopfamily - 1] = ObjectIdGetDatum(opfamilyoid);
        values[Anum_pg_amop_amoplefttype - 1] = ObjectIdGetDatum(op->lefttype);
        values[Anum_pg_amop_amoprighttype - 1] = ObjectIdGetDatum(op->righttype);
@@ -1344,7 +1362,7 @@ storeOperators(List *opfamilyname, Oid amoid,
 
        tup = heap_form_tuple(rel->rd_att, values, nulls);
 
-       entryoid = CatalogTupleInsert(rel, tup);
+       CatalogTupleInsert(rel, tup);
 
        heap_freetuple(tup);
 
@@ -1445,6 +1463,9 @@ storeProcedures(List *opfamilyname, Oid amoid,
        memset(values, 0, sizeof(values));
        memset(nulls, false, sizeof(nulls));
 
+       entryoid = GetNewOidWithIndex(rel, AccessMethodProcedureOidIndexId,
+                                     Anum_pg_amproc_oid);
+       values[Anum_pg_amproc_oid - 1] = ObjectIdGetDatum(entryoid);
        values[Anum_pg_amproc_amprocfamily - 1] = ObjectIdGetDatum(opfamilyoid);
        values[Anum_pg_amproc_amproclefttype - 1] = ObjectIdGetDatum(proc->lefttype);
        values[Anum_pg_amproc_amprocrighttype - 1] = ObjectIdGetDatum(proc->righttype);
@@ -1453,7 +1474,7 @@ storeProcedures(List *opfamilyname, Oid amoid,
 
        tup = heap_form_tuple(rel->rd_att, values, nulls);
 
-       entryoid = CatalogTupleInsert(rel, tup);
+       CatalogTupleInsert(rel, tup);
 
        heap_freetuple(tup);
 
@@ -1515,7 +1536,7 @@ dropOperators(List *opfamilyname, Oid amoid, Oid opfamilyoid,
        Oid         amopid;
        ObjectAddress object;
 
-       amopid = GetSysCacheOid4(AMOPSTRATEGY,
+       amopid = GetSysCacheOid4(AMOPSTRATEGY, Anum_pg_amop_oid,
                                 ObjectIdGetDatum(opfamilyoid),
                                 ObjectIdGetDatum(op->lefttype),
                                 ObjectIdGetDatum(op->righttype),
@@ -1555,7 +1576,7 @@ dropProcedures(List *opfamilyname, Oid amoid, Oid opfamilyoid,
        Oid         amprocid;
        ObjectAddress object;
 
-       amprocid = GetSysCacheOid4(AMPROCNUM,
+       amprocid = GetSysCacheOid4(AMPROCNUM, Anum_pg_amproc_oid,
                                   ObjectIdGetDatum(opfamilyoid),
                                   ObjectIdGetDatum(op->lefttype),
                                   ObjectIdGetDatum(op->righttype),
@@ -1627,7 +1648,7 @@ RemoveAmOpEntryById(Oid entryOid)
    SysScanDesc scan;
 
    ScanKeyInit(&skey[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_amop_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(entryOid));
 
@@ -1656,7 +1677,7 @@ RemoveAmProcEntryById(Oid entryOid)
    SysScanDesc scan;
 
    ScanKeyInit(&skey[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_amproc_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(entryOid));
 
index 2fd17b24b9efbfd0ec56611afc83f540ea73709d..5b27a94471e40ecee4058c7848ff2d18bc25efee 100644 (file)
@@ -365,7 +365,7 @@ RemovePolicyById(Oid policy_id)
     * Find the policy to delete.
     */
    ScanKeyInit(&skey[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_policy_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(policy_id));
 
@@ -457,7 +457,7 @@ RemoveRoleFromObjectPolicy(Oid roleid, Oid classid, Oid policy_id)
     * Find the policy to update.
     */
    ScanKeyInit(&skey[0],
-               ObjectIdAttributeNumber,
+               Anum_pg_policy_oid,
                BTEqualStrategyNumber, F_OIDEQ,
                ObjectIdGetDatum(policy_id));
 
@@ -807,6 +807,9 @@ CreatePolicy(CreatePolicyStmt *stmt)
                 errmsg("policy \"%s\" for table \"%s\" already exists",
                        stmt->policy_name, RelationGetRelationName(target_table))));
 
+   policy_id = GetNewOidWithIndex(pg_policy_rel, PolicyOidIndexId,
+                                  Anum_pg_policy_oid);
+   values[Anum_pg_policy_oid - 1] = ObjectIdGetDatum(policy_id);
    values[Anum_pg_policy_polrelid - 1] = ObjectIdGetDatum(table_id);
    values[Anum_pg_policy_polname - 1] = DirectFunctionCall1(namein,
                                                             CStringGetDatum(stmt->policy_name));
@@ -829,7 +832,7 @@ CreatePolicy(CreatePolicyStmt *stmt)
    policy_tuple = heap_form_tuple(RelationGetDescr(pg_policy_rel), values,
                                   isnull);
 
-   policy_id = CatalogTupleInsert(pg_policy_rel, policy_tuple);
+   CatalogTupleInsert(pg_policy_rel, policy_tuple);
 
    /* Record Dependencies */
    target.classId = RelationRelationId;
@@ -1033,7 +1036,7 @@ AlterPolicy(AlterPolicyStmt *stmt)
                (errcode(ERRCODE_SYNTAX_ERROR),
                 errmsg("only WITH CHECK expression allowed for INSERT")));
 
-   policy_id = HeapTupleGetOid(policy_tuple);
+   policy_id = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
 
    if (role_ids != NULL)
    {
@@ -1284,7 +1287,7 @@ rename_policy(RenameStmt *stmt)
                 errmsg("policy \"%s\" for table \"%s\" does not exist",
                        stmt->subname, RelationGetRelationName(target_table))));
 
-   opoloid = HeapTupleGetOid(policy_tuple);
+   opoloid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
 
    policy_tuple = heap_copytuple(policy_tuple);
 
@@ -1293,8 +1296,7 @@ rename_policy(RenameStmt *stmt)
 
    CatalogTupleUpdate(pg_policy_rel, &policy_tuple->t_self, policy_tuple);
 
-   InvokeObjectPostAlterHook(PolicyRelationId,
-                             HeapTupleGetOid(policy_tuple), 0);
+   InvokeObjectPostAlterHook(PolicyRelationId, opoloid, 0);
 
    ObjectAddressSet(address, PolicyRelationId, opoloid);
 
@@ -1359,7 +1361,7 @@ get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok)
        policy_oid = InvalidOid;
    }
    else
-       policy_oid = HeapTupleGetOid(policy_tuple);
+       policy_oid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
 
    /* Clean up. */
    systable_endscan(sscan);
index b945b1556a83e9273de8a1e7b52f0e3ef4114c7c..6036b735e9f9ef916b8d40ddd5ed128c5576e24d 100644 (file)
@@ -734,7 +734,7 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
     * build tupdesc for result tuples. This must match the definition of the
     * pg_prepared_statements view in system_views.sql
     */
-   tupdesc = CreateTemplateTupleDesc(5, false);
+   tupdesc = CreateTemplateTupleDesc(5);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
                       TEXTOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 2, "statement",
index c900ad9431a5a10ca898cd547690176d851bd5f6..836c9048121fc4bf51bd2b9b0b6b238664096bf3 100644 (file)
@@ -16,6 +16,7 @@
 #include "access/genam.h"
 #include "access/heapam.h"
 #include "access/htup_details.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/objectaccess.h"
@@ -329,6 +330,7 @@ create_proc_lang(const char *languageName, bool replace,
    NameData    langname;
    HeapTuple   oldtup;
    HeapTuple   tup;
+   Oid         langoid;
    bool        is_update;
    ObjectAddress myself,
                referenced;
@@ -356,12 +358,14 @@ create_proc_lang(const char *languageName, bool replace,
 
    if (HeapTupleIsValid(oldtup))
    {
+       Form_pg_language oldform = (Form_pg_language) GETSTRUCT(oldtup);
+
        /* There is one; okay to replace it? */
        if (!replace)
            ereport(ERROR,
                    (errcode(ERRCODE_DUPLICATE_OBJECT),
                     errmsg("language \"%s\" already exists", languageName)));
-       if (!pg_language_ownercheck(HeapTupleGetOid(oldtup), languageOwner))
+       if (!pg_language_ownercheck(oldform->oid, languageOwner))
            aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_LANGUAGE,
                           languageName);
 
@@ -376,12 +380,16 @@ create_proc_lang(const char *languageName, bool replace,
        tup = heap_modify_tuple(oldtup, tupDesc, values, nulls, replaces);
        CatalogTupleUpdate(rel, &tup->t_self, tup);
 
+       langoid = oldform->oid;
        ReleaseSysCache(oldtup);
        is_update = true;
    }
    else
    {
        /* Creating a new language */
+       langoid = GetNewOidWithIndex(rel, LanguageOidIndexId,
+                                    Anum_pg_language_oid);
+       values[Anum_pg_language_oid - 1] = ObjectIdGetDatum(langoid);
        tup = heap_form_tuple(tupDesc, values, nulls);
        CatalogTupleInsert(rel, tup);
        is_update = false;
@@ -394,7 +402,7 @@ create_proc_lang(const char *languageName, bool replace,
     * shared dependencies do *not* need to change, and we leave them alone.)
     */
    myself.classId = LanguageRelationId;
-   myself.objectId = HeapTupleGetOid(tup);
+   myself.objectId = langoid;
    myself.objectSubId = 0;
 
    if (is_update)
@@ -550,7 +558,8 @@ get_language_oid(const char *langname, bool missing_ok)
 {
    Oid         oid;
 
-   oid = GetSysCacheOid1(LANGNAME, CStringGetDatum(langname));
+   oid = GetSysCacheOid1(LANGNAME, Anum_pg_language_oid,
+                         CStringGetDatum(langname));
    if (!OidIsValid(oid) && !missing_ok)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
index 6f7762a906caa32c7fffd472f50083f30a5ce609..b85c3d7c61156d0ac606ce4151a0d03d95f424b0 100644 (file)
@@ -168,7 +168,8 @@ CreatePublication(CreatePublicationStmt *stmt)
    rel = heap_open(PublicationRelationId, RowExclusiveLock);
 
    /* Check if name is used */
-   puboid = GetSysCacheOid1(PUBLICATIONNAME, CStringGetDatum(stmt->pubname));
+   puboid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
+                            CStringGetDatum(stmt->pubname));
    if (OidIsValid(puboid))
    {
        ereport(ERROR,
@@ -190,6 +191,9 @@ CreatePublication(CreatePublicationStmt *stmt)
                              &publish_update, &publish_delete,
                              &publish_truncate);
 
+   puboid = GetNewOidWithIndex(rel, PublicationObjectIndexId,
+                               Anum_pg_publication_oid);
+   values[Anum_pg_publication_oid - 1] = ObjectIdGetDatum(puboid);
    values[Anum_pg_publication_puballtables - 1] =
        BoolGetDatum(stmt->for_all_tables);
    values[Anum_pg_publication_pubinsert - 1] =
@@ -204,7 +208,7 @@ CreatePublication(CreatePublicationStmt *stmt)
    tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
 
    /* Insert tuple into catalog. */
-   puboid = CatalogTupleInsert(rel, tup);
+   CatalogTupleInsert(rel, tup);
    heap_freetuple(tup);
 
    recordDependencyOnOwner(PublicationRelationId, puboid, GetUserId());
@@ -248,6 +252,7 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
    bool        publish_delete;
    bool        publish_truncate;
    ObjectAddress obj;
+   Form_pg_publication pubform;
 
    parse_publication_options(stmt->options,
                              &publish_given, &publish_insert,
@@ -282,14 +287,16 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
 
    CommandCounterIncrement();
 
+   pubform = (Form_pg_publication) GETSTRUCT(tup);
+
    /* Invalidate the relcache. */
-   if (((Form_pg_publication) GETSTRUCT(tup))->puballtables)
+   if (pubform->puballtables)
    {
        CacheInvalidateRelcacheAll();
    }
    else
    {
-       List       *relids = GetPublicationRelations(HeapTupleGetOid(tup));
+       List       *relids = GetPublicationRelations(pubform->oid);
 
        /*
         * We don't want to send too many individual messages, at some point
@@ -310,11 +317,11 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
            CacheInvalidateRelcacheAll();
    }
 
-   ObjectAddressSet(obj, PublicationRelationId, HeapTupleGetOid(tup));
+   ObjectAddressSet(obj, PublicationRelationId, pubform->oid);
    EventTriggerCollectSimpleCommand(obj, InvalidObjectAddress,
                                     (Node *) stmt);
 
-   InvokeObjectPostAlterHook(PublicationRelationId, HeapTupleGetOid(tup), 0);
+   InvokeObjectPostAlterHook(PublicationRelationId, pubform->oid, 0);
 }
 
 /*
@@ -324,9 +331,9 @@ static void
 AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
                       HeapTuple tup)
 {
-   Oid         pubid = HeapTupleGetOid(tup);
    List       *rels = NIL;
    Form_pg_publication pubform = (Form_pg_publication) GETSTRUCT(tup);
+   Oid         pubid = pubform->oid;
 
    /* Check that user is allowed to manipulate the publication tables. */
    if (pubform->puballtables)
@@ -403,6 +410,7 @@ AlterPublication(AlterPublicationStmt *stmt)
 {
    Relation    rel;
    HeapTuple   tup;
+   Form_pg_publication pubform;
 
    rel = heap_open(PublicationRelationId, RowExclusiveLock);
 
@@ -415,8 +423,10 @@ AlterPublication(AlterPublicationStmt *stmt)
                 errmsg("publication \"%s\" does not exist",
                        stmt->pubname)));
 
+   pubform = (Form_pg_publication) GETSTRUCT(tup);
+
    /* must be owner */
-   if (!pg_publication_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+   if (!pg_publication_ownercheck(pubform->oid, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_PUBLICATION,
                       stmt->pubname);
 
@@ -626,7 +636,8 @@ PublicationDropTables(Oid pubid, List *rels, bool missing_ok)
        Relation    rel = (Relation) lfirst(lc);
        Oid         relid = RelationGetRelid(rel);
 
-       prid = GetSysCacheOid2(PUBLICATIONRELMAP, ObjectIdGetDatum(relid),
+       prid = GetSysCacheOid2(PUBLICATIONRELMAP, Anum_pg_publication_rel_oid,
+                              ObjectIdGetDatum(relid),
                               ObjectIdGetDatum(pubid));
        if (!OidIsValid(prid))
        {
@@ -662,7 +673,7 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
        AclResult   aclresult;
 
        /* Must be owner */
-       if (!pg_publication_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+       if (!pg_publication_ownercheck(form->oid, GetUserId()))
            aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_PUBLICATION,
                           NameStr(form->pubname));
 
@@ -688,11 +699,11 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
 
    /* Update owner dependency reference */
    changeDependencyOnOwner(PublicationRelationId,
-                           HeapTupleGetOid(tup),
+                           form->oid,
                            newOwnerId);
 
    InvokeObjectPostAlterHook(PublicationRelationId,
-                             HeapTupleGetOid(tup), 0);
+                             form->oid, 0);
 }
 
 /*
@@ -705,6 +716,7 @@ AlterPublicationOwner(const char *name, Oid newOwnerId)
    HeapTuple   tup;
    Relation    rel;
    ObjectAddress address;
+   Form_pg_publication pubform;
 
    rel = heap_open(PublicationRelationId, RowExclusiveLock);
 
@@ -715,7 +727,8 @@ AlterPublicationOwner(const char *name, Oid newOwnerId)
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("publication \"%s\" does not exist", name)));
 
-   subid = HeapTupleGetOid(tup);
+   pubform = (Form_pg_publication) GETSTRUCT(tup);
+   subid = pubform->oid;
 
    AlterPublicationOwner_internal(rel, tup, newOwnerId);
 
index dc6cb46e4e7b6c117c1caf4d3b1e5c65582303ad..f0ebe2d1c31e9dab127478ec07008ff5c1b47f22 100644 (file)
@@ -246,6 +246,7 @@ RenameSchema(const char *oldname, const char *newname)
    Relation    rel;
    AclResult   aclresult;
    ObjectAddress address;
+   Form_pg_namespace nspform;
 
    rel = heap_open(NamespaceRelationId, RowExclusiveLock);
 
@@ -255,7 +256,8 @@ RenameSchema(const char *oldname, const char *newname)
                (errcode(ERRCODE_UNDEFINED_SCHEMA),
                 errmsg("schema \"%s\" does not exist", oldname)));
 
-   nspOid = HeapTupleGetOid(tup);
+   nspform = (Form_pg_namespace) GETSTRUCT(tup);
+   nspOid = nspform->oid;
 
    /* make sure the new name doesn't exist */
    if (OidIsValid(get_namespace_oid(newname, true)))
@@ -264,7 +266,7 @@ RenameSchema(const char *oldname, const char *newname)
                 errmsg("schema \"%s\" already exists", newname)));
 
    /* must be owner */
-   if (!pg_namespace_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+   if (!pg_namespace_ownercheck(nspOid, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SCHEMA,
                       oldname);
 
@@ -281,10 +283,10 @@ RenameSchema(const char *oldname, const char *newname)
                 errdetail("The prefix \"pg_\" is reserved for system schemas.")));
 
    /* rename */
-   namestrcpy(&(((Form_pg_namespace) GETSTRUCT(tup))->nspname), newname);
+   namestrcpy(&nspform->nspname, newname);
    CatalogTupleUpdate(rel, &tup->t_self, tup);
 
-   InvokeObjectPostAlterHook(NamespaceRelationId, HeapTupleGetOid(tup), 0);
+   InvokeObjectPostAlterHook(NamespaceRelationId, nspOid, 0);
 
    ObjectAddressSet(address, NamespaceRelationId, nspOid);
 
@@ -324,6 +326,7 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
    HeapTuple   tup;
    Relation    rel;
    ObjectAddress address;
+   Form_pg_namespace nspform;
 
    rel = heap_open(NamespaceRelationId, RowExclusiveLock);
 
@@ -333,7 +336,8 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
                (errcode(ERRCODE_UNDEFINED_SCHEMA),
                 errmsg("schema \"%s\" does not exist", name)));
 
-   nspOid = HeapTupleGetOid(tup);
+   nspform = (Form_pg_namespace) GETSTRUCT(tup);
+   nspOid = nspform->oid;
 
    AlterSchemaOwner_internal(tup, rel, newOwnerId);
 
@@ -372,7 +376,7 @@ AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
        AclResult   aclresult;
 
        /* Otherwise, must be owner of the existing object */
-       if (!pg_namespace_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+       if (!pg_namespace_ownercheck(nspForm->oid, GetUserId()))
            aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SCHEMA,
                           NameStr(nspForm->nspname));
 
@@ -422,10 +426,10 @@ AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
        heap_freetuple(newtuple);
 
        /* Update owner dependency reference */
-       changeDependencyOnOwner(NamespaceRelationId, HeapTupleGetOid(tup),
+       changeDependencyOnOwner(NamespaceRelationId, nspForm->oid,
                                newOwnerId);
    }
 
    InvokeObjectPostAlterHook(NamespaceRelationId,
-                             HeapTupleGetOid(tup), 0);
+                             nspForm->oid, 0);
 }
index 6d89925b2372799fa8da86e6734f641147767d22..f9dca39d3db89deb59c9886a260d71ced814360f 100644 (file)
@@ -1788,7 +1788,7 @@ pg_sequence_parameters(PG_FUNCTION_ARGS)
                 errmsg("permission denied for sequence %s",
                        get_rel_name(relid))));
 
-   tupdesc = CreateTemplateTupleDesc(7, false);
+   tupdesc = CreateTemplateTupleDesc(7);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1, "start_value",
                       INT8OID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 2, "minimum_value",
index 3bb0d24cd2003cda65fc83b6f07026c33de02ffa..bfc0f1d1fa1db2df09336a0816f62b491e96250b 100644 (file)
@@ -15,6 +15,7 @@
 #include "postgres.h"
 
 #include "access/relscan.h"
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/namespace.h"
@@ -305,11 +306,17 @@ CreateStatistics(CreateStatsStmt *stmt)
    Assert(ntypes > 0 && ntypes <= lengthof(types));
    stxkind = construct_array(types, ntypes, CHAROID, 1, true, 'c');
 
+   statrel = heap_open(StatisticExtRelationId, RowExclusiveLock);
+
    /*
     * Everything seems fine, so let's build the pg_statistic_ext tuple.
     */
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
+
+   statoid = GetNewOidWithIndex(statrel, StatisticExtOidIndexId,
+                                Anum_pg_statistic_ext_oid);
+   values[Anum_pg_statistic_ext_oid - 1] = ObjectIdGetDatum(statoid);
    values[Anum_pg_statistic_ext_stxrelid - 1] = ObjectIdGetDatum(relid);
    values[Anum_pg_statistic_ext_stxname - 1] = NameGetDatum(&stxname);
    values[Anum_pg_statistic_ext_stxnamespace - 1] = ObjectIdGetDatum(namespaceId);
@@ -322,10 +329,10 @@ CreateStatistics(CreateStatsStmt *stmt)
    nulls[Anum_pg_statistic_ext_stxdependencies - 1] = true;
 
    /* insert it into pg_statistic_ext */
-   statrel = heap_open(StatisticExtRelationId, RowExclusiveLock);
    htup = heap_form_tuple(statrel->rd_att, values, nulls);
-   statoid = CatalogTupleInsert(statrel, htup);
+   CatalogTupleInsert(statrel, htup);
    heap_freetuple(htup);
+
    relation_close(statrel, RowExclusiveLock);
 
    /*
@@ -467,7 +474,7 @@ ChooseExtendedStatisticName(const char *name1, const char *name2,
 
        stxname = makeObjectName(name1, name2, modlabel);
 
-       existingstats = GetSysCacheOid2(STATEXTNAMENSP,
+       existingstats = GetSysCacheOid2(STATEXTNAMENSP, Anum_pg_statistic_ext_oid,
                                        PointerGetDatum(stxname),
                                        ObjectIdGetDatum(namespaceid));
        if (!OidIsValid(existingstats))
index 0efbfec4751f3253b4bf734709b04d86e7776750..9021463a4c7b5258580f263a8b4adcdfe335db7b 100644 (file)
@@ -20,6 +20,7 @@
 #include "access/htup_details.h"
 #include "access/xact.h"
 
+#include "catalog/catalog.h"
 #include "catalog/dependency.h"
 #include "catalog/indexing.h"
 #include "catalog/namespace.h"
@@ -349,8 +350,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
    rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
 
    /* Check if name is used */
-   subid = GetSysCacheOid2(SUBSCRIPTIONNAME, MyDatabaseId,
-                           CStringGetDatum(stmt->subname));
+   subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+                           MyDatabaseId, CStringGetDatum(stmt->subname));
    if (OidIsValid(subid))
    {
        ereport(ERROR,
@@ -379,6 +380,9 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
    memset(values, 0, sizeof(values));
    memset(nulls, false, sizeof(nulls));
 
+   subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
+                              Anum_pg_subscription_oid);
+   values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
    values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
    values[Anum_pg_subscription_subname - 1] =
        DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
@@ -399,7 +403,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
    tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
 
    /* Insert tuple into catalog. */
-   subid = CatalogTupleInsert(rel, tup);
+   CatalogTupleInsert(rel, tup);
    heap_freetuple(tup);
 
    recordDependencyOnOwner(SubscriptionRelationId, subid, owner);
@@ -620,6 +624,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
    Oid         subid;
    bool        update_tuple = false;
    Subscription *sub;
+   Form_pg_subscription form;
 
    rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
 
@@ -633,12 +638,14 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
                 errmsg("subscription \"%s\" does not exist",
                        stmt->subname)));
 
+   form = (Form_pg_subscription) GETSTRUCT(tup);
+   subid = form->oid;
+
    /* must be owner */
-   if (!pg_subscription_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+   if (!pg_subscription_ownercheck(subid, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
                       stmt->subname);
 
-   subid = HeapTupleGetOid(tup);
    sub = GetSubscription(subid, false);
 
    /* Lock the subscription so nobody else can do anything with it. */
@@ -823,6 +830,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
    RepOriginId originid;
    WalReceiverConn *wrconn = NULL;
    StringInfoData cmd;
+   Form_pg_subscription form;
 
    /*
     * Lock pg_subscription with AccessExclusiveLock to ensure that the
@@ -850,7 +858,8 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
        return;
    }
 
-   subid = HeapTupleGetOid(tup);
+   form = (Form_pg_subscription) GETSTRUCT(tup);
+   subid = form->oid;
 
    /* must be owner */
    if (!pg_subscription_ownercheck(subid, GetUserId()))
@@ -1021,7 +1030,7 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
    if (form->subowner == newOwnerId)
        return;
 
-   if (!pg_subscription_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+   if (!pg_subscription_ownercheck(form->oid, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
                       NameStr(form->subname));
 
@@ -1038,11 +1047,11 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
 
    /* Update owner dependency reference */
    changeDependencyOnOwner(SubscriptionRelationId,
-                           HeapTupleGetOid(tup),
+                           form->oid,
                            newOwnerId);
 
    InvokeObjectPostAlterHook(SubscriptionRelationId,
-                             HeapTupleGetOid(tup), 0);
+                             form->oid, 0);
 }
 
 /*
@@ -1055,6 +1064,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
    HeapTuple   tup;
    Relation    rel;
    ObjectAddress address;
+   Form_pg_subscription form;
 
    rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
 
@@ -1066,7 +1076,8 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("subscription \"%s\" does not exist", name)));
 
-   subid = HeapTupleGetOid(tup);
+   form = (Form_pg_subscription) GETSTRUCT(tup);
+   subid = form->oid;
 
    AlterSubscriptionOwner_internal(rel, tup, newOwnerId);
 
index a15e6045075af90fb9adb83dc78da61f50cfd664..a1137a3bf09a30098042bb1c4b4b99161e47bb8e 100644 (file)
@@ -305,8 +305,7 @@ static void truncate_check_activity(Relation rel);
 static void RangeVarCallbackForTruncate(const RangeVar *relation,
                            Oid relId, Oid oldRelId, void *arg);
 static List *MergeAttributes(List *schema, List *supers, char relpersistence,
-               bool is_partition, List **supOids, List **supconstr,
-               int *supOidCount);
+               bool is_partition, List **supOids, List **supconstr);
 static bool MergeCheckConstraint(List *constraints, char *name, Node *expr);
 static void MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel);
 static void MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel);
@@ -363,15 +362,13 @@ static List *find_typed_table_dependencies(Oid typeOid, const char *typeName,
 static void ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
                bool is_view, AlterTableCmd *cmd, LOCKMODE lockmode);
 static ObjectAddress ATExecAddColumn(List **wqueue, AlteredTableInfo *tab,
-               Relation rel, ColumnDef *colDef, bool isOid,
+               Relation rel, ColumnDef *colDef,
                bool recurse, bool recursing,
                bool if_not_exists, LOCKMODE lockmode);
 static bool check_for_column_name_collision(Relation rel, const char *colname,
                                bool if_not_exists);
 static void add_column_datatype_dependency(Oid relid, int32 attnum, Oid typid);
 static void add_column_collation_dependency(Oid relid, int32 attnum, Oid collid);
-static void ATPrepAddOids(List **wqueue, Relation rel, bool recurse,
-             AlterTableCmd *cmd, LOCKMODE lockmode);
 static void ATPrepDropNotNull(Relation rel, bool recurse, bool recursing);
 static ObjectAddress ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode);
 static void ATPrepSetNotNull(Relation rel, bool recurse, bool recursing);
@@ -531,8 +528,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
    TupleDesc   descriptor;
    List       *inheritOids;
    List       *old_constraints;
-   bool        localHasOids;
-   int         parentOidCount;
    List       *rawDefaults;
    List       *cookedDefaults;
    Datum       reloptions;
@@ -654,7 +649,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
        MergeAttributes(stmt->tableElts, stmt->inhRelations,
                        stmt->relation->relpersistence,
                        stmt->partbound != NULL,
-                       &inheritOids, &old_constraints, &parentOidCount);
+                       &inheritOids, &old_constraints);
 
    /*
     * Create a tuple descriptor from the relation schema.  Note that this
@@ -663,29 +658,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
     */
    descriptor = BuildDescForRelation(stmt->tableElts);
 
-   /*
-    * Notice that we allow OIDs here only for plain tables and partitioned
-    * tables, even though some other relkinds can support them.  This is
-    * necessary because the default_with_oids GUC must apply only to plain
-    * tables and not any other relkind; doing otherwise would break existing
-    * pg_dump files.  We could allow explicit "WITH OIDS" while not allowing
-    * default_with_oids to affect other relkinds, but it would complicate
-    * interpretOidsOption().
-    */
-   localHasOids = interpretOidsOption(stmt->options,
-                                      (relkind == RELKIND_RELATION ||
-                                       relkind == RELKIND_PARTITIONED_TABLE));
-   descriptor->tdhasoid = (localHasOids || parentOidCount > 0);
-
-   /*
-    * If a partitioned table doesn't have the system OID column, then none of
-    * its partitions should have it.
-    */
-   if (stmt->partbound && parentOidCount == 0 && localHasOids)
-       ereport(ERROR,
-               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                errmsg("cannot create table with OIDs as partition of table without OIDs")));
-
    /*
     * Find columns with default values and prepare for insertion of the
     * defaults.  Pre-cooked (that is, inherited) defaults go into a list of
@@ -764,8 +736,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
                                          stmt->relation->relpersistence,
                                          false,
                                          false,
-                                         localHasOids,
-                                         parentOidCount,
                                          stmt->oncommit,
                                          reloptions,
                                          true,
@@ -1816,7 +1786,6 @@ storage_name(char c)
  * 'supOids' receives a list of the OIDs of the parent relations.
  * 'supconstr' receives a list of constraints belonging to the parents,
  *     updated as necessary to be valid for the child.
- * 'supOidCount' is set to the number of parents that have OID columns.
  *
  * Return value:
  * Completed schema list.
@@ -1862,14 +1831,12 @@ storage_name(char c)
  */
 static List *
 MergeAttributes(List *schema, List *supers, char relpersistence,
-               bool is_partition, List **supOids, List **supconstr,
-               int *supOidCount)
+               bool is_partition, List **supOids, List **supconstr)
 {
    ListCell   *entry;
    List       *inhSchema = NIL;
    List       *parentOids = NIL;
    List       *constraints = NIL;
-   int         parentsWithOids = 0;
    bool        have_bogus_defaults = false;
    int         child_attno;
    static Node bogus_marker = {0}; /* marks conflicting defaults */
@@ -2077,9 +2044,6 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 
        parentOids = lappend_oid(parentOids, RelationGetRelid(relation));
 
-       if (relation->rd_rel->relhasoids)
-           parentsWithOids++;
-
        tupleDesc = RelationGetDescr(relation);
        constr = tupleDesc->constr;
 
@@ -2498,7 +2462,6 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 
    *supOids = parentOids;
    *supconstr = constraints;
-   *supOidCount = parentsWithOids;
    return schema;
 }
 
@@ -3424,7 +3387,6 @@ AlterTableGetLockLevel(List *cmds)
                                 * to SELECT */
            case AT_SetTableSpace:  /* must rewrite heap */
            case AT_AlterColumnType:    /* must rewrite heap */
-           case AT_AddOids:    /* must rewrite heap */
                cmd_lockmode = AccessExclusiveLock;
                break;
 
@@ -3453,7 +3415,7 @@ AlterTableGetLockLevel(List *cmds)
                 */
            case AT_DropColumn: /* change visible to SELECT */
            case AT_AddColumnToView:    /* CREATE VIEW */
-           case AT_DropOids:   /* calls AT_DropColumn */
+           case AT_DropOids:   /* used to equiv to DropColumn */
            case AT_EnableAlwaysRule:   /* may change SELECT rules */
            case AT_EnableReplicaRule:  /* may change SELECT rules */
            case AT_EnableRule: /* may change SELECT rules */
@@ -3862,25 +3824,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
            }
            pass = AT_PASS_MISC;
            break;
-       case AT_AddOids:        /* SET WITH OIDS */
-           ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE);
-           if (!rel->rd_rel->relhasoids || recursing)
-               ATPrepAddOids(wqueue, rel, recurse, cmd, lockmode);
-           /* Recursion occurs during execution phase */
-           pass = AT_PASS_ADD_COL;
-           break;
        case AT_DropOids:       /* SET WITHOUT OIDS */
            ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE);
-           /* Performs own recursion */
-           if (rel->rd_rel->relhasoids)
-           {
-               AlterTableCmd *dropCmd = makeNode(AlterTableCmd);
-
-               dropCmd->subtype = AT_DropColumn;
-               dropCmd->name = pstrdup("oid");
-               dropCmd->behavior = cmd->behavior;
-               ATPrepCmd(wqueue, rel, dropCmd, recurse, false, lockmode);
-           }
            pass = AT_PASS_DROP;
            break;
        case AT_SetTableSpace:  /* SET TABLESPACE */
@@ -4068,12 +4013,12 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
        case AT_AddColumn:      /* ADD COLUMN */
        case AT_AddColumnToView:    /* add column via CREATE OR REPLACE VIEW */
            address = ATExecAddColumn(wqueue, tab, rel, (ColumnDef *) cmd->def,
-                                     false, false, false,
+                                     false, false,
                                      false, lockmode);
            break;
        case AT_AddColumnRecurse:
            address = ATExecAddColumn(wqueue, tab, rel, (ColumnDef *) cmd->def,
-                                     false, true, false,
+                                     true, false,
                                      cmd->missing_ok, lockmode);
            break;
        case AT_ColumnDefault:  /* ALTER COLUMN DEFAULT */
@@ -4197,28 +4142,8 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
        case AT_SetLogged:      /* SET LOGGED */
        case AT_SetUnLogged:    /* SET UNLOGGED */
            break;
-       case AT_AddOids:        /* SET WITH OIDS */
-           /* Use the ADD COLUMN code, unless prep decided to do nothing */
-           if (cmd->def != NULL)
-               address =
-                   ATExecAddColumn(wqueue, tab, rel, (ColumnDef *) cmd->def,
-                                   true, false, false,
-                                   cmd->missing_ok, lockmode);
-           break;
-       case AT_AddOidsRecurse: /* SET WITH OIDS */
-           /* Use the ADD COLUMN code, unless prep decided to do nothing */
-           if (cmd->def != NULL)
-               address =
-                   ATExecAddColumn(wqueue, tab, rel, (ColumnDef *) cmd->def,
-                                   true, true, false,
-                                   cmd->missing_ok, lockmode);
-           break;
        case AT_DropOids:       /* SET WITHOUT OIDS */
-
-           /*
-            * Nothing to do here; we'll have generated a DropColumn
-            * subcommand to do the real work
-            */
+           /* nothing to do here, oid columns don't exist anymore */
            break;
        case AT_SetTableSpace:  /* SET TABLESPACE */
            /*
@@ -4774,12 +4699,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
        {
            if (tab->rewrite > 0)
            {
-               Oid         tupOid = InvalidOid;
-
                /* Extract data from old tuple */
                heap_deform_tuple(tuple, oldTupDesc, values, isnull);
-               if (oldTupDesc->tdhasoid)
-                   tupOid = HeapTupleGetOid(tuple);
 
                /* Set dropped attributes to null in new tuple */
                foreach(lc, dropped_attrs)
@@ -4807,10 +4728,6 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
                 */
                tuple = heap_form_tuple(newTupDesc, values, isnull);
 
-               /* Preserve OID, if any */
-               if (newTupDesc->tdhasoid)
-                   HeapTupleSetOid(tuple, tupOid);
-
                /*
                 * Constraints might reference the tableoid column, so
                 * initialize t_tableOid before evaluating them.
@@ -5293,6 +5210,8 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
 
    while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
    {
+       Form_pg_class classform = (Form_pg_class) GETSTRUCT(tuple);
+
        if (behavior == DROP_RESTRICT)
            ereport(ERROR,
                    (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
@@ -5300,7 +5219,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
                            typeName),
                     errhint("Use ALTER ... CASCADE to alter the typed tables too.")));
        else
-           result = lappend_oid(result, HeapTupleGetOid(tuple));
+           result = lappend_oid(result, classform->oid);
    }
 
    heap_endscan(scan);
@@ -5345,7 +5264,7 @@ check_of_type(HeapTuple typetuple)
        ereport(ERROR,
                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                 errmsg("type %s is not a composite type",
-                       format_type_be(HeapTupleGetOid(typetuple)))));
+                       format_type_be(typ->oid))));
 }
 
 
@@ -5385,7 +5304,7 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
  */
 static ObjectAddress
 ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
-               ColumnDef *colDef, bool isOid,
+               ColumnDef *colDef,
                bool recurse, bool recursing,
                bool if_not_exists, LOCKMODE lockmode)
 {
@@ -5455,13 +5374,6 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
                                   get_collation_name(ccollid),
                                   get_collation_name(childatt->attcollation))));
 
-           /* If it's OID, child column must actually be OID */
-           if (isOid && childatt->attnum != ObjectIdAttributeNumber)
-               ereport(ERROR,
-                       (errcode(ERRCODE_DATATYPE_MISMATCH),
-                        errmsg("child table \"%s\" has a conflicting \"%s\" column",
-                               RelationGetRelationName(rel), colDef->colname)));
-
            /* Bump the existing child att's inhcount */
            childatt->attinhcount++;
            CatalogTupleUpdate(attrdesc, &tuple->t_self, tuple);
@@ -5506,21 +5418,16 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
    }
 
    /* Determine the new attribute's number */
-   if (isOid)
-       newattnum = ObjectIdAttributeNumber;
-   else
-   {
-       newattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1;
-       if (newattnum > MaxHeapAttributeNumber)
-           ereport(ERROR,
-                   (errcode(ERRCODE_TOO_MANY_COLUMNS),
-                    errmsg("tables can have at most %d columns",
-                           MaxHeapAttributeNumber)));
-   }
+   newattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts + 1;
+   if (newattnum > MaxHeapAttributeNumber)
+       ereport(ERROR,
+               (errcode(ERRCODE_TOO_MANY_COLUMNS),
+                errmsg("tables can have at most %d columns",
+                       MaxHeapAttributeNumber)));
 
    typeTuple = typenameType(NULL, colDef->typeName, &typmod);
    tform = (Form_pg_type) GETSTRUCT(typeTuple);
-   typeOid = HeapTupleGetOid(typeTuple);
+   typeOid = tform->oid;
 
    aclresult = pg_type_aclcheck(typeOid, GetUserId(), ACL_USAGE);
    if (aclresult != ACLCHECK_OK)
@@ -5564,10 +5471,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
    /*
     * Update pg_class tuple as appropriate
     */
-   if (isOid)
-       ((Form_pg_class) GETSTRUCT(reltup))->relhasoids = true;
-   else
-       ((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum;
+   ((Form_pg_class) GETSTRUCT(reltup))->relnatts = newattnum;
 
    CatalogTupleUpdate(pgclass, &reltup->t_self, reltup);
 
@@ -5715,13 +5619,6 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
        }
    }
 
-   /*
-    * If we are adding an OID column, we have to tell Phase 3 to rewrite the
-    * table to fix that.
-    */
-   if (isOid)
-       tab->rewrite |= AT_REWRITE_ALTER_OID;
-
    /*
     * Add needed dependency entries for the new column.
     */
@@ -5767,7 +5664,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
 
        /* Recurse to child; return value is ignored */
        ATExecAddColumn(wqueue, childtab, childrel,
-                       colDef, isOid, recurse, true,
+                       colDef, recurse, true,
                        if_not_exists, lockmode);
 
        heap_close(childrel, NoLock);
@@ -5871,35 +5768,6 @@ add_column_collation_dependency(Oid relid, int32 attnum, Oid collid)
    }
 }
 
-/*
- * ALTER TABLE SET WITH OIDS
- *
- * Basically this is an ADD COLUMN for the special OID column.  We have
- * to cons up a ColumnDef node because the ADD COLUMN code needs one.
- */
-static void
-ATPrepAddOids(List **wqueue, Relation rel, bool recurse, AlterTableCmd *cmd, LOCKMODE lockmode)
-{
-   /* If we're recursing to a child table, the ColumnDef is already set up */
-   if (cmd->def == NULL)
-   {
-       ColumnDef  *cdef = makeNode(ColumnDef);
-
-       cdef->colname = pstrdup("oid");
-       cdef->typeName = makeTypeNameFromOid(OIDOID, -1);
-       cdef->inhcount = 0;
-       cdef->is_local = true;
-       cdef->is_not_null = true;
-       cdef->storage = 0;
-       cdef->location = -1;
-       cmd->def = (Node *) cdef;
-   }
-   ATPrepAddColumn(wqueue, rel, recurse, false, false, cmd, lockmode);
-
-   if (recurse)
-       cmd->subtype = AT_AddOidsRecurse;
-}
-
 /*
  * ALTER TABLE ALTER COLUMN DROP NOT NULL
  *
@@ -6801,8 +6669,8 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
 
    attnum = targetatt->attnum;
 
-   /* Can't drop a system attribute, except OID */
-   if (attnum <= 0 && attnum != ObjectIdAttributeNumber)
+   /* Can't drop a system attribute */
+   if (attnum <= 0)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                 errmsg("cannot drop system column \"%s\"",
@@ -6932,39 +6800,6 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
 
    performDeletion(&object, behavior, 0);
 
-   /*
-    * If we dropped the OID column, must adjust pg_class.relhasoids and tell
-    * Phase 3 to physically get rid of the column.  We formerly left the
-    * column in place physically, but this caused subtle problems.  See
-    * http://archives.postgresql.org/pgsql-hackers/2009-02/msg00363.php
-    */
-   if (attnum == ObjectIdAttributeNumber)
-   {
-       Relation    class_rel;
-       Form_pg_class tuple_class;
-       AlteredTableInfo *tab;
-
-       class_rel = heap_open(RelationRelationId, RowExclusiveLock);
-
-       tuple = SearchSysCacheCopy1(RELOID,
-                                   ObjectIdGetDatum(RelationGetRelid(rel)));
-       if (!HeapTupleIsValid(tuple))
-           elog(ERROR, "cache lookup failed for relation %u",
-                RelationGetRelid(rel));
-       tuple_class = (Form_pg_class) GETSTRUCT(tuple);
-
-       tuple_class->relhasoids = false;
-       CatalogTupleUpdate(class_rel, &tuple->t_self, tuple);
-
-       heap_close(class_rel, RowExclusiveLock);
-
-       /* Find or create work queue entry for this table */
-       tab = ATGetQueueEntry(wqueue, rel);
-
-       /* Tell Phase 3 to physically remove the OID column */
-       tab->rewrite |= AT_REWRITE_ALTER_OID;
-   }
-
    return object;
 }
 
@@ -7878,7 +7713,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
        CatalogTupleUpdate(conrel, &copyTuple->t_self, copyTuple);
 
        InvokeObjectPostAlterHook(ConstraintRelationId,
-                                 HeapTupleGetOid(contuple), 0);
+                                 currcon->oid, 0);
 
        heap_freetuple(copyTuple);
 
@@ -7891,7 +7726,7 @@ ATExecAlterConstraint(Relation rel, AlterTableCmd *cmd,
        ScanKeyInit(&tgkey,
   &