Commit 39b7ec33 authored by Tom Lane's avatar Tom Lane

Create a distinction between Lists of integers and Lists of OIDs, to get

rid of the assumption that sizeof(Oid)==sizeof(int).  This is one small
step towards someday supporting 8-byte OIDs.  For the moment, it doesn't
do much except get rid of a lot of unsightly casts.
parent 3646ab58
...@@ -643,9 +643,8 @@ List *i, *list; ...@@ -643,9 +643,8 @@ List *i, *list;
return the i'th element in list. return the i'th element in list.
lconsi, ... lconsi, ...
There are integer versions of these: lconsi, lappendi, nthi. There are integer versions of these: lconsi, lappendi, etc.
List's containing integers instead of Node pointers are used to Also versions for OID lists: lconso, lappendo, etc.
hold list of relation object id's and other integer quantities.
You can print nodes easily inside gdb. First, to disable output You can print nodes easily inside gdb. First, to disable output
truncation when you use the gdb print command: truncation when you use the gdb print command:
......
...@@ -779,10 +779,8 @@ ...@@ -779,10 +779,8 @@
<DT>lconsi, ...</DT> <DT>lconsi, ...</DT>
<DD>There are integer versions of these: <I>lconsi, lappendi, <DD>There are integer versions of these: <I>lconsi, lappendi</I>,
nthi.</I> <I>List's</I> containing integers instead of Node etc. Also versions for OID lists: <I>lconso, lappendo</I>, etc.</DD>
pointers are used to hold list of relation object id's and
other integer quantities.</DD>
</DL> </DL>
</BLOCKQUOTE> </BLOCKQUOTE>
You can print nodes easily inside <I>gdb.</I> First, to disable You can print nodes easily inside <I>gdb.</I> First, to disable
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.20 2003/02/07 01:33:06 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.21 2003/02/09 06:56:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -948,7 +948,7 @@ find_expr_references_walker(Node *node, ...@@ -948,7 +948,7 @@ find_expr_references_walker(Node *node,
foreach(opid, sublink->operOids) foreach(opid, sublink->operOids)
{ {
add_object_address(OCLASS_OPERATOR, (Oid) lfirsti(opid), 0, add_object_address(OCLASS_OPERATOR, lfirsto(opid), 0,
&context->addrs); &context->addrs);
} }
/* fall through to examine arguments */ /* fall through to examine arguments */
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.46 2003/02/07 01:33:06 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.47 2003/02/09 06:56:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -262,7 +262,7 @@ RelnameGetRelid(const char *relname) ...@@ -262,7 +262,7 @@ RelnameGetRelid(const char *relname)
foreach(lptr, namespaceSearchPath) foreach(lptr, namespaceSearchPath)
{ {
Oid namespaceId = (Oid) lfirsti(lptr); Oid namespaceId = lfirsto(lptr);
relid = get_relname_relid(relname, namespaceId); relid = get_relname_relid(relname, namespaceId);
if (OidIsValid(relid)) if (OidIsValid(relid))
...@@ -300,11 +300,11 @@ RelationIsVisible(Oid relid) ...@@ -300,11 +300,11 @@ RelationIsVisible(Oid relid)
/* /*
* Quick check: if it ain't in the path at all, it ain't visible. * Quick check: if it ain't in the path at all, it ain't visible.
* Items in the system namespace are surely in the path and so we * Items in the system namespace are surely in the path and so we
* needn't even do intMember() for them. * needn't even do oidMember() for them.
*/ */
relnamespace = relform->relnamespace; relnamespace = relform->relnamespace;
if (relnamespace != PG_CATALOG_NAMESPACE && if (relnamespace != PG_CATALOG_NAMESPACE &&
!intMember(relnamespace, namespaceSearchPath)) !oidMember(relnamespace, namespaceSearchPath))
visible = false; visible = false;
else else
{ {
...@@ -342,7 +342,7 @@ TypenameGetTypid(const char *typname) ...@@ -342,7 +342,7 @@ TypenameGetTypid(const char *typname)
foreach(lptr, namespaceSearchPath) foreach(lptr, namespaceSearchPath)
{ {
Oid namespaceId = (Oid) lfirsti(lptr); Oid namespaceId = lfirsto(lptr);
typid = GetSysCacheOid(TYPENAMENSP, typid = GetSysCacheOid(TYPENAMENSP,
PointerGetDatum(typname), PointerGetDatum(typname),
...@@ -382,11 +382,11 @@ TypeIsVisible(Oid typid) ...@@ -382,11 +382,11 @@ TypeIsVisible(Oid typid)
/* /*
* Quick check: if it ain't in the path at all, it ain't visible. * Quick check: if it ain't in the path at all, it ain't visible.
* Items in the system namespace are surely in the path and so we * Items in the system namespace are surely in the path and so we
* needn't even do intMember() for them. * needn't even do oidMember() for them.
*/ */
typnamespace = typform->typnamespace; typnamespace = typform->typnamespace;
if (typnamespace != PG_CATALOG_NAMESPACE && if (typnamespace != PG_CATALOG_NAMESPACE &&
!intMember(typnamespace, namespaceSearchPath)) !oidMember(typnamespace, namespaceSearchPath))
visible = false; visible = false;
else else
{ {
...@@ -480,7 +480,7 @@ FuncnameGetCandidates(List *names, int nargs) ...@@ -480,7 +480,7 @@ FuncnameGetCandidates(List *names, int nargs)
foreach(nsp, namespaceSearchPath) foreach(nsp, namespaceSearchPath)
{ {
if (procform->pronamespace == (Oid) lfirsti(nsp)) if (procform->pronamespace == lfirsto(nsp))
break; break;
pathpos++; pathpos++;
} }
...@@ -583,11 +583,11 @@ FunctionIsVisible(Oid funcid) ...@@ -583,11 +583,11 @@ FunctionIsVisible(Oid funcid)
/* /*
* Quick check: if it ain't in the path at all, it ain't visible. * Quick check: if it ain't in the path at all, it ain't visible.
* Items in the system namespace are surely in the path and so we * Items in the system namespace are surely in the path and so we
* needn't even do intMember() for them. * needn't even do oidMember() for them.
*/ */
pronamespace = procform->pronamespace; pronamespace = procform->pronamespace;
if (pronamespace != PG_CATALOG_NAMESPACE && if (pronamespace != PG_CATALOG_NAMESPACE &&
!intMember(pronamespace, namespaceSearchPath)) !oidMember(pronamespace, namespaceSearchPath))
visible = false; visible = false;
else else
{ {
...@@ -695,7 +695,7 @@ OpernameGetCandidates(List *names, char oprkind) ...@@ -695,7 +695,7 @@ OpernameGetCandidates(List *names, char oprkind)
foreach(nsp, namespaceSearchPath) foreach(nsp, namespaceSearchPath)
{ {
if (operform->oprnamespace == (Oid) lfirsti(nsp)) if (operform->oprnamespace == lfirsto(nsp))
break; break;
pathpos++; pathpos++;
} }
...@@ -795,11 +795,11 @@ OperatorIsVisible(Oid oprid) ...@@ -795,11 +795,11 @@ OperatorIsVisible(Oid oprid)
/* /*
* Quick check: if it ain't in the path at all, it ain't visible. * Quick check: if it ain't in the path at all, it ain't visible.
* Items in the system namespace are surely in the path and so we * Items in the system namespace are surely in the path and so we
* needn't even do intMember() for them. * needn't even do oidMember() for them.
*/ */
oprnamespace = oprform->oprnamespace; oprnamespace = oprform->oprnamespace;
if (oprnamespace != PG_CATALOG_NAMESPACE && if (oprnamespace != PG_CATALOG_NAMESPACE &&
!intMember(oprnamespace, namespaceSearchPath)) !oidMember(oprnamespace, namespaceSearchPath))
visible = false; visible = false;
else else
{ {
...@@ -871,7 +871,7 @@ OpclassGetCandidates(Oid amid) ...@@ -871,7 +871,7 @@ OpclassGetCandidates(Oid amid)
/* Consider only opclasses that are in the search path */ /* Consider only opclasses that are in the search path */
foreach(nsp, namespaceSearchPath) foreach(nsp, namespaceSearchPath)
{ {
if (opcform->opcnamespace == (Oid) lfirsti(nsp)) if (opcform->opcnamespace == lfirsto(nsp))
break; break;
pathpos++; pathpos++;
} }
...@@ -967,7 +967,7 @@ OpclassnameGetOpcid(Oid amid, const char *opcname) ...@@ -967,7 +967,7 @@ OpclassnameGetOpcid(Oid amid, const char *opcname)
foreach(lptr, namespaceSearchPath) foreach(lptr, namespaceSearchPath)
{ {
Oid namespaceId = (Oid) lfirsti(lptr); Oid namespaceId = lfirsto(lptr);
opcid = GetSysCacheOid(CLAAMNAMENSP, opcid = GetSysCacheOid(CLAAMNAMENSP,
ObjectIdGetDatum(amid), ObjectIdGetDatum(amid),
...@@ -1008,11 +1008,11 @@ OpclassIsVisible(Oid opcid) ...@@ -1008,11 +1008,11 @@ OpclassIsVisible(Oid opcid)
/* /*
* Quick check: if it ain't in the path at all, it ain't visible. * Quick check: if it ain't in the path at all, it ain't visible.
* Items in the system namespace are surely in the path and so we * Items in the system namespace are surely in the path and so we
* needn't even do intMember() for them. * needn't even do oidMember() for them.
*/ */
opcnamespace = opcform->opcnamespace; opcnamespace = opcform->opcnamespace;
if (opcnamespace != PG_CATALOG_NAMESPACE && if (opcnamespace != PG_CATALOG_NAMESPACE &&
!intMember(opcnamespace, namespaceSearchPath)) !oidMember(opcnamespace, namespaceSearchPath))
visible = false; visible = false;
else else
{ {
...@@ -1049,7 +1049,7 @@ ConversionGetConid(const char *conname) ...@@ -1049,7 +1049,7 @@ ConversionGetConid(const char *conname)
foreach(lptr, namespaceSearchPath) foreach(lptr, namespaceSearchPath)
{ {
Oid namespaceId = (Oid) lfirsti(lptr); Oid namespaceId = lfirsto(lptr);
conid = GetSysCacheOid(CONNAMENSP, conid = GetSysCacheOid(CONNAMENSP,
PointerGetDatum(conname), PointerGetDatum(conname),
...@@ -1089,11 +1089,11 @@ ConversionIsVisible(Oid conid) ...@@ -1089,11 +1089,11 @@ ConversionIsVisible(Oid conid)
/* /*
* Quick check: if it ain't in the path at all, it ain't visible. * Quick check: if it ain't in the path at all, it ain't visible.
* Items in the system namespace are surely in the path and so we * Items in the system namespace are surely in the path and so we
* needn't even do intMember() for them. * needn't even do oidMember() for them.
*/ */
connamespace = conform->connamespace; connamespace = conform->connamespace;
if (connamespace != PG_CATALOG_NAMESPACE && if (connamespace != PG_CATALOG_NAMESPACE &&
!intMember(connamespace, namespaceSearchPath)) !oidMember(connamespace, namespaceSearchPath))
visible = false; visible = false;
else else
{ {
...@@ -1141,7 +1141,7 @@ DeconstructQualifiedName(List *names, ...@@ -1141,7 +1141,7 @@ DeconstructQualifiedName(List *names,
case 3: case 3:
catalogname = strVal(lfirst(names)); catalogname = strVal(lfirst(names));
schemaname = strVal(lsecond(names)); schemaname = strVal(lsecond(names));
objname = strVal(lfirst(lnext(lnext(names)))); objname = strVal(lthird(names));
/* /*
* We check the catalog name and then ignore it. * We check the catalog name and then ignore it.
...@@ -1251,7 +1251,7 @@ makeRangeVarFromNameList(List *names) ...@@ -1251,7 +1251,7 @@ makeRangeVarFromNameList(List *names)
case 3: case 3:
rel->catalogname = strVal(lfirst(names)); rel->catalogname = strVal(lfirst(names));
rel->schemaname = strVal(lsecond(names)); rel->schemaname = strVal(lsecond(names));
rel->relname = strVal(lfirst(lnext(lnext(names)))); rel->relname = strVal(lthird(names));
break; break;
default: default:
elog(ERROR, "Improper relation name (too many dotted names)"); elog(ERROR, "Improper relation name (too many dotted names)");
...@@ -1402,7 +1402,7 @@ FindConversionByName(List *name) ...@@ -1402,7 +1402,7 @@ FindConversionByName(List *name)
foreach(lptr, namespaceSearchPath) foreach(lptr, namespaceSearchPath)
{ {
namespaceId = (Oid) lfirsti(lptr); namespaceId = lfirsto(lptr);
conoid = FindConversion(conversion_name, namespaceId); conoid = FindConversion(conversion_name, namespaceId);
if (OidIsValid(conoid)) if (OidIsValid(conoid))
return conoid; return conoid;
...@@ -1426,7 +1426,7 @@ FindDefaultConversionProc(int4 for_encoding, int4 to_encoding) ...@@ -1426,7 +1426,7 @@ FindDefaultConversionProc(int4 for_encoding, int4 to_encoding)
foreach(lptr, namespaceSearchPath) foreach(lptr, namespaceSearchPath)
{ {
Oid namespaceId = (Oid) lfirsti(lptr); Oid namespaceId = lfirsto(lptr);
proc = FindDefaultConversion(namespaceId, for_encoding, to_encoding); proc = FindDefaultConversion(namespaceId, for_encoding, to_encoding);
if (OidIsValid(proc)) if (OidIsValid(proc))
...@@ -1499,10 +1499,10 @@ recomputeNamespacePath(void) ...@@ -1499,10 +1499,10 @@ recomputeNamespacePath(void)
0, 0, 0); 0, 0, 0);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
if (OidIsValid(namespaceId) && if (OidIsValid(namespaceId) &&
!intMember(namespaceId, oidlist) && !oidMember(namespaceId, oidlist) &&
pg_namespace_aclcheck(namespaceId, userId, pg_namespace_aclcheck(namespaceId, userId,
ACL_USAGE) == ACLCHECK_OK) ACL_USAGE) == ACLCHECK_OK)
oidlist = lappendi(oidlist, namespaceId); oidlist = lappendo(oidlist, namespaceId);
} }
} }
else else
...@@ -1512,10 +1512,10 @@ recomputeNamespacePath(void) ...@@ -1512,10 +1512,10 @@ recomputeNamespacePath(void)
CStringGetDatum(curname), CStringGetDatum(curname),
0, 0, 0); 0, 0, 0);
if (OidIsValid(namespaceId) && if (OidIsValid(namespaceId) &&
!intMember(namespaceId, oidlist) && !oidMember(namespaceId, oidlist) &&
pg_namespace_aclcheck(namespaceId, userId, pg_namespace_aclcheck(namespaceId, userId,
ACL_USAGE) == ACLCHECK_OK) ACL_USAGE) == ACLCHECK_OK)
oidlist = lappendi(oidlist, namespaceId); oidlist = lappendo(oidlist, namespaceId);
} }
} }
...@@ -1525,23 +1525,23 @@ recomputeNamespacePath(void) ...@@ -1525,23 +1525,23 @@ recomputeNamespacePath(void)
if (oidlist == NIL) if (oidlist == NIL)
firstNS = InvalidOid; firstNS = InvalidOid;
else else
firstNS = (Oid) lfirsti(oidlist); firstNS = lfirsto(oidlist);
/* /*
* Add any implicitly-searched namespaces to the list. Note these go * Add any implicitly-searched namespaces to the list. Note these go
* on the front, not the back; also notice that we do not check USAGE * on the front, not the back; also notice that we do not check USAGE
* permissions for these. * permissions for these.
*/ */
if (!intMember(PG_CATALOG_NAMESPACE, oidlist)) if (!oidMember(PG_CATALOG_NAMESPACE, oidlist))
oidlist = lconsi(PG_CATALOG_NAMESPACE, oidlist); oidlist = lconso(PG_CATALOG_NAMESPACE, oidlist);
if (OidIsValid(myTempNamespace) && if (OidIsValid(myTempNamespace) &&
!intMember(myTempNamespace, oidlist)) !oidMember(myTempNamespace, oidlist))
oidlist = lconsi(myTempNamespace, oidlist); oidlist = lconso(myTempNamespace, oidlist);
if (OidIsValid(mySpecialNamespace) && if (OidIsValid(mySpecialNamespace) &&
!intMember(mySpecialNamespace, oidlist)) !oidMember(mySpecialNamespace, oidlist))
oidlist = lconsi(mySpecialNamespace, oidlist); oidlist = lconso(mySpecialNamespace, oidlist);
/* /*
* Now that we've successfully built the new list of namespace OIDs, * Now that we've successfully built the new list of namespace OIDs,
...@@ -1801,7 +1801,7 @@ InitializeSearchPath(void) ...@@ -1801,7 +1801,7 @@ InitializeSearchPath(void)
MemoryContext oldcxt; MemoryContext oldcxt;
oldcxt = MemoryContextSwitchTo(TopMemoryContext); oldcxt = MemoryContextSwitchTo(TopMemoryContext);
namespaceSearchPath = makeListi1(PG_CATALOG_NAMESPACE); namespaceSearchPath = makeListo1(PG_CATALOG_NAMESPACE);
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
defaultCreationNamespace = PG_CATALOG_NAMESPACE; defaultCreationNamespace = PG_CATALOG_NAMESPACE;
firstExplicitNamespace = PG_CATALOG_NAMESPACE; firstExplicitNamespace = PG_CATALOG_NAMESPACE;
...@@ -1851,7 +1851,7 @@ fetch_search_path(bool includeImplicit) ...@@ -1851,7 +1851,7 @@ fetch_search_path(bool includeImplicit)
result = namespaceSearchPath; result = namespaceSearchPath;
if (!includeImplicit) if (!includeImplicit)
{ {
while (result && (Oid) lfirsti(result) != firstExplicitNamespace) while (result && lfirsto(result) != firstExplicitNamespace)
result = lnext(result); result = lnext(result);
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.104 2002/12/30 19:45:15 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.105 2003/02/09 06:56:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -129,7 +129,7 @@ cluster(ClusterStmt *stmt) ...@@ -129,7 +129,7 @@ cluster(ClusterStmt *stmt)
HeapTuple idxtuple; HeapTuple idxtuple;
Form_pg_index indexForm; Form_pg_index indexForm;
indexOid = lfirsti(index); indexOid = lfirsto(index);
idxtuple = SearchSysCache(INDEXRELID, idxtuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexOid), ObjectIdGetDatum(indexOid),
0, 0, 0); 0, 0, 0);
...@@ -527,7 +527,7 @@ get_indexattr_list(Relation OldHeap, Oid OldIndex) ...@@ -527,7 +527,7 @@ get_indexattr_list(Relation OldHeap, Oid OldIndex)
/* Ask the relcache to produce a list of the indexes of the old rel */ /* Ask the relcache to produce a list of the indexes of the old rel */
foreach(indlist, RelationGetIndexList(OldHeap)) foreach(indlist, RelationGetIndexList(OldHeap))
{ {
Oid indexOID = (Oid) lfirsti(indlist); Oid indexOID = lfirsto(indlist);
HeapTuple indexTuple; HeapTuple indexTuple;
HeapTuple classTuple; HeapTuple classTuple;
Form_pg_index indexForm; Form_pg_index indexForm;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994-5, Regents of the University of California * Portions Copyright (c) 1994-5, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.101 2003/02/08 20:20:53 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.102 2003/02/09 06:56:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -403,7 +403,7 @@ explain_outNode(StringInfo str, ...@@ -403,7 +403,7 @@ explain_outNode(StringInfo str,
{ {
Relation relation; Relation relation;
relation = index_open(lfirsti(l)); relation = index_open(lfirsto(l));
appendStringInfo(str, "%s%s", appendStringInfo(str, "%s%s",
(++i > 1) ? ", " : "", (++i > 1) ? ", " : "",
quote_identifier(RelationGetRelationName(relation))); quote_identifier(RelationGetRelationName(relation)));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.65 2003/01/08 22:06:23 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.66 2003/02/09 06:56:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -456,7 +456,7 @@ TruncateRelation(const RangeVar *relation) ...@@ -456,7 +456,7 @@ TruncateRelation(const RangeVar *relation)
* 'istemp' is TRUE if we are creating a temp relation. * 'istemp' is TRUE if we are creating a temp relation.
* *
* Output arguments: * Output arguments:
* 'supOids' receives an integer list of the OIDs of the parent relations. * 'supOids' receives a list of the OIDs of the parent relations.
* 'supconstr' receives a list of constraints belonging to the parents, * 'supconstr' receives a list of constraints belonging to the parents,
* updated as necessary to be valid for the child. * updated as necessary to be valid for the child.
* 'supHasOids' is set TRUE if any parent has OIDs, else it is set FALSE. * 'supHasOids' is set TRUE if any parent has OIDs, else it is set FALSE.
...@@ -575,11 +575,11 @@ MergeAttributes(List *schema, List *supers, bool istemp, ...@@ -575,11 +575,11 @@ MergeAttributes(List *schema, List *supers, bool istemp,
/* /*
* Reject duplications in the list of parents. * Reject duplications in the list of parents.
*/ */
if (intMember(RelationGetRelid(relation), parentOids)) if (oidMember(RelationGetRelid(relation), parentOids))
elog(ERROR, "CREATE TABLE: inherited relation \"%s\" duplicated", elog(ERROR, "CREATE TABLE: inherited relation \"%s\" duplicated",
parent->relname); parent->relname);
parentOids = lappendi(parentOids, RelationGetRelid(relation)); parentOids = lappendo(parentOids, RelationGetRelid(relation));
setRelhassubclassInRelation(RelationGetRelid(relation), true); setRelhassubclassInRelation(RelationGetRelid(relation), true);
parentHasOids |= relation->rd_rel->relhasoids; parentHasOids |= relation->rd_rel->relhasoids;
...@@ -879,8 +879,8 @@ change_varattnos_of_a_node(Node *node, const AttrNumber *newattno) ...@@ -879,8 +879,8 @@ change_varattnos_of_a_node(Node *node, const AttrNumber *newattno)
* StoreCatalogInheritance * StoreCatalogInheritance
* Updates the system catalogs with proper inheritance information. * Updates the system catalogs with proper inheritance information.
* *
* supers is an integer list of the OIDs of the new relation's direct * supers is a list of the OIDs of the new relation's direct ancestors.
* ancestors. NB: it is destructively changed to include indirect ancestors. * NB: it is destructively changed to include indirect ancestors.
*/ */
static void static void
StoreCatalogInheritance(Oid relationId, List *supers) StoreCatalogInheritance(Oid relationId, List *supers)
...@@ -909,7 +909,7 @@ StoreCatalogInheritance(Oid relationId, List *supers) ...@@ -909,7 +909,7 @@ StoreCatalogInheritance(Oid relationId, List *supers)
seqNumber = 1; seqNumber = 1;
foreach(entry, supers) foreach(entry, supers)
{ {
Oid entryOid = lfirsti(entry); Oid entryOid = lfirsto(entry);
Datum datum[Natts_pg_inherits]; Datum datum[Natts_pg_inherits];
char nullarr[Natts_pg_inherits]; char nullarr[Natts_pg_inherits];
ObjectAddress childobject, ObjectAddress childobject,
...@@ -963,13 +963,12 @@ StoreCatalogInheritance(Oid relationId, List *supers) ...@@ -963,13 +963,12 @@ StoreCatalogInheritance(Oid relationId, List *supers)
*/ */
foreach(entry, supers) foreach(entry, supers)
{ {
Oid id = lfirsto(entry);
HeapTuple tuple; HeapTuple tuple;
Oid id;
int16 number; int16 number;
List *next;
List *current; List *current;
List *next;
id = (Oid) lfirsti(entry);
current = entry; current = entry;
next = lnext(entry); next = lnext(entry);
...@@ -982,13 +981,12 @@ StoreCatalogInheritance(Oid relationId, List *supers) ...@@ -982,13 +981,12 @@ StoreCatalogInheritance(Oid relationId, List *supers)
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
break; break;
lnext(current) = lconsi(((Form_pg_inherits) lnext(current) = lconso(((Form_pg_inherits)
GETSTRUCT(tuple))->inhparent, GETSTRUCT(tuple))->inhparent,
NIL); NIL);
current = lnext(current);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
current = lnext(current);
} }
lnext(current) = next; lnext(current) = next;
} }
...@@ -1003,11 +1001,11 @@ StoreCatalogInheritance(Oid relationId, List *supers) ...@@ -1003,11 +1001,11 @@ StoreCatalogInheritance(Oid relationId, List *supers)
List *rest; List *rest;
again: again:
thisone = lfirsti(entry);
found = false; found = false;
thisone = lfirsto(entry);
foreach(rest, lnext(entry)) foreach(rest, lnext(entry))
{ {
if (thisone == lfirsti(rest)) if (thisone == lfirsto(rest))
{ {
found = true; found = true;
break; break;
...@@ -1018,7 +1016,7 @@ again: ...@@ -1018,7 +1016,7 @@ again:
/* /*
* found a later duplicate, so remove this entry. * found a later duplicate, so remove this entry.
*/ */
lfirsti(entry) = lfirsti(lnext(entry)); lfirsto(entry) = lfirsto(lnext(entry));
lnext(entry) = lnext(lnext(entry)); lnext(entry) = lnext(lnext(entry));
goto again; goto again;
...@@ -1151,7 +1149,7 @@ renameatt(Oid myrelid, ...@@ -1151,7 +1149,7 @@ renameatt(Oid myrelid,
*/ */
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
if (childrelid == myrelid) if (childrelid == myrelid)
continue; continue;
...@@ -1216,7 +1214,7 @@ renameatt(Oid myrelid, ...@@ -1216,7 +1214,7 @@ renameatt(Oid myrelid,
foreach(indexoidscan, indexoidlist) foreach(indexoidscan, indexoidlist)
{ {
Oid indexoid = lfirsti(indexoidscan); Oid indexoid = lfirsto(indexoidscan);
HeapTuple indextup; HeapTuple indextup;
/* /*
...@@ -1668,7 +1666,7 @@ AlterTableAddColumn(Oid myrelid, ...@@ -1668,7 +1666,7 @@ AlterTableAddColumn(Oid myrelid,
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
HeapTuple tuple; HeapTuple tuple;
Form_pg_attribute childatt; Form_pg_attribute childatt;
Relation childrel; Relation childrel;
...@@ -1934,7 +1932,7 @@ AlterTableAlterColumnDropNotNull(Oid myrelid, bool recurse, ...@@ -1934,7 +1932,7 @@ AlterTableAlterColumnDropNotNull(Oid myrelid, bool recurse,
*/ */
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
if (childrelid == myrelid) if (childrelid == myrelid)
continue; continue;
...@@ -1967,7 +1965,7 @@ AlterTableAlterColumnDropNotNull(Oid myrelid, bool recurse, ...@@ -1967,7 +1965,7 @@ AlterTableAlterColumnDropNotNull(Oid myrelid, bool recurse,
foreach(indexoidscan, indexoidlist) foreach(indexoidscan, indexoidlist)
{ {
Oid indexoid = lfirsti(indexoidscan); Oid indexoid = lfirsto(indexoidscan);
HeapTuple indexTuple; HeapTuple indexTuple;
Form_pg_index indexStruct; Form_pg_index indexStruct;
int i; int i;
...@@ -2068,7 +2066,7 @@ AlterTableAlterColumnSetNotNull(Oid myrelid, bool recurse, ...@@ -2068,7 +2066,7 @@ AlterTableAlterColumnSetNotNull(Oid myrelid, bool recurse,
*/ */
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
if (childrelid == myrelid) if (childrelid == myrelid)
continue; continue;
...@@ -2186,7 +2184,7 @@ AlterTableAlterColumnDefault(Oid myrelid, bool recurse, ...@@ -2186,7 +2184,7 @@ AlterTableAlterColumnDefault(Oid myrelid, bool recurse,
*/ */
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
if (childrelid == myrelid) if (childrelid == myrelid)
continue; continue;
...@@ -2334,7 +2332,7 @@ AlterTableAlterColumnFlags(Oid myrelid, bool recurse, ...@@ -2334,7 +2332,7 @@ AlterTableAlterColumnFlags(Oid myrelid, bool recurse,
*/ */
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
if (childrelid == myrelid) if (childrelid == myrelid)
continue; continue;
...@@ -2451,7 +2449,7 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing, ...@@ -2451,7 +2449,7 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing,
attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock); attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock);
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
Relation childrel; Relation childrel;
HeapTuple tuple; HeapTuple tuple;
Form_pg_attribute childatt; Form_pg_attribute childatt;
...@@ -2499,7 +2497,7 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing, ...@@ -2499,7 +2497,7 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing,
attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock); attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock);
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
Relation childrel; Relation childrel;
HeapTuple tuple; HeapTuple tuple;
Form_pg_attribute childatt; Form_pg_attribute childatt;
...@@ -2599,7 +2597,7 @@ AlterTableAddConstraint(Oid myrelid, bool recurse, ...@@ -2599,7 +2597,7 @@ AlterTableAddConstraint(Oid myrelid, bool recurse,
*/ */
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
if (childrelid == myrelid) if (childrelid == myrelid)
continue; continue;
...@@ -3042,7 +3040,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, ...@@ -3042,7 +3040,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
foreach(indexoidscan, indexoidlist) foreach(indexoidscan, indexoidlist)
{ {
Oid indexoid = lfirsti(indexoidscan); Oid indexoid = lfirsto(indexoidscan);
indexTuple = SearchSysCache(INDEXRELID, indexTuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexoid), ObjectIdGetDatum(indexoid),
...@@ -3117,7 +3115,7 @@ transformFkeyCheckAttrs(Relation pkrel, ...@@ -3117,7 +3115,7 @@ transformFkeyCheckAttrs(Relation pkrel,
Form_pg_index indexStruct; Form_pg_index indexStruct;
int i, j; int i, j;
indexoid = lfirsti(indexoidscan); indexoid = lfirsto(indexoidscan);
indexTuple = SearchSysCache(INDEXRELID, indexTuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexoid), ObjectIdGetDatum(indexoid),
0, 0, 0); 0, 0, 0);
...@@ -3564,7 +3562,7 @@ AlterTableDropConstraint(Oid myrelid, bool recurse, ...@@ -3564,7 +3562,7 @@ AlterTableDropConstraint(Oid myrelid, bool recurse,
*/ */
foreach(child, children) foreach(child, children)
{ {
Oid childrelid = lfirsti(child); Oid childrelid = lfirsto(child);
Relation inhrel; Relation inhrel;
if (childrelid == myrelid) if (childrelid == myrelid)
...@@ -3647,7 +3645,7 @@ AlterTableOwner(Oid relationOid, int32 newOwnerSysId) ...@@ -3647,7 +3645,7 @@ AlterTableOwner(Oid relationOid, int32 newOwnerSysId)
/* For each index, recursively change its ownership */ /* For each index, recursively change its ownership */
foreach(i, index_oid_list) foreach(i, index_oid_list)
AlterTableOwner(lfirsti(i), newOwnerSysId); AlterTableOwner(lfirsto(i), newOwnerSysId);
freeList(index_oid_list); freeList(index_oid_list);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.144 2003/01/08 22:29:23 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.145 2003/02/09 06:56:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2245,7 +2245,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) ...@@ -2245,7 +2245,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
cname); cname);
constr_oid = HeapTupleGetOid(htup); constr_oid = HeapTupleGetOid(htup);
loid = lappendi(loid, constr_oid); loid = lappendo(loid, constr_oid);
found = true; found = true;
} }
...@@ -2271,7 +2271,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) ...@@ -2271,7 +2271,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
foreach(ls, deftrig_trigstates) foreach(ls, deftrig_trigstates)
{ {
state = (DeferredTriggerStatus) lfirst(ls); state = (DeferredTriggerStatus) lfirst(ls);
if (state->dts_tgoid == (Oid) lfirsti(l)) if (state->dts_tgoid == lfirsto(l))
{ {
state->dts_tgisdeferred = stmt->deferred; state->dts_tgisdeferred = stmt->deferred;
found = true; found = true;
...@@ -2282,7 +2282,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) ...@@ -2282,7 +2282,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
{ {
state = (DeferredTriggerStatus) state = (DeferredTriggerStatus)
palloc(sizeof(DeferredTriggerStatusData)); palloc(sizeof(DeferredTriggerStatusData));
state->dts_tgoid = (Oid) lfirsti(l); state->dts_tgoid = lfirsto(l);
state->dts_tgisdeferred = stmt->deferred; state->dts_tgisdeferred = stmt->deferred;
deftrig_trigstates = deftrig_trigstates =
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.246 2003/01/07 22:23:17 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.247 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -283,7 +283,7 @@ vacuum(VacuumStmt *vacstmt) ...@@ -283,7 +283,7 @@ vacuum(VacuumStmt *vacstmt)
*/ */
foreach(cur, vrl) foreach(cur, vrl)
{ {
Oid relid = (Oid) lfirsti(cur); Oid relid = lfirsto(cur);
if (vacstmt->vacuum) if (vacstmt->vacuum)
{ {
...@@ -382,7 +382,7 @@ getrels(const RangeVar *vacrel, const char *stmttype) ...@@ -382,7 +382,7 @@ getrels(const RangeVar *vacrel, const char *stmttype)
/* Make a relation list entry for this guy */ /* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context); oldcontext = MemoryContextSwitchTo(vac_context);
vrl = lappendi(vrl, relid); vrl = lappendo(vrl, relid);
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
} }
else else
...@@ -406,7 +406,7 @@ getrels(const RangeVar *vacrel, const char *stmttype) ...@@ -406,7 +406,7 @@ getrels(const RangeVar *vacrel, const char *stmttype)
{ {
/* Make a relation list entry for this guy */ /* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context); oldcontext = MemoryContextSwitchTo(vac_context);
vrl = lappendi(vrl, HeapTupleGetOid(tuple)); vrl = lappendo(vrl, HeapTupleGetOid(tuple));
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
} }
...@@ -2957,7 +2957,7 @@ vac_open_indexes(Relation relation, int *nindexes, Relation **Irel) ...@@ -2957,7 +2957,7 @@ vac_open_indexes(Relation relation, int *nindexes, Relation **Irel)
i = 0; i = 0;
foreach(indexoidscan, indexoidlist) foreach(indexoidscan, indexoidlist)
{ {
Oid indexoid = lfirsti(indexoidscan); Oid indexoid = lfirsto(indexoidscan);
(*Irel)[i] = index_open(indexoid); (*Irel)[i] = index_open(indexoid);
i++; i++;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.97 2003/02/09 00:30:39 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.98 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -677,7 +677,7 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo) ...@@ -677,7 +677,7 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo)
i = 0; i = 0;
foreach(indexoidscan, indexoidlist) foreach(indexoidscan, indexoidlist)
{ {
Oid indexOid = lfirsti(indexoidscan); Oid indexOid = lfirsto(indexoidscan);
Relation indexDesc; Relation indexDesc;
IndexInfo *ii; IndexInfo *ii;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.78 2003/02/03 15:07:07 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.79 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -897,7 +897,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate) ...@@ -897,7 +897,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate)
listscan = indxid; listscan = indxid;
for (i = 0; i < numIndices; i++) for (i = 0; i < numIndices; i++)
{ {
Oid indexOid = (Oid) lfirsti(listscan); Oid indexOid = lfirsto(listscan);
indexDescs[i] = index_open(indexOid); indexDescs[i] = index_open(indexOid);
scanDescs[i] = index_beginscan(currentRelation, scanDescs[i] = index_beginscan(currentRelation,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.241 2003/02/09 00:30:39 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.242 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,6 +47,10 @@ ...@@ -47,6 +47,10 @@
#define COPY_INTLIST_FIELD(fldname) \ #define COPY_INTLIST_FIELD(fldname) \
(newnode->fldname = listCopy(from->fldname)) (newnode->fldname = listCopy(from->fldname))
/* Copy a field that is a pointer to a list of Oids */
#define COPY_OIDLIST_FIELD(fldname) \
(newnode->fldname = listCopy(from->fldname))
/* Copy a field that is a pointer to a Bitmapset */ /* Copy a field that is a pointer to a Bitmapset */
#define COPY_BITMAPSET_FIELD(fldname) \ #define COPY_BITMAPSET_FIELD(fldname) \
(newnode->fldname = bms_copy(from->fldname)) (newnode->fldname = bms_copy(from->fldname))
...@@ -69,31 +73,38 @@ ...@@ -69,31 +73,38 @@
* This copy function only copies the "cons-cells" of the list, not the * This copy function only copies the "cons-cells" of the list, not the
* pointed-to objects. (Use copyObject if you want a "deep" copy.) * pointed-to objects. (Use copyObject if you want a "deep" copy.)
* *
* We also use this function for copying lists of integers, which is * We also use this function for copying lists of integers and Oids,
* grotty but unlikely to break --- it could fail if sizeof(pointer) * which is notationally a bit ugly, but perfectly safe.
* is less than sizeof(int), but I don't know any such machines...
* *
* Note that copyObject will surely coredump if applied to a list * Note that copyObject will surely coredump if applied to a list
* of integers! * of integers or Oids!
*/ */
List * List *
listCopy(List *list) listCopy(List *list)
{ {
List *newlist, List *newlist,
*l, *oldl,
*nl; *newcell,
*prev;
/* rather ugly coding for speed... */ /* rather ugly coding for speed... */
if (list == NIL) if (list == NIL)
return NIL; return NIL;
newlist = nl = makeList1(lfirst(list)); newcell = makeNode(List);
newcell->elem = list->elem;
newlist = prev = newcell;
foreach(l, lnext(list)) foreach(oldl, lnext(list))
{ {
lnext(nl) = makeList1(lfirst(l)); newcell = makeNode(List);
nl = lnext(nl); newcell->elem = oldl->elem;
prev->next = newcell;
prev = newcell;
} }
prev->next = NIL;
return newlist; return newlist;
} }
...@@ -248,7 +259,7 @@ _copyIndexScan(IndexScan *from) ...@@ -248,7 +259,7 @@ _copyIndexScan(IndexScan *from)
/* /*
* copy remainder of node * copy remainder of node
*/ */
COPY_INTLIST_FIELD(indxid); COPY_OIDLIST_FIELD(indxid);
COPY_NODE_FIELD(indxqual); COPY_NODE_FIELD(indxqual);
COPY_NODE_FIELD(indxqualorig); COPY_NODE_FIELD(indxqualorig);
COPY_SCALAR_FIELD(indxorderdir); COPY_SCALAR_FIELD(indxorderdir);
...@@ -816,7 +827,7 @@ _copySubLink(SubLink *from) ...@@ -816,7 +827,7 @@ _copySubLink(SubLink *from)
COPY_SCALAR_FIELD(useOr); COPY_SCALAR_FIELD(useOr);
COPY_NODE_FIELD(lefthand); COPY_NODE_FIELD(lefthand);
COPY_NODE_FIELD(operName); COPY_NODE_FIELD(operName);
COPY_INTLIST_FIELD(operOids); COPY_OIDLIST_FIELD(operOids);
COPY_NODE_FIELD(subselect); COPY_NODE_FIELD(subselect);
return newnode; return newnode;
...@@ -1523,7 +1534,7 @@ _copySetOperationStmt(SetOperationStmt *from) ...@@ -1523,7 +1534,7 @@ _copySetOperationStmt(SetOperationStmt *from)
COPY_SCALAR_FIELD(all); COPY_SCALAR_FIELD(all);
COPY_NODE_FIELD(larg); COPY_NODE_FIELD(larg);
COPY_NODE_FIELD(rarg); COPY_NODE_FIELD(rarg);
COPY_INTLIST_FIELD(colTypes); COPY_OIDLIST_FIELD(colTypes);
return newnode; return newnode;
} }
...@@ -2271,7 +2282,7 @@ _copyPrepareStmt(PrepareStmt *from) ...@@ -2271,7 +2282,7 @@ _copyPrepareStmt(PrepareStmt *from)
COPY_STRING_FIELD(name); COPY_STRING_FIELD(name);
COPY_NODE_FIELD(argtypes); COPY_NODE_FIELD(argtypes);
COPY_INTLIST_FIELD(argtype_oids); COPY_OIDLIST_FIELD(argtype_oids);
COPY_NODE_FIELD(query); COPY_NODE_FIELD(query);
return newnode; return newnode;
...@@ -2527,19 +2538,26 @@ copyObject(void *from) ...@@ -2527,19 +2538,26 @@ copyObject(void *from)
case T_List: case T_List:
{ {
List *list = from, List *list = from,
*l, *oldl,
*nl; *newcell,
*prev;
/* rather ugly coding for speed... */ /* rather ugly coding for speed... */
/* Note the input list cannot be NIL if we got here. */ /* Note the input list cannot be NIL if we got here. */
nl = makeList1(copyObject(lfirst(list))); newcell = makeNode(List);
retval = nl; lfirst(newcell) = copyObject(lfirst(list));
retval = (void *) newcell;
prev = newcell;
foreach(l, lnext(list)) foreach(oldl, lnext(list))
{ {
lnext(nl) = makeList1(copyObject(lfirst(l))); newcell = makeNode(List);
nl = lnext(nl); lfirst(newcell) = copyObject(lfirst(oldl));
prev->next = newcell;
prev = newcell;
} }
prev->next = NIL;
} }
break; break;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.184 2003/02/08 20:20:53 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.185 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -59,6 +59,13 @@ ...@@ -59,6 +59,13 @@
return false; \ return false; \
} while (0) } while (0)
/* Compare a field that is a pointer to a list of Oids */
#define COMPARE_OIDLIST_FIELD(fldname) \
do { \
if (!equalo(a->fldname, b->fldname)) \
return false; \
} while (0)
/* Compare a field that is a pointer to a Bitmapset */ /* Compare a field that is a pointer to a Bitmapset */
#define COMPARE_BITMAPSET_FIELD(fldname) \ #define COMPARE_BITMAPSET_FIELD(fldname) \
do { \ do { \
...@@ -297,7 +304,7 @@ _equalSubLink(SubLink *a, SubLink *b) ...@@ -297,7 +304,7 @@ _equalSubLink(SubLink *a, SubLink *b)
COMPARE_SCALAR_FIELD(useOr); COMPARE_SCALAR_FIELD(useOr);
COMPARE_NODE_FIELD(lefthand); COMPARE_NODE_FIELD(lefthand);
COMPARE_NODE_FIELD(operName); COMPARE_NODE_FIELD(operName);
COMPARE_INTLIST_FIELD(operOids); COMPARE_OIDLIST_FIELD(operOids);
COMPARE_NODE_FIELD(subselect); COMPARE_NODE_FIELD(subselect);
return true; return true;
...@@ -611,7 +618,7 @@ _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b) ...@@ -611,7 +618,7 @@ _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b)
COMPARE_SCALAR_FIELD(all); COMPARE_SCALAR_FIELD(all);
COMPARE_NODE_FIELD(larg); COMPARE_NODE_FIELD(larg);
COMPARE_NODE_FIELD(rarg); COMPARE_NODE_FIELD(rarg);
COMPARE_INTLIST_FIELD(colTypes); COMPARE_OIDLIST_FIELD(colTypes);
return true; return true;
} }
...@@ -1237,7 +1244,7 @@ _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b) ...@@ -1237,7 +1244,7 @@ _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b)
{ {
COMPARE_STRING_FIELD(name); COMPARE_STRING_FIELD(name);
COMPARE_NODE_FIELD(argtypes); COMPARE_NODE_FIELD(argtypes);
COMPARE_INTLIST_FIELD(argtype_oids); COMPARE_OIDLIST_FIELD(argtype_oids);
COMPARE_NODE_FIELD(query); COMPARE_NODE_FIELD(query);
return true; return true;
......
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* *
* list.c * list.c
* various list handling routines * POSTGRES generic list package
*
* *
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.47 2003/02/08 20:20:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.48 2003/02/09 06:56:27 tgl Exp $
* *
* NOTES * NOTES
* XXX a few of the following functions are duplicated to handle * XXX a few of the following functions are duplicated to handle
...@@ -117,6 +118,21 @@ lconsi(int datum, List *list) ...@@ -117,6 +118,21 @@ lconsi(int datum, List *list)
return l; return l;
} }
/*
* lconso
*
* Same as lcons, but for Oid data
*/
List *
lconso(Oid datum, List *list)
{
List *l = makeNode(List);
lfirsto(l) = datum;
lnext(l) = list;
return l;
}
/* /*
* lappend * lappend
* *
...@@ -141,6 +157,17 @@ lappendi(List *list, int datum) ...@@ -141,6 +157,17 @@ lappendi(List *list, int datum)
return nconc(list, makeListi1(datum)); return nconc(list, makeListi1(datum));
} }
/*
* lappendo
*
* Same as lappend, but for Oids
*/
List *
lappendo(List *list, Oid datum)
{
return nconc(list, makeListo1(datum));
}
/* /*
* nconc * nconc
* *
...@@ -159,7 +186,7 @@ nconc(List *l1, List *l2) ...@@ -159,7 +186,7 @@ nconc(List *l1, List *l2)
if (l2 == NIL) if (l2 == NIL)
return l1; return l1;
if (l1 == l2) if (l1 == l2)
elog(ERROR, "tryout to nconc a list to itself"); elog(ERROR, "can't nconc a list to itself");
for (temp = l1; lnext(temp) != NIL; temp = lnext(temp)) for (temp = l1; lnext(temp) != NIL; temp = lnext(temp))
; ;
...@@ -177,44 +204,13 @@ void * ...@@ -177,44 +204,13 @@ void *
nth(int n, List *l) nth(int n, List *l)
{ {
/* XXX assume list is long enough */ /* XXX assume list is long enough */
while (n > 0) while (n-- > 0)
{ {
l = lnext(l); l = lnext(l);
n--;
} }
return lfirst(l); return lfirst(l);
} }
/*
* nthi
*
* Same as nthi, but for integers
*/
int
nthi(int n, List *l)
{
/* XXX assume list is long enough */
while (n > 0)
{
l = lnext(l);
n--;
}
return lfirsti(l);
}
/* this is here solely for rt_store. Get rid of me some day! */
void
set_nth(List *l, int n, void *elem)
{
/* XXX assume list is long enough */
while (n > 0)
{
l = lnext(l);
n--;
}
lfirst(l) = elem;
}
/* /*
* length * length
* *
...@@ -253,7 +249,7 @@ llast(List *l) ...@@ -253,7 +249,7 @@ llast(List *l)
* *
* Free the List nodes of a list * Free the List nodes of a list
* The pointed-to nodes, if any, are NOT freed. * The pointed-to nodes, if any, are NOT freed.
* This works for integer lists too. * This works for integer and Oid lists too.
*/ */
void void
freeList(List *list) freeList(List *list)
...@@ -289,6 +285,28 @@ equali(List *list1, List *list2) ...@@ -289,6 +285,28 @@ equali(List *list1, List *list2)
return true; return true;
} }
/*
* equalo
* compares two lists of Oids
*/
bool
equalo(List *list1, List *list2)
{
List *l;
foreach(l, list1)
{
if (list2 == NIL)
return false;
if (lfirsto(l) != lfirsto(list2))
return false;
list2 = lnext(list2);
}
if (list2 != NIL)
return false;
return true;
}
/* /*
* Generate the union of two lists, * Generate the union of two lists,
* ie, l1 plus all members of l2 that are not already in l1. * ie, l1 plus all members of l2 that are not already in l1.
...@@ -313,17 +331,17 @@ set_union(List *l1, List *l2) ...@@ -313,17 +331,17 @@ set_union(List *l1, List *l2)
return retval; return retval;
} }
/* set_union for integer lists */ /* set_union for Oid lists */
List * List *
set_unioni(List *l1, List *l2) set_uniono(List *l1, List *l2)
{ {
List *retval = listCopy(l1); List *retval = listCopy(l1);
List *i; List *i;
foreach(i, l2) foreach(i, l2)
{ {
if (!intMember(lfirsti(i), retval)) if (!oidMember(lfirsto(i), retval))
retval = lappendi(retval, lfirsti(i)); retval = lappendo(retval, lfirsto(i));
} }
return retval; return retval;
} }
...@@ -353,6 +371,7 @@ set_ptrUnion(List *l1, List *l2) ...@@ -353,6 +371,7 @@ set_ptrUnion(List *l1, List *l2)
* The result is a fresh List, but it points to the same member nodes * The result is a fresh List, but it points to the same member nodes
* as were in the inputs. * as were in the inputs.
*/ */
#ifdef NOT_USED
List * List *
set_intersect(List *l1, List *l2) set_intersect(List *l1, List *l2)
{ {
...@@ -366,20 +385,7 @@ set_intersect(List *l1, List *l2) ...@@ -366,20 +385,7 @@ set_intersect(List *l1, List *l2)
} }
return retval; return retval;
} }
#endif
List *
set_intersecti(List *l1, List *l2)
{
List *retval = NIL;
List *i;
foreach(i, l1)
{
if (intMember(lfirsti(i), l2))
retval = lappendi(retval, lfirsti(i));
}
return retval;
}
/* /*
* member() * member()
...@@ -408,7 +414,7 @@ ptrMember(void *l1, List *l2) ...@@ -408,7 +414,7 @@ ptrMember(void *l1, List *l2)
foreach(i, l2) foreach(i, l2)
{ {
if (l1 == ((void *) lfirst(i))) if (l1 == lfirst(i))
return true; return true;
} }
return false; return false;
...@@ -430,9 +436,26 @@ intMember(int l1, List *l2) ...@@ -430,9 +436,26 @@ intMember(int l1, List *l2)
return false; return false;
} }
/*
* membership test for Oid lists
*/
bool
oidMember(Oid l1, List *l2)
{
List *i;
foreach(i, l2)
{
if (l1 == lfirsto(i))
return true;
}
return false;
}
/* /*
* lremove * lremove
* Removes 'elem' from the linked list (destructively changing the list!). * Removes 'elem' from the linked list (destructively changing the list!).
* (If there is more than one equal list member, the first is removed.)
* *
* This version matches 'elem' using simple pointer comparison. * This version matches 'elem' using simple pointer comparison.
* See also LispRemove. * See also LispRemove.
...@@ -464,9 +487,9 @@ lremove(void *elem, List *list) ...@@ -464,9 +487,9 @@ lremove(void *elem, List *list)
/* /*
* LispRemove * LispRemove
* Removes 'elem' from the linked list (destructively changing the list!). * Removes 'elem' from the linked list (destructively changing the list!).
* (If there is more than one equal list member, the first is removed.)
* *
* This version matches 'elem' using equal(). * This version matches 'elem' using equal().
* (If there is more than one equal list member, the first is removed.)
* See also lremove. * See also lremove.
*/ */
List * List *
...@@ -572,12 +595,12 @@ set_difference(List *l1, List *l2) ...@@ -572,12 +595,12 @@ set_difference(List *l1, List *l2)
} }
/* /*
* set_differencei * set_differenceo
* *
* Same as set_difference, but for integers * Same as set_difference, but for Oid lists
*/ */
List * List *
set_differencei(List *l1, List *l2) set_differenceo(List *l1, List *l2)
{ {
List *result = NIL; List *result = NIL;
List *i; List *i;
...@@ -587,8 +610,8 @@ set_differencei(List *l1, List *l2) ...@@ -587,8 +610,8 @@ set_differencei(List *l1, List *l2)
foreach(i, l1) foreach(i, l1)
{ {
if (!intMember(lfirsti(i), l2)) if (!oidMember(lfirsto(i), l2))
result = lappendi(result, lfirsti(i)); result = lappendo(result, lfirsto(i));
} }
return result; return result;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.197 2003/02/09 00:30:39 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.198 2003/02/09 06:56:27 tgl Exp $
* *
* NOTES * NOTES
* Every node type that can appear in stored rules' parsetrees *must* * Every node type that can appear in stored rules' parsetrees *must*
...@@ -173,7 +173,7 @@ _outOidList(StringInfo str, List *list) ...@@ -173,7 +173,7 @@ _outOidList(StringInfo str, List *list)
appendStringInfoChar(str, '('); appendStringInfoChar(str, '(');
foreach(l, list) foreach(l, list)
appendStringInfo(str, " %u", (Oid) lfirsti(l)); appendStringInfo(str, " %u", lfirsto(l));
appendStringInfoChar(str, ')'); appendStringInfoChar(str, ')');
} }
...@@ -689,7 +689,7 @@ _outSubLink(StringInfo str, SubLink *node) ...@@ -689,7 +689,7 @@ _outSubLink(StringInfo str, SubLink *node)
WRITE_BOOL_FIELD(useOr); WRITE_BOOL_FIELD(useOr);
WRITE_NODE_FIELD(lefthand); WRITE_NODE_FIELD(lefthand);
WRITE_NODE_FIELD(operName); WRITE_NODE_FIELD(operName);
WRITE_INTLIST_FIELD(operOids); WRITE_OIDLIST_FIELD(operOids);
WRITE_NODE_FIELD(subselect); WRITE_NODE_FIELD(subselect);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.147 2003/02/03 21:15:44 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.148 2003/02/09 06:56:27 tgl Exp $
* *
* NOTES * NOTES
* Path and Plan nodes do not have any readfuncs support, because we * Path and Plan nodes do not have any readfuncs support, because we
...@@ -170,12 +170,12 @@ toOidList(List *list) ...@@ -170,12 +170,12 @@ toOidList(List *list)
*/ */
if (IsA(v, Integer)) if (IsA(v, Integer))
{ {
lfirsti(l) = (Oid) intVal(v); lfirsto(l) = (Oid) intVal(v);
pfree(v); pfree(v);
} }
else if (IsA(v, Float)) else if (IsA(v, Float))
{ {
lfirsti(l) = atooid(strVal(v)); lfirsto(l) = atooid(strVal(v));
pfree(strVal(v)); pfree(strVal(v));
pfree(v); pfree(v);
} }
...@@ -534,7 +534,7 @@ _readSubLink(void) ...@@ -534,7 +534,7 @@ _readSubLink(void)
READ_BOOL_FIELD(useOr); READ_BOOL_FIELD(useOr);
READ_NODE_FIELD(lefthand); READ_NODE_FIELD(lefthand);
READ_NODE_FIELD(operName); READ_NODE_FIELD(operName);
READ_INTLIST_FIELD(operOids); READ_OIDLIST_FIELD(operOids);
READ_NODE_FIELD(subselect); READ_NODE_FIELD(subselect);
READ_DONE(); READ_DONE();
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.135 2003/02/08 20:20:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.136 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -658,7 +658,7 @@ create_indexscan_plan(Query *root, ...@@ -658,7 +658,7 @@ create_indexscan_plan(Query *root,
{ {
IndexOptInfo *index = (IndexOptInfo *) lfirst(ixinfo); IndexOptInfo *index = (IndexOptInfo *) lfirst(ixinfo);
indexids = lappendi(indexids, index->indexoid); indexids = lappendo(indexids, index->indexoid);
} }
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.71 2003/02/09 00:30:39 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.72 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -458,7 +458,7 @@ convert_sublink_opers(List *lefthand, List *operOids, ...@@ -458,7 +458,7 @@ convert_sublink_opers(List *lefthand, List *operOids,
foreach(lst, operOids) foreach(lst, operOids)
{ {
Oid opid = (Oid) lfirsti(lst); Oid opid = lfirsto(lst);
Node *leftop = lfirst(lefthand); Node *leftop = lfirst(lefthand);
TargetEntry *te = lfirst(targetlist); TargetEntry *te = lfirst(targetlist);
Node *rightop; Node *rightop;
...@@ -577,7 +577,7 @@ subplan_is_hashable(SubLink *slink, SubPlan *node) ...@@ -577,7 +577,7 @@ subplan_is_hashable(SubLink *slink, SubPlan *node)
*/ */
foreach(opids, slink->operOids) foreach(opids, slink->operOids)
{ {
Oid opid = (Oid) lfirsti(opids); Oid opid = lfirsto(opids);
HeapTuple tup; HeapTuple tup;
Form_pg_operator optup; Form_pg_operator optup;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.89 2003/02/08 20:20:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.90 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -111,7 +111,7 @@ plan_set_operations(Query *parse) ...@@ -111,7 +111,7 @@ plan_set_operations(Query *parse)
* recurse_set_operations * recurse_set_operations
* Recursively handle one step in a tree of set operations * Recursively handle one step in a tree of set operations
* *
* colTypes: integer list of type OIDs of expected output columns * colTypes: list of type OIDs of expected output columns
* junkOK: if true, child resjunk columns may be left in the result * junkOK: if true, child resjunk columns may be left in the result
* flag: if >= 0, add a resjunk output column indicating value of flag * flag: if >= 0, add a resjunk output column indicating value of flag
* refnames_tlist: targetlist to take column names from * refnames_tlist: targetlist to take column names from
...@@ -330,7 +330,7 @@ recurse_union_children(Node *setOp, Query *parse, ...@@ -330,7 +330,7 @@ recurse_union_children(Node *setOp, Query *parse,
if (op->op == top_union->op && if (op->op == top_union->op &&
(op->all == top_union->all || op->all) && (op->all == top_union->all || op->all) &&
equali(op->colTypes, top_union->colTypes)) equalo(op->colTypes, top_union->colTypes))
{ {
/* Same UNION, so fold children into parent's subplan list */ /* Same UNION, so fold children into parent's subplan list */
return nconc(recurse_union_children(op->larg, parse, return nconc(recurse_union_children(op->larg, parse,
...@@ -380,7 +380,7 @@ generate_setop_tlist(List *colTypes, int flag, ...@@ -380,7 +380,7 @@ generate_setop_tlist(List *colTypes, int flag,
foreach(i, colTypes) foreach(i, colTypes)
{ {
Oid colType = (Oid) lfirsti(i); Oid colType = lfirsto(i);
TargetEntry *inputtle = (TargetEntry *) lfirst(input_tlist); TargetEntry *inputtle = (TargetEntry *) lfirst(input_tlist);
TargetEntry *reftle = (TargetEntry *) lfirst(refnames_tlist); TargetEntry *reftle = (TargetEntry *) lfirst(refnames_tlist);
int32 colTypmod; int32 colTypmod;
...@@ -500,7 +500,7 @@ generate_append_tlist(List *colTypes, bool flag, ...@@ -500,7 +500,7 @@ generate_append_tlist(List *colTypes, bool flag,
if (subtle->resdom->resjunk) if (subtle->resdom->resjunk)
continue; continue;
Assert(curColType != NIL); Assert(curColType != NIL);
if (subtle->resdom->restype == (Oid) lfirsti(curColType)) if (subtle->resdom->restype == lfirsto(curColType))
{ {
/* If first subplan, copy the typmod; else compare */ /* If first subplan, copy the typmod; else compare */
if (planl == input_plans) if (planl == input_plans)
...@@ -525,7 +525,7 @@ generate_append_tlist(List *colTypes, bool flag, ...@@ -525,7 +525,7 @@ generate_append_tlist(List *colTypes, bool flag,
colindex = 0; colindex = 0;
foreach(curColType, colTypes) foreach(curColType, colTypes)
{ {
Oid colType = (Oid) lfirsti(curColType); Oid colType = lfirsto(curColType);
int32 colTypmod = colTypmods[colindex++]; int32 colTypmod = colTypmods[colindex++];
TargetEntry *reftle = (TargetEntry *) lfirst(refnames_tlist); TargetEntry *reftle = (TargetEntry *) lfirst(refnames_tlist);
...@@ -591,7 +591,7 @@ tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK) ...@@ -591,7 +591,7 @@ tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK)
{ {
if (colTypes == NIL) if (colTypes == NIL)
return false; return false;
if (tle->resdom->restype != (Oid) lfirsti(colTypes)) if (tle->resdom->restype != lfirsto(colTypes))
return false; return false;
colTypes = lnext(colTypes); colTypes = lnext(colTypes);
} }
...@@ -604,14 +604,14 @@ tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK) ...@@ -604,14 +604,14 @@ tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK)
/* /*
* find_all_inheritors - * find_all_inheritors -
* Returns an integer list of relation OIDs including the given rel plus * Returns a list of relation OIDs including the given rel plus
* all relations that inherit from it, directly or indirectly. * all relations that inherit from it, directly or indirectly.
*/ */
List * List *
find_all_inheritors(Oid parentrel) find_all_inheritors(Oid parentrel)
{ {
List *examined_relids = NIL; List *examined_relids = NIL;
List *unexamined_relids = makeListi1(parentrel); List *unexamined_relids = makeListo1(parentrel);
/* /*
* While the queue of unexamined relids is nonempty, remove the first * While the queue of unexamined relids is nonempty, remove the first
...@@ -620,11 +620,11 @@ find_all_inheritors(Oid parentrel) ...@@ -620,11 +620,11 @@ find_all_inheritors(Oid parentrel)
*/ */
while (unexamined_relids != NIL) while (unexamined_relids != NIL)
{ {
Oid currentrel = lfirsti(unexamined_relids); Oid currentrel = lfirsto(unexamined_relids);
List *currentchildren; List *currentchildren;
unexamined_relids = lnext(unexamined_relids); unexamined_relids = lnext(unexamined_relids);
examined_relids = lappendi(examined_relids, currentrel); examined_relids = lappendo(examined_relids, currentrel);
currentchildren = find_inheritance_children(currentrel); currentchildren = find_inheritance_children(currentrel);
/* /*
...@@ -634,8 +634,8 @@ find_all_inheritors(Oid parentrel) ...@@ -634,8 +634,8 @@ find_all_inheritors(Oid parentrel)
* into an infinite loop, though theoretically there can't be any * into an infinite loop, though theoretically there can't be any
* cycles in the inheritance graph anyway.) * cycles in the inheritance graph anyway.)
*/ */
currentchildren = set_differencei(currentchildren, examined_relids); currentchildren = set_differenceo(currentchildren, examined_relids);
unexamined_relids = set_unioni(unexamined_relids, currentchildren); unexamined_relids = set_uniono(unexamined_relids, currentchildren);
} }
return examined_relids; return examined_relids;
...@@ -702,7 +702,7 @@ expand_inherted_rtentry(Query *parse, Index rti, bool dup_parent) ...@@ -702,7 +702,7 @@ expand_inherted_rtentry(Query *parse, Index rti, bool dup_parent)
foreach(l, inhOIDs) foreach(l, inhOIDs)
{ {
Oid childOID = (Oid) lfirsti(l); Oid childOID = lfirsto(l);
RangeTblEntry *childrte; RangeTblEntry *childrte;
Index childRTindex; Index childRTindex;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.128 2003/02/08 20:20:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.129 2003/02/09 06:56:27 tgl Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -566,7 +566,7 @@ contain_mutable_functions_walker(Node *node, void *context) ...@@ -566,7 +566,7 @@ contain_mutable_functions_walker(Node *node, void *context)
foreach(opid, sublink->operOids) foreach(opid, sublink->operOids)
{ {
if (op_volatile((Oid) lfirsti(opid)) != PROVOLATILE_IMMUTABLE) if (op_volatile(lfirsto(opid)) != PROVOLATILE_IMMUTABLE)
return true; return true;
} }
/* else fall through to check args */ /* else fall through to check args */
...@@ -633,7 +633,7 @@ contain_volatile_functions_walker(Node *node, void *context) ...@@ -633,7 +633,7 @@ contain_volatile_functions_walker(Node *node, void *context)
foreach(opid, sublink->operOids) foreach(opid, sublink->operOids)
{ {
if (op_volatile((Oid) lfirsti(opid)) == PROVOLATILE_VOLATILE) if (op_volatile(lfirsto(opid)) == PROVOLATILE_VOLATILE)
return true; return true;
} }
/* else fall through to check args */ /* else fall through to check args */
...@@ -718,7 +718,7 @@ contain_nonstrict_functions_walker(Node *node, void *context) ...@@ -718,7 +718,7 @@ contain_nonstrict_functions_walker(Node *node, void *context)
foreach(opid, sublink->operOids) foreach(opid, sublink->operOids)
{ {
if (!op_strict((Oid) lfirsti(opid))) if (!op_strict(lfirsto(opid)))
return true; return true;
} }
/* else fall through to check args */ /* else fall through to check args */
...@@ -1679,7 +1679,7 @@ inline_function(Oid funcid, List *args, HeapTuple func_tuple, ...@@ -1679,7 +1679,7 @@ inline_function(Oid funcid, List *args, HeapTuple func_tuple,
return NULL; return NULL;
/* Check for recursive function, and give up trying to expand if so */ /* Check for recursive function, and give up trying to expand if so */
if (intMember(funcid, active_fns)) if (oidMember(funcid, active_fns))
return NULL; return NULL;
/* Check permission to call function (fail later, if not) */ /* Check permission to call function (fail later, if not) */
...@@ -1824,7 +1824,7 @@ inline_function(Oid funcid, List *args, HeapTuple func_tuple, ...@@ -1824,7 +1824,7 @@ inline_function(Oid funcid, List *args, HeapTuple func_tuple,
* add the current function to the context list of active functions. * add the current function to the context list of active functions.
*/ */
newexpr = eval_const_expressions_mutator(newexpr, newexpr = eval_const_expressions_mutator(newexpr,
lconsi(funcid, active_fns)); lconso(funcid, active_fns));
return (Expr *) newexpr; return (Expr *) newexpr;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.78 2003/02/08 20:20:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.79 2003/02/09 06:56:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -98,7 +98,7 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel) ...@@ -98,7 +98,7 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel)
foreach(indexoidscan, indexoidlist) foreach(indexoidscan, indexoidlist)
{ {
Oid indexoid = lfirsti(indexoidscan); Oid indexoid = lfirsto(indexoidscan);
Relation indexRelation; Relation indexRelation;
Form_pg_index index; Form_pg_index index;
IndexOptInfo *info; IndexOptInfo *info;
...@@ -270,7 +270,7 @@ join_selectivity(Query *root, ...@@ -270,7 +270,7 @@ join_selectivity(Query *root,
/* /*
* find_inheritance_children * find_inheritance_children
* *
* Returns an integer list containing the OIDs of all relations which * Returns a list containing the OIDs of all relations which
* inherit *directly* from the relation with OID 'inhparent'. * inherit *directly* from the relation with OID 'inhparent'.
* *
* XXX might be a good idea to create an index on pg_inherits' inhparent * XXX might be a good idea to create an index on pg_inherits' inhparent
...@@ -305,7 +305,7 @@ find_inheritance_children(Oid inhparent) ...@@ -305,7 +305,7 @@ find_inheritance_children(Oid inhparent)
while ((inheritsTuple = heap_getnext(scan, ForwardScanDirection)) != NULL) while ((inheritsTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{ {
inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid; inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid;
list = lappendi(list, inhrelid); list = lappendo(list, inhrelid);
} }
heap_endscan(scan); heap_endscan(scan);
heap_close(relation, AccessShareLock); heap_close(relation, AccessShareLock);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.260 2003/01/17 03:25:04 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.261 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1793,7 +1793,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) ...@@ -1793,7 +1793,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
lefttl = leftmostQuery->targetList; lefttl = leftmostQuery->targetList;
foreach(dtlist, sostmt->colTypes) foreach(dtlist, sostmt->colTypes)
{ {
Oid colType = (Oid) lfirsti(dtlist); Oid colType = lfirsto(dtlist);
Resdom *leftResdom = ((TargetEntry *) lfirst(lefttl))->resdom; Resdom *leftResdom = ((TargetEntry *) lfirst(lefttl))->resdom;
char *colName = pstrdup(leftResdom->resname); char *colName = pstrdup(leftResdom->resname);
Resdom *resdom; Resdom *resdom;
...@@ -2030,13 +2030,13 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) ...@@ -2030,13 +2030,13 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
op->colTypes = NIL; op->colTypes = NIL;
while (lcoltypes != NIL) while (lcoltypes != NIL)
{ {
Oid lcoltype = (Oid) lfirsti(lcoltypes); Oid lcoltype = lfirsto(lcoltypes);
Oid rcoltype = (Oid) lfirsti(rcoltypes); Oid rcoltype = lfirsto(rcoltypes);
Oid rescoltype; Oid rescoltype;
rescoltype = select_common_type(makeListi2(lcoltype, rcoltype), rescoltype = select_common_type(makeListo2(lcoltype, rcoltype),
context); context);
op->colTypes = lappendi(op->colTypes, rescoltype); op->colTypes = lappendo(op->colTypes, rescoltype);
lcoltypes = lnext(lcoltypes); lcoltypes = lnext(lcoltypes);
rcoltypes = lnext(rcoltypes); rcoltypes = lnext(rcoltypes);
} }
...@@ -2069,7 +2069,7 @@ getSetColTypes(ParseState *pstate, Node *node) ...@@ -2069,7 +2069,7 @@ getSetColTypes(ParseState *pstate, Node *node)
if (resnode->resjunk) if (resnode->resjunk)
continue; continue;
result = lappendi(result, resnode->restype); result = lappendo(result, resnode->restype);
} }
return result; return result;
} }
...@@ -2333,7 +2333,7 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt) ...@@ -2333,7 +2333,7 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
TypeName *tn = lfirst(l); TypeName *tn = lfirst(l);
Oid toid = typenameTypeId(tn); Oid toid = typenameTypeId(tn);
argtype_oids = lappendi(argtype_oids, toid); argtype_oids = lappendo(argtype_oids, toid);
argtoids[i++] = toid; argtoids[i++] = toid;
} }
} }
...@@ -2400,7 +2400,7 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) ...@@ -2400,7 +2400,7 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt)
elog(ERROR, "Cannot use aggregates in EXECUTE parameters"); elog(ERROR, "Cannot use aggregates in EXECUTE parameters");
given_type_id = exprType(expr); given_type_id = exprType(expr);
expected_type_id = (Oid) lfirsti(paramtypes); expected_type_id = lfirsto(paramtypes);
expr = coerce_to_target_type(expr, given_type_id, expr = coerce_to_target_type(expr, given_type_id,
expected_type_id, -1, expected_type_id, -1,
...@@ -2533,7 +2533,7 @@ relationHasPrimaryKey(Oid relationOid) ...@@ -2533,7 +2533,7 @@ relationHasPrimaryKey(Oid relationOid)
foreach(indexoidscan, indexoidlist) foreach(indexoidscan, indexoidlist)
{ {
Oid indexoid = lfirsti(indexoidscan); Oid indexoid = lfirsto(indexoidscan);
HeapTuple indexTuple; HeapTuple indexTuple;
indexTuple = SearchSysCache(INDEXRELID, indexTuple = SearchSysCache(INDEXRELID,
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.399 2003/02/05 20:16:42 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.400 2003/02/09 06:56:28 tgl Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -2276,7 +2276,7 @@ DefineStmt: ...@@ -2276,7 +2276,7 @@ DefineStmt:
case 3: case 3:
r->catalogname = strVal(lfirst($3)); r->catalogname = strVal(lfirst($3));
r->schemaname = strVal(lsecond($3)); r->schemaname = strVal(lsecond($3));
r->relname = strVal(lfirst(lnext(lnext($3)))); r->relname = strVal(lthird($3));
break; break;
default: default:
elog(ERROR, elog(ERROR,
...@@ -6857,7 +6857,7 @@ qualified_name: ...@@ -6857,7 +6857,7 @@ qualified_name:
case 3: case 3:
$$->catalogname = strVal(lfirst($1)); $$->catalogname = strVal(lfirst($1));
$$->schemaname = strVal(lsecond($1)); $$->schemaname = strVal(lsecond($1));
$$->relname = strVal(lfirst(lnext(lnext($1)))); $$->relname = strVal(lthird($1));
break; break;
default: default:
elog(ERROR, elog(ERROR,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.104 2003/02/08 20:20:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.105 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -854,7 +854,7 @@ buildMergedJoinVar(JoinType jointype, Var *l_colvar, Var *r_colvar) ...@@ -854,7 +854,7 @@ buildMergedJoinVar(JoinType jointype, Var *l_colvar, Var *r_colvar)
outcoltypmod = l_colvar->vartypmod; outcoltypmod = l_colvar->vartypmod;
if (outcoltype != r_colvar->vartype) if (outcoltype != r_colvar->vartype)
{ {
outcoltype = select_common_type(makeListi2(l_colvar->vartype, outcoltype = select_common_type(makeListo2(l_colvar->vartype,
r_colvar->vartype), r_colvar->vartype),
"JOIN/USING"); "JOIN/USING");
outcoltypmod = -1; /* ie, unknown */ outcoltypmod = -1; /* ie, unknown */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.92 2003/02/03 21:15:44 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.93 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -553,7 +553,7 @@ coerce_to_boolean(Node *node, const char *constructName) ...@@ -553,7 +553,7 @@ coerce_to_boolean(Node *node, const char *constructName)
* This is used for determining the output type of CASE and UNION * This is used for determining the output type of CASE and UNION
* constructs. * constructs.
* *
* typeids is a nonempty integer list of type OIDs. Note that earlier items * typeids is a nonempty list of type OIDs. Note that earlier items
* in the list will be preferred if there is doubt. * in the list will be preferred if there is doubt.
* 'context' is a phrase to use in the error message if we fail to select * 'context' is a phrase to use in the error message if we fail to select
* a usable type. * a usable type.
...@@ -566,11 +566,11 @@ select_common_type(List *typeids, const char *context) ...@@ -566,11 +566,11 @@ select_common_type(List *typeids, const char *context)
List *l; List *l;
Assert(typeids != NIL); Assert(typeids != NIL);
ptype = (Oid) lfirsti(typeids); ptype = lfirsto(typeids);
pcategory = TypeCategory(ptype); pcategory = TypeCategory(ptype);
foreach(l, lnext(typeids)) foreach(l, lnext(typeids))
{ {
Oid ntype = (Oid) lfirsti(l); Oid ntype = lfirsto(l);
/* move on to next one if no new information... */ /* move on to next one if no new information... */
if ((ntype != InvalidOid) && (ntype != UNKNOWNOID) && (ntype != ptype)) if ((ntype != InvalidOid) && (ntype != UNKNOWNOID) && (ntype != ptype))
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.142 2003/02/03 21:15:44 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.143 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -488,7 +488,7 @@ transformExpr(ParseState *pstate, Node *expr) ...@@ -488,7 +488,7 @@ transformExpr(ParseState *pstate, Node *expr)
" to be used with quantified predicate subquery", " to be used with quantified predicate subquery",
opname); opname);
sublink->operOids = lappendi(sublink->operOids, sublink->operOids = lappendo(sublink->operOids,
oprid(optup)); oprid(optup));
ReleaseSysCache(optup); ReleaseSysCache(optup);
...@@ -554,7 +554,7 @@ transformExpr(ParseState *pstate, Node *expr) ...@@ -554,7 +554,7 @@ transformExpr(ParseState *pstate, Node *expr)
neww->result = (Expr *) transformExpr(pstate, warg); neww->result = (Expr *) transformExpr(pstate, warg);
newargs = lappend(newargs, neww); newargs = lappend(newargs, neww);
typeids = lappendi(typeids, exprType((Node *) neww->result)); typeids = lappendo(typeids, exprType((Node *) neww->result));
} }
newc->args = newargs; newc->args = newargs;
...@@ -583,7 +583,7 @@ transformExpr(ParseState *pstate, Node *expr) ...@@ -583,7 +583,7 @@ transformExpr(ParseState *pstate, Node *expr)
* code worked before, but it seems a little bogus to me * code worked before, but it seems a little bogus to me
* --- tgl * --- tgl
*/ */
typeids = lconsi(exprType((Node *) newc->defresult), typeids); typeids = lconso(exprType((Node *) newc->defresult), typeids);
ptype = select_common_type(typeids, "CASE"); ptype = select_common_type(typeids, "CASE");
newc->casetype = ptype; newc->casetype = ptype;
...@@ -830,7 +830,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) ...@@ -830,7 +830,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
{ {
char *name1 = strVal(lfirst(cref->fields)); char *name1 = strVal(lfirst(cref->fields));
char *name2 = strVal(lsecond(cref->fields)); char *name2 = strVal(lsecond(cref->fields));
char *name3 = strVal(lfirst(lnext(lnext(cref->fields)))); char *name3 = strVal(lthird(cref->fields));
/* Whole-row reference? */ /* Whole-row reference? */
if (strcmp(name3, "*") == 0) if (strcmp(name3, "*") == 0)
...@@ -863,8 +863,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) ...@@ -863,8 +863,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
{ {
char *name1 = strVal(lfirst(cref->fields)); char *name1 = strVal(lfirst(cref->fields));
char *name2 = strVal(lsecond(cref->fields)); char *name2 = strVal(lsecond(cref->fields));
char *name3 = strVal(lfirst(lnext(lnext(cref->fields)))); char *name3 = strVal(lthird(cref->fields));
char *name4 = strVal(lfirst(lnext(lnext(lnext(cref->fields))))); char *name4 = strVal(lfourth(cref->fields));
/* /*
* We check the catalog name and then ignore it. * We check the catalog name and then ignore it.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.143 2002/12/12 15:49:39 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.144 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -972,7 +972,7 @@ find_inheritors(Oid relid, Oid **supervec) ...@@ -972,7 +972,7 @@ find_inheritors(Oid relid, Oid **supervec)
* Use queue to do a breadth-first traversal of the inheritance graph * Use queue to do a breadth-first traversal of the inheritance graph
* from the relid supplied up to the root. At the top of the loop, * from the relid supplied up to the root. At the top of the loop,
* relid is the OID of the reltype to check next, queue is the list of * relid is the OID of the reltype to check next, queue is the list of
* pending rels to check after this one, and visited is the list of * pending relids to check after this one, and visited is the list of
* relids we need to output. * relids we need to output.
*/ */
do do
...@@ -989,7 +989,7 @@ find_inheritors(Oid relid, Oid **supervec) ...@@ -989,7 +989,7 @@ find_inheritors(Oid relid, Oid **supervec)
{ {
Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inhtup); Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inhtup);
queue = lappendi(queue, inh->inhparent); queue = lappendo(queue, inh->inhparent);
} }
heap_endscan(inhscan); heap_endscan(inhscan);
...@@ -999,9 +999,9 @@ find_inheritors(Oid relid, Oid **supervec) ...@@ -999,9 +999,9 @@ find_inheritors(Oid relid, Oid **supervec)
newrelid = false; newrelid = false;
while (queue != NIL) while (queue != NIL)
{ {
relid = lfirsti(queue); relid = lfirsto(queue);
queue = lnext(queue); queue = lnext(queue);
if (!intMember(relid, visited)) if (!oidMember(relid, visited))
{ {
newrelid = true; newrelid = true;
break; break;
...@@ -1010,7 +1010,7 @@ find_inheritors(Oid relid, Oid **supervec) ...@@ -1010,7 +1010,7 @@ find_inheritors(Oid relid, Oid **supervec)
if (newrelid) if (newrelid)
{ {
visited = lappendi(visited, relid); visited = lappendo(visited, relid);
nvisited++; nvisited++;
} }
} while (newrelid); } while (newrelid);
...@@ -1025,7 +1025,7 @@ find_inheritors(Oid relid, Oid **supervec) ...@@ -1025,7 +1025,7 @@ find_inheritors(Oid relid, Oid **supervec)
foreach(elt, visited) foreach(elt, visited)
{ {
/* return the type id, rather than the relation id */ /* return the type id, rather than the relation id */
*relidvec++ = get_rel_type_id((Oid) lfirsti(elt)); *relidvec++ = get_rel_type_id(lfirsto(elt));
} }
} }
else else
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.94 2002/12/12 20:35:13 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.95 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -146,7 +146,7 @@ transformTargetList(ParseState *pstate, List *targetlist) ...@@ -146,7 +146,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
if (strcmp(name1, DatabaseName) != 0) if (strcmp(name1, DatabaseName) != 0)
elog(ERROR, "Cross-database references are not implemented"); elog(ERROR, "Cross-database references are not implemented");
schemaname = strVal(lsecond(fields)); schemaname = strVal(lsecond(fields));
relname = strVal(lfirst(lnext(lnext(fields)))); relname = strVal(lthird(fields));
break; break;
} }
default: default:
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.50 2002/09/04 20:31:24 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.51 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -67,13 +67,13 @@ LookupTypeName(const TypeName *typename) ...@@ -67,13 +67,13 @@ LookupTypeName(const TypeName *typename)
case 3: case 3:
rel->schemaname = strVal(lfirst(typename->names)); rel->schemaname = strVal(lfirst(typename->names));
rel->relname = strVal(lsecond(typename->names)); rel->relname = strVal(lsecond(typename->names));
field = strVal(lfirst(lnext(lnext(typename->names)))); field = strVal(lthird(typename->names));
break; break;
case 4: case 4:
rel->catalogname = strVal(lfirst(typename->names)); rel->catalogname = strVal(lfirst(typename->names));
rel->schemaname = strVal(lsecond(typename->names)); rel->schemaname = strVal(lsecond(typename->names));
rel->relname = strVal(lfirst(lnext(lnext(typename->names)))); rel->relname = strVal(lthird(typename->names));
field = strVal(lfirst(lnext(lnext(lnext(typename->names))))); field = strVal(lfourth(typename->names));
break; break;
default: default:
elog(ERROR, "Improper %%TYPE reference (too many dotted names): %s", elog(ERROR, "Improper %%TYPE reference (too many dotted names): %s",
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.41 2002/09/04 20:31:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.42 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -245,7 +245,7 @@ current_schema(PG_FUNCTION_ARGS) ...@@ -245,7 +245,7 @@ current_schema(PG_FUNCTION_ARGS)
if (search_path == NIL) if (search_path == NIL)
PG_RETURN_NULL(); PG_RETURN_NULL();
nspname = get_namespace_name((Oid) lfirsti(search_path)); nspname = get_namespace_name(lfirsto(search_path));
PG_RETURN_DATUM(DirectFunctionCall1(namein, CStringGetDatum(nspname))); PG_RETURN_DATUM(DirectFunctionCall1(namein, CStringGetDatum(nspname)));
} }
...@@ -265,7 +265,7 @@ current_schemas(PG_FUNCTION_ARGS) ...@@ -265,7 +265,7 @@ current_schemas(PG_FUNCTION_ARGS)
{ {
char *nspname; char *nspname;
nspname = get_namespace_name((Oid) lfirsti(search_path)); nspname = get_namespace_name(lfirsto(search_path));
names[i] = DirectFunctionCall1(namein, CStringGetDatum(nspname)); names[i] = DirectFunctionCall1(namein, CStringGetDatum(nspname));
i++; i++;
search_path = lnext(search_path); search_path = lnext(search_path);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.183 2002/12/16 18:39:22 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.184 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2642,20 +2642,20 @@ insert_ordered_oid(List *list, Oid datum) ...@@ -2642,20 +2642,20 @@ insert_ordered_oid(List *list, Oid datum)
List *l; List *l;
/* Does the datum belong at the front? */ /* Does the datum belong at the front? */
if (list == NIL || datum < (Oid) lfirsti(list)) if (list == NIL || datum < lfirsto(list))
return lconsi(datum, list); return lconso(datum, list);
/* No, so find the entry it belongs after */ /* No, so find the entry it belongs after */
l = list; l = list;
for (;;) for (;;)
{ {
List *n = lnext(l); List *n = lnext(l);
if (n == NIL || datum < (Oid) lfirsti(n)) if (n == NIL || datum < lfirsto(n))
break; /* it belongs before n */ break; /* it belongs before n */
l = n; l = n;
} }
/* Insert datum into list after item l */ /* Insert datum into list after item l */
lnext(l) = lconsi(datum, lnext(l)); lnext(l) = lconso(datum, lnext(l));
return list; return list;
} }
...@@ -2967,7 +2967,7 @@ load_relcache_init_file(void) ...@@ -2967,7 +2967,7 @@ load_relcache_init_file(void)
{ {
RelationCacheInsert(rels[relno]); RelationCacheInsert(rels[relno]);
/* also make a list of their OIDs, for RelationIdIsInInitFile */ /* also make a list of their OIDs, for RelationIdIsInInitFile */
initFileRelationIds = lconsi((int) RelationGetRelid(rels[relno]), initFileRelationIds = lconso(RelationGetRelid(rels[relno]),
initFileRelationIds); initFileRelationIds);
} }
...@@ -3133,7 +3133,7 @@ write_relcache_init_file(void) ...@@ -3133,7 +3133,7 @@ write_relcache_init_file(void)
/* also make a list of their OIDs, for RelationIdIsInInitFile */ /* also make a list of their OIDs, for RelationIdIsInInitFile */
oldcxt = MemoryContextSwitchTo(CacheMemoryContext); oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
initFileRelationIds = lconsi((int) RelationGetRelid(rel), initFileRelationIds = lconso(RelationGetRelid(rel),
initFileRelationIds); initFileRelationIds);
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
} }
...@@ -3202,7 +3202,7 @@ write_relcache_init_file(void) ...@@ -3202,7 +3202,7 @@ write_relcache_init_file(void)
bool bool
RelationIdIsInInitFile(Oid relationId) RelationIdIsInInitFile(Oid relationId)
{ {
return intMember((int) relationId, initFileRelationIds); return oidMember(relationId, initFileRelationIds);
} }
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: parsenodes.h,v 1.227 2003/01/23 23:39:07 petere Exp $ * $Id: parsenodes.h,v 1.228 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -639,8 +639,7 @@ typedef struct SetOperationStmt ...@@ -639,8 +639,7 @@ typedef struct SetOperationStmt
/* Eventually add fields for CORRESPONDING spec here */ /* Eventually add fields for CORRESPONDING spec here */
/* Fields derived during parse analysis: */ /* Fields derived during parse analysis: */
List *colTypes; /* integer list of OIDs of output column List *colTypes; /* list of OIDs of output column types */
* types */
} SetOperationStmt; } SetOperationStmt;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_list.h,v 1.34 2003/02/08 20:20:55 tgl Exp $ * $Id: pg_list.h,v 1.35 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -61,6 +61,15 @@ typedef struct Value ...@@ -61,6 +61,15 @@ typedef struct Value
/*---------------------- /*----------------------
* List node * List node
*
* We support three types of lists:
* lists of pointers (in practice always pointers to Nodes, but declare as
* "void *" to minimize casting annoyances)
* lists of integers
* lists of Oids
*
* (At this writing, ints and Oids are the same size, but they may not always
* be so; try to be careful to maintain the distinction.)
*---------------------- *----------------------
*/ */
typedef struct List typedef struct List
...@@ -70,6 +79,7 @@ typedef struct List ...@@ -70,6 +79,7 @@ typedef struct List
{ {
void *ptr_value; void *ptr_value;
int int_value; int int_value;
Oid oid_value;
} elem; } elem;
struct List *next; struct List *next;
} List; } List;
...@@ -78,23 +88,31 @@ typedef struct List ...@@ -78,23 +88,31 @@ typedef struct List
/* ---------------- /* ----------------
* accessor macros * accessor macros
*
* The general naming convention is that the base name xyz() is for the
* pointer version, xyzi() is for integers, xyzo() is for Oids. We don't
* bother with multiple names if the same routine can handle all cases.
* ---------------- * ----------------
*/ */
/* anything that doesn't end in 'i' is assumed to be referring to the */
/* pointer version of the list (where it makes a difference) */
#define lfirst(l) ((l)->elem.ptr_value) #define lfirst(l) ((l)->elem.ptr_value)
#define lfirsti(l) ((l)->elem.int_value)
#define lfirsto(l) ((l)->elem.oid_value)
#define lnext(l) ((l)->next) #define lnext(l) ((l)->next)
#define lsecond(l) lfirst(lnext(l)) #define lsecond(l) lfirst(lnext(l))
#define lfirsti(l) ((l)->elem.int_value) #define lthird(l) lfirst(lnext(lnext(l)))
#define lfourth(l) lfirst(lnext(lnext(lnext(l))))
/* /*
* foreach - * foreach -
* a convenience macro which loops through the list * a convenience macro which loops through the list
*/ */
#define foreach(_elt_,_list_) \ #define foreach(_elt_,_list_) \
for(_elt_=(_list_); _elt_!=NIL; _elt_=lnext(_elt_)) for (_elt_ = (_list_); _elt_ != NIL; _elt_ = lnext(_elt_))
/* /*
* Convenience macros for building fixed-length lists * Convenience macros for building fixed-length lists
...@@ -106,50 +124,49 @@ typedef struct List ...@@ -106,50 +124,49 @@ typedef struct List
#define makeListi1(x1) lconsi(x1, NIL) #define makeListi1(x1) lconsi(x1, NIL)
#define makeListi2(x1,x2) lconsi(x1, makeListi1(x2)) #define makeListi2(x1,x2) lconsi(x1, makeListi1(x2))
#define makeListi3(x1,x2,x3) lconsi(x1, makeListi2(x2,x3))
#define makeListi4(x1,x2,x3,x4) lconsi(x1, makeListi3(x2,x3,x4)) #define makeListo1(x1) lconso(x1, NIL)
#define makeListo2(x1,x2) lconso(x1, makeListo1(x2))
/* /*
* function prototypes in nodes/list.c * function prototypes in nodes/list.c
*/ */
extern int length(List *list);
extern void *llast(List *list);
extern List *nconc(List *list1, List *list2);
extern List *lcons(void *datum, List *list);
extern List *lconsi(int datum, List *list);
extern bool member(void *datum, List *list);
extern bool ptrMember(void *datum, List *list);
extern bool intMember(int datum, List *list);
extern Value *makeInteger(long i); extern Value *makeInteger(long i);
extern Value *makeFloat(char *numericStr); extern Value *makeFloat(char *numericStr);
extern Value *makeString(char *str); extern Value *makeString(char *str);
extern Value *makeBitString(char *str); extern Value *makeBitString(char *str);
extern List *lcons(void *datum, List *list);
extern List *lconsi(int datum, List *list);
extern List *lconso(Oid datum, List *list);
extern List *lappend(List *list, void *datum); extern List *lappend(List *list, void *datum);
extern List *lappendi(List *list, int datum); extern List *lappendi(List *list, int datum);
extern List *lappendo(List *list, Oid datum);
extern List *nconc(List *list1, List *list2);
extern void *nth(int n, List *l);
extern int length(List *list);
extern void *llast(List *list);
extern bool member(void *datum, List *list);
extern bool ptrMember(void *datum, List *list);
extern bool intMember(int datum, List *list);
extern bool oidMember(Oid datum, List *list);
extern List *lremove(void *elem, List *list); extern List *lremove(void *elem, List *list);
extern List *LispRemove(void *elem, List *list); extern List *LispRemove(void *elem, List *list);
extern List *lremovei(int elem, List *list); extern List *lremovei(int elem, List *list);
extern List *ltruncate(int n, List *list); extern List *ltruncate(int n, List *list);
extern void *nth(int n, List *l);
extern int nthi(int n, List *l);
extern void set_nth(List *l, int n, void *elem);
extern List *set_union(List *list1, List *list2); extern List *set_union(List *list1, List *list2);
extern List *set_unioni(List *list1, List *list2); extern List *set_uniono(List *list1, List *list2);
extern List *set_ptrUnion(List *list1, List *list2); extern List *set_ptrUnion(List *list1, List *list2);
extern List *set_intersect(List *l1, List *l2);
extern List *set_intersecti(List *list1, List *list2);
extern List *set_difference(List *list1, List *list2); extern List *set_difference(List *list1, List *list2);
extern List *set_differencei(List *list1, List *list2); extern List *set_differenceo(List *list1, List *list2);
extern List *set_ptrDifference(List *list1, List *list2); extern List *set_ptrDifference(List *list1, List *list2);
extern bool equali(List *list1, List *list2); extern bool equali(List *list1, List *list2);
extern bool equalo(List *list1, List *list2);
extern void freeList(List *list); extern void freeList(List *list);
/* should be in nodes.h but needs List */
/* in copyfuncs.c */ /* in copyfuncs.c */
extern List *listCopy(List *list); extern List *listCopy(List *list);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: parsetree.h,v 1.19 2002/09/04 20:31:45 momjian Exp $ * $Id: parsetree.h,v 1.20 2003/02/09 06:56:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -26,16 +26,12 @@ ...@@ -26,16 +26,12 @@
/* /*
* rt_fetch * rt_fetch
* rt_store
* *
* Access and (destructively) replace rangetable entries. * NB: this will crash and burn if handed an out-of-range RT index
*/ */
#define rt_fetch(rangetable_index, rangetable) \ #define rt_fetch(rangetable_index, rangetable) \
((RangeTblEntry *) nth((rangetable_index)-1, rangetable)) ((RangeTblEntry *) nth((rangetable_index)-1, rangetable))
#define rt_store(rangetable_index, rangetable, rt) \
set_nth(rangetable, (rangetable_index)-1, rt)
/* /*
* getrelid * getrelid
* *
......
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