summaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1998-08-19 02:04:17 +0000
committerBruce Momjian <bruce@momjian.us>1998-08-19 02:04:17 +0000
commit7971539020a344dce3a8b3b9b93ff4f10e2f823a (patch)
tree8dca0af0d3ac8d431bff8c0dec793fe9733a1ee9 /src/backend/parser
parent31de2c9461dff3284ad61084c73eba093fa3f68e (diff)
downloadpostgresql-7971539020a344dce3a8b3b9b93ff4f10e2f823a.tar.gz
heap_fetch requires buffer pointer, must be released; heap_getnext
no longer returns buffer pointer, can be gotten from scan; descriptor; bootstrap can create multi-key indexes; pg_procname index now is multi-key index; oidint2, oidint4, oidname are gone (must be removed from regression tests); use System Cache rather than sequential scan in many places; heap_modifytuple no longer takes buffer parameter; remove unused buffer parameter in a few other functions; oid8 is not index-able; remove some use of single-character variable names; cleanup Buffer variables usage and scan descriptor looping; cleaned up allocation and freeing of tuples; 18k lines of diff;
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/parse_agg.c5
-rw-r--r--src/backend/parser/parse_func.c28
-rw-r--r--src/backend/parser/parse_node.c6
-rw-r--r--src/backend/parser/parse_oper.c81
-rw-r--r--src/backend/parser/parse_relation.c18
-rw-r--r--src/backend/parser/parse_target.c4
-rw-r--r--src/backend/parser/parse_type.c12
7 files changed, 69 insertions, 85 deletions
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c
index 7c874f8845..5d16d31341 100644
--- a/src/backend/parser/parse_agg.c
+++ b/src/backend/parser/parse_agg.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.11 1998/06/15 19:28:54 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.12 1998/08/19 02:02:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -230,7 +230,8 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype,
HeapTuple theAggTuple;
bool usenulls = false;
- theAggTuple = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggname),
+ theAggTuple = SearchSysCacheTuple(AGGNAME,
+ PointerGetDatum(aggname),
ObjectIdGetDatum(basetype),
0, 0);
if (!HeapTupleIsValid(theAggTuple))
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index ffdebccb26..4b02a1f344 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.24 1998/07/27 19:38:02 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.25 1998/08/19 02:02:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -488,7 +488,8 @@ funcid_get_rettype(Oid funcid)
HeapTuple func_tuple = NULL;
Oid funcrettype = (Oid) 0;
- func_tuple = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(funcid),
+ func_tuple = SearchSysCacheTuple(PROOID,
+ ObjectIdGetDatum(funcid),
0, 0, 0);
if (!HeapTupleIsValid(func_tuple))
@@ -514,9 +515,7 @@ func_get_candidates(char *funcname, int nargs)
HeapTuple tuple;
IndexScanDesc sd;
RetrieveIndexResult indexRes;
- Buffer buffer;
Form_pg_proc pgProcP;
- bool bufferUsed = FALSE;
CandidateList candidates = NULL;
CandidateList current_candidate;
int i;
@@ -535,24 +534,19 @@ func_get_candidates(char *funcname, int nargs)
do
{
tuple = (HeapTuple) NULL;
- if (bufferUsed)
- {
- ReleaseBuffer(buffer);
- bufferUsed = FALSE;
- }
indexRes = index_getnext(sd, ForwardScanDirection);
if (indexRes)
{
ItemPointer iptr;
-
+ Buffer buffer;
+
iptr = &indexRes->heap_iptr;
tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer);
pfree(indexRes);
if (HeapTupleIsValid(tuple))
{
pgProcP = (Form_pg_proc) GETSTRUCT(tuple);
- bufferUsed = TRUE;
if (pgProcP->pronargs == nargs)
{
current_candidate = (CandidateList)
@@ -567,6 +561,7 @@ func_get_candidates(char *funcname, int nargs)
current_candidate->next = candidates;
candidates = current_candidate;
}
+ ReleaseBuffer(buffer);
}
}
} while (indexRes);
@@ -1000,7 +995,6 @@ find_inheritors(Oid relid, Oid **supervec)
*elt;
Relation rd;
- Buffer buf;
Datum d;
bool newrelid;
char isNull;
@@ -1026,7 +1020,7 @@ find_inheritors(Oid relid, Oid **supervec)
inhscan = heap_beginscan(inhrel, 0, SnapshotNow, 1, &skey);
- while (HeapTupleIsValid(inhtup = heap_getnext(inhscan, 0, &buf)))
+ while (HeapTupleIsValid(inhtup = heap_getnext(inhscan, 0)))
{
qentry = (SuperQE *) palloc(sizeof(SuperQE));
@@ -1036,8 +1030,6 @@ find_inheritors(Oid relid, Oid **supervec)
/* put this one on the queue */
DLAddTail(queue, DLNewElem(qentry));
-
- ReleaseBuffer(buf);
}
heap_endscan(inhscan);
@@ -1311,7 +1303,7 @@ ParseComplexProjection(ParseState *pstate,
rd = heap_openr(typeidTypeName(argtype));
if (RelationIsValid(rd))
{
- relid = RelationGetRelationId(rd);
+ relid = RelationGetRelid(rd);
heap_close(rd);
}
if (RelationIsValid(rd))
@@ -1369,7 +1361,7 @@ ParseComplexProjection(ParseState *pstate,
rd = heap_openr(typeidTypeName(argtype));
if (RelationIsValid(rd))
{
- relid = RelationGetRelationId(rd);
+ relid = RelationGetRelid(rd);
heap_close(rd);
}
if (RelationIsValid(rd))
@@ -1406,7 +1398,7 @@ ParseComplexProjection(ParseState *pstate,
rd = heap_openr(typeidTypeName(param->paramtype));
if (RelationIsValid(rd))
{
- relid = RelationGetRelationId(rd);
+ relid = RelationGetRelid(rd);
heap_close(rd);
if ((attnum = get_attnum(relid, funcname))
!= InvalidAttrNumber)
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index 7c9f6940d6..4454839871 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.18 1998/07/20 11:17:11 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.19 1998/08/19 02:02:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -284,7 +284,7 @@ make_array_ref(Node *expr,
/* get the type tuple for the element type */
type_tuple = SearchSysCacheTuple(TYPOID,
- ObjectIdGetDatum(type_struct_array->typelem),
+ ObjectIdGetDatum(type_struct_array->typelem),
0, 0, 0);
if (!HeapTupleIsValid(type_tuple))
elog(ERROR, "make_array_ref: Cache lookup failed for type %d\n",
@@ -365,7 +365,7 @@ make_array_set(Expr *target_expr,
type_struct_array->typname);
/* get the type tuple for the element type */
type_tuple = SearchSysCacheTuple(TYPOID,
- ObjectIdGetDatum(type_struct_array->typelem),
+ ObjectIdGetDatum(type_struct_array->typelem),
0, 0, 0);
if (!HeapTupleIsValid(type_tuple))
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index 42e18e4d37..689f64a87d 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.14 1998/07/27 19:38:04 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.15 1998/08/19 02:02:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -86,7 +86,6 @@ binary_oper_get_candidates(char *opname,
HeapScanDesc pg_operator_scan;
HeapTuple tup;
OperatorTupleForm oper;
- Buffer buffer;
int nkeys;
int ncandidates = 0;
ScanKeyData opKey[3];
@@ -112,23 +111,18 @@ binary_oper_get_candidates(char *opname,
nkeys,
opKey);
- do
+ while (HeapTupleIsValid(tup = heap_getnext(pg_operator_scan, 0)))
{
- tup = heap_getnext(pg_operator_scan, 0, &buffer);
- if (HeapTupleIsValid(tup))
- {
- current_candidate = (CandidateList) palloc(sizeof(struct _CandidateList));
- current_candidate->args = (Oid *) palloc(2 * sizeof(Oid));
-
- oper = (OperatorTupleForm) GETSTRUCT(tup);
- current_candidate->args[0] = oper->oprleft;
- current_candidate->args[1] = oper->oprright;
- current_candidate->next = *candidates;
- *candidates = current_candidate;
- ncandidates++;
- ReleaseBuffer(buffer);
- }
- } while (HeapTupleIsValid(tup));
+ current_candidate = (CandidateList) palloc(sizeof(struct _CandidateList));
+ current_candidate->args = (Oid *) palloc(2 * sizeof(Oid));
+
+ oper = (OperatorTupleForm) GETSTRUCT(tup);
+ current_candidate->args[0] = oper->oprleft;
+ current_candidate->args[1] = oper->oprright;
+ current_candidate->next = *candidates;
+ *candidates = current_candidate;
+ ncandidates++;
+ }
heap_endscan(pg_operator_scan);
heap_close(pg_operator_desc);
@@ -465,7 +459,7 @@ oper_exact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWarn
PointerGetDatum(op),
ObjectIdGetDatum(arg1),
ObjectIdGetDatum(arg2),
- Int8GetDatum('b'));
+ CharGetDatum('b'));
/* Did not find anything? then try flipping arguments on a commutative operator... */
if (!HeapTupleIsValid(tup) && (arg1 != arg2))
@@ -474,7 +468,7 @@ oper_exact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWarn
PointerGetDatum(op),
ObjectIdGetDatum(arg2),
ObjectIdGetDatum(arg1),
- Int8GetDatum('b'));
+ CharGetDatum('b'));
if (HeapTupleIsValid(tup))
{
@@ -545,7 +539,7 @@ oper_inexact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWa
PointerGetDatum(op),
ObjectIdGetDatum(candidates->args[0]),
ObjectIdGetDatum(candidates->args[1]),
- Int8GetDatum('b'));
+ CharGetDatum('b'));
Assert(HeapTupleIsValid(tup));
#if PARSEDEBUG
@@ -569,8 +563,7 @@ printf("oper_inexact: found candidate\n");
PointerGetDatum(op),
ObjectIdGetDatum(targetOids[0]),
ObjectIdGetDatum(targetOids[1]),
- Int8GetDatum('b'));
-
+ CharGetDatum('b'));
}
else
tup = NULL;
@@ -635,7 +628,6 @@ unary_oper_get_candidates(char *op,
HeapScanDesc pg_operator_scan;
HeapTuple tup;
OperatorTupleForm oper;
- Buffer buffer;
int ncandidates = 0;
static ScanKeyData opKey[2] = {
@@ -659,29 +651,24 @@ printf("unary_oper_get_candidates: start scan for '%s'\n", op);
2,
opKey);
- do
+ while (HeapTupleIsValid(tup = heap_getnext(pg_operator_scan, 0)))
{
- tup = heap_getnext(pg_operator_scan, 0, &buffer);
- if (HeapTupleIsValid(tup))
- {
- current_candidate = (CandidateList) palloc(sizeof(struct _CandidateList));
- current_candidate->args = (Oid *) palloc(sizeof(Oid));
+ current_candidate = (CandidateList) palloc(sizeof(struct _CandidateList));
+ current_candidate->args = (Oid *) palloc(sizeof(Oid));
- oper = (OperatorTupleForm) GETSTRUCT(tup);
- if (rightleft == 'r')
- current_candidate->args[0] = oper->oprleft;
- else
- current_candidate->args[0] = oper->oprright;
- current_candidate->next = *candidates;
- *candidates = current_candidate;
+ oper = (OperatorTupleForm) GETSTRUCT(tup);
+ if (rightleft == 'r')
+ current_candidate->args[0] = oper->oprleft;
+ else
+ current_candidate->args[0] = oper->oprright;
+ current_candidate->next = *candidates;
+ *candidates = current_candidate;
#ifdef PARSEDEBUG
printf("unary_oper_get_candidates: found candidate '%s' for type %s\n",
op, typeidTypeName(current_candidate->args[0]));
#endif
- ncandidates++;
- ReleaseBuffer(buffer);
- }
- } while (HeapTupleIsValid(tup));
+ ncandidates++;
+ }
heap_endscan(pg_operator_scan);
heap_close(pg_operator_desc);
@@ -707,7 +694,7 @@ right_oper(char *op, Oid arg)
PointerGetDatum(op),
ObjectIdGetDatum(arg),
ObjectIdGetDatum(InvalidOid),
- Int8GetDatum('r'));
+ CharGetDatum('r'));
if (!HeapTupleIsValid(tup))
{
@@ -723,7 +710,7 @@ right_oper(char *op, Oid arg)
PointerGetDatum(op),
ObjectIdGetDatum(candidates->args[0]),
ObjectIdGetDatum(InvalidOid),
- Int8GetDatum('r'));
+ CharGetDatum('r'));
Assert(HeapTupleIsValid(tup));
}
else
@@ -736,7 +723,7 @@ right_oper(char *op, Oid arg)
PointerGetDatum(op),
ObjectIdGetDatum(InvalidOid),
ObjectIdGetDatum(*targetOid),
- Int8GetDatum('r'));
+ CharGetDatum('r'));
}
else
tup = NULL;
@@ -767,7 +754,7 @@ left_oper(char *op, Oid arg)
PointerGetDatum(op),
ObjectIdGetDatum(InvalidOid),
ObjectIdGetDatum(arg),
- Int8GetDatum('l'));
+ CharGetDatum('l'));
if (!HeapTupleIsValid(tup))
{
@@ -783,7 +770,7 @@ left_oper(char *op, Oid arg)
PointerGetDatum(op),
ObjectIdGetDatum(InvalidOid),
ObjectIdGetDatum(candidates->args[0]),
- Int8GetDatum('l'));
+ CharGetDatum('l'));
Assert(HeapTupleIsValid(tup));
#ifdef PARSEDEBUG
printf("left_oper: searched cache for single left oper candidate '%s %s'\n",
@@ -797,7 +784,7 @@ printf("left_oper: searched cache for single left oper candidate '%s %s'\n",
PointerGetDatum(op),
ObjectIdGetDatum(InvalidOid),
ObjectIdGetDatum(*targetOid),
- Int8GetDatum('l'));
+ CharGetDatum('l'));
if (!HeapTupleIsValid(tup))
{
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 181152bfa5..e87476f14b 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.13 1998/08/18 00:48:57 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.14 1998/08/19 02:02:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -208,7 +208,7 @@ addRangeTableEntry(ParseState *pstate,
elog(ERROR, "%s: %s",
relname, aclcheck_error_strings[ACLCHECK_NO_CLASS]);
- rte->relid = RelationGetRelationId(relation);
+ rte->relid = RelationGetRelid(relation);
heap_close(relation);
@@ -237,7 +237,7 @@ addRangeTableEntry(ParseState *pstate,
List *
expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
{
- Relation rdesc;
+ Relation rel;
List *te_tail = NIL,
*te_head = NIL;
Var *varnode;
@@ -249,13 +249,13 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
if (rte == NULL)
rte = addRangeTableEntry(pstate, relname, refname, FALSE, FALSE);
- rdesc = heap_open(rte->relid);
+ rel = heap_open(rte->relid);
- if (rdesc == NULL)
+ if (rel == NULL)
elog(ERROR, "Unable to expand all -- heap_open failed on %s",
rte->refname);
- maxattrs = RelationGetNumberOfAttributes(rdesc);
+ maxattrs = RelationGetNumberOfAttributes(rel);
for (varattno = 0; varattno <= maxattrs - 1; varattno++)
{
@@ -263,7 +263,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
char *resname = NULL;
TargetEntry *te = makeNode(TargetEntry);
- attrname = pstrdup((rdesc->rd_att->attrs[varattno]->attname).data);
+ attrname = pstrdup((rel->rd_att->attrs[varattno]->attname).data);
varnode = (Var *) make_var(pstate, rte->relid, refname, attrname);
handleTargetColname(pstate, &resname, refname, attrname);
@@ -289,7 +289,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
te_tail = lappend(te_tail, te);
}
- heap_close(rdesc);
+ heap_close(rel);
return (te_head);
}
@@ -343,7 +343,7 @@ attnameIsSet(Relation rd, char *name)
return (false); /* no sys attr is a set */
}
}
- return (get_attisset(rd->rd_id, name));
+ return (get_attisset(RelationGetRelid(rd), name));
}
/*
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 58dd3a28b3..a71df49279 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.20 1998/08/05 04:49:11 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.21 1998/08/19 02:02:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -683,7 +683,7 @@ printf("MakeTargetlistExpr: attrtypmod is %d\n", (int4) attrtypmod);
lowerIndexpr,
(Expr *) expr);
attrtype = attnumTypeId(rd, resdomno);
- attrtypmod = get_atttypmod(rd->rd_id, resdomno);
+ attrtypmod = get_atttypmod(RelationGetRelid(rd), resdomno);
}
}
else
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index 6daf38db87..682b214eed 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.13 1998/07/20 11:17:11 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.14 1998/08/19 02:02:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,7 +47,8 @@ typeidTypeName(Oid id)
HeapTuple tup;
TypeTupleForm typetuple;
- if (!(tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(id),
+ if (!(tup = SearchSysCacheTuple(TYPOID,
+ ObjectIdGetDatum(id),
0, 0, 0)))
{
elog(ERROR, "type id lookup of %u failed", id);
@@ -63,7 +64,8 @@ typeidType(Oid id)
{
HeapTuple tup;
- if (!(tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(id),
+ if (!(tup = SearchSysCacheTuple(TYPOID,
+ ObjectIdGetDatum(id),
0, 0, 0)))
{
elog(ERROR, "type id lookup of %u failed", id);
@@ -81,7 +83,9 @@ typenameType(char *s)
if (s == NULL)
elog(ERROR, "type(): Null type");
- if (!(tup = SearchSysCacheTuple(TYPNAME, PointerGetDatum(s), 0, 0, 0)))
+ if (!(tup = SearchSysCacheTuple(TYPNAME,
+ PointerGetDatum(s),
+ 0, 0, 0)))
elog(ERROR, "type name lookup of %s failed", s);
return ((Type) tup);
}