diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-07-20 05:16:59 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-07-20 05:16:59 +0000 |
commit | b0f5086e4133d1d8ec092799952dda65ebd717c8 (patch) | |
tree | 0f717342af7cce7896d40fdb34ccc572e435d499 /src/backend/commands/tablecmds.c | |
parent | 38dd3ae7d032eecc6ddadcbd402d90f6ac38f6a3 (diff) | |
download | postgresql-b0f5086e4133d1d8ec092799952dda65ebd717c8.tar.gz postgresql-b0f5086e4133d1d8ec092799952dda65ebd717c8.zip |
oid is needed, it is added at the end of the struct (after the null
bitmap, if present).
Per Tom Lane's suggestion the information whether a tuple has an oid
or not is carried in the tuple descriptor. For debugging reasons
tdhasoid is of type char, not bool. There are predefined values for
WITHOID, WITHOUTOID and UNDEFOID.
This patch has been generated against a cvs snapshot from last week
and I don't expect it to apply cleanly to current sources. While I
post it here for public review, I'm working on a new version against a
current snapshot. (There's been heavy activity recently; hope to
catch up some day ...)
This is a long patch; if it is too hard to swallow, I can provide it
in smaller pieces:
Part 1: Accessor macros
Part 2: tdhasoid in TupDesc
Part 3: Regression test
Part 4: Parameter withoid to heap_addheader
Part 5: Eliminate t_oid from HeapTupleHeader
Part 2 is the most hairy part because of changes in the executor and
even in the parser; the other parts are straightforward.
Up to part 4 the patched postmaster stays binary compatible to
databases created with an unpatched version. Part 5 is small (100
lines) and finally breaks compatibility.
Manfred Koizar
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 391adb04225..6b943723bb8 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.23 2002/07/16 22:12:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.24 2002/07/20 05:16:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -149,6 +149,7 @@ DefineRelation(CreateStmt *stmt, char relkind) * have to copy inherited constraints here.) */ descriptor = BuildDescForRelation(schema); + descriptor->tdhasoid = BoolToHasOid(stmt->hasoids || parentHasOids); if (old_constraints != NIL) { @@ -1658,6 +1659,7 @@ AlterTableAddColumn(Oid myrelid, tform = (Form_pg_type) GETSTRUCT(typeTuple); attributeTuple = heap_addheader(Natts_pg_attribute, + false, ATTRIBUTE_TUPLE_SIZE, (void *) &attributeD); @@ -1665,7 +1667,7 @@ AlterTableAddColumn(Oid myrelid, attribute->attrelid = myrelid; namestrcpy(&(attribute->attname), colDef->colname); - attribute->atttypid = typeTuple->t_data->t_oid; + attribute->atttypid = HeapTupleGetOid(typeTuple); attribute->attstattarget = DEFAULT_ATTSTATTARGET; attribute->attlen = tform->typlen; attribute->attcacheoff = -1; @@ -1682,6 +1684,7 @@ AlterTableAddColumn(Oid myrelid, ReleaseSysCache(typeTuple); + AssertTupleDescHasNoOid(attrdesc->rd_att); simple_heap_insert(attrdesc, attributeTuple); /* Update indexes on pg_attribute */ @@ -1702,6 +1705,7 @@ AlterTableAddColumn(Oid myrelid, newreltup = heap_copytuple(reltup); ((Form_pg_class) GETSTRUCT(newreltup))->relnatts = maxatts; + AssertTupleDescHasOid(pgclass->rd_att); simple_heap_update(pgclass, &newreltup->t_self, newreltup); /* keep catalog indices current */ @@ -3299,7 +3303,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent) sprintf(toast_idxname, "pg_toast_%u_index", relOid); /* this is pretty painful... need a tuple descriptor */ - tupdesc = CreateTemplateTupleDesc(3); + tupdesc = CreateTemplateTupleDesc(3, WITHOUTOID); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "chunk_id", OIDOID, |