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/executor | |
| parent | 38dd3ae7d032eecc6ddadcbd402d90f6ac38f6a3 (diff) | |
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/executor')
| -rw-r--r-- | src/backend/executor/execJunk.c | 8 | ||||
| -rw-r--r-- | src/backend/executor/execMain.c | 6 | ||||
| -rw-r--r-- | src/backend/executor/execQual.c | 5 | ||||
| -rw-r--r-- | src/backend/executor/execTuples.c | 7 | ||||
| -rw-r--r-- | src/backend/executor/execUtils.c | 18 | ||||
| -rw-r--r-- | src/backend/executor/nodeFunctionscan.c | 4 | ||||
| -rw-r--r-- | src/backend/executor/spi.c | 12 |
7 files changed, 43 insertions, 17 deletions
diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c index 94c375012e1..d808b85337a 100644 --- a/src/backend/executor/execJunk.c +++ b/src/backend/executor/execJunk.c @@ -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) { diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index df7f3b42ae0..ce6d6794d26 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -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 $ * *------------------------------------------------------------------------- */ @@ -717,6 +717,10 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) } /* + * new "INTO" table is created WITH OIDS + */ + tupType->tdhasoid = WITHOID; + /* * have to copy tupType to get rid of constraints */ tupdesc = CreateTupleDescCopy(tupType); diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 63e5bab6ee9..f74f8f1b41b 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -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 diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index 4f234f62b94..5124bd023fb 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -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 diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 7799ed4d935..c2bd2de48ab 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -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); } diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c index 3645a188334..d87f8e6fe88 100644 --- a/src/backend/executor/nodeFunctionscan.c +++ b/src/backend/executor/nodeFunctionscan.c @@ -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, diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 60b39768d53..8535d875328 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -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 { |
