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",
-- 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';
-- 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)
-- 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 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;
* 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;
* 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);
/*
* 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",
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",
*/
ExecClearTuple(slot);
found = NextCopyFrom(festate->cstate, NULL,
- slot->tts_values, slot->tts_isnull,
- NULL);
+ slot->tts_values, slot->tts_isnull);
if (found)
ExecStoreVirtualTuple(slot);
MemoryContextReset(tupcontext);
MemoryContextSwitchTo(tupcontext);
- found = NextCopyFrom(cstate, NULL, values, nulls, NULL);
+ found = NextCopyFrom(cstate, NULL, values, nulls);
MemoryContextSwitchTo(oldcontext);
#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
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;
}
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",
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);
++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);
/* 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 */
}
/*
- * 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))
*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)
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)
{
/*
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
-- ===================================================================
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
(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
-- ===================================================================
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))
*/
if (attrno == SelfItemPointerAttributeNumber)
dmstate->ctidAttno = i;
- else if (attrno == ObjectIdAttributeNumber)
- dmstate->oidAttno = i;
else
Assert(false);
dmstate->hasSystemCols = true;
resultTup->t_self = *ctid;
}
- /* oid */
- if (dmstate->oidAttno)
- {
- Oid oid = InvalidOid;
-
- oid = DatumGetObjectId(old_values[dmstate->oidAttno - 1]);
- HeapTupleSetOid(resultTup, oid);
- }
-
/*
* And remaining columns
*
Datum *values;
bool *nulls;
ItemPointer ctid = NULL;
- Oid oid = InvalidOid;
ConversionLocation errpos;
ErrorContextCallback errcallback;
MemoryContext oldcontext;
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++;
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);
attname = NameStr(attr->attname);
else if (errpos->cur_attno == SelfItemPointerAttributeNumber)
attname = "ctid";
- else if (errpos->cur_attno == ObjectIdAttributeNumber)
- attname = "oid";
relname = RelationGetRelationName(errpos->rel);
}
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
-- ===================================================================
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
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;
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
^
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"
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"
NULL, NULL, NULL);
object.classId = DatabaseRelationId;
- object.objectId = HeapTupleGetOid(tuple);
+ object.objectId = datForm->oid;
object.objectSubId = 0;
break;
NULL, NULL);
object.classId = NamespaceRelationId;
- object.objectId = HeapTupleGetOid(tuple);
+ object.objectId = nspForm->oid;
object.objectSubId = 0;
break;
pfree(namespace_name);
object.classId = RelationRelationId;
- object.objectId = HeapTupleGetOid(tuple);
+ object.objectId = relForm->oid;
object.objectSubId = 0;
break;
pfree(namespace_name);
object.classId = ProcedureRelationId;
- object.objectId = HeapTupleGetOid(tuple);
+ object.objectId = proForm->oid;
object.objectSubId = 0;
break;
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
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
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');
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;
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++)
#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"
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))
The <literal>CATALOG</literal> line can also be annotated, with some
other BKI property macros described in <filename>genbki.h</filename>, to
define other properties of the catalog as a whole, such as whether
- it has OIDs (by default, it does).
+ it is a shared relation.
</para>
<para>
also needed if the row's OID must be referenced from C code.
If neither case applies, the <literal>oid</literal> metadata field can
be omitted, in which case the bootstrap code assigns an OID
- automatically, or leaves it zero in a catalog that has no OIDs.
+ automatically.
In practice we usually preassign OIDs for all or none of the pre-loaded
rows in a given catalog, even if only some of them are actually
cross-referenced.
through the catalog headers and <filename>.dat</filename> files
to see which ones do not appear. You can also use
the <filename>duplicate_oids</filename> script to check for mistakes.
- (<filename>genbki.pl</filename> will also detect duplicate OIDs
+ (<filename>genbki.pl</filename> will assign OIDs for any rows that
+ didn't get one hand-assigned to them and also detect duplicate OIDs
at compile time.)
</para>
<para>
The OID counter starts at 10000 at the beginning of a bootstrap run.
- If a catalog row is in a table that requires OIDs, but no OID was
- preassigned by an <literal>oid</literal> field, then it will
- receive an OID of 10000 or above.
+ If a row from a source other than <filename>postgres.bki</filename>
+ is inserted into a table that requires OIDs, then it will receive an
+ OID of 10000 or above.
</para>
</sect2>
<replaceable class="parameter">tableoid</replaceable>
<optional><literal>bootstrap</literal></optional>
<optional><literal>shared_relation</literal></optional>
- <optional><literal>without_oids</literal></optional>
<optional><literal>rowtype_oid</literal> <replaceable>oid</replaceable></optional>
(<replaceable class="parameter">name1</replaceable> =
<replaceable class="parameter">type1</replaceable>
<para>
The table is created as shared if <literal>shared_relation</literal> is
specified.
- It will have OIDs unless <literal>without_oids</literal> is specified.
The table's row type OID (<structname>pg_type</structname> OID) can optionally
be specified via the <literal>rowtype_oid</literal> clause; if not specified,
an OID is automatically generated for it. (The <literal>rowtype_oid</literal>
<varlistentry>
<term>
- <literal>insert</literal> <optional><literal>OID =</literal> <replaceable class="parameter">oid_value</replaceable></optional> <literal>(</literal> <replaceable class="parameter">value1</replaceable> <replaceable class="parameter">value2</replaceable> ... <literal>)</literal>
+ <literal>insert</literal> <literal>(</literal> <optional><replaceable class="parameter">oid_value</replaceable></optional> <replaceable class="parameter">value1</replaceable> <replaceable class="parameter">value2</replaceable> ... <literal>)</literal>
</term>
<listitem>
Insert a new row into the open table using <replaceable
class="parameter">value1</replaceable>, <replaceable
class="parameter">value2</replaceable>, etc., for its column
- values and <replaceable
- class="parameter">oid_value</replaceable> for its OID. If
- <replaceable class="parameter">oid_value</replaceable> is zero
- (0) or the clause is omitted, and the table has OIDs, then the
- next available OID is assigned.
+ values.
</para>
<para>
<title>BKI Example</title>
<para>
- The following sequence of commands will create the
- table <literal>test_table</literal> with OID 420, having two columns
- <literal>cola</literal> and <literal>colb</literal> of type
- <type>int4</type> and <type>text</type>, respectively, and insert
- two rows into the table:
+ The following sequence of commands will create the table
+ <literal>test_table</literal> with OID 420, having three columns
+ <literal>oid</literal>, <literal>cola</literal> and <literal>colb</literal>
+ of type <type>oid</type>, <type>int4</type> and <type>text</type>,
+ respectively, and insert two rows into the table:
<programlisting>
-create test_table 420 (cola = int4, colb = text)
+create test_table 420 (oid = oid, cola = int4, colb = text)
open test_table
-insert OID=421 ( 1 "value1" )
-insert OID=422 ( 2 _null_ )
+insert ( 421 1 "value1" )
+insert ( 422 2 _null_ )
close test_table
</programlisting>
</para>
<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>
<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>
</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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</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>
<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>
</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>
</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
</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>
<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>
</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>
<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>
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>
</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>
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 }
</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>
<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>
<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>'
</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>
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>
<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>
<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 — 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>
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 ]
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 ]
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>' ]
<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>
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>
] )
[ 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> ]
[, ... ]
) ]
[ 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> ]
[, ... ]
) ] { 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> ]
<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>
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>
<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
<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>
<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>
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>
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>
<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 > $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>
<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>
</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>
<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>
<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>
<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>
<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>
/* 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++)
{
{
case TableOidAttributeNumber:
case SelfItemPointerAttributeNumber:
- case ObjectIdAttributeNumber:
case MinTransactionIdAttributeNumber:
case MinCommandIdAttributeNumber:
case MaxTransactionIdAttributeNumber:
/* 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;
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.
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);
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,
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;
}
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;
}
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);
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,
* 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
*/
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;
def->defnamespace)));
}
- if (ignoreOids && strcmp(def->defname, "oids") == 0)
- continue;
-
/* ignore if not in the same namespace */
if (namspace == NULL)
{
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);
/*
* 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++)
{
/*
* 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++)
* caller can overwrite this if needed.
*/
TupleDesc
-CreateTemplateTupleDesc(int natts, bool hasoid)
+CreateTemplateTupleDesc(int natts)
{
TupleDesc desc;
desc->constr = NULL;
desc->tdtypeid = RECORDOID;
desc->tdtypmod = -1;
- desc->tdhasoid = hasoid;
desc->tdrefcount = -1; /* assume not reference-counted */
return desc;
* 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);
TupleDesc desc;
int i;
- desc = CreateTemplateTupleDesc(tupdesc->natts, tupdesc->tdhasoid);
+ desc = CreateTemplateTupleDesc(tupdesc->natts);
/* Flat-copy the attribute array */
memcpy(TupleDescAttr(desc, 0),
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),
return false;
if (tupdesc1->tdtypeid != tupdesc2->tdtypeid)
return false;
- if (tupdesc1->tdhasoid != tupdesc2->tdhasoid)
- return false;
for (i = 0; i < tupdesc1->natts; i++)
{
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));
* allocate a new tuple descriptor
*/
natts = list_length(schema);
- desc = CreateTemplateTupleDesc(natts, false);
+ desc = CreateTemplateTupleDesc(natts);
has_not_null = false;
attnum = 0;
/*
* allocate a new tuple descriptor
*/
- desc = CreateTemplateTupleDesc(natts, false);
+ desc = CreateTemplateTupleDesc(natts);
attnum = 0;
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);
* 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,
* 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)
{
tup->t_self = heaptup->t_self;
heap_freetuple(heaptup);
}
-
- return HeapTupleGetOid(tup);
}
/*
(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;
* 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);
}
/*
/* 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);
/*
* 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;
}
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;
}
*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
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;
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);
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,
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;
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);
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);
*
* 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
* 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",
false);
multi->iter = 0;
- tupdesc = CreateTemplateTupleDesc(2, false);
+ tupdesc = CreateTemplateTupleDesc(2);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "xid",
XIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "mode",
/* 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",
* 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
* 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",
%type <list> boot_index_params
%type <ielem> boot_index_param
%type <str> boot_ident
-%type <ival> optbootstrap optsharedrelation optwithoutoids boot_column_nullness
-%type <oidval> oidspec optoideq optrowtypeoid
+%type <ival> optbootstrap optsharedrelation boot_column_nullness
+%type <oidval> oidspec optrowtypeoid
%token <str> ID
%token COMMA EQUALS LPAREN RPAREN
/* 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
;
Boot_CreateStmt:
- XCREATE boot_ident oidspec optbootstrap optsharedrelation optwithoutoids optrowtypeoid LPAREN
+ XCREATE boot_ident oidspec optbootstrap optsharedrelation optrowtypeoid LPAREN
{
do_start();
numattr = 0;
do_start();
- tupdesc = CreateTupleDesc(numattr, !($6), attrtypes);
+ tupdesc = CreateTupleDesc(numattr, attrtypes);
shared_relation = $5;
PG_CATALOG_NAMESPACE,
shared_relation ? GLOBALTABLESPACE_OID : 0,
$3,
- $7,
+ $6,
InvalidOid,
BOOTSTRAP_SUPERUSERID,
tupdesc,
RELPERSISTENCE_PERMANENT,
shared_relation,
mapped_relation,
- true,
- 0,
ONCOMMIT_NOOP,
(Datum) 0,
false,
;
Boot_InsertStmt:
- INSERT_TUPLE optoideq
+ INSERT_TUPLE
{
do_start();
- if ($2)
- elog(DEBUG4, "inserting row with oid %u", $2);
- else
- elog(DEBUG4, "inserting row");
+ elog(DEBUG4, "inserting row");
num_columns_read = 0;
}
LPAREN boot_column_val_list RPAREN
numattr, num_columns_read);
if (boot_reldesc == NULL)
elog(FATAL, "relation not open");
- InsertOneTuple($2);
+ InsertOneTuple();
do_end();
}
;
| { $$ = 0; }
;
-optwithoutoids:
- XWITHOUT_OIDS { $$ = 1; }
- | { $$ = 0; }
- ;
-
optrowtypeoid:
XROWTYPE_OID oidspec { $$ = $2; }
| { $$ = InvalidOid; }
boot_ident { $$ = atooid($1); }
;
-optoideq:
- OBJ_ID EQUALS oidspec { $$ = $3; }
- | { $$ = InvalidOid; }
- ;
-
boot_column_val_list:
boot_column_val
| boot_column_val_list boot_column_val
| 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); }
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; }
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));
* ----------------
*/
void
-InsertOneTuple(Oid objectid)
+InsertOneTuple(void)
{
HeapTuple tuple;
TupleDesc tupDesc;
int i;
- elog(DEBUG4, "inserting row oid %u, %d columns", objectid, numattr);
+ elog(DEBUG4, "inserting row with %d columns", 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);
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));
$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;
{
;
}
+ elsif ($attname eq 'oid')
+ {
+ ;
+ }
elsif (defined $column->{default})
{
$row->{$attname} = $column->{default};
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);
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);
* 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);
}
else
{
+ Oid defAclOid;
+
/* Prepare to insert or update pg_default_acl entry */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
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);
}
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;
if (isNew)
{
/* dependency on role */
- recordDependencyOnOwner(DefaultAclRelationId,
- HeapTupleGetOid(newtuple),
+ recordDependencyOnOwner(DefaultAclRelationId, defAclOid,
iacls->roleid);
/* dependency on namespace */
referenced;
myself.classId = DefaultAclRelationId;
- myself.objectId = HeapTupleGetOid(newtuple);
+ myself.objectId = defAclOid;
myself.objectSubId = 0;
referenced.classId = NamespaceRelationId;
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))
rel = heap_open(DefaultAclRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_default_acl_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objid));
rel = heap_open(DefaultAclRelationId, RowExclusiveLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_default_acl_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(defaclOid));
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;
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);
/* Update the shared dependency ACL info */
updateAclDependencies(ForeignDataWrapperRelationId,
- HeapTupleGetOid(tuple), 0,
+ pg_fdw_tuple->oid, 0,
ownerId,
noldmembers, oldmembers,
nnewmembers, newmembers);
/* Update the shared dependency ACL info */
updateAclDependencies(ForeignServerRelationId,
- HeapTupleGetOid(tuple), 0,
+ pg_server_tuple->oid, 0,
ownerId,
noldmembers, oldmembers,
nnewmembers, newmembers);
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);
/* There's no syscache for pg_largeobject_metadata */
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_largeobject_metadata_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid));
/* Update the shared dependency ACL info */
updateAclDependencies(LargeObjectRelationId,
- HeapTupleGetOid(tuple), 0,
+ form_lo_meta->oid, 0,
ownerId,
noldmembers, oldmembers,
nnewmembers, newmembers);
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);
AccessShareLock);
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_largeobject_metadata_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(lobj_oid));
AccessShareLock);
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_largeobject_metadata_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(lobj_oid));
pg_extension = heap_open(ExtensionRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_extension_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(ext_oid));
/* There's no syscache for pg_largeobject_metadata */
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_largeobject_metadata_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objoid));
#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"
#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"
/*
- * 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
* 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
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
* is also an unused OID within pg_class. If the result is to be used only
* as a relfilenode for an existing relation, pass NULL for pg_class.
*
- * As with GetNewOid, there is some theoretical risk of a race condition,
- * but it doesn't seem worth worrying about.
+ * As with GetNewObjectIdWithIndex(), there is some theoretical risk of a race
+ * condition, but it doesn't seem worth worrying about.
*
* Note: we don't support using this in bootstrap mode. All relations
* created by bootstrap have preassigned OIDs, so there's no need.
/* 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();
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;
+}
# 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";
print $bki "create $catname $catalog->{relation_oid}"
. $catalog->{shared_relation}
. $catalog->{bootstrap}
- . $catalog->{without_oids}
. $catalog->{rowtype_oid_clause};
my $first = 1;
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"
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;
$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' },
$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);
}
my $schema = shift;
my @bki_values;
- my $oid = $row->{oid} ? "OID = $row->{oid} " : '';
foreach my $column (@$schema)
{
push @bki_values, $bki_value;
}
- printf $bki "insert %s( %s )\n", $oid, join(' ', @bki_values);
+ printf $bki "insert ( %s )\n", join(' ', @bki_values);
return;
}
};
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),
.attislocal = true,
};
-static const FormData_pg_attribute a4 = {
+static const FormData_pg_attribute a3 = {
.attname = {"cmin"},
.atttypid = CIDOID,
.attlen = sizeof(CommandId),
.attislocal = true,
};
-static const FormData_pg_attribute a5 = {
+static const FormData_pg_attribute a4 = {
.attname = {"xmax"},
.atttypid = XIDOID,
.attlen = sizeof(TransactionId),
.attislocal = true,
};
-static const FormData_pg_attribute a6 = {
+static const FormData_pg_attribute a5 = {
.attname = {"cmax"},
.atttypid = CIDOID,
.attlen = sizeof(CommandId),
* 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),
.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.
* 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];
}
* 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;
{
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;
{
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",
static void
AddNewAttributeTuples(Oid new_rel_oid,
TupleDesc tupdesc,
- char relkind,
- bool oidislocal,
- int oidinhcount)
+ char relkind)
{
Form_pg_attribute attr;
int i;
{
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);
}
}
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);
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);
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);
* 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;
char relpersistence,
bool shared_relation,
bool mapped_relation,
- bool oidislocal,
- int oidinhcount,
OnCommitAction oncommit,
Datum reloptions,
bool use_user_acl,
* 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))
/*
* 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
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,
/* Find the pg_attrdef tuple */
ScanKeyInit(&scankeys[0],
- ObjectIdAttributeNumber,
+ Anum_pg_attrdef_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(attrdefId));
ObjectAddress colobject,
defobject;
+ adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
+
/*
* Flatten expression to string form for storage.
*/
/*
* 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;
/*
* allocate the new tuple descriptor
*/
- indexTupDesc = CreateTemplateTupleDesc(numatts, false);
+ indexTupDesc = CreateTemplateTupleDesc(numatts);
/*
* Fill in the pg_attribute row.
/* 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;
*/
indexRelation->rd_rel->relowner = heapRelation->rd_rel->relowner;
indexRelation->rd_rel->relam = accessMethodObjectId;
- indexRelation->rd_rel->relhasoids = false;
indexRelation->rd_rel->relispartition = OidIsValid(parentIndexRelid);
/*
ScanKeyData key[1];
ScanKeyInit(&key[0],
- ObjectIdAttributeNumber,
+ Anum_pg_class_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(relid));
* 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);
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);
ResetReindexPending();
if (is_pg_class)
- RelationSetIndexList(rel, indexIds, ClassOidIndexId);
+ RelationSetIndexList(rel, indexIds);
/*
* Close rel, but continue to hold the lock.
* 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;
}
/*
* 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;
}
/*
is_supported yes_or_no,
is_verified_by character_data,
comments character_data
-) WITHOUT OIDS;
+);
-- Will be filled with external data by initdb.
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);
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');
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, '');
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, '');
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);
profile_id character_data,
required_value cardinal_number,
comments character_data
-) WITHOUT OIDS;
+);
GRANT SELECT ON sql_sizing_profiles TO PUBLIC;
{
Oid namespaceId = lfirst_oid(l);
- typid = GetSysCacheOid2(TYPENAMENSP,
+ typid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
PointerGetDatum(typname),
ObjectIdGetDatum(namespaceId));
if (OidIsValid(typid))
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)
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;
if (operform->oprnamespace == namespaceId)
{
- Oid result = HeapTupleGetOid(opertup);
+ Oid result = operform->oid;
ReleaseSysCacheList(catlist);
return result;
continue; /* keep previous result */
/* replace previous result */
prevResult->pathpos = pathpos;
- prevResult->oid = HeapTupleGetOid(opertup);
+ prevResult->oid = operform->oid;
continue; /* args are same, of course */
}
}
nextResult += SPACE_PER_OP;
newResult->pathpos = pathpos;
- newResult->oid = HeapTupleGetOid(opertup);
+ newResult->oid = operform->oid;
newResult->nargs = 2;
newResult->nvargs = 0;
newResult->ndargs = 0;
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));
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));
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));
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;
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))
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));
}
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))
if (missing_ok && !OidIsValid(namespaceId))
prsoid = InvalidOid;
else
- prsoid = GetSysCacheOid2(TSPARSERNAMENSP,
+ prsoid = GetSysCacheOid2(TSPARSERNAMENSP, Anum_pg_ts_parser_oid,
PointerGetDatum(parser_name),
ObjectIdGetDatum(namespaceId));
}
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))
if (missing_ok && !OidIsValid(namespaceId))
dictoid = InvalidOid;
else
- dictoid = GetSysCacheOid2(TSDICTNAMENSP,
+ dictoid = GetSysCacheOid2(TSDICTNAMENSP, Anum_pg_ts_dict_oid,
PointerGetDatum(dict_name),
ObjectIdGetDatum(namespaceId));
}
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))
if (missing_ok && !OidIsValid(namespaceId))
tmploid = InvalidOid;
else
- tmploid = GetSysCacheOid2(TSTEMPLATENAMENSP,
+ tmploid = GetSysCacheOid2(TSTEMPLATENAMENSP, Anum_pg_ts_template_oid,
PointerGetDatum(template_name),
ObjectIdGetDatum(namespaceId));
}
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))
if (missing_ok && !OidIsValid(namespaceId))
cfgoid = InvalidOid;
else
- cfgoid = GetSysCacheOid2(TSCONFIGNAMENSP,
+ cfgoid = GetSysCacheOid2(TSCONFIGNAMENSP, Anum_pg_ts_config_oid,
PointerGetDatum(config_name),
ObjectIdGetDatum(namespaceId));
}
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))
{
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),
if (missing_ok && !OidIsValid(namespaceId))
conoid = InvalidOid;
else
- conoid = GetSysCacheOid2(CONNAMENSP,
+ conoid = GetSysCacheOid2(CONNAMENSP, Anum_pg_conversion_oid,
PointerGetDatum(conversion_name),
ObjectIdGetDatum(namespaceId));
}
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))
#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"
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 */
AmOidIndexId,
AMOID,
AMNAME,
+ Anum_pg_am_oid,
Anum_pg_am_amname,
InvalidAttrNumber,
InvalidAttrNumber,
CastOidIndexId,
-1,
-1,
+ Anum_pg_cast_oid,
InvalidAttrNumber,
InvalidAttrNumber,
InvalidAttrNumber,
CollationOidIndexId,
COLLOID,
-1, /* COLLNAMEENCNSP also takes encoding */
+ Anum_pg_collation_oid,
Anum_pg_collation_collname,
Anum_pg_collation_collnamespace,
Anum_pg_collation_collowner,
ConstraintOidIndexId,
CONSTROID,
-1,
+ Anum_pg_constraint_oid,
Anum_pg_constraint_conname,
Anum_pg_constraint_connamespace,
InvalidAttrNumber,
ConversionOidIndexId,
CONVOID,
CONNAMENSP,
+ Anum_pg_conversion_oid,
Anum_pg_conversion_conname,
Anum_pg_conversion_connamespace,
Anum_pg_conversion_conowner,
DatabaseOidIndexId,
DATABASEOID,
-1,
+ Anum_pg_database_oid,
Anum_pg_database_datname,
InvalidAttrNumber,
Anum_pg_database_datdba,
ExtensionOidIndexId,
-1,
-1,
+ Anum_pg_extension_oid,
Anum_pg_extension_extname,
InvalidAttrNumber, /* extension doesn't belong to extnamespace */
Anum_pg_extension_extowner,
ForeignDataWrapperOidIndexId,
FOREIGNDATAWRAPPEROID,
FOREIGNDATAWRAPPERNAME,
+ Anum_pg_foreign_data_wrapper_oid,
Anum_pg_foreign_data_wrapper_fdwname,
InvalidAttrNumber,
Anum_pg_foreign_data_wrapper_fdwowner,
ForeignServerOidIndexId,
FOREIGNSERVEROID,
FOREIGNSERVERNAME,
+ Anum_pg_foreign_server_oid,
Anum_pg_foreign_server_srvname,
InvalidAttrNumber,
Anum_pg_foreign_server_srvowner,
ProcedureOidIndexId,
PROCOID,
-1, /* PROCNAMEARGSNSP also takes argument types */
+ Anum_pg_proc_oid,
Anum_pg_proc_proname,
Anum_pg_proc_pronamespace,
Anum_pg_proc_proowner,
LanguageOidIndexId,
LANGOID,
LANGNAME,
+ Anum_pg_language_oid,
Anum_pg_language_lanname,
InvalidAttrNumber,
Anum_pg_language_lanowner,
LargeObjectMetadataOidIndexId,
-1,
-1,
+ Anum_pg_largeobject_metadata_oid,
InvalidAttrNumber,
InvalidAttrNumber,
Anum_pg_largeobject_metadata_lomowner,
OpclassOidIndexId,
CLAOID,
-1, /* CLAAMNAMENSP also takes opcmethod */
+ Anum_pg_opclass_oid,
Anum_pg_opclass_opcname,
Anum_pg_opclass_opcnamespace,
Anum_pg_opclass_opcowner,
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,
OpfamilyOidIndexId,
OPFAMILYOID,
-1, /* OPFAMILYAMNAMENSP also takes opfmethod */
+ Anum_pg_opfamily_oid,
Anum_pg_opfamily_opfname,
Anum_pg_opfamily_opfnamespace,
Anum_pg_opfamily_opfowner,
AuthIdOidIndexId,
AUTHOID,
AUTHNAME,
+ Anum_pg_authid_oid,
Anum_pg_authid_rolname,
InvalidAttrNumber,
InvalidAttrNumber,
RewriteOidIndexId,
-1,
-1,
+ Anum_pg_rewrite_oid,
Anum_pg_rewrite_rulename,
InvalidAttrNumber,
InvalidAttrNumber,
NamespaceOidIndexId,
NAMESPACEOID,
NAMESPACENAME,
+ Anum_pg_namespace_oid,
Anum_pg_namespace_nspname,
InvalidAttrNumber,
Anum_pg_namespace_nspowner,
ClassOidIndexId,
RELOID,
RELNAMENSP,
+ Anum_pg_class_oid,
Anum_pg_class_relname,
Anum_pg_class_relnamespace,
Anum_pg_class_relowner,
TablespaceOidIndexId,
TABLESPACEOID,
-1,
+ Anum_pg_tablespace_oid,
Anum_pg_tablespace_spcname,
InvalidAttrNumber,
Anum_pg_tablespace_spcowner,
TransformRelationId,
TransformOidIndexId,
TRFOID,
- InvalidAttrNumber
+ InvalidAttrNumber,
+ Anum_pg_transform_oid
},
{
TriggerRelationId,
TriggerOidIndexId,
-1,
-1,
+ Anum_pg_trigger_oid,
Anum_pg_trigger_tgname,
InvalidAttrNumber,
InvalidAttrNumber,
PolicyOidIndexId,
-1,
-1,
+ Anum_pg_policy_oid,
Anum_pg_policy_polname,
InvalidAttrNumber,
InvalidAttrNumber,
EventTriggerOidIndexId,
EVENTTRIGGEROID,
EVENTTRIGGERNAME,
+ Anum_pg_event_trigger_oid,
Anum_pg_event_trigger_evtname,
InvalidAttrNumber,
Anum_pg_event_trigger_evtowner,
TSConfigOidIndexId,
TSCONFIGOID,
TSCONFIGNAMENSP,
+ Anum_pg_ts_config_oid,
Anum_pg_ts_config_cfgname,
Anum_pg_ts_config_cfgnamespace,
Anum_pg_ts_config_cfgowner,
TSDictionaryOidIndexId,
TSDICTOID,
TSDICTNAMENSP,
+ Anum_pg_ts_dict_oid,
Anum_pg_ts_dict_dictname,
Anum_pg_ts_dict_dictnamespace,
Anum_pg_ts_dict_dictowner,
TSParserOidIndexId,
TSPARSEROID,
TSPARSERNAMENSP,
+ Anum_pg_ts_parser_oid,
Anum_pg_ts_parser_prsname,
Anum_pg_ts_parser_prsnamespace,
InvalidAttrNumber,
TSTemplateOidIndexId,
TSTEMPLATEOID,
TSTEMPLATENAMENSP,
+ Anum_pg_ts_template_oid,
Anum_pg_ts_template_tmplname,
Anum_pg_ts_template_tmplnamespace,
InvalidAttrNumber,
TypeOidIndexId,
TYPEOID,
TYPENAMENSP,
+ Anum_pg_type_oid,
Anum_pg_type_typname,
Anum_pg_type_typnamespace,
Anum_pg_type_typowner,
PublicationObjectIndexId,
PUBLICATIONOID,
PUBLICATIONNAME,
+ Anum_pg_publication_oid,
Anum_pg_publication_pubname,
InvalidAttrNumber,
Anum_pg_publication_pubowner,
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
+ Anum_pg_subscription_oid,
Anum_pg_subscription_subname,
InvalidAttrNumber,
Anum_pg_subscription_subowner,
StatisticExtOidIndexId,
STATEXTOID,
STATEXTNAMENSP,
+ Anum_pg_statistic_ext_oid,
Anum_pg_statistic_ext_stxname,
Anum_pg_statistic_ext_stxnamespace,
Anum_pg_statistic_ext_stxowner,
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);
}
else
{
- address.objectId = HeapTupleGetOid(tp);
+ address.objectId = ((Form_pg_amop) GETSTRUCT(tp))->oid;
ReleaseSysCache(tp);
}
}
}
else
{
- address.objectId = HeapTupleGetOid(tp);
+ address.objectId = ((Form_pg_amproc) GETSTRUCT(tp))->oid;
ReleaseSysCache(tp);
}
}
username, servername)));
return address;
}
- userid = HeapTupleGetOid(tp);
+ userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
ReleaseSysCache(tp);
}
return address;
}
- address.objectId = HeapTupleGetOid(tp);
+ address.objectId = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
ReleaseSysCache(tp);
/* 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))
CStringGetDatum(username));
if (!HeapTupleIsValid(tp))
goto not_found;
- userid = HeapTupleGetOid(tp);
+ userid = ((Form_pg_authid) GETSTRUCT(tp))->oid;
ReleaseSysCache(tp);
/*
if (!HeapTupleIsValid(tp))
goto not_found;
- address.objectId = HeapTupleGetOid(tp);
+ address.objectId = ((Form_pg_default_acl) GETSTRUCT(tp))->oid;
ReleaseSysCache(tp);
return address;
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",
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)
{
* 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);
Assert(OidIsValid(oidIndexId));
ScanKeyInit(&skey,
- ObjectIdAttributeNumber,
+ oidcol,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(objectId));
castDesc = heap_open(CastRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_cast_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_attrdef_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_amop_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_amproc_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
ruleDesc = heap_open(RewriteRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_rewrite_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
trigDesc = heap_open(TriggerRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_trigger_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
defaclrel = heap_open(DefaultAclRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_default_acl_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
policy_rel = heap_open(PolicyRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_policy_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
* 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",
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;
* 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",
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);
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);
}
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",
attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_attrdef_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_amop_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_amproc_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
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",
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",
defaclrel = heap_open(DefaultAclRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_default_acl_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(object->objectId));
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",
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",
/*
* 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++)
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);
#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"
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);
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 */
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
/* create dependency on owner */
- recordDependencyOnOwner(CollationRelationId, HeapTupleGetOid(tup),
- collowner);
+ recordDependencyOnOwner(CollationRelationId, oid, collowner);
/* dependency on extension */
recordDependencyOnCurrentExtension(&myself, false);
rel = heap_open(CollationRelationId, RowExclusiveLock);
ScanKeyInit(&scanKeyData,
- ObjectIdAttributeNumber,
+ Anum_pg_collation_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(collationOid));
#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"
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);
tup = heap_form_tuple(RelationGetDescr(conDesc), values, nulls);
- conOid = CatalogTupleInsert(conDesc, tup);
+ CatalogTupleInsert(conDesc, tup);
conobject.classId = ConstraintRelationId;
conobject.objectId = conOid;
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 */
ReleaseSysCache(partcontup);
/* looks good! Attach this constraint */
- ConstraintSetParentConstraint(fk->conoid,
- HeapTupleGetOid(tuple));
+ ConstraintSetParentConstraint(fk->conoid, constrForm->oid);
CommandCounterIncrement();
attach_it = true;
break;
constrForm->condeferrable,
constrForm->condeferred,
constrForm->convalidated,
- HeapTupleGetOid(tuple),
+ constrForm->oid,
RelationGetRelid(partRel),
mapped_conkey,
nelem,
ObjectAddress thisobj;
thisobj.classId = ConstraintRelationId;
- thisobj.objectId = HeapTupleGetOid(tup);
+ thisobj.objectId = conform->oid;
thisobj.objectSubId = 0;
if (object_address_present(&thisobj, objsMoved))
/* 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);
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,
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
if (constrForm->conindid == indexId)
{
- constraintId = HeapTupleGetOid(tuple);
+ constraintId = constrForm->oid;
break;
}
}
/* 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);
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 ||
pkattnos = bms_add_member(pkattnos,
attnums[i] - FirstLowInvalidHeapAttributeNumber);
}
- *constraintOid = HeapTupleGetOid(tuple);
+ *constraintOid = ((Form_pg_constraint) GETSTRUCT(tuple))->oid;
/* No need to search further */
break;
#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"
Relation rel;
TupleDesc tupDesc;
HeapTuple tup;
+ Oid oid;
bool nulls[Natts_pg_conversion];
Datum values[Natts_pg_conversion];
NameData cname;
/* 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);
CatalogTupleInsert(rel, tup);
myself.classId = ConversionRelationId;
- myself.objectId = HeapTupleGetOid(tup);
+ myself.objectId = oid;
myself.objectSubId = 0;
/* create dependency on conversion procedure */
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);
ScanKeyData scanKeyData;
ScanKeyInit(&scanKeyData,
- ObjectIdAttributeNumber,
+ Anum_pg_conversion_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(conversionOid));
do
{
- new_oid = GetNewOid(pg_enum);
+ new_oid = GetNewOidWithIndex(pg_enum, EnumOidIndexId,
+ Anum_pg_enum_oid);
} while (new_oid & 1);
oids[elemno] = new_oid;
}
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);
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
{
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 */
/* 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);
#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"
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);
* Delete an entry from pg_largeobject_metadata
*/
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_largeobject_metadata_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid));
bool retval = false;
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_largeobject_metadata_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid));
#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"
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);
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);
#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"
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
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
*/
* 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);
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
*/
/*
* insert our "shell" operator tuple
*/
- operatorObjectId = CatalogTupleInsert(pg_operator_desc, tup);
+ CatalogTupleInsert(pg_operator_desc, tup);
/* Add dependencies for the entry */
makeOperatorDependencies(tup, false);
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,
{
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 */
referenced;
myself.classId = OperatorRelationId;
- myself.objectId = HeapTupleGetOid(tuple);
+ myself.objectId = oper->oid;
myself.objectSubId = 0;
/*
}
/* Dependency on owner */
- recordDependencyOnOwner(OperatorRelationId, HeapTupleGetOid(tuple),
+ recordDependencyOnOwner(OperatorRelationId, oper->oid,
oper->oprowner);
/* Dependency on extension */
#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"
(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);
/* 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
/* translator: first %s is DROP FUNCTION or DROP PROCEDURE */
errhint("Use %s %s first.",
dropcmd,
- format_procedure(HeapTupleGetOid(oldtup)))));
+ format_procedure(oldproc->oid))));
}
/*
/* translator: first %s is DROP FUNCTION or DROP PROCEDURE */
errhint("Use %s %s first.",
dropcmd,
- format_procedure(HeapTupleGetOid(oldtup)))));
+ format_procedure(oldproc->oid))));
}
}
/* 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,
/* 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;
else
{
/* Creating a new procedure */
+ Oid newOid;
/* First, get default permissions and set up proacl */
proacl = get_user_default_acl(OBJECT_FUNCTION, proowner,
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
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] =
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);
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);
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);
{
Oid oid;
- oid = GetSysCacheOid1(PUBLICATIONNAME, CStringGetDatum(pubname));
+ oid = GetSysCacheOid1(PUBLICATIONNAME, Anum_pg_publication_oid,
+ CStringGetDatum(pubname));
if (!OidIsValid(oid))
{
if (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),
{
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),
/*
* 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];
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];
/* Update the catalog. */
CatalogTupleUpdate(rel, &tup->t_self, tup);
- subrelid = HeapTupleGetOid(tup);
-
/* Cleanup. */
heap_close(rel, NoLock);
-
- return subrelid;
}
/*
#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"
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)
{
(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.
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)));
/*
* 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
*/
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)
{
(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);
}
/*
arrayOid = typ->typarray;
/* Check for a conflicting type name. */
- oldTypeOid = GetSysCacheOid2(TYPENAMENSP,
+ oldTypeOid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
CStringGetDatum(newTypeName),
ObjectIdGetDatum(typeNamespace));
"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,
rel->rd_rel->relpersistence,
shared_relation,
mapped_relation,
- true,
- 0,
ONCOMMIT_NOOP,
reloptions,
false,
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);
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));
}
else
{
- snprintf(namebuf, sizeof(namebuf), "%u",
- HeapTupleGetOid(oldtup));
+ snprintf(namebuf, sizeof(namebuf), "%u", objectId);
objname = namebuf;
}
aclcheck_error(ACLCHECK_NOT_OWNER, objtype, objname);
/* Update owner dependency reference */
if (classId == LargeObjectMetadataRelationId)
classId = LargeObjectRelationId;
- changeDependencyOnOwner(classId, HeapTupleGetOid(newtup), new_ownerId);
+ changeDependencyOnOwner(classId, objectId, new_ownerId);
/* Release memory */
pfree(values);
#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"
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,
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);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
- amoid = CatalogTupleInsert(rel, tup);
+ CatalogTupleInsert(rel, tup);
heap_freetuple(tup);
myself.classId = AccessMethodRelationId;
NameStr(amform->amname),
get_am_type_string(amtype))));
- oid = HeapTupleGetOid(tup);
+ oid = amform->oid;
ReleaseSysCache(tup);
}
static void reform_and_rewrite_tuple(HeapTuple tuple,
TupleDesc oldTupDesc, TupleDesc newTupDesc,
Datum *values, bool *isnull,
- bool newRelHasOids, RewriteState rwstate);
+ RewriteState rwstate);
/*---------------------------------------------------------------------------
relpersistence,
false,
RelationIsMapped(OldHeap),
- true,
- 0,
ONCOMMIT_NOOP,
reloptions,
false,
reform_and_rewrite_tuple(tuple,
oldTupDesc, newTupDesc,
values, isnull,
- NewHeap->rd_rel->relhasoids, rwstate);
+ rwstate);
}
if (indexScan != NULL)
reform_and_rewrite_tuple(tuple,
oldTupDesc, newTupDesc,
values, isnull,
- NewHeap->rd_rel->relhasoids, rwstate);
+ rwstate);
}
tuplesort_end(tuplesort);
*
* 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.
*/
reform_and_rewrite_tuple(HeapTuple tuple,
TupleDesc oldTupDesc, TupleDesc newTupDesc,
Datum *values, bool *isnull,
- bool newRelHasOids, RewriteState rwstate)
+ RewriteState rwstate)
{
HeapTuple copiedTuple;
int i;
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);
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? */
* 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 */
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,
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)
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
{
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).
CopySendData(cstate, BinarySignature, 11);
/* Flags field */
tmp = 0;
- if (cstate->oids)
- tmp |= (1 << 16);
CopySendInt32(cstate, tmp);
/* No header extension */
tmp = 0;
heap_deform_tuple(tuple, tupDesc, values, nulls);
/* Format and send the data */
- CopyOneRowTo(cstate, HeapTupleGetOid(tuple), values, nulls);
+ CopyOneRowTo(cstate, values, nulls);
processed++;
}
* 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;
{
/* 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)
{
TupleTableSlot *slot;
bool skip_tuple;
- Oid loaded_oid = InvalidOid;
CHECK_FOR_INTERRUPTS();
/* 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.
}
}
- 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];
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,
}
}
- 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);
*/
bool
NextCopyFrom(CopyState cstate, ExprContext *econtext,
- Datum *values, bool *nulls, Oid *tupleOid)
+ Datum *values, bool *nulls)
{
TupleDesc tupDesc;
AttrNumber num_phys_attrs,
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));
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)
{
cstate->cur_attval = NULL;
}
- Assert(fieldno == nfields);
+ Assert(fieldno == attr_count);
}
else
{
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)
{
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;
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;
*/
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,
do
{
- dboid = GetNewOid(pg_database_rel);
+ dboid = GetNewOidWithIndex(pg_database_rel, DatabaseOidIndexId,
+ Anum_pg_database_oid);
} while (check_db_file_conflict(dboid));
/*
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);
tuple = heap_form_tuple(RelationGetDescr(pg_database_rel),
new_record, new_record_nulls);
- HeapTupleSetOid(tuple, dboid);
-
CatalogTupleInsert(pg_database_rel, tuple);
/*
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;
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);
Oid dboid;
HeapTuple tuple,
newtuple;
+ Form_pg_database datform;
ScanKeyData scankey;
SysScanDesc scan;
ListCell *option;
(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);
new_record_nulls, new_record_repl);
CatalogTupleUpdate(rel, &tuple->t_self, newtuple);
- InvokeObjectPostAlterHook(DatabaseRelationId,
- HeapTupleGetOid(newtuple), 0);
+ InvokeObjectPostAlterHook(DatabaseRelationId, dboid, 0);
systable_endscan(scan);
(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
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);
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);
break;
}
- dbOid = HeapTupleGetOid(tuple);
+ dbOid = ((Form_pg_database) GETSTRUCT(tuple))->oid;
systable_endscan(scan);
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;
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;
/* 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;
#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"
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);
/* 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. */
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);
{
Oid evtOid;
HeapTuple tup;
+ Form_pg_event_trigger evtForm;
Relation rel;
ObjectAddress address;
(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);
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));
/* Update owner dependency reference */
changeDependencyOnOwner(EventTriggerRelationId,
- HeapTupleGetOid(tup),
+ form->oid,
newOwnerId);
InvokeObjectPostAlterHook(EventTriggerRelationId,
- HeapTupleGetOid(tup), 0);
+ form->oid, 0);
}
/*
{
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),
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)
{
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",
}
/* 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;
#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"
/* 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;
rel = heap_open(ExtensionRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_extension_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(ext_oid));
rel = heap_open(ExtensionRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_extension_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(ext_oid));
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);
tuple = heap_form_tuple(rel->rd_att, values, nulls);
- extensionOid = CatalogTupleInsert(rel, tuple);
+ CatalogTupleInsert(rel, tuple);
heap_freetuple(tuple);
heap_close(rel, RowExclusiveLock);
rel = heap_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_extension_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(extId));
scandesc = systable_beginscan(rel, ExtensionOidIndexId, true,
extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
- ObjectIdAttributeNumber,
+ Anum_pg_extension_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(CurrentExtensionObject));
extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
- ObjectIdAttributeNumber,
+ Anum_pg_extension_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(extensionoid));
extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
- ObjectIdAttributeNumber,
+ Anum_pg_extension_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(extensionOid));
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
extRel = heap_open(ExtensionRelationId, RowExclusiveLock);
ScanKeyInit(&key[0],
- ObjectIdAttributeNumber,
+ Anum_pg_extension_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(extensionOid));
#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"
/* Update owner dependency reference */
changeDependencyOnOwner(ForeignDataWrapperRelationId,
- HeapTupleGetOid(tup),
+ form->oid,
newOwnerId);
}
InvokeObjectPostAlterHook(ForeignDataWrapperRelationId,
- HeapTupleGetOid(tup), 0);
+ form->oid, 0);
}
/*
HeapTuple tup;
Relation rel;
ObjectAddress address;
+ Form_pg_foreign_data_wrapper form;
+
rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
(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);
Oid srvId;
AclResult aclresult;
- srvId = HeapTupleGetOid(tup);
+ srvId = form->oid;
/* Must be owner */
if (!pg_foreign_server_ownercheck(srvId, GetUserId()))
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);
}
/*
HeapTuple tup;
Relation rel;
ObjectAddress address;
+ Form_pg_foreign_server form;
rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
(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);
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);
tuple = heap_form_tuple(rel->rd_att, values, nulls);
- fdwId = CatalogTupleInsert(rel, tuple);
+ CatalogTupleInsert(rel, tuple);
heap_freetuple(tuple);
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));
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);
tuple = heap_form_tuple(rel->rd_att, values, nulls);
- srvId = CatalogTupleInsert(rel, tuple);
+ CatalogTupleInsert(rel, tuple);
heap_freetuple(tuple);
(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.
/*
* 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));
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);
tuple = heap_form_tuple(rel->rd_att, values, nulls);
- umId = CatalogTupleInsert(rel, tuple);
+ CatalogTupleInsert(rel, tuple);
heap_freetuple(tuple);
srv = GetForeignServerByName(stmt->servername, false);
- umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
+ umId = GetSysCacheOid2(USERMAPPINGUSERSERVER, Anum_pg_user_mapping_oid,
ObjectIdGetDatum(useId),
ObjectIdGetDatum(srv->serverid));
if (!OidIsValid(umId))
return InvalidOid;
}
- umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
+ umId = GetSysCacheOid2(USERMAPPINGUSERSERVER, Anum_pg_user_mapping_oid,
ObjectIdGetDatum(useId),
ObjectIdGetDatum(srv->serverid));
#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"
(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)
{
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);
tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls);
- castid = CatalogTupleInsert(relation, tuple);
+ CatalogTupleInsert(relation, tuple);
/* make dependency entries */
myself.classId = CastRelationId;
{
Oid oid;
- oid = GetSysCacheOid2(CASTSOURCETARGET,
+ oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
ObjectIdGetDatum(sourcetypeid),
ObjectIdGetDatum(targettypeid));
if (!OidIsValid(oid) && !missing_ok)
relation = heap_open(CastRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- ObjectIdAttributeNumber,
+ Anum_pg_cast_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(castOid));
scan = systable_beginscan(relation, CastOidIndexId, true,
ObjectIdGetDatum(langid));
if (HeapTupleIsValid(tuple))
{
+ Form_pg_transform form = (Form_pg_transform) GETSTRUCT(tuple);
+
if (!stmt->replace)
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
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;
}
{
Oid oid;
- oid = GetSysCacheOid2(TRFTYPELANG,
+ oid = GetSysCacheOid2(TRFTYPELANG, Anum_pg_transform_oid,
ObjectIdGetDatum(type_id),
ObjectIdGetDatum(lang_id));
if (!OidIsValid(oid) && !missing_ok)
relation = heap_open(TransformRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- ObjectIdAttributeNumber,
+ Anum_pg_transform_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(transformOid));
scan = systable_beginscan(relation, TransformOidIndexId, true,
(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;
(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);
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)
/*
- * 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")));
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),
char *schemaname;
char *opcname;
HeapTuple tuple;
+ Form_pg_opclass opform;
Oid opClassId,
opInputType;
* 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,
if (opclass->opcintype == type_id)
{
nexact++;
- result = HeapTupleGetOid(tup);
+ result = opclass->oid;
}
else if (nexact == 0 &&
IsBinaryCoercible(type_id, opclass->opcintype))
if (IsPreferredType(tcategory, opclass->opcintype))
{
ncompatiblepreferred++;
- result = HeapTupleGetOid(tup);
+ result = opclass->oid;
}
else if (ncompatiblepreferred == 0)
{
ncompatible++;
- result = HeapTupleGetOid(tup);
+ result = opclass->oid;
}
}
}
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
(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.
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);
#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"
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;
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;
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);
tup = heap_form_tuple(rel->rd_att, values, nulls);
- opfamilyoid = CatalogTupleInsert(rel, tup);
+ CatalogTupleInsert(rel, tup);
heap_freetuple(tup);
ListCell *l;
Relation rel;
HeapTuple tup;
+ Form_pg_am amform;
IndexAmRoutine *amroutine;
Datum values[Natts_pg_opclass];
bool nulls[Natts_pg_opclass];
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);
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
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);
tup = heap_form_tuple(rel->rd_att, values, nulls);
- opclassoid = CatalogTupleInsert(rel, tup);
+ CatalogTupleInsert(rel, tup);
heap_freetuple(tup);
int maxOpNumber, /* amstrategies value */
maxProcNumber; /* amsupport value */
HeapTuple tup;
+ Form_pg_am amform;
IndexAmRoutine *amroutine;
/* Get necessary info about access method */
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);
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);
tup = heap_form_tuple(rel->rd_att, values, nulls);
- entryoid = CatalogTupleInsert(rel, tup);
+ CatalogTupleInsert(rel, tup);
heap_freetuple(tup);
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);
tup = heap_form_tuple(rel->rd_att, values, nulls);
- entryoid = CatalogTupleInsert(rel, tup);
+ CatalogTupleInsert(rel, tup);
heap_freetuple(tup);
Oid amopid;
ObjectAddress object;
- amopid = GetSysCacheOid4(AMOPSTRATEGY,
+ amopid = GetSysCacheOid4(AMOPSTRATEGY, Anum_pg_amop_oid,
ObjectIdGetDatum(opfamilyoid),
ObjectIdGetDatum(op->lefttype),
ObjectIdGetDatum(op->righttype),
Oid amprocid;
ObjectAddress object;
- amprocid = GetSysCacheOid4(AMPROCNUM,
+ amprocid = GetSysCacheOid4(AMPROCNUM, Anum_pg_amproc_oid,
ObjectIdGetDatum(opfamilyoid),
ObjectIdGetDatum(op->lefttype),
ObjectIdGetDatum(op->righttype),
SysScanDesc scan;
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_amop_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(entryOid));
SysScanDesc scan;
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_amproc_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(entryOid));
* Find the policy to delete.
*/
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_policy_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(policy_id));
* Find the policy to update.
*/
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_policy_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(policy_id));
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));
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;
(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)
{
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);
CatalogTupleUpdate(pg_policy_rel, &policy_tuple->t_self, policy_tuple);
- InvokeObjectPostAlterHook(PolicyRelationId,
- HeapTupleGetOid(policy_tuple), 0);
+ InvokeObjectPostAlterHook(PolicyRelationId, opoloid, 0);
ObjectAddressSet(address, PolicyRelationId, opoloid);
policy_oid = InvalidOid;
}
else
- policy_oid = HeapTupleGetOid(policy_tuple);
+ policy_oid = ((Form_pg_policy) GETSTRUCT(policy_tuple))->oid;
/* Clean up. */
systable_endscan(sscan);
* 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",
#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"
NameData langname;
HeapTuple oldtup;
HeapTuple tup;
+ Oid langoid;
bool is_update;
ObjectAddress myself,
referenced;
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);
/*
- * Do not change existing ownership or permissions. Note
+ * Do not change existing oid, ownership or permissions. Note
* dependency-update code below has to agree with this decision.
*/
+ replaces[Anum_pg_language_oid - 1] = false;
replaces[Anum_pg_language_lanowner - 1] = false;
replaces[Anum_pg_language_lanacl - 1] = false;
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;
* 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)
{
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),
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,
&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] =
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());
bool publish_delete;
bool publish_truncate;
ObjectAddress obj;
+ Form_pg_publication pubform;
parse_publication_options(stmt->options,
&publish_given, &publish_insert,
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
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);
}
/*
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)
{
Relation rel;
HeapTuple tup;
+ Form_pg_publication pubform;
rel = heap_open(PublicationRelationId, RowExclusiveLock);
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);
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))
{
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));
/* Update owner dependency reference */
changeDependencyOnOwner(PublicationRelationId,
- HeapTupleGetOid(tup),
+ form->oid,
newOwnerId);
InvokeObjectPostAlterHook(PublicationRelationId,
- HeapTupleGetOid(tup), 0);
+ form->oid, 0);
}
/*
HeapTuple tup;
Relation rel;
ObjectAddress address;
+ Form_pg_publication pubform;
rel = heap_open(PublicationRelationId, RowExclusiveLock);
(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);
Relation rel;
AclResult aclresult;
ObjectAddress address;
+ Form_pg_namespace nspform;
rel = heap_open(NamespaceRelationId, RowExclusiveLock);
(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)))
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);
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);
HeapTuple tup;
Relation rel;
ObjectAddress address;
+ Form_pg_namespace nspform;
rel = heap_open(NamespaceRelationId, RowExclusiveLock);
(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);
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));
heap_freetuple(newtuple);
/* Update owner dependency reference */
- changeDependencyOnOwner(NamespaceRelationId, HeapTupleGetOid(tup),
+ changeDependencyOnOwner(NamespaceRelationId, nspForm->oid,
newOwnerId);
}
InvokeObjectPostAlterHook(NamespaceRelationId,
- HeapTupleGetOid(tup), 0);
+ nspForm->oid, 0);
}
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",
#include "postgres.h"
#include "access/relscan.h"
+#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
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);
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);
/*
stxname = makeObjectName(name1, name2, modlabel);
- existingstats = GetSysCacheOid2(STATEXTNAMENSP,
+ existingstats = GetSysCacheOid2(STATEXTNAMENSP, Anum_pg_statistic_ext_oid,
PointerGetDatum(stxname),
ObjectIdGetDatum(namespaceid));
if (!OidIsValid(existingstats))
#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"
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,
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));
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);
Oid subid;
bool update_tuple = false;
Subscription *sub;
+ Form_pg_subscription form;
rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
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. */
RepOriginId originid;
WalReceiverConn *wrconn = NULL;
StringInfoData cmd;
+ Form_pg_subscription form;
/*
* Lock pg_subscription with AccessExclusiveLock to ensure that the
return;
}
- subid = HeapTupleGetOid(tup);
+ form = (Form_pg_subscription) GETSTRUCT(tup);
+ subid = form->oid;
/* must be owner */
if (!pg_subscription_ownercheck(subid, GetUserId()))
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));
/* Update owner dependency reference */
changeDependencyOnOwner(SubscriptionRelationId,
- HeapTupleGetOid(tup),
+ form->oid,
newOwnerId);
InvokeObjectPostAlterHook(SubscriptionRelationId,
- HeapTupleGetOid(tup), 0);
+ form->oid, 0);
}
/*
HeapTuple tup;
Relation rel;
ObjectAddress address;
+ Form_pg_subscription form;
rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
(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);
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);
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);
TupleDesc descriptor;
List *inheritOids;
List *old_constraints;
- bool localHasOids;
- int parentOidCount;
List *rawDefaults;
List *cookedDefaults;
Datum reloptions;
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
*/
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
stmt->relation->relpersistence,
false,
false,
- localHasOids,
- parentOidCount,
stmt->oncommit,
reloptions,
true,
* '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.
*/
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 */
parentOids = lappend_oid(parentOids, RelationGetRelid(relation));
- if (relation->rd_rel->relhasoids)
- parentsWithOids++;
-
tupleDesc = RelationGetDescr(relation);
constr = tupleDesc->constr;
*supOids = parentOids;
*supconstr = constraints;
- *supOidCount = parentsWithOids;
return schema;
}
* to SELECT */
case AT_SetTableSpace: /* must rewrite heap */
case AT_AlterColumnType: /* must rewrite heap */
- case AT_AddOids: /* must rewrite heap */
cmd_lockmode = AccessExclusiveLock;
break;
*/
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 */
}
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 */
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 */
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 */
/*
{
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)
*/
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.
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),
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);
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))));
}
*/
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)
{
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);
}
/* 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)
/*
* 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);
}
}
- /*
- * 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.
*/
/* 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);
}
}
-/*
- * 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
*
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\"",
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;
}
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
InvokeObjectPostAlterHook(ConstraintRelationId,
- HeapTupleGetOid(contuple), 0);
+ currcon->oid, 0);
heap_freetuple(copyTuple);
ScanKeyInit(&tgkey,
Anum_pg_trigger_tgconstraint,
BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(HeapTupleGetOid(contuple)));
+ ObjectIdGetDatum(currcon->oid));
tgscan = systable_beginscan(tgrel, TriggerConstraintIndexId, true,
NULL, 1, &tgkey);
copy_tg->tginitdeferred = cmdcon->initdeferred;
CatalogTupleUpdate(tgrel, ©Tuple->t_self, copyTuple);
- InvokeObjectPostAlterHook(TriggerRelationId,
- HeapTupleGetOid(tgtuple), 0);
+ InvokeObjectPostAlterHook(TriggerRelationId, currcon->oid, 0);
heap_freetuple(copyTuple);
}
CacheInvalidateRelcacheByRelid(lfirst_oid(lc));
}
- ObjectAddressSet(address, ConstraintRelationId,
- HeapTupleGetOid(contuple));
+ ObjectAddressSet(address, ConstraintRelationId, currcon->oid);
}
else
address = InvalidObjectAddress;
validateForeignKeyConstraint(constrName, rel, refrel,
con->conindid,
- HeapTupleGetOid(tuple));
+ con->oid);
heap_close(refrel, NoLock);
/*
copy_con->convalidated = true;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
- InvokeObjectPostAlterHook(ConstraintRelationId,
- HeapTupleGetOid(tuple), 0);
+ InvokeObjectPostAlterHook(ConstraintRelationId, con->oid, 0);
heap_freetuple(copyTuple);
- ObjectAddressSet(address, ConstraintRelationId,
- HeapTupleGetOid(tuple));
+ ObjectAddressSet(address, ConstraintRelationId, con->oid);
}
else
address = InvalidObjectAddress; /* already validated */
&isnull);
if (isnull)
elog(ERROR, "null conbin for constraint %u",
- HeapTupleGetOid(constrtup));
+ constrForm->oid);
conbin = TextDatumGetCString(val);
origexpr = (Expr *) stringToNode(conbin);
exprstate = ExecPrepareExpr(origexpr, estate);
* Perform the actual constraint deletion
*/
conobj.classId = ConstraintRelationId;
- conobj.objectId = HeapTupleGetOid(tuple);
+ conobj.objectId = con->oid;
conobj.objectSubId = 0;
performDeletion(&conobj, behavior, 0);
/* Look up the target type (should not fail, since prep found it) */
typeTuple = typenameType(NULL, typeName, &targettypmod);
tform = (Form_pg_type) GETSTRUCT(typeTuple);
- targettype = HeapTupleGetOid(typeTuple);
+ targettype = tform->oid;
/* And the collation */
targetcollid = GetColumnDefCollation(NULL, def, targettype);
scan = heap_beginscan_catalog(rel, 1, key);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid relOid = HeapTupleGetOid(tuple);
- Form_pg_class relForm;
-
- relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Oid relOid = relForm->oid;
/*
* Do not move objects in pg_catalog as part of this, if an admin
parent->relname,
RelationGetRelationName(child_rel))));
- /* If parent has OIDs then child must have OIDs */
- if (parent_rel->rd_rel->relhasoids && !child_rel->rd_rel->relhasoids)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("table \"%s\" without OIDs cannot inherit from table \"%s\" with OIDs",
- RelationGetRelationName(child_rel),
- RelationGetRelationName(parent_rel))));
-
/*
* If child_rel has row-level triggers with transition tables, we
* currently don't allow it to become an inheritance child. See also
con = (Form_pg_constraint) GETSTRUCT(contup);
attr = heap_getattr(contup, Anum_pg_constraint_conbin, tupdesc, &isnull);
if (isnull)
- elog(ERROR, "null conbin for constraint %u", HeapTupleGetOid(contup));
+ elog(ERROR, "null conbin for constraint %u", con->oid);
expr = DirectFunctionCall2(pg_get_expr, attr,
ObjectIdGetDatum(con->conrelid));
}
}
- /*
- * If the parent has an OID column, so must the child, and we'd better
- * update the child's attinhcount and attislocal the same as for normal
- * columns. We needn't check data type or not-nullness though.
- */
- if (tupleDesc->tdhasoid)
- {
- /*
- * Here we match by column number not name; the match *must* be the
- * system column, not some random column named "oid".
- */
- tuple = SearchSysCacheCopy2(ATTNUM,
- ObjectIdGetDatum(RelationGetRelid(child_rel)),
- Int16GetDatum(ObjectIdAttributeNumber));
- if (HeapTupleIsValid(tuple))
- {
- Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple);
-
- /* See comments above; these changes should be the same */
- childatt->attinhcount++;
-
- if (child_is_partition)
- {
- Assert(childatt->attinhcount == 1);
- childatt->attislocal = false;
- }
-
- CatalogTupleUpdate(attrrel, &tuple->t_self, tuple);
- heap_freetuple(tuple);
- }
- else
- {
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("child table is missing column \"%s\"",
- "oid")));
- }
- }
-
heap_close(attrrel, RowExclusiveLock);
}
{
Oid relid = RelationGetRelid(rel);
Type typetuple;
+ Form_pg_type typeform;
Oid typeid;
Relation inheritsRelation,
relationRelation;
/* Validate the type. */
typetuple = typenameType(NULL, ofTypename, NULL);
check_of_type(typetuple);
- typeid = HeapTupleGetOid(typetuple);
+ typeform = (Form_pg_type) GETSTRUCT(typetuple);
+ typeid = typeform->oid;
/* Fail if the table has any inheritance parents. */
inheritsRelation = heap_open(InheritsRelationId, AccessShareLock);
/*
* Check the tuple descriptors for compatibility. Unlike inheritance, we
* require that the order also match. However, attnotnull need not match.
- * Also unlike inheritance, we do not require matching relhasoids.
*/
typeTupleDesc = lookup_rowtype_tupdesc(typeid, -1);
tableTupleDesc = RelationGetDescr(rel);
int16 attno = indexRel->rd_index->indkey.values[key];
Form_pg_attribute attr;
- /* Allow OID column to be indexed; it's certainly not nullable */
- if (attno == ObjectIdAttributeNumber)
- continue;
-
/*
* Reject any other system columns. (Going forward, we'll disallow
* indexes containing such columns in the first place, but they might
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot attach temporary relation of another session as partition")));
- /* If parent has OIDs then child must have OIDs */
- if (rel->rd_rel->relhasoids && !attachrel->rd_rel->relhasoids)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("cannot attach table \"%s\" without OIDs as partition of"
- " table \"%s\" with OIDs", RelationGetRelationName(attachrel),
- RelationGetRelationName(rel))));
-
- /* OTOH, if parent doesn't have them, do not allow in attachrel either */
- if (attachrel->rd_rel->relhasoids && !rel->rd_rel->relhasoids)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("cannot attach table \"%s\" with OIDs as partition of table"
- " \"%s\" without OIDs", RelationGetRelationName(attachrel),
- RelationGetRelationName(rel))));
-
/* Check if there are any columns in attachrel that aren't in the parent */
tupleDesc = RelationGetDescr(attachrel);
natts = tupleDesc->natts;
CreateTrigger(trigStmt, NULL, RelationGetRelid(partition),
trigForm->tgconstrrelid, InvalidOid, InvalidOid,
- trigForm->tgfoid, HeapTupleGetOid(tuple), qual,
+ trigForm->tgfoid, trigForm->oid, qual,
false, true);
MemoryContextReset(perTupCxt);
MemSet(nulls, false, sizeof(nulls));
+ tablespaceoid = GetNewOidWithIndex(rel, TablespaceOidIndexId,
+ Anum_pg_tablespace_oid);
+ values[Anum_pg_tablespace_oid - 1] = ObjectIdGetDatum(tablespaceoid);
values[Anum_pg_tablespace_spcname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->tablespacename));
values[Anum_pg_tablespace_spcowner - 1] =
tuple = heap_form_tuple(rel->rd_att, values, nulls);
- tablespaceoid = CatalogTupleInsert(rel, tuple);
+ CatalogTupleInsert(rel, tuple);
heap_freetuple(tuple);
HeapScanDesc scandesc;
Relation rel;
HeapTuple tuple;
+ Form_pg_tablespace spcform;
ScanKeyData entry[1];
Oid tablespaceoid;
return;
}
- tablespaceoid = HeapTupleGetOid(tuple);
+ spcform = (Form_pg_tablespace) GETSTRUCT(tuple);
+ tablespaceoid = spcform->oid;
/* Must be tablespace owner */
if (!pg_tablespace_ownercheck(tablespaceoid, GetUserId()))
errmsg("tablespace \"%s\" does not exist",
oldname)));
- tspId = HeapTupleGetOid(tup);
newtuple = heap_copytuple(tup);
newform = (Form_pg_tablespace) GETSTRUCT(newtuple);
+ tspId = newform->oid;
heap_endscan(scan);
/* Must be owner */
- if (!pg_tablespace_ownercheck(HeapTupleGetOid(newtuple), GetUserId()))
+ if (!pg_tablespace_ownercheck(tspId, GetUserId()))
aclcheck_error(ACLCHECK_NO_PRIV, OBJECT_TABLESPACE, oldname);
/* Validate new name */
errmsg("tablespace \"%s\" does not exist",
stmt->tablespacename)));
- tablespaceoid = HeapTupleGetOid(tup);
+ tablespaceoid = ((Form_pg_tablespace) GETSTRUCT(tup))->oid;
/* Must be owner of the existing object */
- if (!pg_tablespace_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+ if (!pg_tablespace_ownercheck(tablespaceoid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLESPACE,
stmt->tablespacename);
/* Update system catalog. */
CatalogTupleUpdate(rel, &newtuple->t_self, newtuple);
- InvokeObjectPostAlterHook(TableSpaceRelationId, HeapTupleGetOid(tup), 0);
+ InvokeObjectPostAlterHook(TableSpaceRelationId, tablespaceoid, 0);
heap_freetuple(newtuple);
/* We assume that there can be at most one matching tuple */
if (HeapTupleIsValid(tuple))
- result = HeapTupleGetOid(tuple);
+ result = ((Form_pg_tablespace) GETSTRUCT(tuple))->oid;
else
result = InvalidOid;
rel = heap_open(TableSpaceRelationId, AccessShareLock);
ScanKeyInit(&entry[0],
- ObjectIdAttributeNumber,
+ Anum_pg_tablespace_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(spc_oid));
scandesc = heap_beginscan_catalog(rel, 1, entry);
*/
tgrel = heap_open(TriggerRelationId, RowExclusiveLock);
- trigoid = GetNewOid(tgrel);
+ trigoid = GetNewOidWithIndex(tgrel, TriggerOidIndexId,
+ Anum_pg_trigger_oid);
/*
* If trigger is internally generated, modify the provided trigger name to
*/
memset(nulls, false, sizeof(nulls));
+ values[Anum_pg_trigger_oid - 1] = ObjectIdGetDatum(trigoid);
values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(RelationGetRelid(rel));
values[Anum_pg_trigger_tgname - 1] = DirectFunctionCall1(namein,
CStringGetDatum(trigname));
tuple = heap_form_tuple(tgrel->rd_att, values, nulls);
- /* force tuple to have the desired OID */
- HeapTupleSetOid(tuple, trigoid);
-
/*
* Insert tuple into pg_trigger.
*/
* Find the trigger to delete.
*/
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_trigger_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(trigOid));
}
else
{
- oid = HeapTupleGetOid(tup);
+ oid = ((Form_pg_trigger) GETSTRUCT(tup))->oid;
}
systable_endscan(tgscan);
NULL, 2, key);
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
- tgoid = HeapTupleGetOid(tuple);
+ Form_pg_trigger trigform = (Form_pg_trigger) GETSTRUCT(tuple);
+
+ tgoid = trigform->oid;
/*
* Update pg_trigger tuple with new tgname.
*/
tuple = heap_copytuple(tuple); /* need a modifiable copy */
- namestrcpy(&((Form_pg_trigger) GETSTRUCT(tuple))->tgname,
+ namestrcpy(&trigform->tgname,
stmt->newname);
CatalogTupleUpdate(tgrel, &tuple->t_self, tuple);
InvokeObjectPostAlterHook(TriggerRelationId,
- HeapTupleGetOid(tuple), 0);
+ tgoid, 0);
/*
* Invalidate relation's relcache entry so that other backends (and
}
InvokeObjectPostAlterHook(TriggerRelationId,
- HeapTupleGetOid(tuple), 0);
+ oldtrig->oid, 0);
}
systable_endscan(tgscan);
}
build = &(triggers[numtrigs]);
- build->tgoid = HeapTupleGetOid(htup);
+ build->tgoid = pg_trigger->oid;
build->tgname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&pg_trigger->tgname)));
build->tgfoid = pg_trigger->tgfoid;
Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup);
if (con->condeferrable)
- conoidlist = lappend_oid(conoidlist,
- HeapTupleGetOid(tup));
+ conoidlist = lappend_oid(conoidlist, con->oid);
else if (stmt->deferred)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
scan = systable_beginscan(conrel, ConstraintParentIndexId, true, NULL, 1, &key);
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
- conoidlist = lappend_oid(conoidlist, HeapTupleGetOid(tuple));
+ {
+ Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple);
+
+ conoidlist = lappend_oid(conoidlist, con->oid);
+ }
systable_endscan(scan);
}
* actions.
*/
if (pg_trigger->tgdeferrable)
- tgoidlist = lappend_oid(tgoidlist,
- HeapTupleGetOid(htup));
+ tgoidlist = lappend_oid(tgoidlist, pg_trigger->oid);
found = true;
}
#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/objectaccess.h"
referenced;
myself.classId = TSParserRelationId;
- myself.objectId = HeapTupleGetOid(tuple);
+ myself.objectId = prs->oid;
myself.objectSubId = 0;
/* dependency on namespace */
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to create text search parsers")));
+ prsRel = heap_open(TSParserRelationId, RowExclusiveLock);
+
/* Convert list of names to a name and namespace */
namespaceoid = QualifiedNameGetCreationNamespace(names, &prsname);
memset(values, 0, sizeof(values));
memset(nulls, false, sizeof(nulls));
+ prsOid = GetNewOidWithIndex(prsRel, TSParserOidIndexId,
+ Anum_pg_ts_parser_oid);
+ values[Anum_pg_ts_parser_oid - 1] = ObjectIdGetDatum(prsOid);
namestrcpy(&pname, prsname);
values[Anum_pg_ts_parser_prsname - 1] = NameGetDatum(&pname);
values[Anum_pg_ts_parser_prsnamespace - 1] = ObjectIdGetDatum(namespaceoid);
/*
* Looks good, insert
*/
- prsRel = heap_open(TSParserRelationId, RowExclusiveLock);
-
tup = heap_form_tuple(prsRel->rd_att, values, nulls);
- prsOid = CatalogTupleInsert(prsRel, tup);
+ CatalogTupleInsert(prsRel, tup);
address = makeParserDependencies(tup);
referenced;
myself.classId = TSDictionaryRelationId;
- myself.objectId = HeapTupleGetOid(tuple);
+ myself.objectId = dict->oid;
myself.objectSubId = 0;
/* dependency on namespace */
verify_dictoptions(templId, dictoptions);
+
+ dictRel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
+
/*
* Looks good, insert
*/
memset(values, 0, sizeof(values));
memset(nulls, false, sizeof(nulls));
+ dictOid = GetNewOidWithIndex(dictRel, TSDictionaryOidIndexId,
+ Anum_pg_ts_dict_oid);
+ values[Anum_pg_ts_dict_oid - 1] = ObjectIdGetDatum(dictOid);
namestrcpy(&dname, dictname);
values[Anum_pg_ts_dict_dictname - 1] = NameGetDatum(&dname);
values[Anum_pg_ts_dict_dictnamespace - 1] = ObjectIdGetDatum(namespaceoid);
else
nulls[Anum_pg_ts_dict_dictinitoption - 1] = true;
- dictRel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
-
tup = heap_form_tuple(dictRel->rd_att, values, nulls);
- dictOid = CatalogTupleInsert(dictRel, tup);
+ CatalogTupleInsert(dictRel, tup);
address = makeDictionaryDependencies(tup);
referenced;
myself.classId = TSTemplateRelationId;
- myself.objectId = HeapTupleGetOid(tuple);
+ myself.objectId = tmpl->oid;
myself.objectSubId = 0;
/* dependency on namespace */
/* Convert list of names to a name and namespace */
namespaceoid = QualifiedNameGetCreationNamespace(names, &tmplname);
+ tmplRel = heap_open(TSTemplateRelationId, RowExclusiveLock);
+
for (i = 0; i < Natts_pg_ts_template; i++)
{
nulls[i] = false;
values[i] = ObjectIdGetDatum(InvalidOid);
}
+ tmplOid = GetNewOidWithIndex(tmplRel, TSTemplateOidIndexId,
+ Anum_pg_ts_dict_oid);
+ values[Anum_pg_ts_template_oid - 1] = ObjectIdGetDatum(tmplOid);
namestrcpy(&dname, tmplname);
values[Anum_pg_ts_template_tmplname - 1] = NameGetDatum(&dname);
values[Anum_pg_ts_template_tmplnamespace - 1] = ObjectIdGetDatum(namespaceoid);
/*
* Looks good, insert
*/
-
- tmplRel = heap_open(TSTemplateRelationId, RowExclusiveLock);
-
tup = heap_form_tuple(tmplRel->rd_att, values, nulls);
- tmplOid = CatalogTupleInsert(tmplRel, tup);
+ CatalogTupleInsert(tmplRel, tup);
address = makeTSTemplateDependencies(tup);
referenced;
myself.classId = TSConfigRelationId;
- myself.objectId = HeapTupleGetOid(tuple);
+ myself.objectId = cfg->oid;
myself.objectSubId = 0;
/* for ALTER case, first flush old dependencies, except extension deps */
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("text search parser is required")));
+ cfgRel = heap_open(TSConfigRelationId, RowExclusiveLock);
+
/*
* Looks good, build tuple and insert
*/
memset(values, 0, sizeof(values));
memset(nulls, false, sizeof(nulls));
+ cfgOid = GetNewOidWithIndex(cfgRel, TSConfigOidIndexId,
+ Anum_pg_ts_config_oid);
+ values[Anum_pg_ts_config_oid - 1] = ObjectIdGetDatum(cfgOid);
namestrcpy(&cname, cfgname);
values[Anum_pg_ts_config_cfgname - 1] = NameGetDatum(&cname);
values[Anum_pg_ts_config_cfgnamespace - 1] = ObjectIdGetDatum(namespaceoid);
values[Anum_pg_ts_config_cfgowner - 1] = ObjectIdGetDatum(GetUserId());
values[Anum_pg_ts_config_cfgparser - 1] = ObjectIdGetDatum(prsOid);
- cfgRel = heap_open(TSConfigRelationId, RowExclusiveLock);
-
tup = heap_form_tuple(cfgRel->rd_att, values, nulls);
- cfgOid = CatalogTupleInsert(cfgRel, tup);
+ CatalogTupleInsert(cfgRel, tup);
if (OidIsValid(sourceOid))
{
errmsg("text search configuration \"%s\" does not exist",
NameListToString(stmt->cfgname))));
- cfgId = HeapTupleGetOid(tup);
+ cfgId = ((Form_pg_ts_config) GETSTRUCT(tup))->oid;
/* must be owner */
- if (!pg_ts_config_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+ if (!pg_ts_config_ownercheck(cfgId, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TSCONFIGURATION,
NameListToString(stmt->cfgname));
/* Update dependencies */
makeConfigurationDependencies(tup, true, relMap);
- InvokeObjectPostAlterHook(TSConfigRelationId,
- HeapTupleGetOid(tup), 0);
+ InvokeObjectPostAlterHook(TSConfigRelationId, cfgId, 0);
ObjectAddressSet(address, TSConfigRelationId, cfgId);
MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
HeapTuple tup, Relation relMap)
{
- Oid cfgId = HeapTupleGetOid(tup);
+ Form_pg_ts_config tsform;
+ Oid cfgId;
ScanKeyData skey[2];
SysScanDesc scan;
HeapTuple maptup;
int ndict;
ListCell *c;
- prsId = ((Form_pg_ts_config) GETSTRUCT(tup))->cfgparser;
+ tsform = (Form_pg_ts_config) GETSTRUCT(tup);
+ cfgId = tsform->oid;
+ prsId = tsform->cfgparser;
tokens = getTokenTypes(prsId, stmt->tokentype);
ntoken = list_length(stmt->tokentype);
DropConfigurationMapping(AlterTSConfigurationStmt *stmt,
HeapTuple tup, Relation relMap)
{
- Oid cfgId = HeapTupleGetOid(tup);
+ Form_pg_ts_config tsform;
+ Oid cfgId;
ScanKeyData skey[2];
SysScanDesc scan;
HeapTuple maptup;
int *tokens;
ListCell *c;
- prsId = ((Form_pg_ts_config) GETSTRUCT(tup))->cfgparser;
+ tsform = (Form_pg_ts_config) GETSTRUCT(tup);
+ cfgId = tsform->oid;
+ prsId = tsform->cfgparser;
tokens = getTokenTypes(prsId, stmt->tokentype);
* Look to see if type already exists (presumably as a shell; if not,
* TypeCreate will complain).
*/
- typoid = GetSysCacheOid2(TYPENAMENSP,
+ typoid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
CStringGetDatum(typeName),
ObjectIdGetDatum(typeNamespace));
* Check for collision with an existing type name. If there is one and
* it's an autogenerated array, we can rename it out of the way.
*/
- old_type_oid = GetSysCacheOid2(TYPENAMENSP,
+ old_type_oid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
CStringGetDatum(domainName),
ObjectIdGetDatum(domainNamespace));
if (OidIsValid(old_type_oid))
*/
typeTup = typenameType(NULL, stmt->typeName, &basetypeMod);
baseType = (Form_pg_type) GETSTRUCT(typeTup);
- basetypeoid = HeapTupleGetOid(typeTup);
+ basetypeoid = baseType->oid;
/*
* Base type must be a plain base type, a composite type, another domain,
* Check for collision with an existing type name. If there is one and
* it's an autogenerated array, we can rename it out of the way.
*/
- old_type_oid = GetSysCacheOid2(TYPENAMENSP,
+ old_type_oid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
CStringGetDatum(enumName),
ObjectIdGetDatum(enumNamespace));
if (OidIsValid(old_type_oid))
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("%s is not an enum",
- format_type_be(HeapTupleGetOid(tup)))));
+ format_type_be(typTup->oid))));
/* Permission check: must own type */
- if (!pg_type_ownercheck(HeapTupleGetOid(tup), GetUserId()))
- aclcheck_error_type(ACLCHECK_NOT_OWNER, HeapTupleGetOid(tup));
+ if (!pg_type_ownercheck(typTup->oid, GetUserId()))
+ aclcheck_error_type(ACLCHECK_NOT_OWNER, typTup->oid);
}
/*
* Look to see if type already exists.
*/
- typoid = GetSysCacheOid2(TYPENAMENSP,
+ typoid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
CStringGetDatum(typeName),
ObjectIdGetDatum(typeNamespace));
{
Relation pg_type = heap_open(TypeRelationId, AccessShareLock);
- type_array_oid = GetNewOid(pg_type);
+ type_array_oid = GetNewOidWithIndex(pg_type, TypeOidIndexId,
+ Anum_pg_type_oid);
heap_close(pg_type, AccessShareLock);
}
NoLock, NULL);
RangeVarAdjustRelationPersistence(createStmt->relation, typeNamespace);
old_type_oid =
- GetSysCacheOid2(TYPENAMENSP,
+ GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
CStringGetDatum(createStmt->relation->relname),
ObjectIdGetDatum(typeNamespace));
if (OidIsValid(old_type_oid))
ObjectAddress conobj;
conobj.classId = ConstraintRelationId;
- conobj.objectId = HeapTupleGetOid(contup);
+ conobj.objectId = ((Form_pg_constraint) GETSTRUCT(contup))->oid;
conobj.objectSubId = 0;
performDeletion(&conobj, behavior, 0);
&isnull);
if (isnull)
elog(ERROR, "null conbin for constraint %u",
- HeapTupleGetOid(tuple));
+ con->oid);
conbin = TextDatumGetCString(val);
validateDomainConstraint(domainoid, conbin);
copy_con->convalidated = true;
CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple);
- InvokeObjectPostAlterHook(ConstraintRelationId,
- HeapTupleGetOid(copyTuple), 0);
+ InvokeObjectPostAlterHook(ConstraintRelationId, con->oid, 0);
ObjectAddressSet(address, TypeRelationId, domainoid);
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("%s is not a domain",
- format_type_be(HeapTupleGetOid(tup)))));
+ format_type_be(typTup->oid))));
/* Permission check: must own type */
- if (!pg_type_ownercheck(HeapTupleGetOid(tup), GetUserId()))
- aclcheck_error_type(ACLCHECK_NOT_OWNER, HeapTupleGetOid(tup));
+ if (!pg_type_ownercheck(typTup->oid, GetUserId()))
+ aclcheck_error_type(ACLCHECK_NOT_OWNER, typTup->oid);
}
/*
if (!superuser())
{
/* Otherwise, must be owner of the existing object */
- if (!pg_type_ownercheck(HeapTupleGetOid(tup), GetUserId()))
- aclcheck_error_type(ACLCHECK_NOT_OWNER, HeapTupleGetOid(tup));
+ if (!pg_type_ownercheck(typTup->oid, GetUserId()))
+ aclcheck_error_type(ACLCHECK_NOT_OWNER, typTup->oid);
/* Must be able to become new owner */
check_is_member_of_role(GetUserId(), newOwnerId);
new_record[Anum_pg_authid_rolbypassrls - 1] = BoolGetDatum(bypassrls);
- tuple = heap_form_tuple(pg_authid_dsc, new_record, new_record_nulls);
-
/*
* pg_largeobject_metadata contains pg_authid.oid's, so we use the
* binary-upgrade override.
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("pg_authid OID value not set when in binary upgrade mode")));
- HeapTupleSetOid(tuple, binary_upgrade_next_pg_authid_oid);
+ roleid = binary_upgrade_next_pg_authid_oid;
binary_upgrade_next_pg_authid_oid = InvalidOid;
}
+ else
+ {
+ roleid = GetNewOidWithIndex(pg_authid_rel, AuthIdOidIndexId,
+ Anum_pg_authid_oid);
+ }
+
+ new_record[Anum_pg_authid_oid - 1] = ObjectIdGetDatum(roleid);
+
+ tuple = heap_form_tuple(pg_authid_dsc, new_record, new_record_nulls);
/*
* Insert new record in the pg_authid table
*/
- roleid = CatalogTupleInsert(pg_authid_rel, tuple);
+ CatalogTupleInsert(pg_authid_rel, tuple);
/*
* Advance command counter so we can see new record; else tests in
{
RoleSpec *oldrole = lfirst(item);
HeapTuple oldroletup = get_rolespec_tuple(oldrole);
- Oid oldroleid = HeapTupleGetOid(oldroletup);
- char *oldrolename = NameStr(((Form_pg_authid) GETSTRUCT(oldroletup))->rolname);
+ Form_pg_authid oldroleform = (Form_pg_authid) GETSTRUCT(oldroletup);
+ Oid oldroleid = oldroleform->oid;
+ char *oldrolename = NameStr(oldroleform->rolname);
AddRoleMems(oldrolename, oldroleid,
list_make1(makeString(stmt->role)),
tuple = get_rolespec_tuple(stmt->role);
authform = (Form_pg_authid) GETSTRUCT(tuple);
rolename = pstrdup(NameStr(authform->rolname));
- roleid = HeapTupleGetOid(tuple);
+ roleid = authform->oid;
/*
* To mess with a superuser you gotta be superuser; else you need
AlterRoleSet(AlterRoleSetStmt *stmt)
{
HeapTuple roletuple;
+ Form_pg_authid roleform;
Oid databaseid = InvalidOid;
Oid roleid = InvalidOid;
"Cannot alter reserved roles.");
roletuple = get_rolespec_tuple(stmt->role);
- roleid = HeapTupleGetOid(roletuple);
+ roleform = (Form_pg_authid) GETSTRUCT(roletuple);
+ roleid = roleform->oid;
/*
* Obtain a lock on the role and make sure it didn't go away in the
* meantime.
*/
- shdepLockAndCheckObject(AuthIdRelationId, HeapTupleGetOid(roletuple));
+ shdepLockAndCheckObject(AuthIdRelationId, roleid);
/*
* To mess with a superuser you gotta be superuser; else you need
* createrole, or just want to change your own settings
*/
- if (((Form_pg_authid) GETSTRUCT(roletuple))->rolsuper)
+ if (roleform->rolsuper)
{
if (!superuser())
ereport(ERROR,
}
else
{
- if (!have_createrole_privilege() &&
- HeapTupleGetOid(roletuple) != GetUserId())
+ if (!have_createrole_privilege() && roleid != GetUserId())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied")));
char *role;
HeapTuple tuple,
tmp_tuple;
+ Form_pg_authid roleform;
ScanKeyData scankey;
char *detail;
char *detail_log;
continue;
}
- roleid = HeapTupleGetOid(tuple);
+ roleform = (Form_pg_authid) GETSTRUCT(tuple);
+ roleid = roleform->oid;
if (roleid == GetUserId())
ereport(ERROR,
* roles but not superuser roles. This is mainly to avoid the
* scenario where you accidentally drop the last superuser.
*/
- if (((Form_pg_authid) GETSTRUCT(tuple))->rolsuper &&
- !superuser())
+ if (roleform->rolsuper && !superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to drop superusers")));
* effective userid, though.
*/
- roleid = HeapTupleGetOid(oldtuple);
authform = (Form_pg_authid) GETSTRUCT(oldtuple);
+ roleid = authform->oid;
if (roleid == GetSessionUserId())
ereport(ERROR,
{
Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
MemoryContext oldcontext;
- Oid relid = HeapTupleGetOid(tuple);
+ Oid relid = classForm->oid;
/* check permissions of relation */
if (!vacuum_is_relation_owner(relid, classForm, options))
else if (TransactionIdPrecedes(datfrozenxid, frozenXID))
{
frozenXID = datfrozenxid;
- oldestxid_datoid = HeapTupleGetOid(tuple);
+ oldestxid_datoid = dbform->oid;
}
if (MultiXactIdPrecedes(datminmxid, minMulti))
{
minMulti = datminmxid;
- minmulti_datoid = HeapTupleGetOid(tuple);
+ minmulti_datoid = dbform->oid;
}
}
all_visible = false;
break;
case HEAPTUPLE_LIVE:
- /* Tuple is good --- but let's do some validity checks */
- if (onerel->rd_rel->relhasoids &&
- !OidIsValid(HeapTupleGetOid(&tuple)))
- elog(WARNING, "relation \"%s\" TID %u/%u: OID is invalid",
- relname, blkno, offnum);
-
/*
* Count it as live. Not only is this natural, but it's
* also what acquire_sample_rows() does.
check_session_authorization(char **newval, void **extra, GucSource source)
{
HeapTuple roleTup;
+ Form_pg_authid roleform;
Oid roleid;
bool is_superuser;
role_auth_extra *myextra;
return false;
}
- roleid = HeapTupleGetOid(roleTup);
- is_superuser = ((Form_pg_authid) GETSTRUCT(roleTup))->rolsuper;
+ roleform = (Form_pg_authid) GETSTRUCT(roleTup);
+ roleid = roleform->oid;
+ is_superuser = roleform->rolsuper;
ReleaseSysCache(roleTup);
Oid roleid;
bool is_superuser;
role_auth_extra *myextra;
+ Form_pg_authid roleform;
if (strcmp(*newval, "none") == 0)
{
return false;
}
- roleid = HeapTupleGetOid(roleTup);
- is_superuser = ((Form_pg_authid) GETSTRUCT(roleTup))->rolsuper;
+ roleform = (Form_pg_authid) GETSTRUCT(roleTup);
+ roleid = roleform->oid;
+ is_superuser = roleform->rolsuper;
ReleaseSysCache(roleTup);
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("cannot drop columns from view")));
- /* we can ignore tdhasoid */
for (i = 0; i < olddesc->natts; i++)
{
{
scratch->d.wholerow.junkFilter =
ExecInitJunkFilter(subplan->plan->targetlist,
- ExecGetResultType(subplan)->tdhasoid,
ExecInitExtraTupleSlot(parent->state, NULL,
&TTSOpsVirtual));
}
* Initialize the Junk filter.
*
* The source targetlist is passed in. The output tuple descriptor is
- * built from the non-junk tlist entries, plus the passed specification
- * of whether to include room for an OID or not.
+ * built from the non-junk tlist entries.
* An optional resultSlot can be passed as well.
*/
JunkFilter *
-ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot)
+ExecInitJunkFilter(List *targetList, TupleTableSlot *slot)
{
JunkFilter *junkfilter;
TupleDesc cleanTupType;
/*
* Compute the tuple descriptor for the cleaned tuple.
*/
- cleanTupType = ExecCleanTypeFromTL(targetList, hasoid);
+ cleanTupType = ExecCleanTypeFromTL(targetList);
/*
* Use the given slot, or make a new slot if we weren't given one.
* startup tuple receiver, if we will be emitting tuples
*/
estate->es_processed = 0;
- estate->es_lastoid = InvalidOid;
sendTuples = (operation == CMD_SELECT ||
queryDesc->plannedstmt->hasReturning);
slot = ExecInitExtraTupleSlot(estate, NULL, &TTSOpsVirtual);
j = ExecInitJunkFilter(planstate->plan->targetlist,
- tupType->tdhasoid,
slot);
estate->es_junkFilter = j;
}
}
-/*
- * ExecContextForcesOids
- *
- * This is pretty grotty: when doing INSERT, UPDATE, or CREATE TABLE AS,
- * we need to ensure that result tuples have space for an OID iff they are
- * going to be stored into a relation that has OIDs. In other contexts
- * we are free to choose whether to leave space for OIDs in result tuples
- * (we generally don't want to, but we do if a physical-tlist optimization
- * is possible). This routine checks the plan context and returns true if the
- * choice is forced, false if the choice is not forced. In the true case,
- * *hasoids is set to the required value.
- *
- * One reason this is ugly is that all plan nodes in the plan tree will emit
- * tuples with space for an OID, though we really only need the topmost node
- * to do so. However, node types like Sort don't project new tuples but just
- * return their inputs, and in those cases the requirement propagates down
- * to the input node. Eventually we might make this code smart enough to
- * recognize how far down the requirement really goes, but for now we just
- * make all plan nodes do the same thing if the top level forces the choice.
- *
- * We assume that if we are generating tuples for INSERT or UPDATE,
- * estate->es_result_relation_info is already set up to describe the target
- * relation. Note that in an UPDATE that spans an inheritance tree, some of
- * the target relations may have OIDs and some not. We have to make the
- * decisions on a per-relation basis as we initialize each of the subplans of
- * the ModifyTable node, so ModifyTable has to set es_result_relation_info
- * while initializing each subplan.
- *
- * CREATE TABLE AS is even uglier, because we don't have the target relation's
- * descriptor available when this code runs; we have to look aside at the
- * flags passed to ExecutorStart().
- */
-bool
-ExecContextForcesOids(PlanState *planstate, bool *hasoids)
-{
- ResultRelInfo *ri = planstate->state->es_result_relation_info;
-
- if (ri != NULL)
- {
- Relation rel = ri->ri_RelationDesc;
-
- if (rel != NULL)
- {
- *hasoids = rel->rd_rel->relhasoids;
- return true;
- }
- }
-
- if (planstate->state->es_top_eflags & EXEC_FLAG_WITH_OIDS)
- {
- *hasoids = true;
- return true;
- }
- if (planstate->state->es_top_eflags & EXEC_FLAG_WITHOUT_OIDS)
- {
- *hasoids = false;
- return true;
- }
-
- return false;
-}
-
/* ----------------------------------------------------------------
* ExecPostprocessPlan
*
* partition that's tupdesc-equal to the partitioned table;
* partitions of different tupdescs must generate their own.
*/
- tupDesc = ExecTypeFromTL(onconflset, partrelDesc->tdhasoid);
+ tupDesc = ExecTypeFromTL(onconflset);
ExecSetSlotDescriptor(mtstate->mt_conflproj, tupDesc);
leaf_part_rri->ri_onConflict->oc_ProjInfo =
ExecBuildProjectionInfo(onconflset, econtext,
rsinfo.setResult = tupstore;
if (!returnsTuple)
{
- tupdesc = CreateTemplateTupleDesc(1, false);
+ tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitEntry(tupdesc,
(AttrNumber) 1,
"column",
else if (functypclass == TYPEFUNC_SCALAR)
{
/* Base data type, i.e. scalar */
- tupdesc = CreateTemplateTupleDesc(1, false);
+ tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitEntry(tupdesc,
(AttrNumber) 1,
NULL,
static TupleDesc ExecTypeFromTLInternal(List *targetList,
- bool hasoid, bool skipjunk);
+ bool skipjunk);
static pg_attribute_always_inline void
slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
int natts);
void
ExecInitResultTypeTL(PlanState *planstate)
{
- bool hasoid;
- TupleDesc tupDesc;
-
- if (ExecContextForcesOids(planstate, &hasoid))
- {
- /* context forces OID choice; hasoid is now set correctly */
- }
- else
- {
- /* given free choice, don't leave space for OIDs in result tuples */
- hasoid = false;
- }
+ TupleDesc tupDesc = ExecTypeFromTL(planstate->plan->targetlist);
- tupDesc = ExecTypeFromTL(planstate->plan->targetlist, hasoid);
+ tupDesc = ExecTypeFromTL(planstate->plan->targetlist);
planstate->ps_ResultTupleDesc = tupDesc;
}
* ----------------------------------------------------------------
*/
TupleDesc
-ExecTypeFromTL(List *targetList, bool hasoid)
+ExecTypeFromTL(List *targetList)
{
- return ExecTypeFromTLInternal(targetList, hasoid, false);
+ return ExecTypeFromTLInternal(targetList, false);
}
/* ----------------------------------------------------------------
* ----------------------------------------------------------------
*/
TupleDesc
-ExecCleanTypeFromTL(List *targetList, bool hasoid)
+ExecCleanTypeFromTL(List *targetList)
{
- return ExecTypeFromTLInternal(targetList, hasoid, true);
+ return ExecTypeFromTLInternal(targetList, true);
}
static TupleDesc
-ExecTypeFromTLInternal(List *targetList, bool hasoid, bool skipjunk)
+ExecTypeFromTLInternal(List *targetList, bool skipjunk)
{
TupleDesc typeInfo;
ListCell *l;
len = ExecCleanTargetListLength(targetList);
else
len = ExecTargetListLength(targetList);
- typeInfo = CreateTemplateTupleDesc(len, hasoid);
+ typeInfo = CreateTemplateTupleDesc(len);
foreach(l, targetList)
{
ListCell *lc;
int cur_resno = 1;
- typeInfo = CreateTemplateTupleDesc(list_length(exprList), false);
+ typeInfo = CreateTemplateTupleDesc(list_length(exprList));
foreach(lc, exprList)
{
estate->es_tupleTable = NIL;
estate->es_processed = 0;
- estate->es_lastoid = InvalidOid;
estate->es_top_eflags = 0;
estate->es_instrument = 0;
{
int numattrs = tupdesc->natts;
int attrno;
- bool hasoid;
ListCell *tlist_item = list_head(tlist);
/* Check the tlist attributes */
if (tlist_item)
return false; /* tlist too long */
- /*
- * If the plan context requires a particular hasoid setting, then that has
- * to match, too.
- */
- if (ExecContextForcesOids(ps, &hasoid) &&
- hasoid != tupdesc->tdhasoid)
- return false;
-
return true;
}
/* Set up junk filter if needed */
if (junkFilter)
- *junkFilter = ExecInitJunkFilter(tlist, false,
+ *junkFilter = ExecInitJunkFilter(tlist,
MakeSingleTupleTableSlot(NULL, &TTSOpsMinimalTuple));
}
else if (fn_typtype == TYPTYPE_COMPOSITE || rettype == RECORDOID)
TupleTableSlot *slot =
MakeSingleTupleTableSlot(NULL, &TTSOpsMinimalTuple);
- *junkFilter = ExecInitJunkFilter(tlist, false, slot);
+ *junkFilter = ExecInitJunkFilter(tlist, slot);
}
return false; /* NOT returning whole tuple */
}
TupleTableSlot *slot;
slot = MakeSingleTupleTableSlot(NULL, &TTSOpsMinimalTuple);
- *junkFilter = ExecInitJunkFilter(tlist, false, slot);
+ *junkFilter = ExecInitJunkFilter(tlist, slot);
}
return true;
}
Max(varNumber + 1, perhash->largestGrpColIdx);
}
- hashDesc = ExecTypeFromTL(hashTlist, false);
+ hashDesc = ExecTypeFromTL(hashTlist);
execTuplesHashPrepare(perhash->numCols,
perhash->aggnode->grpOperators,
*/
if (numSortCols > 0 || aggref->aggfilter)
{
- pertrans->sortdesc = ExecTypeFromTL(aggref->args, false);
+ pertrans->sortdesc = ExecTypeFromTL(aggref->args);
pertrans->sortslot =
ExecInitExtraTupleSlot(estate, pertrans->sortdesc,
&TTSOpsMinimalTuple);
{
TupleDesc scan_tupdesc;
- scan_tupdesc = ExecTypeFromTL(cscan->custom_scan_tlist, false);
+ scan_tupdesc = ExecTypeFromTL(cscan->custom_scan_tlist);
ExecInitScanTupleSlot(estate, &css->ss, scan_tupdesc, &TTSOpsVirtual);
/* Node's targetlist will contain Vars with varno = INDEX_VAR */
tlistvarno = INDEX_VAR;
{
TupleDesc scan_tupdesc;
- scan_tupdesc = ExecTypeFromTL(node->fdw_scan_tlist, false);
+ scan_tupdesc = ExecTypeFromTL(node->fdw_scan_tlist);
ExecInitScanTupleSlot(estate, &scanstate->ss, scan_tupdesc,
&TTSOpsHeapTuple);
/* Node's targetlist will contain Vars with varno = INDEX_VAR */
else if (functypclass == TYPEFUNC_SCALAR)
{
/* Base data type, i.e. scalar */
- tupdesc = CreateTemplateTupleDesc(1, false);
+ tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitEntry(tupdesc,
(AttrNumber) 1,
NULL, /* don't care about the name here */
if (node->funcordinality)
natts++;
- scan_tupdesc = CreateTemplateTupleDesc(natts, false);
+ scan_tupdesc = CreateTemplateTupleDesc(natts);
for (i = 0; i < nfuncs; i++)
{
* types of the original datums. (It's the AM's responsibility to return
* suitable data anyway.)
*/
- tupDesc = ExecTypeFromTL(node->indextlist, false);
+ tupDesc = ExecTypeFromTL(node->indextlist);
ExecInitScanTupleSlot(estate, &indexstate->ss, tupDesc, &TTSOpsHeapTuple);
/*
#include "access/htup_details.h"
#include "access/xact.h"
+#include "catalog/catalog.h"
#include "commands/trigger.h"
#include "executor/execPartition.h"
#include "executor/executor.h"
HeapTuple tuple;
ResultRelInfo *resultRelInfo;
Relation resultRelationDesc;
- Oid newId;
List *recheckIndexes = NIL;
TupleTableSlot *result = NULL;
TransitionCaptureState *ar_insert_trig_tcs;
resultRelInfo = estate->es_result_relation_info;
resultRelationDesc = resultRelInfo->ri_RelationDesc;
- /*
- * If the result relation has OIDs, force the tuple's OID to zero so that
- * heap_insert will assign a fresh OID. Usually the OID already will be
- * zero at this point, but there are corner cases where the plan tree can
- * return a tuple extracted literally from some table with the same
- * rowtype.
- *
- * XXX if we ever wanted to allow users to assign their own OIDs to new
- * rows, this'd be the place to do it. For the moment, we make a point of
- * doing this before calling triggers, so that a user-supplied trigger
- * could hack the OID if desired.
- */
- if (resultRelationDesc->rd_rel->relhasoids)
- HeapTupleSetOid(tuple, InvalidOid);
-
/*
* BEFORE ROW INSERT Triggers.
*
/* trigger might have changed tuple */
tuple = ExecFetchSlotHeapTuple(slot, true, NULL);
-
- newId = InvalidOid;
}
else if (resultRelInfo->ri_FdwRoutine)
{
* tableoid column, so initialize t_tableOid before evaluating them.
*/
tuple->t_tableOid = RelationGetRelid(resultRelationDesc);
-
- newId = InvalidOid;
}
else
{
HeapTupleHeaderSetSpeculativeToken(tuple->t_data, specToken);
/* insert the tuple, with the speculative token */
- newId = heap_insert(resultRelationDesc, tuple,
- estate->es_output_cid,
- HEAP_INSERT_SPECULATIVE,
- NULL);
+ heap_insert(resultRelationDesc, tuple,
+ estate->es_output_cid,
+ HEAP_INSERT_SPECULATIVE,
+ NULL);
/* insert index entries for tuple */
recheckIndexes = ExecInsertIndexTuples(slot, &(tuple->t_self),
* Note: heap_insert returns the tid (location) of the new tuple
* in the t_self field.
*/
- newId = heap_insert(resultRelationDesc, tuple,
- estate->es_output_cid,
- 0, NULL);
+ heap_insert(resultRelationDesc, tuple,
+ estate->es_output_cid,
+ 0, NULL);
/* insert index entries for tuple */
if (resultRelInfo->ri_NumIndices > 0)
if (canSetTag)
{
(estate->es_processed)++;
- estate->es_lastoid = newId;
setLastTid(&(tuple->t_self));
}
* the tupdesc in the parent's state: it can be reused by partitions
* with an identical descriptor to the parent.
*/
- tupDesc = ExecTypeFromTL((List *) node->onConflictSet,
- relationDesc->tdhasoid);
+ tupDesc = ExecTypeFromTL((List *) node->onConflictSet);
mtstate->mt_conflproj =
ExecInitExtraTupleSlot(mtstate->ps.state,
mtstate->mt_partition_tuple_routing ?
subplan->targetlist);
j = ExecInitJunkFilter(subplan->targetlist,
- resultRelInfo->ri_RelationDesc->rd_att->tdhasoid,
ExecInitExtraTupleSlot(estate, NULL,
&TTSOpsHeapTuple));
* (hack alert!). The righthand expressions will be evaluated in our
* own innerecontext.
*/
- tupDescLeft = ExecTypeFromTL(lefttlist, false);
+ tupDescLeft = ExecTypeFromTL(lefttlist);
slot = ExecInitExtraTupleSlot(estate, tupDescLeft, &TTSOpsVirtual);
sstate->projLeft = ExecBuildProjectionInfo(lefttlist,
NULL,
parent,
NULL);
- sstate->descRight = tupDescRight = ExecTypeFromTL(righttlist, false);
+ sstate->descRight = tupDescRight = ExecTypeFromTL(righttlist);
slot = ExecInitExtraTupleSlot(estate, tupDescRight, &TTSOpsVirtual);
sstate->projRight = ExecBuildProjectionInfo(righttlist,
sstate->innerecontext,
* when entering/exiting a SPI nesting level.
*/
uint64 SPI_processed = 0;
-Oid SPI_lastoid = InvalidOid;
SPITupleTable *SPI_tuptable = NULL;
int SPI_result = 0;
_SPI_current = &(_SPI_stack[_SPI_connected]);
_SPI_current->processed = 0;
- _SPI_current->lastoid = InvalidOid;
_SPI_current->tuptable = NULL;
_SPI_current->execSubid = InvalidSubTransactionId;
slist_init(&_SPI_current->tuptables);
_SPI_current->atomic = (options & SPI_OPT_NONATOMIC ? false : true);
_SPI_current->internal_xact = false;
_SPI_current->outer_processed = SPI_processed;
- _SPI_current->outer_lastoid = SPI_lastoid;
_SPI_current->outer_tuptable = SPI_tuptable;
_SPI_current->outer_result = SPI_result;
* depend on state of an outer caller.
*/
SPI_processed = 0;
- SPI_lastoid = InvalidOid;
SPI_tuptable = NULL;
SPI_result = 0;
* pointing at a just-deleted tuptable
*/
SPI_processed = _SPI_current->outer_processed;
- SPI_lastoid = _SPI_current->outer_lastoid;
SPI_tuptable = _SPI_current->outer_tuptable;
SPI_result = _SPI_current->outer_result;
_SPI_connected = -1;
/* Reset API global variables, too */
SPI_processed = 0;
- SPI_lastoid = InvalidOid;
SPI_tuptable = NULL;
SPI_result = 0;
}
* be already gone.
*/
SPI_processed = connection->outer_processed;
- SPI_lastoid = connection->outer_lastoid;
SPI_tuptable = connection->outer_tuptable;
SPI_result = connection->outer_result;
mtuple->t_data->t_ctid = tuple->t_data->t_ctid;
mtuple->t_self = tuple->t_self;
mtuple->t_tableOid = tuple->t_tableOid;
- if (rel->rd_att->tdhasoid)
- HeapTupleSetOid(mtuple, HeapTupleGetOid(tuple));
}
else
{
return res + 1;
}
- sysatt = SystemAttributeByName(fname, true /* "oid" will be accepted */ );
+ sysatt = SystemAttributeByName(fname);
if (sysatt != NULL)
return sysatt->attnum;
if (fnumber > 0)
att = TupleDescAttr(tupdesc, fnumber - 1);
else
- att = SystemAttributeDefinition(fnumber, true);
+ att = SystemAttributeDefinition(fnumber);
return pstrdup(NameStr(att->attname));
}
if (fnumber > 0)
typoid = TupleDescAttr(tupdesc, fnumber - 1)->atttypid;
else
- typoid = (SystemAttributeDefinition(fnumber, true))->atttypid;
+ typoid = (SystemAttributeDefinition(fnumber))->atttypid;
getTypeOutputInfo(typoid, &foutoid, &typisvarlena);
if (fnumber > 0)
typoid = TupleDescAttr(tupdesc, fnumber - 1)->atttypid;
else
- typoid = (SystemAttributeDefinition(fnumber, true))->atttypid;
+ typoid = (SystemAttributeDefinition(fnumber))->atttypid;
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typoid));
if (fnumber > 0)
return TupleDescAttr(tupdesc, fnumber - 1)->atttypid;
else
- return (SystemAttributeDefinition(fnumber, true))->atttypid;
+ return (SystemAttributeDefinition(fnumber))->atttypid;
}
char *
{
int my_res = 0;
uint64 my_processed = 0;
- Oid my_lastoid = InvalidOid;
SPITupleTable *my_tuptable = NULL;
int res = 0;
bool pushed_active_snap = false;
DestReceiver *dest;
_SPI_current->processed = 0;
- _SPI_current->lastoid = InvalidOid;
_SPI_current->tuptable = NULL;
if (stmt->utilityStmt)
if (canSetTag)
{
my_processed = _SPI_current->processed;
- my_lastoid = _SPI_current->lastoid;
SPI_freetuptable(my_tuptable);
my_tuptable = _SPI_current->tuptable;
my_res = res;
/* Save results for caller */
SPI_processed = my_processed;
- SPI_lastoid = my_lastoid;
SPI_tuptable = my_tuptable;
/* tuptable now is caller's responsibility, not SPI's */
ExecutorRun(queryDesc, ForwardScanDirection, tcount, true);
_SPI_current->processed = queryDesc->estate->es_processed;
- _SPI_current->lastoid = queryDesc->estate->es_lastoid;
if ((res == SPI_OK_SELECT || queryDesc->plannedstmt->hasReturning) &&
queryDesc->dest->mydest == DestSPI)
MappingUserName(userid))));
um = (UserMapping *) palloc(sizeof(UserMapping));
- um->umid = HeapTupleGetOid(tp);
+ um->umid = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
um->userid = userid;
um->serverid = serverid;
{
Oid oid;
- oid = GetSysCacheOid1(FOREIGNDATAWRAPPERNAME, CStringGetDatum(fdwname));
+ oid = GetSysCacheOid1(FOREIGNDATAWRAPPERNAME,
+ Anum_pg_foreign_data_wrapper_oid,
+ CStringGetDatum(fdwname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
{
Oid oid;
- oid = GetSysCacheOid1(FOREIGNSERVERNAME, CStringGetDatum(servername));
+ oid = GetSysCacheOid1(FOREIGNSERVERNAME, Anum_pg_foreign_server_oid,
+ CStringGetDatum(servername));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
const FormData_pg_attribute *att_tup;
if (indexkey < 0)
- att_tup = SystemAttributeDefinition(indexkey,
- heapRelation->rd_rel->relhasoids);
+ att_tup = SystemAttributeDefinition(indexkey);
else
att_tup = TupleDescAttr(heapRelation->rd_att, indexkey - 1);
%type <boolean> opt_instead
%type <boolean> opt_unique opt_concurrently opt_verbose opt_full
%type <boolean> opt_freeze opt_analyze opt_default opt_recheck
-%type <defelt> opt_binary opt_oids copy_delimiter
+%type <defelt> opt_binary copy_delimiter
%type <boolean> copy_from opt_program
n->missing_ok = false;
$$ = (Node *)n;
}
- /* ALTER TABLE <name> SET WITH OIDS */
- | SET WITH OIDS
- {
- AlterTableCmd *n = makeNode(AlterTableCmd);
- n->subtype = AT_AddOids;
- $$ = (Node *)n;
- }
- /* ALTER TABLE <name> SET WITHOUT OIDS */
+ /* ALTER TABLE <name> SET WITHOUT OIDS, for backward compat */
| SET WITHOUT OIDS
{
AlterTableCmd *n = makeNode(AlterTableCmd);
* syntax had a hard-wired, space-separated set of options.
*
* Really old syntax, from versions 7.2 and prior:
- * COPY [ BINARY ] table [ WITH OIDS ] FROM/TO file
+ * COPY [ BINARY ] table FROM/TO file
* [ [ USING ] DELIMITERS 'delimiter' ] ]
* [ WITH NULL AS 'null string' ]
* This option placement is not supported with COPY (query...).
*
*****************************************************************************/
-CopyStmt: COPY opt_binary qualified_name opt_column_list opt_oids
+CopyStmt: COPY opt_binary qualified_name opt_column_list
copy_from opt_program copy_file_name copy_delimiter opt_with copy_options
{
CopyStmt *n = makeNode(CopyStmt);
n->relation = $3;
n->query = NULL;
n->attlist = $4;
- n->is_from = $6;
- n->is_program = $7;
- n->filename = $8;
+ n->is_from = $5;
+ n->is_program = $6;
+ n->filename = $7;
if (n->is_program && n->filename == NULL)
ereport(ERROR,
/* Concatenate user-supplied flags */
if ($2)
n->options = lappend(n->options, $2);
- if ($5)
- n->options = lappend(n->options, $5);
- if ($9)
- n->options = lappend(n->options, $9);
- if ($11)
- n->options = list_concat(n->options, $11);
+ if ($8)
+ n->options = lappend(n->options, $8);
+ if ($10)
+ n->options = list_concat(n->options, $10);
$$ = (Node *)n;
}
| COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
{
$$ = makeDefElem("format", (Node *)makeString("binary"), @1);
}
- | OIDS
- {
- $$ = makeDefElem("oids", (Node *)makeInteger(true), @1);
- }
| FREEZE
{
$$ = makeDefElem("freeze", (Node *)makeInteger(true), @1);
| /*EMPTY*/ { $$ = NULL; }
;
-opt_oids:
- WITH OIDS
- {
- $$ = makeDefElem("oids", (Node *)makeInteger(true), @1);
- }
- | /*EMPTY*/ { $$ = NULL; }
- ;
-
copy_delimiter:
opt_using DELIMITERS Sconst
{
$$ = n;
}
;
-/* WITH (options) is preferred, WITH OIDS and WITHOUT OIDS are legacy forms */
+/* WITHOUT OIDS is legacy only */
OptWith:
WITH reloptions { $$ = $2; }
- | WITH OIDS { $$ = list_make1(makeDefElem("oids", (Node *) makeInteger(true), @1)); }
- | WITHOUT OIDS { $$ = list_make1(makeDefElem("oids", (Node *) makeInteger(false), @1)); }
+ | WITHOUT OIDS { $$ = NIL; }
| /*EMPTY*/ { $$ = NIL; }
;
return rtindex;
}
-/*
- * Given a relation-options list (of DefElems), return true iff the specified
- * table/result set should be created with OIDs. This needs to be done after
- * parsing the query string because the return value can depend upon the
- * default_with_oids GUC var.
- *
- * In some situations, we want to reject an OIDS option even if it's present.
- * That's (rather messily) handled here rather than reloptions.c, because that
- * code explicitly punts checking for oids to here.
- */
-bool
-interpretOidsOption(List *defList, bool allowOids)
-{
- ListCell *cell;
-
- /* Scan list to see if OIDS was included */
- foreach(cell, defList)
- {
- DefElem *def = (DefElem *) lfirst(cell);
-
- if (def->defnamespace == NULL &&
- strcmp(def->defname, "oids") == 0)
- {
- if (!allowOids)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("unrecognized parameter \"%s\"",
- def->defname)));
- return defGetBoolean(def);
- }
- }
-
- /* Force no-OIDS result if caller disallows OIDS. */
- if (!allowOids)
- return false;
-
- /* OIDS option was not specified, so use default. */
- return default_with_oids;
-}
-
/*
* Extract all not-in-common columns from column lists of a source table
*/
Oid
oprid(Operator op)
{
- return HeapTupleGetOid(op);
+ return ((Form_pg_operator) GETSTRUCT(op))->oid;
}
/* given operator tuple, return the underlying function's OID */
else if (functypclass == TYPEFUNC_SCALAR)
{
/* Base data type, i.e. scalar */
- tupdesc = CreateTemplateTupleDesc(1, false);
+ tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitEntry(tupdesc,
(AttrNumber) 1,
chooseScalarFunctionAlias(funcexpr, funcname,
* Use the column definition list to construct a tupdesc and fill
* in the RangeTblFunction's lists.
*/
- tupdesc = CreateTemplateTupleDesc(list_length(coldeflist), false);
+ tupdesc = CreateTemplateTupleDesc(list_length(coldeflist));
i = 1;
foreach(col, coldeflist)
{
totalatts++;
/* Merge the tuple descs of each function into a composite one */
- tupdesc = CreateTemplateTupleDesc(totalatts, false);
+ tupdesc = CreateTemplateTupleDesc(totalatts);
natts = 0;
for (i = 0; i < nfuncs; i++)
{
if (sysColOK)
{
if ((i = specialAttNum(attname)) != InvalidAttrNumber)
- {
- if (i != ObjectIdAttributeNumber || rd->rd_rel->relhasoids)
- return i;
- }
+ return i;
}
/* on failure */
/* specialAttNum()
*
- * Check attribute name to see if it is "special", e.g. "oid".
+ * Check attribute name to see if it is "special", e.g. "xmin".
* - thomas 2000-02-07
*
* Note: this only discovers whether the name could be a system attribute.
- * Caller needs to verify that it really is an attribute of the rel,
- * at least in the case of "oid", which is now optional.
+ * Caller needs to ensure that it really is an attribute of the rel.
*/
static int
specialAttNum(const char *attname)
{
const FormData_pg_attribute *sysatt;
- sysatt = SystemAttributeByName(attname,
- true /* "oid" will be accepted */ );
+ sysatt = SystemAttributeByName(attname);
if (sysatt != NULL)
return sysatt->attnum;
return InvalidAttrNumber;
{
const FormData_pg_attribute *sysatt;
- sysatt = SystemAttributeDefinition(attid, rd->rd_rel->relhasoids);
+ sysatt = SystemAttributeDefinition(attid);
return &sysatt->attname;
}
if (attid > rd->rd_att->natts)
{
const FormData_pg_attribute *sysatt;
- sysatt = SystemAttributeDefinition(attid, rd->rd_rel->relhasoids);
+ sysatt = SystemAttributeDefinition(attid);
return sysatt->atttypid;
}
if (attid > rd->rd_att->natts)
expandRTE(rte, var->varno, 0, var->location, false,
&names, &vars);
- tupleDesc = CreateTemplateTupleDesc(list_length(vars), false);
+ tupleDesc = CreateTemplateTupleDesc(list_length(vars));
i = 1;
forboth(lname, names, lvar, vars)
{
namespaceId = LookupExplicitNamespace(schemaname, missing_ok);
if (OidIsValid(namespaceId))
- typoid = GetSysCacheOid2(TYPENAMENSP,
+ typoid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
PointerGetDatum(typname),
ObjectIdGetDatum(namespaceId));
else
return InvalidOid;
}
- typoid = HeapTupleGetOid(tup);
+ typoid = ((Form_pg_type) GETSTRUCT(tup))->oid;
ReleaseSysCache(tup);
return typoid;
Type tup;
tup = typenameType(pstate, typeName, NULL);
- typoid = HeapTupleGetOid(tup);
+ typoid = ((Form_pg_type) GETSTRUCT(tup))->oid;
ReleaseSysCache(tup);
return typoid;
Type tup;
tup = typenameType(pstate, typeName, typmod_p);
- *typeid_p = HeapTupleGetOid(tup);
+ *typeid_p = ((Form_pg_type) GETSTRUCT(tup))->oid;
ReleaseSysCache(tup);
}
{
if (tp == NULL) /* probably useless */
elog(ERROR, "typeTypeId() called with NULL type struct");
- return HeapTupleGetOid(tp);
+ return ((Form_pg_type) GETSTRUCT(tp))->oid;
}
/* given type (as type struct), return the length of type */
}
else
{
- if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined)
+ Form_pg_type typ = (Form_pg_type) GETSTRUCT(tup);
+
+ if (!typ->typisdefined)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type \"%s\" is only a shell",
TypeNameToString(typeName)),
parser_errposition(NULL, typeName->location)));
- *typeid_p = HeapTupleGetOid(tup);
+ *typeid_p = typ->oid;
ReleaseSysCache(tup);
}
}
List *inhRelations; /* relations to inherit from */
bool isforeign; /* true if CREATE/ALTER FOREIGN TABLE */
bool isalter; /* true if altering existing table */
- bool hasoids; /* does relation have an OID column? */
List *columns; /* ColumnDef items */
List *ckconstraints; /* CHECK constraints */
List *fkconstraints; /* FOREIGN KEY constraints */
Oid namespaceid;
Oid existing_relid;
ParseCallbackState pcbstate;
- bool like_found = false;
bool is_foreign_table = IsA(stmt, CreateForeignTableStmt);
/*
cxt.partbound = stmt->partbound;
cxt.ofType = (stmt->ofTypename != NULL);
- /*
- * Notice that we allow OIDs here only for plain tables, even though
- * foreign tables also 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(),
- * and right now there's no WITH OIDS option in CREATE FOREIGN TABLE
- * anyway.
- */
- cxt.hasoids = interpretOidsOption(stmt->options, !cxt.isforeign);
-
Assert(!stmt->ofTypename || !stmt->inhRelations); /* grammar enforces */
if (stmt->ofTypename)
break;
case T_TableLikeClause:
- like_found = true;
transformTableLikeClause(&cxt, (TableLikeClause *) element);
break;
}
}
- /*
- * If we had any LIKE tables, they may require creation of an OID column
- * even though the command's own WITH clause didn't ask for one (or,
- * perhaps, even specifically rejected having one). Insert a WITH option
- * to ensure that happens. We prepend to the list because the first oid
- * option will be honored, and we want to override anything already there.
- * (But note that DefineRelation will override this again to add an OID
- * column if one appears in an inheritance parent table.)
- */
- if (like_found && cxt.hasoids)
- stmt->options = lcons(makeDefElem("oids",
- (Node *) makeInteger(true), -1),
- stmt->options);
-
/*
* transformIndexConstraints wants cxt.alist to contain only index
* statements, so transfer anything we already have into save_alist.
errmsg("identity columns are not supported on partitions")));
ctype = typenameType(cxt->pstate, column->typeName, NULL);
- typeOid = HeapTupleGetOid(ctype);
+ typeOid = ((Form_pg_type) GETSTRUCT(ctype))->oid;
ReleaseSysCache(ctype);
if (saw_identity)
}
}
- /* We use oids if at least one LIKE'ed table has oids. */
- cxt->hasoids |= relation->rd_rel->relhasoids;
-
/*
* Copy CHECK constraints if requested, being careful to adjust attribute
* numbers so they match the child.
tuple = typenameType(NULL, ofTypename, NULL);
check_of_type(tuple);
- ofTypeId = HeapTupleGetOid(tuple);
+ ofTypeId = ((Form_pg_type) GETSTRUCT(tuple))->oid;
ofTypename->typeOid = ofTypeId; /* cached for later */
tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
attform = TupleDescAttr(heap_rel->rd_att, attnum - 1);
}
else
- attform = SystemAttributeDefinition(attnum,
- heap_rel->rd_rel->relhasoids);
+ attform = SystemAttributeDefinition(attnum);
attname = pstrdup(NameStr(attform->attname));
if (i < index_form->indnkeyatts)
if (constraint->contype == CONSTR_PRIMARY)
column->is_not_null = true;
}
- else if (SystemAttributeByName(key, cxt->hasoids) != NULL)
+ else if (SystemAttributeByName(key) != NULL)
{
/*
* column will be a system column in the new table, so accept
if (!found)
{
- if (SystemAttributeByName(key, cxt->hasoids) != NULL)
+ if (SystemAttributeByName(key) != NULL)
{
/*
* column will be a system column in the new table, so accept
cxt.rel = rel;
cxt.inhRelations = NIL;
cxt.isalter = true;
- cxt.hasoids = false; /* need not be right */
cxt.columns = NIL;
cxt.ckconstraints = NIL;
cxt.fkconstraints = NIL;
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("collations are not supported by type %s",
- format_type_be(HeapTupleGetOid(ctype))),
+ format_type_be(typtup->oid)),
parser_errposition(cxt->pstate,
column->collClause->location)));
}
avdb = (avw_dbase *) palloc(sizeof(avw_dbase));
- avdb->adw_datid = HeapTupleGetOid(tup);
+ avdb->adw_datid = pgdatabase->oid;
avdb->adw_name = pstrdup(NameStr(pgdatabase->datname));
avdb->adw_frozenxid = pgdatabase->datfrozenxid;
avdb->adw_minmulti = pgdatabase->datminmxid;
classForm->relkind != RELKIND_MATVIEW)
continue;
- relid = HeapTupleGetOid(tuple);
+ relid = classForm->oid;
/*
* Check if it is a temp table (presumably, of some other backend's).
if (classForm->relpersistence == RELPERSISTENCE_TEMP)
continue;
- relid = HeapTupleGetOid(tuple);
+ relid = classForm->oid;
/*
* fetch reloptions -- if this toast table does not have them, try the
static void pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg);
static void pgstat_send_funcstats(void);
-static HTAB *pgstat_collect_oids(Oid catalogid);
+static HTAB *pgstat_collect_oids(Oid catalogid, AttrNumber anum_oid);
static PgStat_TableStatus *get_tabstat_entry(Oid rel_id, bool isshared);
/*
* Read pg_database and make a list of OIDs of all existing databases
*/
- htab = pgstat_collect_oids(DatabaseRelationId);
+ htab = pgstat_collect_oids(DatabaseRelationId, Anum_pg_database_oid);
/*
* Search the database hash table for dead databases and tell the
/*
* Similarly to above, make a list of all known relations in this DB.
*/
- htab = pgstat_collect_oids(RelationRelationId);
+ htab = pgstat_collect_oids(RelationRelationId, Anum_pg_class_oid);
/*
* Initialize our messages table counter to zero
if (dbentry->functions != NULL &&
hash_get_num_entries(dbentry->functions) > 0)
{
- htab = pgstat_collect_oids(ProcedureRelationId);
+ htab = pgstat_collect_oids(ProcedureRelationId, Anum_pg_proc_oid);
pgstat_setheader(&f_msg.m_hdr, PGSTAT_MTYPE_FUNCPURGE);
f_msg.m_databaseid = MyDatabaseId;
* ----------
*/
static HTAB *
-pgstat_collect_oids(Oid catalogid)
+pgstat_collect_oids(Oid catalogid, AttrNumber anum_oid)
{
HTAB *htab;
HASHCTL hash_ctl;
scan = heap_beginscan(rel, snapshot, 0, NULL);
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid thisoid = HeapTupleGetOid(tup);
+ Oid thisoid;
+ bool isnull;
+
+ thisoid = heap_getattr(tup, anum_oid, RelationGetDescr(rel), &isnull);
+ Assert(!isnull);
CHECK_FOR_INTERRUPTS();
walres->tuplestore = tuplestore_begin_heap(true, false, work_mem);
/* Create tuple descriptor corresponding to expected result. */
- walres->tupledesc = CreateTemplateTupleDesc(nRetTypes, false);
+ walres->tupledesc = CreateTemplateTupleDesc(nRetTypes);
for (coln = 0; coln < nRetTypes; coln++)
TupleDescInitEntry(walres->tupledesc, (AttrNumber) coln + 1,
PQfname(pgres, coln), retTypes[coln], -1, 0);
oldcxt = MemoryContextSwitchTo(resultcxt);
sub = (Subscription *) palloc0(sizeof(Subscription));
- sub->oid = HeapTupleGetOid(tup);
+ sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
sub->enabled = subform->subenabled;
MemSet(nulls, false, sizeof(nulls));
/* need a tuple descriptor representing four columns */
- tupdesc = CreateTemplateTupleDesc(4, false);
+ tupdesc = CreateTemplateTupleDesc(4);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "systemid",
TEXTOID, -1, 0);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 2, "timeline",
* like a surprising data type for this, but in theory int4 would not
* be wide enough for this, as TimeLineID is unsigned.
*/
- tupdesc = CreateTemplateTupleDesc(2, false);
+ tupdesc = CreateTemplateTupleDesc(2);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "next_tli",
INT8OID, -1, 0);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 2, "next_tli_startpos",
* - fourth field: output plugin
*----------
*/
- tupdesc = CreateTemplateTupleDesc(4, false);
+ tupdesc = CreateTemplateTupleDesc(4);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "slot_name",
TEXTOID, -1, 0);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 2, "consistent_point",
ReleaseSysCache(oldtup);
- rewriteObjectId = HeapTupleGetOid(tup);
+ rewriteObjectId = ((Form_pg_rewrite) GETSTRUCT(tup))->oid;
is_update = true;
}
else
{
+ rewriteObjectId = GetNewOidWithIndex(pg_rewrite_desc,
+ RewriteOidIndexId,
+ Anum_pg_rewrite_oid);
+ values[Anum_pg_rewrite_oid - 1] = ObjectIdGetDatum(rewriteObjectId);
+
tup = heap_form_tuple(pg_rewrite_desc->rd_att, values, nulls);
- rewriteObjectId = CatalogTupleInsert(pg_rewrite_desc, tup);
+ CatalogTupleInsert(pg_rewrite_desc, tup);
}
classForm->reltoastrelid = InvalidOid;
classForm->relhasindex = false;
classForm->relkind = RELKIND_VIEW;
- classForm->relhasoids = false;
classForm->relfrozenxid = InvalidTransactionId;
classForm->relminmxid = InvalidMultiXactId;
classForm->relreplident = REPLICA_IDENTITY_NOTHING;
Oid owningRel = RelationGetRelid(rel);
Oid eventRelationOid;
HeapTuple ruletup;
+ Form_pg_rewrite ruleform;
bool changed = false;
/*
errmsg("rule \"%s\" for relation \"%s\" does not exist",
rulename, get_rel_name(owningRel))));
+ ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
+
/*
* Verify that the user has appropriate permissions.
*/
- eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(ruletup))->ev_class;
+ eventRelationOid = ruleform->ev_class;
Assert(eventRelationOid == owningRel);
if (!pg_class_ownercheck(eventRelationOid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(eventRelationOid)),
/*
* Change ev_enabled if it is different from the desired new state.
*/
- if (DatumGetChar(((Form_pg_rewrite) GETSTRUCT(ruletup))->ev_enabled) !=
+ if (DatumGetChar(ruleform->ev_enabled) !=
fires_when)
{
- ((Form_pg_rewrite) GETSTRUCT(ruletup))->ev_enabled =
- CharGetDatum(fires_when);
+ ruleform->ev_enabled = CharGetDatum(fires_when);
CatalogTupleUpdate(pg_rewrite_desc, &ruletup->t_self, ruletup);
changed = true;
}
- InvokeObjectPostAlterHook(RewriteRelationId,
- HeapTupleGetOid(ruletup), 0);
+ InvokeObjectPostAlterHook(RewriteRelationId, ruleform->oid, 0);
heap_freetuple(ruletup);
heap_close(pg_rewrite_desc, RowExclusiveLock);
errmsg("rule \"%s\" for relation \"%s\" does not exist",
oldName, RelationGetRelationName(targetrel))));
ruleform = (Form_pg_rewrite) GETSTRUCT(ruletup);
- ruleOid = HeapTupleGetOid(ruletup);
+ ruleOid = ruleform->oid;
/* rule with the new name should not already exist */
if (IsDefinedRewriteRule(relid, newName))
* Find the tuple for the target rule.
*/
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_rewrite_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(ruleOid));
get_rewrite_oid(Oid relid, const char *rulename, bool missing_ok)
{
HeapTuple tuple;
+ Form_pg_rewrite ruleform;
Oid ruleoid;
/* Find the rule's pg_rewrite tuple, get its OID */
errmsg("rule \"%s\" for relation \"%s\" does not exist",
rulename, get_rel_name(relid))));
}
- Assert(relid == ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class);
- ruleoid = HeapTupleGetOid(tuple);
+ ruleform = (Form_pg_rewrite) GETSTRUCT(tuple);
+ Assert(relid == ruleform->ev_class);
+ ruleoid = ruleform->oid;
ReleaseSysCache(tuple);
return ruleoid;
}
Form_pg_statistic_ext staForm;
entry = palloc0(sizeof(StatExtEntry));
- entry->statOid = HeapTupleGetOid(htup);
staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
+ entry->statOid = staForm->oid;
entry->schema = get_namespace_name(staForm->stxnamespace);
entry->name = pstrdup(NameStr(staForm->stxname));
for (i = 0; i < staForm->stxkeys.dim1; i++)
bool retval = false;
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_largeobject_metadata_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(loid));
queryDesc->estate->es_processed);
break;
case CMD_INSERT:
- if (queryDesc->estate->es_processed == 1)
- lastOid = queryDesc->estate->es_lastoid;
- else
- lastOid = InvalidOid;
+ /* lastoid doesn't exist anymore */
+ lastOid = InvalidOid;
snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
"INSERT %u " UINT64_FORMAT,
lastOid, queryDesc->estate->es_processed);
pstmt = PortalGetPrimaryStmt(portal);
portal->tupDesc =
- ExecCleanTypeFromTL(pstmt->planTree->targetlist,
- false);
+ ExecCleanTypeFromTL(pstmt->planTree->targetlist);
}
/*
(Datum) 0));
funcctx->user_fctx = (void *) st;
- tupdesc = CreateTemplateTupleDesc(3, false);
+ tupdesc = CreateTemplateTupleDesc(3);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "tokid",
INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "alias",
st->cur = 0;
funcctx->user_fctx = (void *) st;
- tupdesc = CreateTemplateTupleDesc(2, false);
+ tupdesc = CreateTemplateTupleDesc(2);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "tokid",
INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "token",
* build tupdesc for result tuples (matches out parameters in pg_proc
* entry)
*/
- tupdesc = CreateTemplateTupleDesc(4, false);
+ tupdesc = CreateTemplateTupleDesc(4);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "grantor",
OIDOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "grantee",
{
Oid oid;
- oid = GetSysCacheOid1(AUTHNAME, CStringGetDatum(rolname));
+ oid = GetSysCacheOid1(AUTHNAME, Anum_pg_authid_oid,
+ CStringGetDatum(rolname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
* build tupdesc for result tuples. This must match this function's
* pg_proc entry!
*/
- tupdesc = CreateTemplateTupleDesc(3, false);
+ tupdesc = CreateTemplateTupleDesc(3);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "abbrev",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "utc_offset",
* build tupdesc for result tuples. This must match this function's
* pg_proc entry!
*/
- tupdesc = CreateTemplateTupleDesc(4, false);
+ tupdesc = CreateTemplateTupleDesc(4);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "abbrev",
check_safe_enum_use(HeapTuple enumval_tup)
{
TransactionId xmin;
- Form_pg_enum en;
+ Form_pg_enum en = (Form_pg_enum) GETSTRUCT(enumval_tup);
/*
* If the row is hinted as committed, it's surely safe. This provides a
* owning type. (This'd also be false for values made by other
* transactions; but the previous tests should have handled all of those.)
*/
- if (!EnumBlacklisted(HeapTupleGetOid(enumval_tup)))
+ if (!EnumBlacklisted(en->oid))
return;
/*
* There might well be other tests we could do here to narrow down the
* unsafe conditions, but for now just raise an exception.
*/
- en = (Form_pg_enum) GETSTRUCT(enumval_tup);
ereport(ERROR,
(errcode(ERRCODE_UNSAFE_NEW_ENUM_VALUE_USAGE),
errmsg("unsafe use of new value \"%s\" of enum type %s",
* This comes from pg_enum.oid and stores system oids in user tables. This
* oid must be preserved by binary upgrades.
*/
- enumoid = HeapTupleGetOid(tup);
+ enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
ReleaseSysCache(tup);
/* check it's safe to use in SQL */
check_safe_enum_use(tup);
- enumoid = HeapTupleGetOid(tup);
+ enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
ReleaseSysCache(tup);
{
/* check it's safe to use in SQL */
check_safe_enum_use(enum_tuple);
- minmax = HeapTupleGetOid(enum_tuple);
+ minmax = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid;
}
else
{
while (HeapTupleIsValid(enum_tuple = systable_getnext_ordered(enum_scan, ForwardScanDirection)))
{
- Oid enum_oid = HeapTupleGetOid(enum_tuple);
+ Oid enum_oid = ((Form_pg_enum) GETSTRUCT(enum_tuple))->oid;
if (!left_found && lower == enum_oid)
left_found = true;
if (hasnull)
len += BITMAPLEN(tupdesc->natts);
- if (tupdesc->tdhasoid)
- len += sizeof(Oid);
-
hoff = len = MAXALIGN(len); /* align user data safely */
data_len = heap_compute_data_size(tupdesc, erh->dvalues, erh->dnulls);
HeapTupleHeaderSetNatts(tuphdr, tupdesc->natts);
tuphdr->t_hoff = erh->hoff;
- if (tupdesc->tdhasoid) /* else leave infomask = 0 */
- tuphdr->t_infomask = HEAP_HASOID;
-
/* And fill the data area from dvalues/dnulls */
heap_fill_tuple(tupdesc,
erh->dvalues,
}
/* How about system attributes? */
- sysattr = SystemAttributeByName(fieldname, tupdesc->tdhasoid);
+ sysattr = SystemAttributeByName(fieldname);
if (sysattr != NULL)
{
finfo->fnumber = sysattr->attnum;
* This record type had better match the output parameters declared for me
* in pg_proc.h.
*/
- tupdesc = CreateTemplateTupleDesc(6, false);
+ tupdesc = CreateTemplateTupleDesc(6);
TupleDescInitEntry(tupdesc, (AttrNumber) 1,
"size", INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2,
fctx = palloc(sizeof(directory_fctx));
- tupdesc = CreateTemplateTupleDesc(3, false);
+ tupdesc = CreateTemplateTupleDesc(3);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "size",
/* build tupdesc for result tuples */
/* this had better match function's declaration in pg_proc.h */
- tupdesc = CreateTemplateTupleDesc(NUM_LOCK_STATUS_COLUMNS, false);
+ tupdesc = CreateTemplateTupleDesc(NUM_LOCK_STATUS_COLUMNS);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "locktype",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "database",
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
- tupdesc = CreateTemplateTupleDesc(3, false);
+ tupdesc = CreateTemplateTupleDesc(3);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "word",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "catcode",
* Get a tupledesc corresponding to the aggregated inputs
* (including sort expressions) of the agg.
*/
- qstate->tupdesc = ExecTypeFromTL(aggref->args, false);
+ qstate->tupdesc = ExecTypeFromTL(aggref->args);
/* If we need a flag column, hack the tupledesc to include that */
if (ishypothetical)
TupleDesc newdesc;
int natts = qstate->tupdesc->natts;
- newdesc = CreateTemplateTupleDesc(natts + 1, false);
+ newdesc = CreateTemplateTupleDesc(natts + 1);
for (i = 1; i <= natts; i++)
TupleDescCopyEntry(newdesc, i, qstate->tupdesc, i);
*/
partitions = find_all_inheritors(rootrelid, AccessShareLock, NULL);
- tupdesc = CreateTemplateTupleDesc(PG_PARTITION_TREE_COLS, false);
+ tupdesc = CreateTemplateTupleDesc(PG_PARTITION_TREE_COLS);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "relid",
REGCLASSOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "parentid",
MemSet(nulls, 0, sizeof(nulls));
/* Initialise attributes information in the tuple descriptor */
- tupdesc = CreateTemplateTupleDesc(7, false);
+ tupdesc = CreateTemplateTupleDesc(7);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "archived_count",
INT8OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "last_archived_wal",
tgrel = heap_open(TriggerRelationId, AccessShareLock);
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_trigger_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(trigid));
Relation relation = heap_open(ConstraintRelationId, AccessShareLock);
ScanKeyInit(&scankey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_constraint_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(constraintId));
HeapTuple aggtup;
Form_pg_aggregate agg;
- aggtup = SearchSysCache1(AGGFNOID,
- ObjectIdGetDatum(HeapTupleGetOid(proctup)));
+ aggtup = SearchSysCache1(AGGFNOID, proc->oid);
if (!HeapTupleIsValid(aggtup))
elog(ERROR, "cache lookup failed for aggregate %u",
- HeapTupleGetOid(proctup));
+ proc->oid);
agg = (Form_pg_aggregate) GETSTRUCT(aggtup);
if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
insertorderbyat = agg->aggnumdirectargs;
{
switch (((Var *) vardata->var)->varattno)
{
- case ObjectIdAttributeNumber:
case SelfItemPointerAttributeNumber:
stadistinct = -1.0; /* unique (and all non null) */
break;
newheader = newtuple->t_data;
oldheader = oldtuple->t_data;
- /*
- * We are called before the OID, if any, has been transcribed from the old
- * tuple to the new (in heap_update). To avoid a bogus compare failure,
- * copy the OID now. But check that someone didn't already put another
- * OID value into newtuple. (That's not actually possible at present, but
- * maybe someday.)
- */
- if (trigdata->tg_relation->rd_rel->relhasoids &&
- !OidIsValid(HeapTupleHeaderGetOid(newheader)))
- HeapTupleHeaderSetOid(newheader, HeapTupleHeaderGetOid(oldheader));
-
/* if the tuple payload is the same ... */
if (newtuple->t_len == oldtuple->t_len &&
newheader->t_hoff == oldheader->t_hoff &&
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
- tupdesc = CreateTemplateTupleDesc(3, false);
+ tupdesc = CreateTemplateTupleDesc(3);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "lexeme",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "positions",
}
Assert(stat->stackpos <= stat->maxdepth);
- tupdesc = CreateTemplateTupleDesc(3, false);
+ tupdesc = CreateTemplateTupleDesc(3);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "word",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "ndoc",
switch (nkeys)
{
case 4:
- v4 = (cc_keyno[3] == ObjectIdAttributeNumber)
- ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
- : fastgetattr(tuple,
- cc_keyno[3],
- cc_tupdesc,
- &isNull);
+ v4 = fastgetattr(tuple,
+ cc_keyno[3],
+ cc_tupdesc,
+ &isNull);
Assert(!isNull);
/* FALLTHROUGH */
case 3:
- v3 = (cc_keyno[2] == ObjectIdAttributeNumber)
- ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
- : fastgetattr(tuple,
- cc_keyno[2],
- cc_tupdesc,
- &isNull);
+ v3 = fastgetattr(tuple,
+ cc_keyno[2],
+ cc_tupdesc,
+ &isNull);
Assert(!isNull);
/* FALLTHROUGH */
case 2:
- v2 = (cc_keyno[1] == ObjectIdAttributeNumber)
- ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
- : fastgetattr(tuple,
- cc_keyno[1],
- cc_tupdesc,
- &isNull);
+ v2 = fastgetattr(tuple,
+ cc_keyno[1],
+ cc_tupdesc,
+ &isNull);
Assert(!isNull);
/* FALLTHROUGH */
case 1:
- v1 = (cc_keyno[0] == ObjectIdAttributeNumber)
- ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
- : fastgetattr(tuple,
- cc_keyno[0],
- cc_tupdesc,
- &isNull);
+ v1 = fastgetattr(tuple,
+ cc_keyno[0],
+ cc_tupdesc,
+ &isNull);
Assert(!isNull);
break;
default:
}
else
{
- if (cache->cc_keyno[i] != ObjectIdAttributeNumber)
- elog(FATAL, "only sys attr supported in caches is OID");
+ if (cache->cc_keyno[i] < 0)
+ elog(FATAL, "sys attributes are not supported in caches");
keytype = OIDOID;
}
int attnum = attnos[i];
Form_pg_attribute att;
- /* only valid system attribute is the oid, which is by value */
- if (attnum == ObjectIdAttributeNumber)
- continue;
+ /* system attribute are not supported in caches */
Assert(attnum > 0);
att = TupleDescAttr(tupdesc, attnum - 1);
for (i = 0; i < nkeys; i++)
{
int attnum = attnos[i];
+ Form_pg_attribute att = TupleDescAttr(tupdesc, attnum - 1);
+ Datum src = srckeys[i];
+ NameData srcname;
- if (attnum == ObjectIdAttributeNumber)
+ /*
+ * Must be careful in case the caller passed a C string where a
+ * NAME is wanted: convert the given argument to a correctly
+ * padded NAME. Otherwise the memcpy() done by datumCopy() could
+ * fall off the end of memory.
+ */
+ if (att->atttypid == NAMEOID)
{
- dstkeys[i] = srckeys[i];
+ namestrcpy(&srcname, DatumGetCString(src));
+ src = NameGetDatum(&srcname);
}
- else
- {
- Form_pg_attribute att = TupleDescAttr(tupdesc, attnum - 1);
- Datum src = srckeys[i];
- NameData srcname;
- /*
- * Must be careful in case the caller passed a C string where a
- * NAME is wanted: convert the given argument to a correctly
- * padded NAME. Otherwise the memcpy() done by datumCopy() could
- * fall off the end of memory.
- */
- if (att->atttypid == NAMEOID)
- {
- namestrcpy(&srcname, DatumGetCString(src));
- src = NameGetDatum(&srcname);
- }
-
- dstkeys[i] = datumCopy(src,
- att->attbyval,
- att->attlen);
- }
+ dstkeys[i] = datumCopy(src,
+ att->attbyval,
+ att->attlen);
}
}
{
Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
- relationId = HeapTupleGetOid(tuple);
+ relationId = classtup->oid;
if (classtup->relisshared)
databaseId = InvalidOid;
else
PrepareInvalidationState();
- relationId = HeapTupleGetOid(classTuple);
+ relationId = classtup->oid;
if (classtup->relisshared)
databaseId = InvalidOid;
else
Oid
get_relname_relid(const char *relname, Oid relnamespace)
{
- return GetSysCacheOid2(RELNAMENSP,
+ return GetSysCacheOid2(RELNAMENSP, Anum_pg_class_oid,
PointerGetDatum(relname),
ObjectIdGetDatum(relnamespace));
}
if (OidIsValid(typeStruct->typelem))
return typeStruct->typelem;
else
- return HeapTupleGetOid(typeTuple);
+ return typeStruct->oid;
}
/*
case PORTAL_ONE_SELECT:
case PORTAL_ONE_MOD_WITH:
query = linitial_node(Query, stmt_list);
- return ExecCleanTypeFromTL(query->targetList, false);
+ return ExecCleanTypeFromTL(query->targetList);
case PORTAL_ONE_RETURNING:
query = QueryListGetPrimaryStmt(stmt_list);
Assert(query->returningList);
- return ExecCleanTypeFromTL(query->returningList, false);
+ return ExecCleanTypeFromTL(query->returningList);
case PORTAL_UTIL_SELECT:
query = linitial_node(Query, stmt_list);
static void write_item(const void *data, Size len, FILE *fp);
static void formrdesc(const char *relationName, Oid relationReltype,
- bool isshared, bool hasoids,
- int natts, const FormData_pg_attribute *attrs);
+ bool isshared, int natts, const FormData_pg_attribute *attrs);
static HeapTuple ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic);
static Relation AllocateRelationDesc(Form_pg_class relp);
* form a scan key
*/
ScanKeyInit(&key[0],
- ObjectIdAttributeNumber,
+ Anum_pg_class_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(targetRelId));
relation->rd_rel = relationForm;
/* and allocate attribute tuple form storage */
- relation->rd_att = CreateTemplateTupleDesc(relationForm->relnatts,
- relationForm->relhasoids);
+ relation->rd_att = CreateTemplateTupleDesc(relationForm->relnatts);
/* which we mark as a reference-counted tupdesc */
relation->rd_att->tdrefcount = 1;
/* copy some fields from pg_class row to rd_att */
relation->rd_att->tdtypeid = relation->rd_rel->reltype;
relation->rd_att->tdtypmod = -1; /* unnecessary, but... */
- relation->rd_att->tdhasoid = relation->rd_rel->relhasoids;
constr = (TupleConstr *) MemoryContextAlloc(CacheMemoryContext,
sizeof(TupleConstr));
rule = (RewriteRule *) MemoryContextAlloc(rulescxt,
sizeof(RewriteRule));
- rule->ruleId = HeapTupleGetOid(rewrite_tuple);
+ rule->ruleId = rewrite_form->oid;
rule->event = rewrite_form->ev_type - '0';
rule->enabled = rewrite_form->ev_enabled;
/*
* get information from the pg_class_tuple
*/
- relid = HeapTupleGetOid(pg_class_tuple);
relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
+ relid = relp->oid;
Assert(relid == targetRelId);
/*
* work while bootstrapping.
*/
ScanKeyInit(&skey[0],
- ObjectIdAttributeNumber,
+ Anum_pg_opclass_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(operatorClassOid));
rel = heap_open(OperatorClassRelationId, AccessShareLock);
*/
static void
formrdesc(const char *relationName, Oid relationReltype,
- bool isshared, bool hasoids,
+ bool isshared,
int natts, const FormData_pg_attribute *attrs)
{
Relation relation;
relation->rd_rel->reltuples = 0;
relation->rd_rel->relallvisible = 0;
relation->rd_rel->relkind = RELKIND_RELATION;
- relation->rd_rel->relhasoids = hasoids;
relation->rd_rel->relnatts = (int16) natts;
/*
* because it will never be replaced. The data comes from
* src/include/catalog/ headers via genbki.pl.
*/
- relation->rd_att = CreateTemplateTupleDesc(natts, hasoids);
+ relation->rd_att = CreateTemplateTupleDesc(natts);
relation->rd_att->tdrefcount = 1; /* mark as refcounted */
relation->rd_att->tdtypeid = relationReltype;
{
list_free(relation->rd_indexlist);
relation->rd_indexlist = NIL;
- relation->rd_oidindex = InvalidOid;
relation->rd_pkindex = InvalidOid;
relation->rd_replidindex = InvalidOid;
relation->rd_indexvalid = 0;
{
list_free(relation->rd_indexlist);
relation->rd_indexlist = NIL;
- relation->rd_oidindex = InvalidOid;
relation->rd_pkindex = InvalidOid;
relation->rd_replidindex = InvalidOid;
relation->rd_indexvalid = 0;
rel->rd_rel->relnamespace = relnamespace;
rel->rd_rel->relkind = relkind;
- rel->rd_rel->relhasoids = rel->rd_att->tdhasoid;
rel->rd_rel->relnatts = natts;
rel->rd_rel->reltype = InvalidOid;
/* needed when bootstrapping: */
if (!load_relcache_init_file(true))
{
formrdesc("pg_database", DatabaseRelation_Rowtype_Id, true,
- true, Natts_pg_database, Desc_pg_database);
+ Natts_pg_database, Desc_pg_database);
formrdesc("pg_authid", AuthIdRelation_Rowtype_Id, true,
- true, Natts_pg_authid, Desc_pg_authid);
+ Natts_pg_authid, Desc_pg_authid);
formrdesc("pg_auth_members", AuthMemRelation_Rowtype_Id, true,
- false, Natts_pg_auth_members, Desc_pg_auth_members);
+ Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
- false, Natts_pg_shseclabel, Desc_pg_shseclabel);
+ Natts_pg_shseclabel, Desc_pg_shseclabel);
formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- true, Natts_pg_subscription, Desc_pg_subscription);
+ Natts_pg_subscription, Desc_pg_subscription);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
needNewCacheFile = true;
formrdesc("pg_class", RelationRelation_Rowtype_Id, false,
- true, Natts_pg_class, Desc_pg_class);
+ Natts_pg_class, Desc_pg_class);
formrdesc("pg_attribute", AttributeRelation_Rowtype_Id, false,
- false, Natts_pg_attribute, Desc_pg_attribute);
+ Natts_pg_attribute, Desc_pg_attribute);
formrdesc("pg_proc", ProcedureRelation_Rowtype_Id, false,
- true, Natts_pg_proc, Desc_pg_proc);
+ Natts_pg_proc, Desc_pg_proc);
formrdesc("pg_type", TypeRelation_Rowtype_Id, false,
- true, Natts_pg_type, Desc_pg_type);
+ Natts_pg_type, Desc_pg_type);
#define NUM_CRITICAL_LOCAL_RELS 4 /* fix if you change list above */
}
*/
Assert(relation->rd_att->tdtypeid == relp->reltype);
Assert(relation->rd_att->tdtypmod == -1);
- Assert(relation->rd_att->tdhasoid == relp->relhasoids);
ReleaseSysCache(htup);
* extracting fields.
*/
static TupleDesc
-BuildHardcodedDescriptor(int natts, const FormData_pg_attribute *attrs,
- bool hasoids)
+BuildHardcodedDescriptor(int natts, const FormData_pg_attribute *attrs)
{
TupleDesc result;
MemoryContext oldcxt;
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
- result = CreateTemplateTupleDesc(natts, hasoids);
+ result = CreateTemplateTupleDesc(natts);
result->tdtypeid = RECORDOID; /* not right, but we don't care */
result->tdtypmod = -1;
/* Already done? */
if (pgclassdesc == NULL)
pgclassdesc = BuildHardcodedDescriptor(Natts_pg_class,
- Desc_pg_class,
- true);
+ Desc_pg_class);
return pgclassdesc;
}
/* Already done? */
if (pgindexdesc == NULL)
pgindexdesc = BuildHardcodedDescriptor(Natts_pg_index,
- Desc_pg_index,
- false);
+ Desc_pg_index);
return pgindexdesc;
}
continue;
info = makeNode(ForeignKeyCacheInfo);
- info->conoid = HeapTupleGetOid(htup);
+ info->conoid = constraint->oid;
info->conrelid = constraint->conrelid;
info->confrelid = constraint->confrelid;
* since the caller will typically be doing syscache lookups on the relevant
* indexes, and syscache lookup could cause SI messages to be processed!
*
- * We also update rd_oidindex, which this module treats as effectively part
- * of the index list. rd_oidindex is valid when rd_indexvalid isn't zero;
- * it is the pg_class OID of a unique index on OID when the relation has one,
- * and InvalidOid if there is no such index.
- *
* In exactly the same way, we update rd_pkindex, which is the OID of the
* relation's primary key index if any, else InvalidOid; and rd_replidindex,
* which is the pg_class OID of an index to be used as the relation's
List *result;
List *oldlist;
char replident = relation->rd_rel->relreplident;
- Oid oidIndex = InvalidOid;
Oid pkeyIndex = InvalidOid;
Oid candidateIndex = InvalidOid;
MemoryContext oldcxt;
* if we get some sort of error partway through.
*/
result = NIL;
- oidIndex = InvalidOid;
/* Prepare to scan pg_index for entries having indrelid = this rel. */
ScanKeyInit(&skey,
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
{
Form_pg_index index = (Form_pg_index) GETSTRUCT(htup);
- Datum indclassDatum;
- oidvector *indclass;
- bool isnull;
/*
* Ignore any indexes that are currently being dropped. This will
/* Add index's OID to result list in the proper order */
result = insert_ordered_oid(result, index->indexrelid);
- /*
- * indclass cannot be referenced directly through the C struct,
- * because it comes after the variable-width indkey field. Must
- * extract the datum the hard way...
- */
- indclassDatum = heap_getattr(htup,
- Anum_pg_index_indclass,
- GetPgIndexDescriptor(),
- &isnull);
- Assert(!isnull);
- indclass = (oidvector *) DatumGetPointer(indclassDatum);
-
/*
* Invalid, non-unique, non-immediate or predicate indexes aren't
* interesting for either oid indexes or replication identity indexes,
!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
continue;
- /* Check to see if is a usable btree index on OID */
- if (index->indnatts == 1 &&
- index->indkey.values[0] == ObjectIdAttributeNumber &&
- indclass->values[0] == OID_BTREE_OPS_OID)
- oidIndex = index->indexrelid;
-
/* remember primary key index if any */
if (index->indisprimary)
pkeyIndex = index->indexrelid;
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
oldlist = relation->rd_indexlist;
relation->rd_indexlist = list_copy(result);
- relation->rd_oidindex = oidIndex;
relation->rd_pkindex = pkeyIndex;
if (replident == REPLICA_IDENTITY_DEFAULT && OidIsValid(pkeyIndex))
relation->rd_replidindex = pkeyIndex;
NULL, 1, &skey);
while (HeapTupleIsValid(htup = systable_getnext(indscan)))
- result = insert_ordered_oid(result, HeapTupleGetOid(htup));
+ {
+ Oid oid = ((Form_pg_statistic_ext) GETSTRUCT(htup))->oid;
+
+ result = insert_ordered_oid(result, oid);
+ }
systable_endscan(indscan);
* touch rd_keyattr, rd_pkattr or rd_idattr.
*/
void
-RelationSetIndexList(Relation relation, List *indexIds, Oid oidIndex)
+RelationSetIndexList(Relation relation, List *indexIds)
{
MemoryContext oldcxt;
/* Okay to replace old list */
list_free(relation->rd_indexlist);
relation->rd_indexlist = indexIds;
- relation->rd_oidindex = oidIndex;
/*
* For the moment, assume the target rel hasn't got a pk or replica index.
EOXactListAdd(relation);
}
-/*
- * RelationGetOidIndex -- get the pg_class OID of the relation's OID index
- *
- * Returns InvalidOid if there is no such index.
- */
-Oid
-RelationGetOidIndex(Relation relation)
-{
- List *ilist;
-
- /*
- * If relation doesn't have OIDs at all, caller is probably confused. (We
- * could just silently return InvalidOid, but it seems better to throw an
- * assertion.)
- */
- Assert(relation->rd_rel->relhasoids);
-
- if (relation->rd_indexvalid == 0)
- {
- /* RelationGetIndexList does the heavy lifting. */
- ilist = RelationGetIndexList(relation);
- list_free(ilist);
- Assert(relation->rd_indexvalid != 0);
- }
-
- return relation->rd_oidindex;
-}
-
/*
* RelationGetPrimaryKeyIndex -- get OID of the relation's primary key index
*
rel->rd_rel = relform;
/* initialize attribute tuple forms */
- rel->rd_att = CreateTemplateTupleDesc(relform->relnatts,
- relform->relhasoids);
+ rel->rd_att = CreateTemplateTupleDesc(relform->relnatts);
rel->rd_att->tdrefcount = 1; /* mark as refcounted */
rel->rd_att->tdtypeid = relform->reltype;
rel->rd_fkeylist = NIL;
rel->rd_fkeyvalid = false;
rel->rd_indexlist = NIL;
- rel->rd_oidindex = InvalidOid;
rel->rd_pkindex = InvalidOid;
rel->rd_replidindex = InvalidOid;
rel->rd_indexattr = NULL;
while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
{
+ Form_pg_class classform = (Form_pg_class) GETSTRUCT(ntp);
+
if (found)
elog(ERROR,
"unexpected duplicate for tablespace %u, relfilenode %u",
reltablespace, relfilenode);
found = true;
-#ifdef USE_ASSERT_CHECKING
- {
- bool isnull;
- Oid check;
-
- check = fastgetattr(ntp, Anum_pg_class_reltablespace,
- RelationGetDescr(relation),
- &isnull);
- Assert(!isnull && check == reltablespace);
-
- check = fastgetattr(ntp, Anum_pg_class_relfilenode,
- RelationGetDescr(relation),
- &isnull);
- Assert(!isnull && check == relfilenode);
- }
-#endif
- relid = HeapTupleGetOid(ntp);
+ Assert(classform->reltablespace == reltablespace);
+ Assert(classform->relfilenode == relfilenode);
+ relid = classform->oid;
}
systable_endscan(scandesc);
AmOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_am_oid,
0,
0,
0
AuthIdOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_authid_oid,
0,
0,
0
OpclassOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_opclass_oid,
0,
0,
0
CollationOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_collation_oid,
0,
0,
0
Anum_pg_conversion_connamespace,
Anum_pg_conversion_conforencoding,
Anum_pg_conversion_contoencoding,
- ObjectIdAttributeNumber,
+ Anum_pg_conversion_oid
},
8
},
ConstraintOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_constraint_oid,
0,
0,
0
ConversionOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_conversion_oid,
0,
0,
0
DatabaseOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_database_oid,
0,
0,
0
EnumOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_enum_oid,
0,
0,
0
EventTriggerOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_event_trigger_oid,
0,
0,
0
ForeignDataWrapperOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_foreign_data_wrapper_oid,
0,
0,
0
ForeignServerOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_foreign_server_oid,
0,
0,
0
LanguageOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_language_oid,
0,
0,
0
NamespaceOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_namespace_oid,
0,
0,
0
OperatorOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_operator_oid,
0,
0,
0
OpfamilyOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_opfamily_oid,
0,
0,
0
ProcedureOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_proc_oid,
0,
0,
0
PublicationObjectIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_publication_oid,
0,
0,
0
PublicationRelObjectIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_publication_rel_oid,
0,
0,
0
ClassOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_class_oid,
0,
0,
0
StatisticExtOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_statistic_ext_oid,
0,
0,
0
SubscriptionObjectIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_subscription_oid,
0,
0,
0
TablespaceOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_tablespace_oid,
0,
0,
0,
TransformOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_transform_oid,
0,
0,
0,
TSConfigOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_ts_config_oid,
0,
0,
0
TSDictionaryOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_ts_dict_oid,
0,
0,
0
TSParserOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_ts_parser_oid,
0,
0,
0
TSTemplateOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_ts_template_oid,
0,
0,
0
TypeOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_type_oid,
0,
0,
0
UserMappingOidIndexId,
1,
{
- ObjectIdAttributeNumber,
+ Anum_pg_user_mapping_oid,
0,
0,
0
/*
* GetSysCacheOid
*
- * A convenience routine that does SearchSysCache and returns the OID
- * of the found tuple, or InvalidOid if no tuple could be found.
+ * A convenience routine that does SearchSysCache and returns the OID in the
+ * oidcol column of the found tuple, or InvalidOid if no tuple could be found.
* No lock is retained on the syscache entry.
*/
Oid
GetSysCacheOid(int cacheId,
+ AttrNumber oidcol,
Datum key1,
Datum key2,
Datum key3,
Datum key4)
{
HeapTuple tuple;
+ bool isNull;
Oid result;
tuple = SearchSysCache(cacheId, key1, key2, key3, key4);
if (!HeapTupleIsValid(tuple))
return InvalidOid;
- result = HeapTupleGetOid(tuple);
+ result = heap_getattr(tuple, oidcol,
+ SysCache[cacheId]->cc_tupdesc,
+ &isNull);
+ Assert(!isNull); /* columns used as oids should never be NULL */
ReleaseSysCache(tuple);
return result;
}
maxitems *= 2;
items = (EnumItem *) repalloc(items, sizeof(EnumItem) * maxitems);
}
- items[numitems].enum_oid = HeapTupleGetOid(enum_tuple);
+ items[numitems].enum_oid = en->oid;
items[numitems].sort_order = en->enumsortorder;
numitems++;
}
static CFuncHashTabEntry *
lookup_C_func(HeapTuple procedureTuple)
{
- Oid fn_oid = HeapTupleGetOid(procedureTuple);
+ Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
CFuncHashTabEntry *entry;
if (CFuncHash == NULL)
record_C_func(HeapTuple procedureTuple,
PGFunction user_fn, const Pg_finfo_record *inforec)
{
- Oid fn_oid = HeapTupleGetOid(procedureTuple);
+ Oid fn_oid = ((Form_pg_proc) GETSTRUCT(procedureTuple))->oid;
CFuncHashTabEntry *entry;
bool found;
if (numoutargs < 2 && prokind != PROKIND_PROCEDURE)
return NULL;
- desc = CreateTemplateTupleDesc(numoutargs, false);
+ desc = CreateTemplateTupleDesc(numoutargs);
for (i = 0; i < numoutargs; i++)
{
TupleDescInitEntry(desc, i + 1,
/* OK, get the column alias */
attname = strVal(linitial(colaliases));
- tupdesc = CreateTemplateTupleDesc(1, false);
+ tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitEntry(tupdesc,
(AttrNumber) 1,
attname,
}
rform = (Form_pg_authid) GETSTRUCT(roleTup);
- roleid = HeapTupleGetOid(roleTup);
+ roleid = rform->oid;
rname = NameStr(rform->rolname);
AuthenticatedUserId = roleid;
* form a scan key
*/
ScanKeyInit(&key[0],
- ObjectIdAttributeNumber,
+ Anum_pg_database_oid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dboid));
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", in_dbname)));
dbform = (Form_pg_database) GETSTRUCT(tuple);
- MyDatabaseId = HeapTupleGetOid(tuple);
+ MyDatabaseId = dbform->oid;
MyDatabaseTableSpace = dbform->dattablespace;
/* take database name from the caller, just for paranoia */
strlcpy(dbname, in_dbname, sizeof(dbname));
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database %u does not exist", dboid)));
dbform = (Form_pg_database) GETSTRUCT(tuple);
- MyDatabaseId = HeapTupleGetOid(tuple);
+ MyDatabaseId = dbform->oid;
MyDatabaseTableSpace = dbform->dattablespace;
Assert(MyDatabaseId == dboid);
strlcpy(dbname, NameStr(dbform->datname), sizeof(dbname));
tuple = GetDatabaseTuple(dbname);
if (!HeapTupleIsValid(tuple) ||
- MyDatabaseId != HeapTupleGetOid(tuple) ||
+ MyDatabaseId != ((Form_pg_database) GETSTRUCT(tuple))->oid ||
MyDatabaseTableSpace != ((Form_pg_database) GETSTRUCT(tuple))->dattablespace)
ereport(FATAL,
(errcode(ERRCODE_UNDEFINED_DATABASE),
bool row_security;
bool check_function_bodies = true;
-bool default_with_oids = false;
bool session_auth_is_superuser;
int log_min_error_statement = ERROR;
true,
NULL, NULL, NULL
},
- {
- {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
- gettext_noop("Create new tables with OIDs by default."),
- NULL
- },
- &default_with_oids,
- false,
- NULL, NULL, NULL
- },
{
{"logging_collector", PGC_POSTMASTER, LOGGING_WHERE,
gettext_noop("Start a subprocess to capture stderr output and/or csvlogs into log files."),
if (guc_name_compare(name, "all") == 0)
{
/* need a tuple descriptor representing three TEXT columns */
- tupdesc = CreateTemplateTupleDesc(3, false);
+ tupdesc = CreateTemplateTupleDesc(3);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
(void) GetConfigOptionByName(name, &varname, false);
/* need a tuple descriptor representing a single TEXT column */
- tupdesc = CreateTemplateTupleDesc(1, false);
+ tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
TEXTOID, -1, 0);
}
value = GetConfigOptionByName(name, &varname, false);
/* need a tuple descriptor representing a single TEXT column */
- tupdesc = CreateTemplateTupleDesc(1, false);
+ tupdesc = CreateTemplateTupleDesc(1);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, varname,
TEXTOID, -1, 0);
bool isnull[3] = {false, false, false};
/* need a tuple descriptor representing three TEXT columns */
- tupdesc = CreateTemplateTupleDesc(3, false);
+ tupdesc = CreateTemplateTupleDesc(3);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "name",
TEXTOID, -1, 0);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 2, "setting",
* need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
* of the appropriate types
*/
- tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false);
+ tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
oldcontext = MemoryContextSwitchTo(per_query_ctx);
/* Build a tuple descriptor for our result type */
- tupdesc = CreateTemplateTupleDesc(NUM_PG_FILE_SETTINGS_ATTS, false);
+ tupdesc = CreateTemplateTupleDesc(NUM_PG_FILE_SETTINGS_ATTS);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "sourcefile",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "sourceline",
* 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, "pg_control_version",
INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "catalog_version_no",
* Construct a tuple descriptor for the result row. This must match this
* function's pg_proc entry!
*/
- tupdesc = CreateTemplateTupleDesc(18, false);
+ tupdesc = CreateTemplateTupleDesc(18);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "checkpoint_lsn",
LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "redo_lsn",
* Construct a tuple descriptor for the result row. This must match this
* function's pg_proc entry!
*/
- tupdesc = CreateTemplateTupleDesc(5, false);
+ tupdesc = CreateTemplateTupleDesc(5);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "min_recovery_end_lsn",
LSNOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "min_recovery_end_timeline",
* Construct a tuple descriptor for the result row. This must match this
* function's pg_proc entry!
*/
- tupdesc = CreateTemplateTupleDesc(12, false);
+ tupdesc = CreateTemplateTupleDesc(12);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "max_data_alignment",
INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "database_block_size",
#array_nulls = on
#backslash_quote = safe_encoding # on, off, or safe_encoding
-#default_with_oids = off
#escape_string_warning = on
#lo_compat_privileges = off
#operator_precedence_warning = off
* build tupdesc for result tuples. This must match the definition of the
* pg_cursors view in system_views.sql
*/
- tupdesc = CreateTemplateTupleDesc(6, false);
+ tupdesc = CreateTemplateTupleDesc(6);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
TEXTOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "statement",
" objoid oid, "
" classname name, "
" objsubid int4, "
- " description text) WITHOUT OIDS;\n\n");
+ " description text);\n\n");
PG_CMD_PRINTF1("COPY tmp_pg_description FROM E'%s';\n\n",
escape_quotes(desc_file));
PG_CMD_PUTS("CREATE TEMP TABLE tmp_pg_shdescription ( "
" objoid oid, "
" classname name, "
- " description text) WITHOUT OIDS;\n\n");
+ " description text);\n\n");
PG_CMD_PRINTF1("COPY tmp_pg_shdescription FROM E'%s';\n\n",
escape_quotes(shdesc_file));
* in pg_collation.h. But add it before reading system collations, so
* that it wins if libc defines a locale named ucs_basic.
*/
- PG_CMD_PRINTF3("INSERT INTO pg_collation (collname, collnamespace, collowner, collprovider, collencoding, collcollate, collctype) VALUES ('ucs_basic', 'pg_catalog'::regnamespace, %u, '%c', %d, 'C', 'C');\n\n",
+ PG_CMD_PRINTF3("INSERT INTO pg_collation (oid, collname, collnamespace, collowner, collprovider, collencoding, collcollate, collctype)"
+ "VALUES (pg_nextoid('pg_catalog.pg_collation', 'oid', 'pg_catalog.pg_collation_oid_index'), 'ucs_basic', 'pg_catalog'::regnamespace, %u, '%c', %d, 'C', 'C');\n\n",
BOOTSTRAP_SUPERUSERID, COLLPROVIDER_LIBC, PG_UTF8);
/* Now import all collations we can find in the operating system */
const char *pghost;
const char *pgport;
const char *username;
- bool oids;
int binary_upgrade;
static char *replace_line_endings(const char *str);
static void _doSetFixedOutputState(ArchiveHandle *AH);
static void _doSetSessionAuth(ArchiveHandle *AH, const char *user);
-static void _doSetWithOids(ArchiveHandle *AH, const bool withOids);
static void _reconnectToDB(ArchiveHandle *AH, const char *dbname);
static void _becomeUser(ArchiveHandle *AH, const char *user);
static void _becomeOwner(ArchiveHandle *AH, TocEntry *te);
const char *tag,
const char *namespace,
const char *tablespace,
- const char *owner, bool withOids,
+ const char *owner,
const char *desc, teSection section,
const char *defn,
const char *dropStmt, const char *copyStmt,
newToc->namespace = namespace ? pg_strdup(namespace) : NULL;
newToc->tablespace = tablespace ? pg_strdup(tablespace) : NULL;
newToc->owner = pg_strdup(owner);
- newToc->withOids = withOids;
newToc->desc = pg_strdup(desc);
newToc->defn = pg_strdup(defn);
newToc->dropStmt = pg_strdup(dropStmt);
AH->currUser = NULL; /* unknown */
AH->currSchema = NULL; /* ditto */
AH->currTablespace = NULL; /* ditto */
- AH->currWithOids = -1; /* force SET */
AH->toc = (TocEntry *) pg_malloc0(sizeof(TocEntry));
WriteStr(AH, te->namespace);
WriteStr(AH, te->tablespace);
WriteStr(AH, te->owner);
- WriteStr(AH, te->withOids ? "true" : "false");
+ WriteStr(AH, "false");
/* Dump list of dependencies */
for (i = 0; i < te->nDeps; i++)
te->tablespace = ReadStr(AH);
te->owner = ReadStr(AH);
- if (AH->version >= K_VERS_1_9)
- {
- if (strcmp(ReadStr(AH), "true") == 0)
- te->withOids = true;
- else
- te->withOids = false;
- }
- else
- te->withOids = true;
+ if (AH->version < K_VERS_1_9 || strcmp(ReadStr(AH), "true") == 0)
+ write_msg(modulename,
+ "WARNING: restoring tables WITH OIDS is not supported anymore");
/* Read TOC entry dependencies */
if (AH->version >= K_VERS_1_5)
}
-/*
- * Issue a SET default_with_oids command. Caller is responsible
- * for updating state if appropriate.
- */
-static void
-_doSetWithOids(ArchiveHandle *AH, const bool withOids)
-{
- PQExpBuffer cmd = createPQExpBuffer();
-
- appendPQExpBuffer(cmd, "SET default_with_oids = %s;", withOids ?
- "true" : "false");
-
- if (RestoringToDB(AH))
- {
- PGresult *res;
-
- res = PQexec(AH->connection, cmd->data);
-
- if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- warn_or_exit_horribly(AH, modulename,
- "could not set default_with_oids: %s",
- PQerrorMessage(AH->connection));
-
- PQclear(res);
- }
- else
- ahprintf(AH, "%s\n\n", cmd->data);
-
- destroyPQExpBuffer(cmd);
-}
-
-
/*
* Issue the commands to connect to the specified database.
*
if (AH->currTablespace)
free(AH->currTablespace);
AH->currTablespace = NULL;
- AH->currWithOids = -1;
/* re-establish fixed state */
_doSetFixedOutputState(AH);
}
-/*
- * Set the proper default_with_oids value for the table.
- */
-static void
-_setWithOids(ArchiveHandle *AH, TocEntry *te)
-{
- if (AH->currWithOids != te->withOids)
- {
- _doSetWithOids(AH, te->withOids);
- AH->currWithOids = te->withOids;
- }
-}
-
-
/*
* Issue the commands to select the specified schema as the current schema
* in the target database.
_selectOutputSchema(AH, te->namespace);
_selectTablespace(AH, te->tablespace);
- /* Set up OID mode too */
- if (strcmp(te->desc, "TABLE") == 0)
- _setWithOids(AH, te);
-
/* Emit header comment for item */
if (!AH->noTocComments)
{
if (AH->currTablespace)
free(AH->currTablespace);
AH->currTablespace = NULL;
- AH->currWithOids = -1;
}
/*
clone->currUser = NULL;
clone->currSchema = NULL;
clone->currTablespace = NULL;
- clone->currWithOids = -1;
/* savedPassword must be local in case we change it while connecting */
if (clone->savedPassword)
char *currUser; /* current username, or NULL if unknown */
char *currSchema; /* current schema, or NULL */
char *currTablespace; /* current tablespace, or NULL */
- char currWithOids; /* current default_with_oids setting: true,
- * false, or -1 for unknown, forcing a SET */
void *lo_buf;
size_t lo_buf_used;
char *tablespace; /* null if not in a tablespace; empty string
* means use database default */
char *owner;
- bool withOids; /* Used only by "TABLE" tags */
char *desc;
char *defn;
char *dropStmt;
CatalogId catalogId, DumpId dumpId,
const char *tag,
const char *namespace, const char *tablespace,
- const char *owner, bool withOids,
+ const char *owner,
const char *desc, teSection section,
const char *defn,
const char *dropStmt, const char *copyStmt,
DumpableObject *boundaryObjs);
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo);
-static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids, char relkind);
-static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids);
+static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, char relkind);
+static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo);
static void buildMatViewRefreshDependencies(Archive *fout);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs,
{"host", required_argument, NULL, 'h'},
{"jobs", 1, NULL, 'j'},
{"no-reconnect", no_argument, NULL, 'R'},
- {"oids", no_argument, NULL, 'o'},
{"no-owner", no_argument, NULL, 'O'},
{"port", required_argument, NULL, 'p'},
{"schema", required_argument, NULL, 'n'},
simple_string_list_append(&schema_exclude_patterns, optarg);
break;
- case 'o': /* Dump oids */
- dopt.oids = true;
- break;
-
case 'O': /* Don't reconnect to match owner */
dopt.outputNoOwner = 1;
break;
exit_nicely(1);
}
- if (dopt.dump_inserts && dopt.oids)
- {
- write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n");
- write_msg(NULL, "(The INSERT command cannot set OIDs.)\n");
- exit_nicely(1);
- }
-
if (dopt.if_exists && !dopt.outputClean)
exit_horribly(NULL, "option --if-exists requires option -c/--clean\n");
if (!dopt.schemaOnly)
{
- getTableData(&dopt, tblinfo, numTables, dopt.oids, 0);
+ getTableData(&dopt, tblinfo, numTables, 0);
buildMatViewRefreshDependencies(fout);
if (dopt.dataOnly)
getTableDataFKConstraints();
}
if (dopt.schemaOnly && dopt.sequence_data)
- getTableData(&dopt, tblinfo, numTables, dopt.oids, RELKIND_SEQUENCE);
+ getTableData(&dopt, tblinfo, numTables, RELKIND_SEQUENCE);
/*
* In binary-upgrade mode, we do not have to worry about the actual blob
printf(_(" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
printf(_(" -n, --schema=SCHEMA dump the named schema(s) only\n"));
printf(_(" -N, --exclude-schema=SCHEMA do NOT dump the named schema(s)\n"));
- printf(_(" -o, --oids include OIDs in dump\n"));
printf(_(" -O, --no-owner skip restoration of object ownership in\n"
" plain-text format\n"));
printf(_(" -s, --schema-only dump only the schema, no data\n"));
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
const char *classname = tbinfo->dobj.name;
- const bool hasoids = tbinfo->hasoids;
- const bool oids = tdinfo->oids;
PQExpBuffer q = createPQExpBuffer();
/*
*/
column_list = fmtCopyColumnList(tbinfo, clistBuf);
- if (oids && hasoids)
- {
- appendPQExpBuffer(q, "COPY %s %s WITH OIDS TO stdout;",
- fmtQualifiedDumpable(tbinfo),
- column_list);
- }
- else if (tdinfo->filtercond)
+ if (tdinfo->filtercond)
{
/* Note: this syntax is only supported in 8.2 and up */
appendPQExpBufferStr(q, "COPY (SELECT ");
/* must use 2 steps here 'cause fmtId is nonreentrant */
appendPQExpBuffer(copyBuf, "COPY %s ",
copyFrom);
- appendPQExpBuffer(copyBuf, "%s %sFROM stdin;\n",
- fmtCopyColumnList(tbinfo, clistBuf),
- (tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : "");
+ appendPQExpBuffer(copyBuf, "%s FROM stdin;\n",
+ fmtCopyColumnList(tbinfo, clistBuf));
copyStmt = copyBuf->data;
}
else
te = ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId,
tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name,
NULL, tbinfo->rolname,
- false, "TABLE DATA", SECTION_DATA,
+ "TABLE DATA", SECTION_DATA,
"", "", copyStmt,
&(tbinfo->dobj.dumpId), 1,
dumpFn, tdinfo);
tbinfo->dobj.namespace->dobj.name, /* Namespace */
NULL, /* Tablespace */
tbinfo->rolname, /* Owner */
- false, /* with oids */
"MATERIALIZED VIEW DATA", /* Desc */
SECTION_POST_DATA, /* Section */
q->data, /* Create */
* set up dumpable objects representing the contents of tables
*/
static void
-getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids, char relkind)
+getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, char relkind)
{
int i;
{
if (tblinfo[i].dobj.dump & DUMP_COMPONENT_DATA &&
(!relkind || tblinfo[i].relkind == relkind))
- makeTableDataInfo(dopt, &(tblinfo[i]), oids);
+ makeTableDataInfo(dopt, &(tblinfo[i]));
}
}
* table data; the "dump" flag in such objects isn't used.
*/
static void
-makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids)
+makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo)
{
TableDataInfo *tdinfo;
tdinfo->dobj.name = tbinfo->dobj.name;
tdinfo->dobj.namespace = tbinfo->dobj.namespace;
tdinfo->tdtable = tbinfo;
- tdinfo->oids = oids;
tdinfo->filtercond = NULL; /* might get set later */
addObjectDependency(&tdinfo->dobj, tbinfo->dobj.dumpId);
NULL, /* Namespace */
NULL, /* Tablespace */
dba, /* Owner */
- false, /* with oids */
"DATABASE", /* Desc */
SECTION_PRE_DATA, /* Section */
creaQry->data, /* Create */
ArchiveEntry(fout, nilCatalogId, createDumpId(),
labelq->data, NULL, NULL, dba,
- false, "COMMENT", SECTION_NONE,
+ "COMMENT", SECTION_NONE,
dbQry->data, "", NULL,
&(dbDumpId), 1,
NULL, NULL);
if (seclabelQry->len > 0)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
labelq->data, NULL, NULL, dba,
- false, "SECURITY LABEL", SECTION_NONE,
+ "SECURITY LABEL", SECTION_NONE,
seclabelQry->data, "", NULL,
&(dbDumpId), 1,
NULL, NULL);
if (creaQry->len > 0)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
datname, NULL, NULL, dba,
- false, "DATABASE PROPERTIES", SECTION_PRE_DATA,
+ "DATABASE PROPERTIES", SECTION_PRE_DATA,
creaQry->data, delQry->data, NULL,
&(dbDumpId), 1,
NULL, NULL);
LargeObjectRelationId);
ArchiveEntry(fout, nilCatalogId, createDumpId(),
"pg_largeobject", NULL, NULL, "",
- false, "pg_largeobject", SECTION_PRE_DATA,
+ "pg_largeobject", SECTION_PRE_DATA,
loOutQry->data, "", NULL,
NULL, 0,
NULL, NULL);
LargeObjectMetadataRelationId);
ArchiveEntry(fout, nilCatalogId, createDumpId(),
"pg_largeobject_metadata", NULL, NULL, "",
- false, "pg_largeobject_metadata", SECTION_PRE_DATA,
+ "pg_largeobject_metadata", SECTION_PRE_DATA,
loOutQry->data, "", NULL,
NULL, 0,
NULL, NULL);
ArchiveEntry(AH, nilCatalogId, createDumpId(),
"ENCODING", NULL, NULL, "",
- false, "ENCODING", SECTION_PRE_DATA,
+ "ENCODING", SECTION_PRE_DATA,
qry->data, "", NULL,
NULL, 0,
NULL, NULL);
ArchiveEntry(AH, nilCatalogId, createDumpId(),
"STDSTRINGS", NULL, NULL, "",
- false, "STDSTRINGS", SECTION_PRE_DATA,
+ "STDSTRINGS", SECTION_PRE_DATA,
qry->data, "", NULL,
NULL, 0,
NULL, NULL);
ArchiveEntry(AH, nilCatalogId, createDumpId(),
"SEARCHPATH", NULL, NULL, "",
- false, "SEARCHPATH", SECTION_PRE_DATA,
+ "SEARCHPATH", SECTION_PRE_DATA,
qry->data, "", NULL,
NULL, 0,
NULL, NULL);
ArchiveEntry(fout, binfo->dobj.catId, binfo->dobj.dumpId,
binfo->dobj.name,
NULL, NULL,
- binfo->rolname, false,
+ binfo->rolname,
"BLOB", SECTION_PRE_DATA,
cquery->data, dquery->data, NULL,
NULL, 0,
polinfo->dobj.name,
polinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->rolname, false,
+ tbinfo->rolname,
"ROW SECURITY", SECTION_POST_DATA,
query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
tag,
polinfo->dobj.namespace->dobj.name,
NULL,
- tbinfo->rolname, false,
+ tbinfo->rolname,
"POLICY", SECTION_POST_DATA,
query->data, delqry->data, NULL,
NULL, 0,
pubinfo->dobj.name,
NULL,
NULL,
- pubinfo->rolname, false,
+ pubinfo->rolname,
"PUBLICATION", SECTION_POST_DATA,
query->data, delq->data, NULL,
NULL, 0,
tag,
tbinfo->dobj.namespace->dobj.name,
NULL,
- "", false,
+ "",
"PUBLICATION TABLE", SECTION_POST_DATA,
query->data, "", NULL,
NULL, 0,
subinfo->dobj.name,
NULL,
NULL,
- subinfo->rolname, false,
+ subinfo->rolname,
"SUBSCRIPTION", SECTION_POST_DATA,
query->data, delq->data, NULL,
NULL, 0,
char *partkeydef = "NULL";
char *ispartition = "false";
char *partbound = "NULL";
+ char *relhasoids = "c.relhasoids";
PQExpBuffer acl_subquery = createPQExpBuffer();
PQExpBuffer racl_subquery = createPQExpBuffer();
partbound = "pg_get_expr(c.relpartbound, c.oid)";
}
+ /* In PG12 upwards WITH OIDS does not exist anymore. */
+ if (fout->remoteVersion >= 120000)
+ relhasoids = "'f'::bool";
+
/*
* Left join to pick up dependency info linking sequences to their
* owning column, if any (note this dependency is AUTO as of 8.2)
"c.relkind, c.relnamespace, "
"(%s c.relowner) AS rolname, "
"c.relchecks, c.relhastriggers, "
- "c.relhasindex, c.relhasrules, c.relhasoids, "
+ "c.relhasindex, c.relhasrules, %s AS relhasoids, "
"c.relrowsecurity, c.relforcerowsecurity, "
"c.relfrozenxid, c.relminmxid, tc.oid AS toid, "
"tc.relfrozenxid AS tfrozenxid, "
initacl_subquery->data,
initracl_subquery->data,
username_subquery,
+ relhasoids,
RELKIND_SEQUENCE,
attacl_subquery->data,
attracl_subquery->data,
*/
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tag->data, namespace, NULL, owner,
- false, "COMMENT", SECTION_NONE,
+ "COMMENT", SECTION_NONE,
query->data, "", NULL,
&(dumpId), 1,
NULL, NULL);
tag->data,
tbinfo->dobj.namespace->dobj.name,
NULL, tbinfo->rolname,
- false, "COMMENT", SECTION_NONE,
+ "COMMENT", SECTION_NONE,
query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);