mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +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:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.30 2002/06/20 20:29:27 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.31 2002/07/20 05:16:57 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -170,7 +170,7 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType,
|
||||
* Now calculate the tuple type for the cleaned tuple (we were already
|
||||
* given the type for the original targetlist).
|
||||
*/
|
||||
cleanTupType = ExecTypeFromTL(cleanTargetList);
|
||||
cleanTupType = ExecTypeFromTL(cleanTargetList, tupType->tdhasoid);
|
||||
|
||||
len = ExecTargetListLength(targetList);
|
||||
cleanLength = ExecTargetListLength(cleanTargetList);
|
||||
@ -383,8 +383,8 @@ ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
|
||||
* information for the new "clean" tuple.
|
||||
*
|
||||
* Note: we use memory on the stack to optimize things when we are
|
||||
* dealing with a small number of tuples. for large tuples we just use
|
||||
* palloc.
|
||||
* dealing with a small number of attributes. for large tuples we
|
||||
* just use palloc.
|
||||
*/
|
||||
if (cleanLength > 64)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.170 2002/07/11 21:36:20 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.171 2002/07/20 05:16:57 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -716,6 +716,10 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
|
||||
get_namespace_name(namespaceId));
|
||||
}
|
||||
|
||||
/*
|
||||
* new "INTO" table is created WITH OIDS
|
||||
*/
|
||||
tupType->tdhasoid = WITHOID;
|
||||
/*
|
||||
* have to copy tupType to get rid of constraints
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.99 2002/07/18 17:14:19 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.100 2002/07/20 05:16:57 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1770,7 +1770,10 @@ ExecTargetList(List *targetlist,
|
||||
* natts = 0 to deal with it.
|
||||
*/
|
||||
if (targettype == NULL)
|
||||
{
|
||||
targettype = &NullTupleDesc;
|
||||
targettype->tdhasoid = WITHOUTOID;
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate an array of char's to hold the "null" information only if
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.54 2002/07/18 04:40:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.55 2002/07/20 05:16:57 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -540,6 +540,7 @@ ExecInitNullTupleSlot(EState *estate, TupleDesc tupType)
|
||||
|
||||
ExecSetSlotDescriptor(slot, tupType, false);
|
||||
|
||||
NullTupleDesc.tdhasoid = WITHOUTOID;
|
||||
nullTuple = heap_formtuple(&NullTupleDesc, values, nulls);
|
||||
|
||||
return ExecStoreTuple(nullTuple, slot, InvalidBuffer, true);
|
||||
@ -557,7 +558,7 @@ ExecInitNullTupleSlot(EState *estate, TupleDesc tupType)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
TupleDesc
|
||||
ExecTypeFromTL(List *targetList)
|
||||
ExecTypeFromTL(List *targetList, hasoid_t withoid)
|
||||
{
|
||||
List *tlitem;
|
||||
TupleDesc typeInfo;
|
||||
@ -576,7 +577,7 @@ ExecTypeFromTL(List *targetList)
|
||||
/*
|
||||
* allocate a new typeInfo
|
||||
*/
|
||||
typeInfo = CreateTemplateTupleDesc(len);
|
||||
typeInfo = CreateTemplateTupleDesc(len, withoid);
|
||||
|
||||
/*
|
||||
* scan list, generate type info for each entry
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.86 2002/06/26 21:58:56 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.87 2002/07/20 05:16:58 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -290,9 +290,23 @@ ExecAssignResultTypeFromOuterPlan(Plan *node, CommonState *commonstate)
|
||||
void
|
||||
ExecAssignResultTypeFromTL(Plan *node, CommonState *commonstate)
|
||||
{
|
||||
ResultRelInfo *ri;
|
||||
Relation rel;
|
||||
hasoid_t withoid;
|
||||
TupleDesc tupDesc;
|
||||
|
||||
tupDesc = ExecTypeFromTL(node->targetlist);
|
||||
ri = node->state->es_result_relation_info;
|
||||
if (ri != NULL)
|
||||
rel = ri->ri_RelationDesc;
|
||||
else
|
||||
rel = node->state->es_into_relation_descriptor;
|
||||
|
||||
if (rel != NULL)
|
||||
withoid = BoolToHasOid(rel->rd_rel->relhasoids);
|
||||
else
|
||||
withoid = WITHOUTOID;
|
||||
|
||||
tupDesc = ExecTypeFromTL(node->targetlist, withoid);
|
||||
ExecAssignResultType(commonstate, tupDesc, true);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.2 2002/06/20 20:29:28 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.3 2002/07/20 05:16:58 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -234,7 +234,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, Plan *parent)
|
||||
*/
|
||||
char *attname = strVal(lfirst(rte->eref->colnames));
|
||||
|
||||
tupdesc = CreateTemplateTupleDesc(1);
|
||||
tupdesc = CreateTemplateTupleDesc(1, WITHOUTOID);
|
||||
TupleDescInitEntry(tupdesc,
|
||||
(AttrNumber) 1,
|
||||
attname,
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.71 2002/06/20 20:29:28 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.72 2002/07/20 05:16:58 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -435,11 +435,15 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
|
||||
{
|
||||
mtuple = heap_formtuple(rel->rd_att, v, n);
|
||||
infomask = mtuple->t_data->t_infomask;
|
||||
memmove(&(mtuple->t_data->t_oid), &(tuple->t_data->t_oid),
|
||||
((char *) &(tuple->t_data->t_hoff) -
|
||||
(char *) &(tuple->t_data->t_oid)));
|
||||
/*
|
||||
* copy t_xmin, t_cid, t_xmax, t_ctid, t_natts, t_infomask
|
||||
*/
|
||||
memmove((char *)mtuple->t_data, (char *)tuple->t_data,
|
||||
offsetof(HeapTupleHeaderData, t_hoff));
|
||||
mtuple->t_data->t_infomask = infomask;
|
||||
mtuple->t_data->t_natts = numberOfAttributes;
|
||||
if (rel->rd_rel->relhasoids)
|
||||
HeapTupleSetOid(mtuple, HeapTupleGetOid(tuple));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user