mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
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
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.159 2002/07/18 04:43:50 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.160 2002/07/20 05:16:57 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -614,9 +614,13 @@ CopyTo(Relation rel, List *attlist, bool binary, bool oids,
|
||||
/* Send OID if wanted --- note fld_count doesn't include it */
|
||||
if (oids)
|
||||
{
|
||||
Oid oid;
|
||||
|
||||
AssertTupleDescHasOid(tupDesc);
|
||||
oid = HeapTupleGetOid(tuple);
|
||||
fld_size = sizeof(Oid);
|
||||
CopySendData(&fld_size, sizeof(int16), fp);
|
||||
CopySendData(&tuple->t_data->t_oid, sizeof(Oid), fp);
|
||||
CopySendData(&oid, sizeof(Oid), fp);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -624,8 +628,9 @@ CopyTo(Relation rel, List *attlist, bool binary, bool oids,
|
||||
/* Text format has no per-tuple header, but send OID if wanted */
|
||||
if (oids)
|
||||
{
|
||||
AssertTupleDescHasOid(tupDesc);
|
||||
string = DatumGetCString(DirectFunctionCall1(oidout,
|
||||
ObjectIdGetDatum(tuple->t_data->t_oid)));
|
||||
ObjectIdGetDatum(HeapTupleGetOid(tuple))));
|
||||
CopySendString(string, fp);
|
||||
pfree(string);
|
||||
need_delim = true;
|
||||
@ -1069,7 +1074,7 @@ CopyFrom(Relation rel, List *attlist, bool binary, bool oids,
|
||||
tuple = heap_formtuple(tupDesc, values, nulls);
|
||||
|
||||
if (oids && file_has_oids)
|
||||
tuple->t_data->t_oid = loaded_oid;
|
||||
HeapTupleSetOid(tuple, loaded_oid);
|
||||
|
||||
skip_tuple = false;
|
||||
|
||||
|
Reference in New Issue
Block a user