Commit 1ee26b77 authored by Tom Lane's avatar Tom Lane

Reimplement nodeMaterial to use a temporary BufFile (or even memory, if the

materialized tupleset is small enough) instead of a temporary relation.
This was something I was thinking of doing anyway for performance, and Jan
says he needs it for TOAST because he doesn't want to cope with toasting
noname relations.  With this change, the 'noname table' support in heap.c
is dead code, and I have accordingly removed it.  Also clean up 'noname'
plan handling in planner --- nonames are either sort or materialize plans,
and it seems less confusing to handle them separately under those names.
parent 2c0edb3c
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.66 2000/06/08 22:36:54 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.67 2000/06/18 22:43:51 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
......@@ -878,14 +878,6 @@ StartTransaction()
AtStart_Locks();
AtStart_Memory();
/* --------------
initialize temporary relations list
the tempRelList is a list of temporary relations that
are created in the course of the transactions
they need to be destroyed properly at the end of the transactions
*/
InitNoNameRelList();
/* ----------------
* Tell the trigger manager to we're starting a transaction
* ----------------
......@@ -960,7 +952,6 @@ CommitTransaction()
AtCommit_Notify();
CloseSequences();
DropNoNameRels();
AtEOXact_portals();
RecordTransactionCommit();
......@@ -1056,7 +1047,6 @@ AbortTransaction()
CommonSpecialPortalClose();
RecordTransactionAbort();
RelationPurgeLocalRelation(false);
DropNoNameRels();
invalidate_temp_relations();
AtEOXact_nbtree();
AtAbort_Cache();
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.29 2000/01/26 05:56:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.30 2000/06/18 22:43:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -166,7 +166,7 @@ Boot_CreateStmt:
puts("creating bootstrap relation");
tupdesc = CreateTupleDesc(numattr,attrtypes);
reldesc = heap_create(LexIDStr($3), tupdesc,
false, false, true);
false, true);
if (DebugMode)
puts("bootstrap relation created ok");
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.132 2000/06/17 23:41:31 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.133 2000/06/18 22:43:55 tgl Exp $
*
*
* INTERFACE ROUTINES
......@@ -70,14 +70,11 @@ static void AddNewRelationTuple(Relation pg_class_desc,
Relation new_rel_desc, Oid new_rel_oid,
int natts,
char relkind, char *temp_relname);
static void AddToNoNameRelList(Relation r);
static void DeleteAttributeTuples(Relation rel);
static void DeleteRelationTuple(Relation rel);
static void DeleteTypeTuple(Relation rel);
static void RelationRemoveIndexes(Relation relation);
static void RelationRemoveInheritance(Relation relation);
static void RemoveFromNoNameRelList(Relation r);
static void AddNewRelationType(char *typeName, Oid new_rel_oid);
static void StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
bool updatePgAttribute);
......@@ -141,22 +138,6 @@ static Form_pg_attribute HeapAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6};
* ----------------------------------------------------------------
*/
/* the tempRelList holds
the list of temporary uncatalogued relations that are created.
these relations should be destroyed at the end of transactions
*/
typedef struct tempRelList
{
Relation *rels; /* array of relation descriptors */
int num; /* number of temporary relations */
int size; /* size of space allocated for the rels
* array */
} TempRelList;
#define NONAME_REL_LIST_SIZE 32
static TempRelList *tempRels = NULL;
/* ----------------------------------------------------------------
* heap_create - Create an uncataloged heap relation
......@@ -170,15 +151,16 @@ static TempRelList *tempRels = NULL;
* Eventually, must place information about this temporary relation
* into the transaction context block.
*
* NOTE: if istemp is TRUE then heap_create will overwrite relname with
* the unique "real" name chosen for the temp relation.
*
* if heap_create is called with "" as the name, then heap_create will create
* a temporary name "pg_noname.$PID.$SEQUENCE" for the relation
* If storage_create is TRUE then heap_storage_create is called here,
* else caller must call heap_storage_create later.
* ----------------------------------------------------------------
*/
Relation
heap_create(char *relname,
TupleDesc tupDesc,
bool isnoname,
bool istemp,
bool storage_create)
{
......@@ -245,18 +227,11 @@ heap_create(char *relname,
else
relid = newoid();
if (isnoname)
{
Assert(!relname);
relname = palloc(NAMEDATALEN);
snprintf(relname, NAMEDATALEN, "pg_noname.%d.%u",
(int) MyProcPid, uniqueId++);
}
if (istemp)
{
/* replace relname of caller */
snprintf(relname, NAMEDATALEN, "pg_temp.%d.%u", MyProcPid, uniqueId++);
/* replace relname of caller with a unique name for a temp relation */
snprintf(relname, NAMEDATALEN, "pg_temp.%d.%u",
(int) MyProcPid, uniqueId++);
}
/* ----------------
......@@ -268,7 +243,7 @@ heap_create(char *relname,
rel = (Relation) palloc(len);
MemSet((char *) rel, 0, len);
rel->rd_fd = -1; /* table is not open */
rel->rd_unlinked = TRUE; /* table is not created yet */
rel->rd_unlinked = true; /* table is not created yet */
/*
* create a new tuple descriptor from the one passed in
......@@ -310,12 +285,6 @@ heap_create(char *relname,
rel->rd_rel->reltype = relid;
}
/* ----------------
* remember if this is a noname relation
* ----------------
*/
rel->rd_isnoname = isnoname;
/* ----------------
* have the storage manager create the relation.
* ----------------
......@@ -329,13 +298,6 @@ heap_create(char *relname,
MemoryContextSwitchTo(oldcxt);
/*
* add all noname relations to the tempRels list so they can be
* properly disposed of at the end of transaction
*/
if (isnoname)
AddToNoNameRelList(rel);
return rel;
}
......@@ -347,7 +309,7 @@ heap_storage_create(Relation rel)
if (rel->rd_unlinked)
{
rel->rd_fd = (File) smgrcreate(DEFAULT_SMGR, rel);
rel->rd_unlinked = FALSE;
rel->rd_unlinked = false;
smgrcall = true;
}
return smgrcall;
......@@ -810,7 +772,7 @@ heap_create_with_catalog(char *relname,
* get_temp_rel_by_username() couldn't check the simultaneous
* creation. Uniqueness will be really checked by unique
* indexes of system tables but we couldn't check it here.
* We have to pospone to create the disk file for this
* We have to postpone creating the disk file for this
* relation.
* Another boolean parameter "storage_create" was added
* to heap_create() function. If the parameter is false
......@@ -821,12 +783,12 @@ heap_create_with_catalog(char *relname,
* relation descriptor.
*
* Note: The call to heap_create() changes relname for
* noname and temp tables.
* temp tables; it becomes the true physical relname.
* The call to heap_storage_create() does all the "real"
* work of creating the disk file for the relation.
* ----------------
*/
new_rel_desc = heap_create(relname, tupdesc, false, istemp, false);
new_rel_desc = heap_create(relname, tupdesc, istemp, false);
new_rel_oid = new_rel_desc->rd_att->attrs[0]->attrelid;
......@@ -1546,10 +1508,9 @@ heap_drop_with_catalog(const char *relname)
* unlink the relation's physical file and finish up.
* ----------------
*/
if (!(rel->rd_isnoname) || !(rel->rd_unlinked))
if (! rel->rd_unlinked)
smgrunlink(DEFAULT_SMGR, rel);
rel->rd_unlinked = TRUE;
rel->rd_unlinked = true;
/*
* Close relcache entry, but *keep* AccessExclusiveLock on the
......@@ -1568,133 +1529,6 @@ heap_drop_with_catalog(const char *relname)
remove_temp_relation(rid);
}
/*
* heap_drop
* destroy and close temporary relations
*
*/
void
heap_drop(Relation rel)
{
Oid rid = RelationGetRelid(rel);
ReleaseRelationBuffers(rel);
if (!(rel->rd_isnoname) || !(rel->rd_unlinked))
smgrunlink(DEFAULT_SMGR, rel);
rel->rd_unlinked = TRUE;
heap_close(rel, NoLock);
RemoveFromNoNameRelList(rel);
RelationForgetRelation(rid);
}
/**************************************************************
functions to deal with the list of temporary relations
**************************************************************/
/* --------------
InitTempRellist():
initialize temporary relations list
the tempRelList is a list of temporary relations that
are created in the course of the transactions
they need to be destroyed properly at the end of the transactions
MODIFIES the global variable tempRels
>> NOTE <<
malloc is used instead of palloc because we KNOW when we are
going to free these things. Keeps us away from the memory context
hairyness
*/
void
InitNoNameRelList(void)
{
if (tempRels)
{
free(tempRels->rels);
free(tempRels);
}
tempRels = (TempRelList *) malloc(sizeof(TempRelList));
tempRels->size = NONAME_REL_LIST_SIZE;
tempRels->rels = (Relation *) malloc(sizeof(Relation) * tempRels->size);
MemSet(tempRels->rels, 0, sizeof(Relation) * tempRels->size);
tempRels->num = 0;
}
/*
removes a relation from the TempRelList
MODIFIES the global variable tempRels
we don't really remove it, just mark it as NULL
and DropNoNameRels will look for NULLs
*/
static void
RemoveFromNoNameRelList(Relation r)
{
int i;
if (!tempRels)
return;
for (i = 0; i < tempRels->num; i++)
{
if (tempRels->rels[i] == r)
{
tempRels->rels[i] = NULL;
break;
}
}
}
/*
add a temporary relation to the TempRelList
MODIFIES the global variable tempRels
*/
static void
AddToNoNameRelList(Relation r)
{
if (!tempRels)
return;
if (tempRels->num == tempRels->size)
{
tempRels->size += NONAME_REL_LIST_SIZE;
tempRels->rels = realloc(tempRels->rels,
sizeof(Relation) * tempRels->size);
}
tempRels->rels[tempRels->num] = r;
tempRels->num++;
}
/*
go through the tempRels list and destroy each of the relations
*/
void
DropNoNameRels(void)
{
int i;
Relation rel;
if (!tempRels)
return;
for (i = 0; i < tempRels->num; i++)
{
rel = tempRels->rels[i];
/* rel may be NULL if it has been removed from the list already */
if (rel)
heap_drop(rel);
}
free(tempRels->rels);
free(tempRels);
tempRels = NULL;
}
/*
* Store a default expression for column attnum of relation rel.
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.118 2000/06/17 23:41:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.119 2000/06/18 22:43:55 tgl Exp $
*
*
* INTERFACE ROUTINES
......@@ -976,7 +976,6 @@ index_create(char *heapRelationName,
/* ----------------
* get heap relation oid and open the heap relation
* XXX ADD INDEXING
* ----------------
*/
heapoid = GetHeapRelationOid(heapRelationName, indexRelationName, istemp);
......@@ -1012,8 +1011,8 @@ index_create(char *heapRelationName,
* create the index relation
* ----------------
*/
indexRelation = heap_create(indexRelationName,
indexTupDesc, false, istemp, false);
indexRelation = heap_create(indexRelationName, indexTupDesc,
istemp, false);
/* ----------------
* construct the index relation descriptor
......
......@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.56 2000/04/12 17:14:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.57 2000/06/18 22:43:58 tgl Exp $
*
*/
......@@ -176,9 +176,6 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
case T_IndexScan:
pname = "Index Scan";
break;
case T_Noname:
pname = "Noname Scan";
break;
case T_Material:
pname = "Materialize";
break;
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: execAmi.c,v 1.47 2000/06/15 04:09:50 momjian Exp $
* $Id: execAmi.c,v 1.48 2000/06/18 22:44:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -17,13 +17,9 @@
* ExecBeginScan \ / ambeginscan
* ExecCloseR \ / amclose
* ExecInsert \ executor interface / aminsert
* ExecReScanNode / to access methods \ amrescan
* ExecReScanR / \ amrescan
* ExecMarkPos / \ ammarkpos
* ExecRestrPos / \ amrestpos
*
* ExecCreatR function to create temporary relations
*
* ExecReScanR / to access methods \ amrescan
* ExecMarkPos / \ ammarkpos
* ExecRestrPos / \ amrestpos
*/
#include "postgres.h"
......@@ -49,7 +45,6 @@
#include "executor/nodeSort.h"
#include "executor/nodeSubplan.h"
#include "executor/nodeUnique.h"
#include "optimizer/internal.h"
static Pointer ExecBeginScan(Relation relation, int nkeys, ScanKey skeys,
bool isindex, ScanDirection dir, Snapshot snapshot);
......@@ -170,7 +165,6 @@ ExecBeginScan(Relation relation,
if (scanDesc == NULL)
elog(DEBUG, "ExecBeginScan: scanDesc = NULL, heap_beginscan failed.");
return scanDesc;
}
......@@ -179,9 +173,6 @@ ExecBeginScan(Relation relation,
*
* closes the relation and scan descriptor for a scan or sort
* node. Also closes index relations and scans for index scans.
*
* old comments
* closes the relation indicated in 'relID'
* ----------------------------------------------------------------
*/
void
......@@ -206,10 +197,6 @@ ExecCloseR(Plan *node)
state = ((IndexScan *) node)->scan.scanstate;
break;
case T_Material:
state = &(((Material *) node)->matstate->csstate);
break;
case T_Sort:
state = &(((Sort *) node)->sortstate->csstate);
break;
......@@ -223,7 +210,7 @@ ExecCloseR(Plan *node)
break;
default:
elog(DEBUG, "ExecCloseR: not a scan, material, or sort node!");
elog(DEBUG, "ExecCloseR: not a scan or sort node!");
return;
}
......@@ -423,7 +410,7 @@ ExecMarkPos(Plan *node)
{
switch (nodeTag(node))
{
case T_SeqScan:
case T_SeqScan:
ExecSeqMarkPos((SeqScan *) node);
break;
......@@ -431,6 +418,10 @@ ExecMarkPos(Plan *node)
ExecIndexMarkPos((IndexScan *) node);
break;
case T_Material:
ExecMaterialMarkPos((Material *) node);
break;
case T_Sort:
ExecSortMarkPos((Sort *) node);
break;
......@@ -457,7 +448,7 @@ ExecRestrPos(Plan *node)
{
switch (nodeTag(node))
{
case T_SeqScan:
case T_SeqScan:
ExecSeqRestrPos((SeqScan *) node);
return;
......@@ -465,6 +456,10 @@ ExecRestrPos(Plan *node)
ExecIndexRestrPos((IndexScan *) node);
return;
case T_Material:
ExecMaterialRestrPos((Material *) node);
return;
case T_Sort:
ExecSortRestrPos((Sort *) node);
return;
......@@ -474,65 +469,3 @@ ExecRestrPos(Plan *node)
return;
}
}
/* ----------------------------------------------------------------
* ExecCreatR
*
* old comments
* Creates a relation.
*
* Parameters:
* attrType -- type information on the attributes.
* accessMtd -- access methods used to access the created relation.
* relation -- optional. Either an index to the range table or
* negative number indicating a temporary relation.
* A temporary relation is assume if this field is absent.
* ----------------------------------------------------------------
*/
Relation
ExecCreatR(TupleDesc tupType,
Oid relationOid)
{
Relation relDesc;
EU3_printf("ExecCreatR: %s type=%d oid=%u\n",
"entering: ", tupType, relationOid);
CXT1_printf("ExecCreatR: context is %d\n", CurrentMemoryContext);
relDesc = NULL;
if (relationOid == _NONAME_RELATION_ID_)
{
/* ----------------
* create a temporary relation
* (currently the planner always puts a _NONAME_RELATION_ID
* in the relation argument so we expect this to be the case although
* it's possible that someday we'll get the name from
* from the range table.. -cim 10/12/89)
* ----------------
*/
/*
* heap_create creates a name if the argument to heap_create is
* '\0 '
*/
relDesc = heap_create(NULL, tupType, true, false, true);
}
else
{
/* ----------------
* use a relation from the range table
* ----------------
*/
elog(DEBUG, "ExecCreatR: %s",
"stuff using range table id's is not functional");
}
if (relDesc == NULL)
elog(DEBUG, "ExecCreatR: failed to create relation.");
EU1_printf("ExecCreatR: returning relDesc=%d\n", relDesc);
return relDesc;
}
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.113 2000/04/12 17:15:16 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.114 2000/06/18 22:44:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -414,41 +414,6 @@ _copyHashJoin(HashJoin *from)
}
/* ----------------
* CopyNonameFields
*
* This function copies the fields of the Noname node. It is used by
* all the copy functions for classes which inherit from Noname.
* ----------------
*/
static void
CopyNonameFields(Noname *from, Noname *newnode)
{
newnode->nonameid = from->nonameid;
newnode->keycount = from->keycount;
return;
}
/* ----------------
* _copyNoname
* ----------------
*/
static Noname *
_copyNoname(Noname *from)
{
Noname *newnode = makeNode(Noname);
/* ----------------
* copy node superclass fields
* ----------------
*/
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyNonameFields(from, newnode);
return newnode;
}
/* ----------------
* _copyMaterial
* ----------------
......@@ -463,7 +428,6 @@ _copyMaterial(Material *from)
* ----------------
*/
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyNonameFields((Noname *) from, (Noname *) newnode);
return newnode;
}
......@@ -483,7 +447,8 @@ _copySort(Sort *from)
* ----------------
*/
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyNonameFields((Noname *) from, (Noname *) newnode);
newnode->keycount = from->keycount;
return newnode;
}
......@@ -552,7 +517,6 @@ _copyUnique(Unique *from)
* ----------------
*/
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyNonameFields((Noname *) from, (Noname *) newnode);
/* ----------------
* copy remainder of node
......@@ -1695,9 +1659,6 @@ copyObject(void *from)
case T_HashJoin:
retval = _copyHashJoin(from);
break;
case T_Noname:
retval = _copyNoname(from);
break;
case T_Material:
retval = _copyMaterial(from);
break;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.41 2000/05/28 17:55:57 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.42 2000/06/18 22:44:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -305,37 +305,6 @@ _freeHashJoin(HashJoin *node)
}
/* ----------------
* FreeNonameFields
*
* This function frees the fields of the Noname node. It is used by
* all the free functions for classes which inherit node Noname.
* ----------------
*/
static void
FreeNonameFields(Noname *node)
{
return;
}
/* ----------------
* _freeNoname
* ----------------
*/
static void
_freeNoname(Noname *node)
{
/* ----------------
* free node superclass fields
* ----------------
*/
FreePlanFields((Plan *) node);
FreeNonameFields(node);
pfree(node);
}
/* ----------------
* _freeMaterial
* ----------------
......@@ -348,7 +317,6 @@ _freeMaterial(Material *node)
* ----------------
*/
FreePlanFields((Plan *) node);
FreeNonameFields((Noname *) node);
pfree(node);
}
......@@ -366,7 +334,6 @@ _freeSort(Sort *node)
* ----------------
*/
FreePlanFields((Plan *) node);
FreeNonameFields((Noname *) node);
pfree(node);
}
......@@ -421,7 +388,6 @@ _freeUnique(Unique *node)
* ----------------
*/
FreePlanFields((Plan *) node);
FreeNonameFields((Noname *) node);
/* ----------------
* free remainder of node
......@@ -1194,9 +1160,6 @@ freeObject(void *node)
case T_HashJoin:
_freeHashJoin(node);
break;
case T_Noname:
_freeNoname(node);
break;
case T_Material:
_freeMaterial(node);
break;
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.119 2000/06/16 05:27:02 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.120 2000/06/18 22:44:05 tgl Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
......@@ -531,51 +531,29 @@ _outTidScan(StringInfo str, TidScan *node)
}
/*
* Noname is a subclass of Plan
*/
static void
_outNoname(StringInfo str, Noname *node)
{
appendStringInfo(str, " NONAME ");
_outPlanInfo(str, (Plan *) node);
appendStringInfo(str, " :nonameid %u :keycount %d ",
node->nonameid,
node->keycount);
}
/*
* Material is a subclass of Noname
* Material is a subclass of Plan
*/
static void
_outMaterial(StringInfo str, Material *node)
{
appendStringInfo(str, " MATERIAL ");
_outPlanInfo(str, (Plan *) node);
appendStringInfo(str, " :nonameid %u :keycount %d ",
node->nonameid,
node->keycount);
}
/*
* Sort is a subclass of Noname
* Sort is a subclass of Plan
*/
static void
_outSort(StringInfo str, Sort *node)
{
appendStringInfo(str, " SORT ");
_outPlanInfo(str, (Plan *) node);
appendStringInfo(str, " :nonameid %u :keycount %d ",
node->nonameid,
node->keycount);
appendStringInfo(str, " :keycount %d ", node->keycount);
}
static void
_outAgg(StringInfo str, Agg *node)
{
appendStringInfo(str, " AGG ");
_outPlanInfo(str, (Plan *) node);
}
......@@ -592,9 +570,6 @@ _outGroup(StringInfo str, Group *node)
node->tuplePerGroup ? "true" : "false");
}
/*
* For some reason, unique is a subclass of Noname.
*/
static void
_outUnique(StringInfo str, Unique *node)
{
......@@ -603,17 +578,14 @@ _outUnique(StringInfo str, Unique *node)
appendStringInfo(str, " UNIQUE ");
_outPlanInfo(str, (Plan *) node);
appendStringInfo(str, " :nonameid %u :keycount %d :numCols %d :uniqColIdx ",
node->nonameid,
node->keycount,
appendStringInfo(str, " :numCols %d :uniqColIdx ",
node->numCols);
for (i = 0; i < node->numCols; i++)
appendStringInfo(str, "%d ", (int) node->uniqColIdx[i]);
}
/*
* Hash is a subclass of Noname
* Hash is a subclass of Plan
*/
static void
_outHash(StringInfo str, Hash *node)
......@@ -1502,9 +1474,6 @@ _outNode(StringInfo str, void *obj)
case T_TidScan:
_outTidScan(str, obj);
break;
case T_Noname:
_outNoname(str, obj);
break;
case T_Material:
_outMaterial(str, obj);
break;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.38 2000/04/12 17:15:16 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.39 2000/06/18 22:44:05 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -315,9 +315,6 @@ plannode_type(Plan *p)
case T_HashJoin:
return "HASHJOIN";
break;
case T_Noname:
return "NONAME";
break;
case T_Material:
return "MATERIAL";
break;
......@@ -333,9 +330,6 @@ plannode_type(Plan *p)
case T_Hash:
return "HASH";
break;
case T_Choose:
return "CHOOSE";
break;
case T_Group:
return "GROUP";
break;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.90 2000/06/16 05:27:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.91 2000/06/18 22:44:05 tgl Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
......@@ -555,38 +555,10 @@ _readTidScan()
return local_node;
}
/* ----------------
* _readNoname
*
* Noname is a subclass of Plan
* ----------------
*/
static Noname *
_readNoname()
{
Noname *local_node;
char *token;
int length;
local_node = makeNode(Noname);
_getPlan((Plan *) local_node);
token = lsptok(NULL, &length); /* eat :nonameid */
token = lsptok(NULL, &length); /* get nonameid */
local_node->nonameid = atol(token);
token = lsptok(NULL, &length); /* eat :keycount */
token = lsptok(NULL, &length); /* get keycount */
local_node->keycount = atoi(token);
return local_node;
}
/* ----------------
* _readSort
*
* Sort is a subclass of Noname
* Sort is a subclass of Plan
* ----------------
*/
static Sort *
......@@ -600,10 +572,6 @@ _readSort()
_getPlan((Plan *) local_node);
token = lsptok(NULL, &length); /* eat :nonameid */
token = lsptok(NULL, &length); /* get nonameid */
local_node->nonameid = atol(token);
token = lsptok(NULL, &length); /* eat :keycount */
token = lsptok(NULL, &length); /* get keycount */
local_node->keycount = atoi(token);
......@@ -625,7 +593,7 @@ _readAgg()
/* ----------------
* _readHash
*
* Hash is a subclass of Noname
* Hash is a subclass of Plan
* ----------------
*/
static Hash *
......@@ -1853,8 +1821,6 @@ parsePlanString(void)
return_value = _readIndexScan();
else if (length == 7 && strncmp(token, "TIDSCAN", length) == 0)
return_value = _readTidScan();
else if (length == 6 && strncmp(token, "NONAME", length) == 0)
return_value = _readNoname();
else if (length == 4 && strncmp(token, "SORT", length) == 0)
return_value = _readSort();
else if (length == 6 && strncmp(token, "AGGREG", length) == 0)
......
......@@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.61 2000/05/31 00:28:22 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.62 2000/06/18 22:44:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -55,10 +55,15 @@
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/internal.h"
#include "utils/lsyscache.h"
/*
* The length of a variable-length field in bytes (stupid estimate...)
*/
#define _DEFAULT_ATTRIBUTE_WIDTH_ 12
#define LOG2(x) (log(x) / 0.693147180559945)
#define LOG6(x) (log(x) / 1.79175946922805)
......@@ -114,29 +119,17 @@ cost_seqscan(Path *path, RelOptInfo *baserel)
if (!enable_seqscan)
startup_cost += disable_cost;
/* disk costs */
if (lfirsti(baserel->relids) < 0)
{
/*
* cost of sequentially scanning a materialized temporary relation
*/
run_cost += _NONAME_SCAN_COST_;
}
else
{
/*
* The cost of reading a page sequentially is 1.0, by definition.
* Note that the Unix kernel will typically do some amount of
* read-ahead optimization, so that this cost is less than the
* true cost of reading a page from disk. We ignore that issue
* here, but must take it into account when estimating the cost of
* non-sequential accesses!
*/
run_cost += baserel->pages; /* sequential fetches with cost
* 1.0 */
}
/*
* disk costs
*
* The cost of reading a page sequentially is 1.0, by definition.
* Note that the Unix kernel will typically do some amount of
* read-ahead optimization, so that this cost is less than the
* true cost of reading a page from disk. We ignore that issue
* here, but must take it into account when estimating the cost of
* non-sequential accesses!
*/
run_cost += baserel->pages; /* sequential fetches with cost 1.0 */
/* CPU costs */
cpu_per_tuple = cpu_tuple_cost + baserel->baserestrictcost;
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.83 2000/06/15 03:32:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.84 2000/06/18 22:44:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -21,7 +21,6 @@
#include "executor/executor.h"
#include "nodes/makefuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/internal.h"
#include "optimizer/paths.h"
#include "optimizer/plancat.h"
#include "optimizer/planmain.h"
......@@ -40,7 +39,7 @@ static List *make_subplanTargetList(Query *parse, List *tlist,
static Plan *make_groupplan(List *group_tlist, bool tuplePerGroup,
List *groupClause, AttrNumber *grpColIdx,
bool is_presorted, Plan *subplan);
static Plan *make_sortplan(List *tlist, List *sortcls, Plan *plannode);
static Plan *make_sortplan(List *tlist, Plan *plannode, List *sortcls);
/*****************************************************************************
*
......@@ -641,7 +640,8 @@ union_planner(Query *parse,
if (parse->sortClause)
{
if (!pathkeys_contained_in(sort_pathkeys, current_pathkeys))
result_plan = make_sortplan(tlist, parse->sortClause, result_plan);
result_plan = make_sortplan(tlist, result_plan,
parse->sortClause);
}
/*
......@@ -818,10 +818,9 @@ make_groupplan(List *group_tlist,
}
}
subplan = (Plan *) make_sort(sort_tlist,
_NONAME_RELATION_ID_,
subplan,
keyno);
Assert(keyno > 0);
subplan = (Plan *) make_sort(sort_tlist, subplan, keyno);
}
return (Plan *) make_group(group_tlist, tuplePerGroup, numCols,
......@@ -833,9 +832,9 @@ make_groupplan(List *group_tlist,
* Add a Sort node to implement an explicit ORDER BY clause.
*/
static Plan *
make_sortplan(List *tlist, List *sortcls, Plan *plannode)
make_sortplan(List *tlist, Plan *plannode, List *sortcls)
{
List *temp_tlist;
List *sort_tlist;
List *i;
int keyno = 0;
......@@ -843,13 +842,12 @@ make_sortplan(List *tlist, List *sortcls, Plan *plannode)
* First make a copy of the tlist so that we don't corrupt the
* original.
*/
temp_tlist = new_unsorted_tlist(tlist);
sort_tlist = new_unsorted_tlist(tlist);
foreach(i, sortcls)
{
SortClause *sortcl = (SortClause *) lfirst(i);
TargetEntry *tle = get_sortgroupclause_tle(sortcl, temp_tlist);
TargetEntry *tle = get_sortgroupclause_tle(sortcl, sort_tlist);
Resdom *resdom = tle->resdom;
/*
......@@ -865,10 +863,9 @@ make_sortplan(List *tlist, List *sortcls, Plan *plannode)
}
}
return (Plan *) make_sort(temp_tlist,
_NONAME_RELATION_ID_,
plannode,
keyno);
Assert(keyno > 0);
return (Plan *) make_sort(sort_tlist, plannode, keyno);
}
/*
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.37 2000/05/30 00:49:47 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.38 2000/06/18 22:44:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -363,9 +363,7 @@ make_subplan(SubLink *slink)
}
if (use_material)
{
plan = (Plan *) make_noname(plan->targetlist,
NIL,
plan);
plan = (Plan *) make_material(plan->targetlist, plan);
node->plan = plan;
}
}
......
......@@ -8,14 +8,13 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.26 2000/04/12 17:15:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.27 2000/06/18 22:44:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "optimizer/cost.h"
#include "optimizer/internal.h"
#include "optimizer/joininfo.h"
#include "optimizer/pathnode.h"
#include "optimizer/plancat.h"
......@@ -76,26 +75,9 @@ get_base_rel(Query *root, int relid)
rel->joininfo = NIL;
rel->innerjoin = NIL;
if (relid < 0)
{
/*
* If the relation is a materialized relation, assume constants
* for sizes.
*/
rel->pages = _NONAME_RELATION_PAGES_;
rel->tuples = _NONAME_RELATION_TUPLES_;
}
else
{
/*
* Otherwise, retrieve relation statistics from the system
* catalogs.
*/
relation_info(root, relid,
&rel->indexed, &rel->pages, &rel->tuples);
}
/* Retrieve relation statistics from the system catalogs. */
relation_info(root, relid,
&rel->indexed, &rel->pages, &rel->tuples);
root->base_rel_list = lcons(rel, root->base_rel_list);
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.27 2000/06/13 07:35:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.28 2000/06/18 22:44:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -21,7 +21,6 @@
#include "fmgr.h"
#include "libpq/be-fsstubs.h"
#include "libpq/libpq-fs.h"
#include "optimizer/internal.h"
#include "utils/array.h"
#include "utils/memutils.h"
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.101 2000/06/17 21:48:55 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.102 2000/06/18 22:44:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1784,21 +1784,15 @@ RelationPurgeLocalRelation(bool xactCommitted)
if (!xactCommitted)
{
/*
* remove the file if we abort. This is so that files for
* tables created inside a transaction block get removed.
*/
if (reln->rd_isnoname)
if (! reln->rd_unlinked)
{
if (!(reln->rd_unlinked))
{
smgrunlink(DEFAULT_SMGR, reln);
reln->rd_unlinked = TRUE;
}
}
else
smgrunlink(DEFAULT_SMGR, reln);
reln->rd_unlinked = true;
}
}
if (!IsBootstrapProcessingMode())
......
......@@ -4,14 +4,14 @@
# Makefile for utils/sort
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/sort/Makefile,v 1.10 2000/05/29 05:45:40 tgl Exp $
# $Header: /cvsroot/pgsql/src/backend/utils/sort/Makefile,v 1.11 2000/06/18 22:44:20 tgl Exp $
#
#-------------------------------------------------------------------------
SRCDIR = ../../..
include ../../../Makefile.global
OBJS = logtape.o tuplesort.o
OBJS = logtape.o tuplesort.o tuplestore.o
all: SUBSYS.o
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: heapam.h,v 1.52 2000/04/12 17:16:25 momjian Exp $
* $Id: heapam.h,v 1.53 2000/06/18 22:44:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -242,9 +242,11 @@ extern HeapAccessStatistics heap_access_stats; /* in stats.c */
/* ----------------
* function prototypes for heap access method
*
* heap_create, heap_create_with_catalog, and heap_drop_with_catalog
* are declared in catalog/heap.h
* ----------------
*/
/* heap_create, heap_creatr, and heap_destroy are declared in catalog/heap.h */
/* heapam.c */
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: heap.h,v 1.29 2000/04/12 17:16:27 momjian Exp $
* $Id: heap.h,v 1.30 2000/06/18 22:44:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -24,8 +24,9 @@ typedef struct RawColumnDefault
} RawColumnDefault;
extern Oid RelnameFindRelid(const char *relname);
extern Relation heap_create(char *relname, TupleDesc att,
bool isnoname, bool istemp, bool storage_create);
extern Relation heap_create(char *relname, TupleDesc tupDesc,
bool istemp, bool storage_create);
extern bool heap_storage_create(Relation rel);
extern Oid heap_create_with_catalog(char *relname, TupleDesc tupdesc,
......@@ -33,13 +34,9 @@ extern Oid heap_create_with_catalog(char *relname, TupleDesc tupdesc,
extern void heap_drop_with_catalog(const char *relname);
extern void heap_truncate(char *relname);
extern void heap_drop(Relation rel);
extern void AddRelationRawConstraints(Relation rel,
List *rawColDefaults,
List *rawConstraints);
extern void InitNoNameRelList(void);
extern void DropNoNameRels(void);
#endif /* HEAP_H */
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: executor.h,v 1.44 2000/06/17 21:48:56 tgl Exp $
* $Id: executor.h,v 1.45 2000/06/18 22:44:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -39,7 +39,6 @@ extern HeapScanDesc ExecReScanR(Relation relDesc, HeapScanDesc scanDesc,
ScanDirection direction, int nkeys, ScanKey skeys);
extern void ExecMarkPos(Plan *node);
extern void ExecRestrPos(Plan *node);
extern Relation ExecCreatR(TupleDesc tupType, Oid relationOid);
/*
* prototypes from functions in execJunk.c
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: nodeMaterial.h,v 1.12 2000/01/26 05:58:05 momjian Exp $
* $Id: nodeMaterial.h,v 1.13 2000/06/18 22:44:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -20,11 +20,8 @@ extern TupleTableSlot *ExecMaterial(Material *node);
extern bool ExecInitMaterial(Material *node, EState *estate, Plan *parent);
extern int ExecCountSlotsMaterial(Material *node);
extern void ExecEndMaterial(Material *node);
extern void ExecMaterialReScan(Material *node, ExprContext *exprCtxt, Plan *parent);
#ifdef NOT_USED
extern List ExecMaterialMarkPos(Material *node);
extern void ExecMaterialMarkPos(Material *node);
extern void ExecMaterialRestrPos(Material *node);
extern void ExecMaterialReScan(Material *node, ExprContext *exprCtxt, Plan *parent);
#endif
#endif /* NODEMATERIAL_H */
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: execnodes.h,v 1.41 2000/04/12 17:16:39 momjian Exp $
* $Id: execnodes.h,v 1.42 2000/06/18 22:44:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -565,11 +565,9 @@ typedef struct HashJoinState
* MaterialState information
*
* materialize nodes are used to materialize the results
* of a subplan into a temporary relation.
* of a subplan into a temporary file.
*
* Flag indicated whether subplan has been materialized
* TempRelation temporary relation containing result of executing
* the subplan.
* tuplestorestate private state of tuplestore.c
*
* CommonScanState information
*
......@@ -590,8 +588,7 @@ typedef struct HashJoinState
typedef struct MaterialState
{
CommonScanState csstate; /* its first field is NodeTag */
bool mat_Flag;
Relation mat_TempRelation;
void *tuplestorestate;
} MaterialState;
/* ---------------------
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: nodes.h,v 1.68 2000/05/29 01:59:12 tgl Exp $
* $Id: nodes.h,v 1.69 2000/06/18 22:44:31 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -39,13 +39,13 @@ typedef enum NodeTag
T_NestLoop,
T_MergeJoin,
T_HashJoin,
T_Noname,
T_Noname_XXX, /* not used anymore; this tag# is available */
T_Material,
T_Sort,
T_Agg,
T_Unique,
T_Hash,
T_Choose,
T_Choose_XXX, /* not used anymore; this tag# is available */
T_Group,
T_SubPlan,
T_TidScan,
......@@ -261,10 +261,6 @@ typedef struct Node
(IsA(jp, Join) || IsA(jp, NestLoop) || \
IsA(jp, MergeJoin) || IsA(jp, HashJoin))
#define IsA_Noname(t) \
(IsA(t, Noname) || IsA(t, Material) || IsA(t, Sort) || \
IsA(t, Unique))
#define IsA_Value(t) \
(IsA(t, Integer) || IsA(t, Float) || IsA(t, String))
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: plannodes.h,v 1.39 2000/04/12 17:16:40 momjian Exp $
* $Id: plannodes.h,v 1.40 2000/06/18 22:44:31 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -277,27 +277,13 @@ typedef struct Group
GroupState *grpstate;
} Group;
/*
* ==========
* Noname nodes
* ==========
*/
typedef struct Noname
{
Plan plan;
Oid nonameid;
int keycount;
} Noname;
/* ----------------
* materialization node
* ----------------
*/
typedef struct Material
{
Plan plan; /* noname node flattened out */
Oid nonameid;
int keycount;
Plan plan;
MaterialState *matstate;
} Material;
......@@ -307,8 +293,7 @@ typedef struct Material
*/
typedef struct Sort
{
Plan plan; /* noname node flattened out */
Oid nonameid;
Plan plan;
int keycount;
SortState *sortstate;
} Sort;
......@@ -319,9 +304,7 @@ typedef struct Sort
*/
typedef struct Unique
{
Plan plan; /* noname node flattened out */
Oid nonameid;
int keycount;
Plan plan;
int numCols; /* number of columns to check for
* uniqueness */
AttrNumber *uniqColIdx; /* indexes into the target list */
......
/*-------------------------------------------------------------------------
*
* internal.h
* Definitions required throughout the query optimizer.
*
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: internal.h,v 1.27 2000/06/15 03:32:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef INTERNAL_H
#define INTERNAL_H
/*
* ---------- SHARED MACROS
*
* Macros common to modules for creating, accessing, and modifying
* query tree and query plan components.
* Shared with the executor.
*
*/
/*
* Size estimates
*
*/
/* The cost of sequentially scanning a materialized temporary relation
*/
#define _NONAME_SCAN_COST_ 10
/* The number of pages and tuples in a materialized relation
*/
#define _NONAME_RELATION_PAGES_ 1
#define _NONAME_RELATION_TUPLES_ 10
/* The length of a variable-length field in bytes (stupid estimate...)
*/
#define _DEFAULT_ATTRIBUTE_WIDTH_ 12
/*
* Flags and identifiers
*
*/
/* Identifier for (sort) temp relations */
/* used to be -1 */
#define _NONAME_RELATION_ID_ InvalidOid
#endif /* INTERNAL_H */
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: planmain.h,v 1.41 2000/06/08 22:37:51 momjian Exp $
* $Id: planmain.h,v 1.42 2000/06/18 22:44:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -27,12 +27,13 @@ extern Plan *query_planner(Query *root, List *tlist, List *qual,
* prototypes for plan/createplan.c
*/
extern Plan *create_plan(Query *root, Path *best_path);
extern Sort *make_sort(List *tlist, Oid nonameid, Plan *lefttree,
int keycount);
extern Sort *make_sort(List *tlist, Plan *lefttree, int keycount);
extern Sort *make_sort_from_pathkeys(List *tlist, Plan *lefttree,
List *pathkeys);
extern Agg *make_agg(List *tlist, List *qual, Plan *lefttree);
extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp,
AttrNumber *grpColIdx, Plan *lefttree);
extern Noname *make_noname(List *tlist, List *pathkeys, Plan *subplan);
extern Material *make_material(List *tlist, Plan *lefttree);
extern Unique *make_unique(List *tlist, Plan *lefttree, List *distinctList);
extern Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: rel.h,v 1.37 2000/06/17 21:49:02 tgl Exp $
* $Id: rel.h,v 1.38 2000/06/18 22:44:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -90,7 +90,6 @@ typedef struct RelationData
uint16 rd_refcnt; /* reference count */
bool rd_myxactonly; /* rel uses the local buffer mgr */
bool rd_isnailed; /* rel is nailed in cache */
bool rd_isnoname; /* rel has no name */
bool rd_unlinked; /* rel already unlinked or not created yet */
bool rd_indexfound; /* true if rd_indexlist is valid */
Form_pg_am rd_am; /* AM tuple */
......
/*-------------------------------------------------------------------------
*
* tuplestore.h
* Generalized routines for temporary tuple storage.
*
* This module handles temporary storage of tuples for purposes such
* as Materialize nodes, hashjoin batch files, etc. It is essentially
* a dumbed-down version of tuplesort.c; it does no sorting of tuples
* but can only store a sequence of tuples and regurgitate it later.
* A temporary file is used to handle the data if it exceeds the
* space limit specified by the caller.
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: tuplestore.h,v 1.1 2000/06/18 22:44:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef TUPLESTORE_H
#define TUPLESTORE_H
#include "access/htup.h"
/* Tuplestorestate is an opaque type whose details are not known outside
* tuplestore.c.
*/
typedef struct Tuplestorestate Tuplestorestate;
/*
* Currently we only need to store HeapTuples, but it would be easy
* to support the same behavior for IndexTuples and/or bare Datums.
*/
extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
int maxKBytes);
extern void tuplestore_puttuple(Tuplestorestate *state, void *tuple);
extern void tuplestore_donestoring(Tuplestorestate *state);
extern void *tuplestore_gettuple(Tuplestorestate *state, bool forward,
bool *should_free);
#define tuplestore_getheaptuple(state, forward, should_free) \
((HeapTuple) tuplestore_gettuple(state, forward, should_free))
extern void tuplestore_end(Tuplestorestate *state);
/*
* These routines may only be called if randomAccess was specified 'true'.
* Likewise, backwards scan in gettuple/getdatum is only allowed if
* randomAccess was specified.
*/
extern void tuplestore_rescan(Tuplestorestate *state);
extern void tuplestore_markpos(Tuplestorestate *state);
extern void tuplestore_restorepos(Tuplestorestate *state);
#endif /* TUPLESTORE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment