- 4 bytes per row (on most machines), slightly improving performance.
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name
[ (column_name [, ...] ) ]
- [ WITH ( storage_parameter [= value ] [, ... ] ) | WITH OIDS | WITH OUT OIDS ]
+ [ WITH ( storage_parameter [= value ] [, ... ] ) | WITHOUT OIDS ]
[ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
[ TABLESPACE tablespace_name ]
AS query
This clause specifies optional storage parameters for the new table;
see
endterm="sql-createtable-storage-parameters-title"/> for more
- information. The WITH clause
- can also include OIDS=TRUE (or just OIDS )
- to specify that rows of the new table
- should have OIDs (object identifiers) assigned to them, or
- OIDS=FALSE to specify that the rows should not have OIDs.
- See for more information.
+ information. For backward-compatibility the WITH
+ clause for a table can also include OIDS=FALSE to
+ specify that rows of the new table should contain no OIDs (object
+ identifiers), OIDS=TRUE is not supported anymore.
+ OIDs.
- WITH OIDS
WITHOUT OIDS
- These are obsolescent syntaxes equivalent to WITH (OIDS)
- and WITH (OIDS=FALSE) , respectively. If you wish to give
- both an OIDS setting and storage parameters, you must use
- the WITH ( ... ) syntax; see above.
+ This is backward-compatible syntax for declaring a table
+ WITHOUT OIDS , creating a table WITH
+ OIDS is not supported anymore.
TABLE AS offers a superset of the functionality offered
by SELECT INTO .
-
- The CREATE TABLE AS command allows the user to
- explicitly specify whether OIDs should be included. If the
- presence of OIDs is not explicitly specified,
- the configuration variable is
- used.
-
Create a new temporary table films_recent , consisting of
only recent entries from the table films , 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:
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');
The
WITH clause is a
PostgreSQL
- extension; neither storage parameters nor OIDs are in the standard.
+ extension; storage parameters are not in the standard.
-
- -o
- --oids
-
- Dump object identifiers (
OID s) as part of the
- data for every table. Use this option if your application references
- columns in some way (e.g., in a foreign key constraint).
- Otherwise, this option should not be used.
-
-
-
-
-O
--no-owner
CREATE TABLE AS offers a superset of the
functionality provided by SELECT INTO .
-
- To add OIDs to the table created by SELECT INTO ,
- enable the configuration
- variable. Alternatively, CREATE TABLE AS can be
- used with the WITH OIDS clause.
-
Prevent foreign tables from being created with OIDS
- when <xref linkend="guc-default-with-oids"/ > is true
+ when <literal>default_with_oids"> is true
(Etsuro Fujita)
Prevent foreign tables from being created with OIDS
- when <xref linkend="guc-default-with-oids"/ > is true
+ when <literal>default_with_oids"> is true
(Etsuro Fujita)
Prevent foreign tables from being created with OIDS
- when <xref linkend="guc-default-with-oids"/ > is true
+ when <literal>default_with_oids"> is true
(Etsuro Fujita)
/* 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.
*/
-O id
+vo id
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.
*/
-O id
+vo id
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 boot_index_params
%type boot_index_param
%type boot_ident
-%type optbootstrap optsharedrelation optwithoutoids boot_column_nullness
-%type oidspec optoideq opt rowtypeoid
+%type optbootstrap optsharedrelation boot_column_nullness
+%type oidspec optrowtypeoid
%token ID
%token COMMA EQUALS LPAREN RPAREN
/* All the rest are unreserved, and should be handled in boot_ident! */
%token OPEN XCLOSE XCREATE INSERT_TUPLE
%token XDECLARE INDEX ON USING XBUILD INDICES UNIQUE XTOAST
-%token OBJ_ID XBOOTSTRAP XSHARED_RELATION XWITHOUT_OIDS X ROWTYPE_OID
+%token OBJ_ID XBOOTSTRAP XSHARED_RELATION XROWTYPE_OID
%token XFORCE XNOT XNULL
%start TopLevel
;
Boot_CreateStmt:
- XCREATE boot_ident oidspec optbootstrap optsharedrelation optwithoutoids opt rowtypeoid 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 object id)
+InsertOneTuple(vo id)
{
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
#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.)
*/
-O id
+vo id
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.
*/
-O id
+vo id
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->opr code);
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 ))));
}
/*