Commit 4a5b781d authored by Bruce Momjian's avatar Bruce Momjian

Break parser functions into smaller files, group together.

parent 3aff4011
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.28 1997/11/24 05:07:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.29 1997/11/25 21:58:35 momjian Exp $
* *
* NOTES * NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be * some of the executor utility code such as "ExecTypeFromTL" should be
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
#include <postgres.h> #include <postgres.h>
#include <parser/catalog_utils.h> #include <catalog/pg_type.h>
#include <nodes/parsenodes.h> #include <nodes/parsenodes.h>
#include <parser/parse_type.h>
#include <utils/builtins.h> #include <utils/builtins.h>
#include <utils/fcache.h> #include <utils/fcache.h>
#include <utils/syscache.h> #include <utils/syscache.h>
...@@ -377,10 +378,10 @@ TupleDescInitEntry(TupleDesc desc, ...@@ -377,10 +378,10 @@ TupleDescInitEntry(TupleDesc desc,
*/ */
if (attisset) if (attisset)
{ {
Type t = type("oid"); Type t = typeidType(OIDOID);
att->attlen = tlen(t); att->attlen = typeLen(t);
att->attbyval = tbyval(t); att->attbyval = typeByVal(t);
} }
else else
{ {
...@@ -410,12 +411,12 @@ TupleDescMakeSelfReference(TupleDesc desc, ...@@ -410,12 +411,12 @@ TupleDescMakeSelfReference(TupleDesc desc,
char *relname) char *relname)
{ {
AttributeTupleForm att; AttributeTupleForm att;
Type t = type("oid"); Type t = typeidType(OIDOID);
att = desc->attrs[attnum - 1]; att = desc->attrs[attnum - 1];
att->atttypid = TypeShellMake(relname); att->atttypid = TypeShellMake(relname);
att->attlen = tlen(t); att->attlen = typeLen(t);
att->attbyval = tbyval(t); att->attbyval = typeByVal(t);
att->attnelems = 0; att->attnelems = 0;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.33 1997/11/24 05:08:07 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.34 1997/11/25 21:58:40 momjian Exp $
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
* heap_creatr() - Create an uncataloged heap relation * heap_creatr() - Create an uncataloged heap relation
...@@ -42,11 +42,12 @@ ...@@ -42,11 +42,12 @@
#include <catalog/pg_attrdef.h> #include <catalog/pg_attrdef.h>
#include <catalog/pg_relcheck.h> #include <catalog/pg_relcheck.h>
#include <commands/trigger.h> #include <commands/trigger.h>
#include <parser/parse_expr.h>
#include <parser/parse_node.h>
#include <parser/parse_type.h>
#include <storage/bufmgr.h> #include <storage/bufmgr.h>
#include <storage/lmgr.h> #include <storage/lmgr.h>
#include <storage/smgr.h> #include <storage/smgr.h>
#include <parser/catalog_utils.h>
#include <parser/parse_query.h>
#include <rewrite/rewriteRemove.h> #include <rewrite/rewriteRemove.h>
#include <utils/builtins.h> #include <utils/builtins.h>
#include <utils/mcxt.h> #include <utils/mcxt.h>
...@@ -722,8 +723,8 @@ addNewRelationType(char *typeName, Oid new_rel_oid) ...@@ -722,8 +723,8 @@ addNewRelationType(char *typeName, Oid new_rel_oid)
*/ */
new_type_oid = TypeCreate(typeName, /* type name */ new_type_oid = TypeCreate(typeName, /* type name */
new_rel_oid, /* relation oid */ new_rel_oid, /* relation oid */
tlen(type("oid")), /* internal size */ typeLen(typeidType(OIDOID)), /* internal size */
tlen(type("oid")), /* external size */ typeLen(typeidType(OIDOID)), /* external size */
'c', /* type-type (catalog) */ 'c', /* type-type (catalog) */
',', /* default array delimiter */ ',', /* default array delimiter */
"int4in", /* input procedure */ "int4in", /* input procedure */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.29 1997/11/24 05:08:11 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.30 1997/11/25 21:58:43 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -30,26 +30,27 @@ ...@@ -30,26 +30,27 @@
#include <fmgr.h> #include <fmgr.h>
#include <access/genam.h> #include <access/genam.h>
#include <access/heapam.h> #include <access/heapam.h>
#include <storage/lmgr.h> #include <access/istrat.h>
#include <miscadmin.h>
#include <access/xact.h> #include <access/xact.h>
#include <parser/catalog_utils.h>
#include <storage/smgr.h>
#include <utils/builtins.h>
#include <utils/mcxt.h>
#include <utils/relcache.h>
#include <utils/syscache.h>
#include <utils/tqual.h>
#include <bootstrap/bootstrap.h> #include <bootstrap/bootstrap.h>
#include <catalog/catname.h> #include <catalog/catname.h>
#include <catalog/catalog.h> #include <catalog/catalog.h>
#include <catalog/indexing.h> #include <catalog/indexing.h>
#include <catalog/heap.h> #include <catalog/heap.h>
#include <catalog/index.h> #include <catalog/index.h>
#include <catalog/pg_type.h>
#include <executor/executor.h> #include <executor/executor.h>
#include <miscadmin.h>
#include <optimizer/clauses.h> #include <optimizer/clauses.h>
#include <optimizer/prep.h> #include <optimizer/prep.h>
#include <access/istrat.h> #include <parser/parse_func.h>
#include <storage/lmgr.h>
#include <storage/smgr.h>
#include <utils/builtins.h>
#include <utils/mcxt.h>
#include <utils/relcache.h>
#include <utils/syscache.h>
#include <utils/tqual.h>
#ifndef HAVE_MEMMOVE #ifndef HAVE_MEMMOVE
#include <regex/utils.h> #include <regex/utils.h>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.16 1997/11/24 05:08:15 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.17 1997/11/25 21:58:46 momjian Exp $
* *
* NOTES * NOTES
* these routines moved here from commands/define.c and somewhat cleaned up. * these routines moved here from commands/define.c and somewhat cleaned up.
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
#include <utils/syscache.h> #include <utils/syscache.h>
#include <utils/tqual.h> #include <utils/tqual.h>
#include <access/heapam.h> #include <access/heapam.h>
#include <parser/catalog_utils.h>
#include <catalog/catname.h> #include <catalog/catname.h>
#include <catalog/pg_operator.h> #include <catalog/pg_operator.h>
#include <catalog/pg_type.h>
#include <parser/parse_oper.h>
#include <storage/bufmgr.h> #include <storage/bufmgr.h>
#include <fmgr.h> #include <fmgr.h>
#include <miscadmin.h> #include <miscadmin.h>
......
...@@ -7,28 +7,28 @@ ...@@ -7,28 +7,28 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.9 1997/09/18 20:20:18 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.10 1997/11/25 21:58:48 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include <postgres.h> #include <postgres.h>
#include <fmgr.h>
#include <miscadmin.h>
#include <utils/syscache.h> #include <utils/syscache.h>
#include <catalog/pg_proc.h> #include <catalog/pg_proc.h>
#include <access/heapam.h> #include <access/heapam.h>
#include <access/relscan.h> #include <access/relscan.h>
#include <fmgr.h>
#include <utils/builtins.h>
#include <utils/sets.h>
#include <catalog/catname.h> #include <catalog/catname.h>
#include <catalog/indexing.h> #include <catalog/indexing.h>
#include <parser/parse_query.h> #include <catalog/pg_type.h>
#include <parser/parse_node.h>
#include <tcop/tcopprot.h> #include <tcop/tcopprot.h>
#include <parser/catalog_utils.h> #include <utils/builtins.h>
#include <utils/sets.h>
#include <utils/lsyscache.h>
#include <optimizer/internal.h> #include <optimizer/internal.h>
#include <optimizer/planner.h> #include <optimizer/planner.h>
#include <utils/lsyscache.h>
#include <miscadmin.h>
#ifndef HAVE_MEMMOVE #ifndef HAVE_MEMMOVE
#include <regex/utils.h> #include <regex/utils.h>
#else #else
...@@ -200,7 +200,7 @@ ProcedureCreate(char *procedureName, ...@@ -200,7 +200,7 @@ ProcedureCreate(char *procedureName,
if (parameterCount == 1 && if (parameterCount == 1 &&
(toid = TypeGet(strVal(lfirst(argList)), &defined)) && (toid = TypeGet(strVal(lfirst(argList)), &defined)) &&
defined && defined &&
(relid = typeid_get_relid(toid)) != 0 && (relid = typeidTypeRelid(toid)) != 0 &&
get_attnum(relid, procedureName) != InvalidAttrNumber) get_attnum(relid, procedureName) != InvalidAttrNumber)
elog(WARN, "method %s already an attribute of type %s", elog(WARN, "method %s already an attribute of type %s",
procedureName, strVal(lfirst(argList))); procedureName, strVal(lfirst(argList)));
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.13 1997/11/24 05:08:17 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.14 1997/11/25 21:58:50 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
#include <utils/builtins.h> #include <utils/builtins.h>
#include <utils/tqual.h> #include <utils/tqual.h>
#include <fmgr.h> #include <fmgr.h>
#include <parser/catalog_utils.h>
#include <catalog/catname.h> #include <catalog/catname.h>
#include <catalog/indexing.h> #include <catalog/indexing.h>
#include <catalog/pg_type.h>
#include <parser/parse_func.h>
#include <storage/lmgr.h> #include <storage/lmgr.h>
#include <miscadmin.h> #include <miscadmin.h>
#ifndef HAVE_MEMMOVE #ifndef HAVE_MEMMOVE
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.7 1997/09/08 02:22:18 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.8 1997/11/25 21:59:11 momjian Exp $
* *
* NOTES * NOTES
* At the point the version is defined, 2 physical relations are created * At the point the version is defined, 2 physical relations are created
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <utils/builtins.h> #include <utils/builtins.h>
#include <commands/version.h> #include <commands/version.h>
#include <access/xact.h> /* for GetCurrentXactStartTime */ #include <access/xact.h> /* for GetCurrentXactStartTime */
#include <parser/parse_node.h>
#include <tcop/tcopprot.h> #include <tcop/tcopprot.h>
#define MAX_QUERY_LEN 1024 #define MAX_QUERY_LEN 1024
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.14 1997/09/18 20:20:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.15 1997/11/25 21:58:53 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -16,12 +16,11 @@ ...@@ -16,12 +16,11 @@
#include <postgres.h> #include <postgres.h>
#include <parser/catalog_utils.h>
#include <parser/parse_query.h> /* for MakeTimeRange() */
#include <nodes/plannodes.h> #include <nodes/plannodes.h>
#include <tcop/tcopprot.h> #include <tcop/tcopprot.h>
#include <lib/stringinfo.h> #include <lib/stringinfo.h>
#include <commands/explain.h> #include <commands/explain.h>
#include <parser/parse_node.h>
#include <optimizer/planner.h> #include <optimizer/planner.h>
#include <access/xact.h> #include <access/xact.h>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.12 1997/11/21 18:09:51 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.13 1997/11/25 21:59:00 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include <catalog/pg_type.h> #include <catalog/pg_type.h>
#include <commands/recipe.h> #include <commands/recipe.h>
#include <libpq/libpq-be.h> #include <libpq/libpq-be.h>
#include <parser/parse_node.h>
#include <utils/builtins.h> #include <utils/builtins.h>
#include <utils/relcache.h> /* for RelationNameGetRelation */ #include <utils/relcache.h> /* for RelationNameGetRelation */
#include <parser/parse_query.h>
#include <rewrite/rewriteHandler.h> #include <rewrite/rewriteHandler.h>
#include <rewrite/rewriteManip.h> #include <rewrite/rewriteManip.h>
#include <tcop/pquery.h> #include <tcop/pquery.h>
...@@ -488,7 +488,7 @@ tg_replaceNumberedParam(Node *expression, ...@@ -488,7 +488,7 @@ tg_replaceNumberedParam(Node *expression,
* "result" attribute from the tee relation * "result" attribute from the tee relation
*/ */
isRel = (typeid_get_relid(p->paramtype) != 0); isRel = (typeidTypeRelid(p->paramtype) != 0);
if (isRel) if (isRel)
{ {
newVar = makeVar(rt_ind, newVar = makeVar(rt_ind,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.16 1997/11/20 23:21:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.17 1997/11/25 21:59:03 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
#include <catalog/pg_language.h> #include <catalog/pg_language.h>
#include <catalog/pg_operator.h> #include <catalog/pg_operator.h>
#include <catalog/pg_proc.h> #include <catalog/pg_proc.h>
#include <parser/catalog_utils.h> #include <catalog/pg_type.h>
#include <parser/parse_func.h>
#include <storage/bufmgr.h> #include <storage/bufmgr.h>
#include <fmgr.h> #include <fmgr.h>
#ifndef HAVE_MEMMOVE #ifndef HAVE_MEMMOVE
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.52 1997/11/21 19:59:34 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.53 1997/11/25 21:59:09 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <catalog/pg_statistic.h> #include <catalog/pg_statistic.h>
#include <catalog/pg_type.h> #include <catalog/pg_type.h>
#include <catalog/pg_operator.h> #include <catalog/pg_operator.h>
#include <parser/parse_oper.h>
#include <storage/smgr.h> #include <storage/smgr.h>
#include <storage/lmgr.h> #include <storage/lmgr.h>
#include <utils/inval.h> #include <utils/inval.h>
...@@ -44,7 +45,6 @@ ...@@ -44,7 +45,6 @@
#include <utils/syscache.h> #include <utils/syscache.h>
#include <utils/builtins.h> #include <utils/builtins.h>
#include <commands/vacuum.h> #include <commands/vacuum.h>
#include <parser/catalog_utils.h>
#include <storage/bufpage.h> #include <storage/bufpage.h>
#include "storage/shmem.h" #include "storage/shmem.h"
#ifndef HAVE_GETRUSAGE #ifndef HAVE_GETRUSAGE
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.15 1997/11/21 18:09:58 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.16 1997/11/25 21:59:12 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include <access/xact.h> #include <access/xact.h>
#include <utils/builtins.h> #include <utils/builtins.h>
#include <nodes/relation.h> #include <nodes/relation.h>
#include <parser/catalog_utils.h> #include <parser/parse_relation.h>
#include <parser/parse_query.h> #include <parser/parse_type.h>
#include <rewrite/rewriteDefine.h> #include <rewrite/rewriteDefine.h>
#include <rewrite/rewriteHandler.h> #include <rewrite/rewriteHandler.h>
#include <rewrite/rewriteManip.h> #include <rewrite/rewriteManip.h>
...@@ -72,7 +72,7 @@ DefineVirtualRelation(char *relname, List *tlist) ...@@ -72,7 +72,7 @@ DefineVirtualRelation(char *relname, List *tlist)
entry = lfirst(t); entry = lfirst(t);
res = entry->resdom; res = entry->resdom;
resname = res->resname; resname = res->resname;
restypename = tname(get_id_type(res->restype)); restypename = typeidTypeName(res->restype);
typename = makeNode(TypeName); typename = makeNode(TypeName);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.10 1997/09/18 20:20:32 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.11 1997/11/25 21:59:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -125,11 +125,11 @@ ...@@ -125,11 +125,11 @@
#undef ExecStoreTuple #undef ExecStoreTuple
#include "access/tupdesc.h" #include "access/tupdesc.h"
#include "catalog/pg_type.h"
#include "parser/parse_type.h"
#include "storage/bufmgr.h"
#include "utils/palloc.h" #include "utils/palloc.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "storage/bufmgr.h"
#include "parser/catalog_utils.h"
#include "catalog/pg_type.h"
static TupleTableSlot *NodeGetResultTupleSlot(Plan *node); static TupleTableSlot *NodeGetResultTupleSlot(Plan *node);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.12 1997/09/18 20:20:37 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.13 1997/11/25 21:59:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "nodes/plannodes.h" #include "nodes/plannodes.h"
#include "catalog/pg_proc.h" #include "catalog/pg_proc.h"
#include "parser/parse_query.h"
#include "tcop/pquery.h" #include "tcop/pquery.h"
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
#include "tcop/utility.h" #include "tcop/utility.h"
......
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
#include "access/heapam.h" #include "access/heapam.h"
#include "catalog/pg_aggregate.h" #include "catalog/pg_aggregate.h"
#include "catalog/catalog.h" #include "catalog/catalog.h"
#include "parser/parse_type.h"
#include "executor/executor.h" #include "executor/executor.h"
#include "executor/nodeAgg.h" #include "executor/nodeAgg.h"
#include "storage/bufmgr.h" #include "storage/bufmgr.h"
#include "utils/palloc.h" #include "utils/palloc.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "parser/catalog_utils.h"
/* /*
* AggFuncInfo - * AggFuncInfo -
...@@ -172,7 +172,7 @@ ExecAgg(Agg *node) ...@@ -172,7 +172,7 @@ ExecAgg(Agg *node)
if (!HeapTupleIsValid(aggTuple)) if (!HeapTupleIsValid(aggTuple))
elog(WARN, "ExecAgg: cache lookup failed for aggregate \"%s\"(%s)", elog(WARN, "ExecAgg: cache lookup failed for aggregate \"%s\"(%s)",
aggname, aggname,
tname(get_id_type(agg->basetype))); typeidTypeName(agg->basetype));
aggp = (Form_pg_aggregate) GETSTRUCT(aggTuple); aggp = (Form_pg_aggregate) GETSTRUCT(aggTuple);
xfn1_oid = aggp->aggtransfn1; xfn1_oid = aggp->aggtransfn1;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "executor/spi.h" #include "executor/spi.h"
#include "catalog/pg_type.h"
#include "access/printtup.h" #include "access/printtup.h"
#include "fmgr.h" #include "fmgr.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.15 1997/11/20 23:21:40 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.16 1997/11/25 21:59:40 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "nodes/primnodes.h" #include "nodes/primnodes.h"
#include "nodes/relation.h" #include "nodes/relation.h"
#include "parser/parse_query.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/builtins.h" /* for namecpy */ #include "utils/builtins.h" /* for namecpy */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.10 1997/10/25 01:09:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.11 1997/11/25 21:59:44 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "nodes/print.h" #include "nodes/print.h"
#include "parser/parsetree.h" #include "parser/parsetree.h"
#include "parser/catalog_utils.h"
#include "access/heapam.h" #include "access/heapam.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "nodes/nodes.h" #include "nodes/nodes.h"
#include "nodes/plannodes.h" #include "nodes/plannodes.h"
#include "parser/parse_relation.h"
#include "optimizer/clauses.h" #include "optimizer/clauses.h"
static char *plannode_type(Plan *p); static char *plannode_type(Plan *p);
...@@ -194,7 +194,7 @@ print_expr(Node *expr, List *rtable) ...@@ -194,7 +194,7 @@ print_expr(Node *expr, List *rtable)
r = heap_openr(relname); r = heap_openr(relname);
if (rt->refname) if (rt->refname)
relname = rt->refname; /* table renamed */ relname = rt->refname; /* table renamed */
attname = getAttrName(r, var->varattno); attname = attnumAttName(r, var->varattno);
heap_close(r); heap_close(r);
} }
break; break;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.6 1997/09/08 21:45:10 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.7 1997/11/25 21:59:50 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -641,10 +641,10 @@ xfunc_width(LispValue clause) ...@@ -641,10 +641,10 @@ xfunc_width(LispValue clause)
} }
else if (IsA(clause, Param)) else if (IsA(clause, Param))
{ {
if (typeid_get_relid(get_paramtype((Param) clause))) if (typeidTypeRelid(get_paramtype((Param) clause)))
{ {
/* Param node returns a tuple. Find its width */ /* Param node returns a tuple. Find its width */
rd = heap_open(typeid_get_relid(get_paramtype((Param) clause))); rd = heap_open(typeidTypeRelid(get_paramtype((Param) clause)));
retval = xfunc_tuple_width(rd); retval = xfunc_tuple_width(rd);
heap_close(rd); heap_close(rd);
} }
...@@ -659,7 +659,7 @@ xfunc_width(LispValue clause) ...@@ -659,7 +659,7 @@ xfunc_width(LispValue clause)
else else
{ {
/* Param node returns a base type */ /* Param node returns a base type */
retval = tlen(get_id_type(get_paramtype((Param) clause))); retval = typeLen(typeidType(get_paramtype((Param) clause)));
} }
goto exit; goto exit;
} }
...@@ -1324,9 +1324,9 @@ xfunc_func_width(RegProcedure funcid, LispValue args) ...@@ -1324,9 +1324,9 @@ xfunc_func_width(RegProcedure funcid, LispValue args)
proc = (Form_pg_proc) GETSTRUCT(tupl); proc = (Form_pg_proc) GETSTRUCT(tupl);
/* if function returns a tuple, get the width of that */ /* if function returns a tuple, get the width of that */
if (typeid_get_relid(proc->prorettype)) if (typeidTypeRelid(proc->prorettype))
{ {
rd = heap_open(typeid_get_relid(proc->prorettype)); rd = heap_open(typeidTypeRelid(proc->prorettype));
retval = xfunc_tuple_width(rd); retval = xfunc_tuple_width(rd);
heap_close(rd); heap_close(rd);
goto exit; goto exit;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.15 1997/09/08 21:45:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.16 1997/11/25 21:59:56 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "utils/palloc.h" #include "utils/palloc.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "parser/parse_query.h"
#include "optimizer/clauseinfo.h" #include "optimizer/clauseinfo.h"
#include "optimizer/clauses.h" #include "optimizer/clauses.h"
#include "optimizer/planmain.h" #include "optimizer/planmain.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.10 1997/11/21 18:10:26 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.11 1997/11/25 21:59:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
#include "nodes/plannodes.h" #include "nodes/plannodes.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "nodes/relation.h" #include "nodes/relation.h"
#include "parser/parse_expr.h"
#include "parser/catalog_utils.h"
#include "parser/parse_query.h"
#include "utils/elog.h" #include "utils/elog.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "access/heapam.h" #include "access/heapam.h"
...@@ -310,7 +309,7 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList) ...@@ -310,7 +309,7 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList)
} }
/* by here, the function is declared to return some type */ /* by here, the function is declared to return some type */
if ((typ = (Type) get_id_type(rettype)) == NULL) if ((typ = typeidType(rettype)) == NULL)
elog(WARN, "can't find return type %d for function\n", rettype); elog(WARN, "can't find return type %d for function\n", rettype);
/* /*
...@@ -318,21 +317,21 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList) ...@@ -318,21 +317,21 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList)
* final query had better be a retrieve. * final query had better be a retrieve.
*/ */
if (cmd != CMD_SELECT) if (cmd != CMD_SELECT)
elog(WARN, "function declared to return type %s, but final query is not a retrieve", tname(typ)); elog(WARN, "function declared to return type %s, but final query is not a retrieve", typeTypeName(typ));
/* /*
* test 4: for base type returns, the target list should have exactly * test 4: for base type returns, the target list should have exactly
* one entry, and its type should agree with what the user declared. * one entry, and its type should agree with what the user declared.
*/ */
if (get_typrelid(typ) == InvalidOid) if (typeTypeRelid(typ) == InvalidOid)
{ {
if (exec_tlist_length(tlist) > 1) if (exec_tlist_length(tlist) > 1)
elog(WARN, "function declared to return %s returns multiple values in final retrieve", tname(typ)); elog(WARN, "function declared to return %s returns multiple values in final retrieve", typeTypeName(typ));
resnode = (Resdom *) ((TargetEntry *) lfirst(tlist))->resdom; resnode = (Resdom *) ((TargetEntry *) lfirst(tlist))->resdom;
if (resnode->restype != rettype) if (resnode->restype != rettype)
elog(WARN, "return type mismatch in function: declared to return %s, returns %s", tname(typ), tname(get_id_type(resnode->restype))); elog(WARN, "return type mismatch in function: declared to return %s, returns %s", typeTypeName(typ), typeidTypeName(resnode->restype));
/* by here, base return types match */ /* by here, base return types match */
return; return;
...@@ -358,16 +357,16 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList) ...@@ -358,16 +357,16 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList)
* declared return type, and be sure that attributes 1 .. n in the * declared return type, and be sure that attributes 1 .. n in the
* target list match the declared types. * target list match the declared types.
*/ */
reln = heap_open(get_typrelid(typ)); reln = heap_open(typeTypeRelid(typ));
if (!RelationIsValid(reln)) if (!RelationIsValid(reln))
elog(WARN, "cannot open relation relid %d", get_typrelid(typ)); elog(WARN, "cannot open relation relid %d", typeTypeRelid(typ));
relid = reln->rd_id; relid = reln->rd_id;
relnatts = reln->rd_rel->relnatts; relnatts = reln->rd_rel->relnatts;
if (exec_tlist_length(tlist) != relnatts) if (exec_tlist_length(tlist) != relnatts)
elog(WARN, "function declared to return type %s does not retrieve (%s.*)", tname(typ), tname(typ)); elog(WARN, "function declared to return type %s does not retrieve (%s.*)", typeTypeName(typ), typeTypeName(typ));
/* expect attributes 1 .. n in order */ /* expect attributes 1 .. n in order */
for (i = 1; i <= relnatts; i++) for (i = 1; i <= relnatts; i++)
...@@ -397,14 +396,14 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList) ...@@ -397,14 +396,14 @@ pg_checkretval(Oid rettype, QueryTreeList *queryTreeList)
else if (IsA(thenode, Func)) else if (IsA(thenode, Func))
tletype = (Oid) get_functype((Func *) thenode); tletype = (Oid) get_functype((Func *) thenode);
else else
elog(WARN, "function declared to return type %s does not retrieve (%s.all)", tname(typ), tname(typ)); elog(WARN, "function declared to return type %s does not retrieve (%s.all)", typeTypeName(typ), typeTypeName(typ));
} }
else else
elog(WARN, "function declared to return type %s does not retrieve (%s.all)", tname(typ), tname(typ)); elog(WARN, "function declared to return type %s does not retrieve (%s.all)", typeTypeName(typ), typeTypeName(typ));
#endif #endif
/* reach right in there, why don't you? */ /* reach right in there, why don't you? */
if (tletype != reln->rd_att->attrs[i - 1]->atttypid) if (tletype != reln->rd_att->attrs[i - 1]->atttypid)
elog(WARN, "function declared to return type %s does not retrieve (%s.all)", tname(typ), tname(typ)); elog(WARN, "function declared to return type %s does not retrieve (%s.all)", typeTypeName(typ), typeTypeName(typ));
} }
heap_close(reln); heap_close(reln);
......
...@@ -7,13 +7,14 @@ ...@@ -7,13 +7,14 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.5 1997/09/08 21:45:36 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.6 1997/11/25 22:00:06 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include <string.h> #include <string.h>
#include "postgres.h" #include "postgres.h"
#include "catalog/pg_type.h"
#include "nodes/pg_list.h" #include "nodes/pg_list.h"
#include "nodes/relation.h" #include "nodes/relation.h"
#include "nodes/primnodes.h" #include "nodes/primnodes.h"
...@@ -24,9 +25,9 @@ ...@@ -24,9 +25,9 @@
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "utils/palloc.h" #include "utils/palloc.h"
#include "parser/parse_type.h"
#include "parser/parsetree.h" /* for getrelid() */ #include "parser/parsetree.h" /* for getrelid() */
#include "parser/catalog_utils.h"
#include "optimizer/internal.h" #include "optimizer/internal.h"
#include "optimizer/prep.h" #include "optimizer/prep.h"
...@@ -278,7 +279,7 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type) ...@@ -278,7 +279,7 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
attisset = get_attisset( /* type_id, */ relid, attname); attisset = get_attisset( /* type_id, */ relid, attname);
if (attisset) if (attisset)
{ {
typlen = tlen(type("oid")); typlen = typeLen(typeidType(OIDOID));
} }
else else
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.8 1997/11/21 18:10:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.9 1997/11/25 22:00:10 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "nodes/plannodes.h" #include "nodes/plannodes.h"
#include "nodes/relation.h" #include "nodes/relation.h"
#include "parser/parse_query.h"
#include "parser/parsetree.h" #include "parser/parsetree.h"
#include "utils/elog.h" #include "utils/elog.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.7 1997/09/08 21:45:55 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.8 1997/11/25 22:00:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "optimizer/clauses.h" #include "optimizer/clauses.h"
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
#include "parser/catalog_utils.h"
static Node *flatten_tlistentry(Node *tlistentry, List *flat_tlist); static Node *flatten_tlistentry(Node *tlistentry, List *flat_tlist);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for parser # Makefile for parser
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.11 1997/11/24 05:20:57 momjian Exp $ # $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.12 1997/11/25 22:00:21 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -22,8 +22,9 @@ CFLAGS+= -Wno-error ...@@ -22,8 +22,9 @@ CFLAGS+= -Wno-error
endif endif
OBJS= analyze.o catalog_utils.o gram.o \ OBJS= analyze.o gram.o keywords.o parser.o parse_agg.o parse_clause.o \
keywords.o parser.o parse_query.o scan.o scansup.o parse_expr.o parse_func.o parse_node.o parse_oper.o parse_relation.o \
parse_type.o parse_target.o scan.o scansup.o
all: SUBSYS.o all: SUBSYS.o
......
This diff is collapsed.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.71 1997/11/24 16:55:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.72 1997/11/25 22:05:29 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "nodes/print.h" #include "nodes/print.h"
#include "parser/gramparse.h" #include "parser/gramparse.h"
#include "parser/catalog_utils.h"
#include "parser/parse_query.h"
#include "utils/acl.h" #include "utils/acl.h"
#include "catalog/catname.h" #include "catalog/catname.h"
#include "utils/elog.h" #include "utils/elog.h"
...@@ -49,8 +47,11 @@ ...@@ -49,8 +47,11 @@
static char saved_relname[NAMEDATALEN]; /* need this for complex attributes */ static char saved_relname[NAMEDATALEN]; /* need this for complex attributes */
static bool QueryIsRule = FALSE; static bool QueryIsRule = FALSE;
static Node *saved_In_Expr; static Node *saved_In_Expr;
static Oid *param_type_info;
static int pfunc_num_args;
extern List *parsetree; extern List *parsetree;
/* /*
* If you need access to certain yacc-generated variables and find that * If you need access to certain yacc-generated variables and find that
* they're static by default, uncomment the next line. (this is not a * they're static by default, uncomment the next line. (this is not a
...@@ -64,6 +65,9 @@ static List *makeConstantList( A_Const *node); ...@@ -64,6 +65,9 @@ static List *makeConstantList( A_Const *node);
static char *FlattenStringList(List *list); static char *FlattenStringList(List *list);
static char *fmtId(char *rawid); static char *fmtId(char *rawid);
static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr); static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr);
static void param_type_init(Oid *typev, int nargs);
Oid param_type(int t); /* used in parse_expr.c */
/* old versions of flex define this as a macro */ /* old versions of flex define this as a macro */
#if defined(yywrap) #if defined(yywrap)
...@@ -2324,7 +2328,7 @@ Typename: Array opt_array_bounds ...@@ -2324,7 +2328,7 @@ Typename: Array opt_array_bounds
* emp(name=text,mgr=emp) * emp(name=text,mgr=emp)
*/ */
$$->setof = TRUE; $$->setof = TRUE;
else if (get_typrelid((Type)type($$->name)) != InvalidOid) else if (typeTypeRelid(typenameType($$->name)) != InvalidOid)
/* (Eventually add in here that the set can only /* (Eventually add in here that the set can only
* contain one element.) * contain one element.)
*/ */
...@@ -3690,4 +3694,24 @@ printf("fmtId- %sconvert %s to %s\n", ((cp == rawid)? "do not ": ""), rawid, cp) ...@@ -3690,4 +3694,24 @@ printf("fmtId- %sconvert %s to %s\n", ((cp == rawid)? "do not ": ""), rawid, cp)
#endif #endif
return(cp); return(cp);
} /* fmtId() */ }
/*
* param_type_init()
*
* keep enough information around fill out the type of param nodes
* used in postquel functions
*/
static void
param_type_init(Oid *typev, int nargs)
{
pfunc_num_args = nargs;
param_type_info = typev;
}
Oid param_type(int t)
{
if ((t > pfunc_num_args) || (t == 0))
return InvalidOid;
return param_type_info[t - 1];
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.24 1997/11/24 05:32:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.25 1997/11/25 22:05:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include "nodes/pg_list.h" #include "nodes/pg_list.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "parse.h" #include "parse.h"
#include "utils/elog.h"
#include "parser/keywords.h" #include "parser/keywords.h"
#include "utils/elog.h"
/* /*
* List of (keyword-name, keyword-token-value) pairs. * List of (keyword-name, keyword-token-value) pairs.
......
/*-------------------------------------------------------------------------
*
* parse_agg.c--
* handle aggregates in parser
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.1 1997/11/25 22:05:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "postgres.h"
#include "access/heapam.h"
#include "catalog/pg_aggregate.h"
#include "nodes/nodeFuncs.h"
#include "nodes/primnodes.h"
#include "nodes/relation.h"
#include "optimizer/clauses.h"
#include "parser/parse_agg.h"
#include "parser/parse_node.h"
#include "parser/parse_target.h"
#include "utils/syscache.h"
#ifdef 0
#include "nodes/nodes.h"
#include "nodes/params.h"
#include "parse.h" /* for AND, OR, etc. */
#include "catalog/pg_type.h" /* for INT4OID, etc. */
#include "catalog/pg_proc.h"
#include "utils/elog.h"
#include "utils/builtins.h" /* namecmp(), textout() */
#include "utils/lsyscache.h"
#include "utils/palloc.h"
#include "utils/mcxt.h"
#include "utils/acl.h"
#include "nodes/makefuncs.h" /* for makeResdom(), etc. */
#include "commands/sequence.h"
#endif
/*
* AddAggToParseState -
* add the aggregate to the list of unique aggregates in pstate.
*
* SIDE EFFECT: aggno in target list entry will be modified
*/
void
AddAggToParseState(ParseState *pstate, Aggreg *aggreg)
{
List *ag;
int i;
/*
* see if we have the aggregate already (we only need to record the
* aggregate once)
*/
i = 0;
foreach(ag, pstate->p_aggs)
{
Aggreg *a = lfirst(ag);
if (!strcmp(a->aggname, aggreg->aggname) &&
equal(a->target, aggreg->target))
{
/* fill in the aggno and we're done */
aggreg->aggno = i;
return;
}
i++;
}
/* not found, new aggregate */
aggreg->aggno = i;
pstate->p_numAgg++;
pstate->p_aggs = lappend(pstate->p_aggs, aggreg);
return;
}
/*
* finalizeAggregates -
* fill in qry_aggs from pstate. Also checks to make sure that aggregates
* are used in the proper place.
*/
void
finalizeAggregates(ParseState *pstate, Query *qry)
{
List *l;
int i;
parseCheckAggregates(pstate, qry);
qry->qry_numAgg = pstate->p_numAgg;
qry->qry_aggs =
(Aggreg **) palloc(sizeof(Aggreg *) * qry->qry_numAgg);
i = 0;
foreach(l, pstate->p_aggs)
qry->qry_aggs[i++] = (Aggreg *) lfirst(l);
}
/*
* contain_agg_clause--
* Recursively find aggreg nodes from a clause.
*
* Returns true if any aggregate found.
*/
bool
contain_agg_clause(Node *clause)
{
if (clause == NULL)
return FALSE;
else if (IsA(clause, Aggreg))
return TRUE;
else if (IsA(clause, Iter))
return contain_agg_clause(((Iter *) clause)->iterexpr);
else if (single_node(clause))
return FALSE;
else if (or_clause(clause))
{
List *temp;
foreach(temp, ((Expr *) clause)->args)
if (contain_agg_clause(lfirst(temp)))
return TRUE;
return FALSE;
}
else if (is_funcclause(clause))
{
List *temp;
foreach(temp, ((Expr *) clause)->args)
if (contain_agg_clause(lfirst(temp)))
return TRUE;
return FALSE;
}
else if (IsA(clause, ArrayRef))
{
List *temp;
foreach(temp, ((ArrayRef *) clause)->refupperindexpr)
if (contain_agg_clause(lfirst(temp)))
return TRUE;
foreach(temp, ((ArrayRef *) clause)->reflowerindexpr)
if (contain_agg_clause(lfirst(temp)))
return TRUE;
if (contain_agg_clause(((ArrayRef *) clause)->refexpr))
return TRUE;
if (contain_agg_clause(((ArrayRef *) clause)->refassgnexpr))
return TRUE;
return FALSE;
}
else if (not_clause(clause))
return contain_agg_clause((Node *) get_notclausearg((Expr *) clause));
else if (is_opclause(clause))
return (contain_agg_clause((Node *) get_leftop((Expr *) clause)) ||
contain_agg_clause((Node *) get_rightop((Expr *) clause)));
return FALSE;
}
/*
* exprIsAggOrGroupCol -
* returns true if the expression does not contain non-group columns.
*/
bool
exprIsAggOrGroupCol(Node *expr, List *groupClause)
{
List *gl;
if (expr == NULL || IsA(expr, Const) ||
IsA(expr, Param) ||IsA(expr, Aggreg))
return TRUE;
foreach(gl, groupClause)
{
GroupClause *grpcl = lfirst(gl);
if (equal(expr, grpcl->entry->expr))
return TRUE;
}
if (IsA(expr, Expr))
{
List *temp;
foreach(temp, ((Expr *) expr)->args)
if (!exprIsAggOrGroupCol(lfirst(temp), groupClause))
return FALSE;
return TRUE;
}
return FALSE;
}
/*
* tleIsAggOrGroupCol -
* returns true if the TargetEntry is Agg or GroupCol.
*/
bool
tleIsAggOrGroupCol(TargetEntry *tle, List *groupClause)
{
Node *expr = tle->expr;
List *gl;
if (expr == NULL || IsA(expr, Const) ||IsA(expr, Param))
return TRUE;
foreach(gl, groupClause)
{
GroupClause *grpcl = lfirst(gl);
if (tle->resdom->resno == grpcl->entry->resdom->resno)
{
if (contain_agg_clause((Node *) expr))
elog(WARN, "parser: aggregates not allowed in GROUP BY clause");
return TRUE;
}
}
if (IsA(expr, Aggreg))
return TRUE;
if (IsA(expr, Expr))
{
List *temp;
foreach(temp, ((Expr *) expr)->args)
if (!exprIsAggOrGroupCol(lfirst(temp), groupClause))
return FALSE;
return TRUE;
}
return FALSE;
}
/*
* parseCheckAggregates -
* this should really be done earlier but the current grammar
* cannot differentiate functions from aggregates. So we have do check
* here when the target list and the qualifications are finalized.
*/
void
parseCheckAggregates(ParseState *pstate, Query *qry)
{
List *tl;
Assert(pstate->p_numAgg > 0);
/*
* aggregates never appear in WHERE clauses. (we have to check where
* clause first because if there is an aggregate, the check for
* non-group column in target list may fail.)
*/
if (contain_agg_clause(qry->qual))
elog(WARN, "parser: aggregates not allowed in WHERE clause");
/*
* the target list can only contain aggregates, group columns and
* functions thereof.
*/
foreach(tl, qry->targetList)
{
TargetEntry *tle = lfirst(tl);
if (!tleIsAggOrGroupCol(tle, qry->groupClause))
elog(WARN,
"parser: illegal use of aggregates or non-group column in target list");
}
/*
* the expression specified in the HAVING clause has the same
* restriction as those in the target list.
*/
/*
* Need to change here when we get HAVING works. Currently
* qry->havingQual is NULL. - vadim 04/05/97
if (!exprIsAggOrGroupCol(qry->havingQual, qry->groupClause))
elog(WARN,
"parser: illegal use of aggregates or non-group column in HAVING clause");
*/
return;
}
Aggreg *
ParseAgg(char *aggname, Oid basetype, Node *target)
{
Oid fintype;
Oid vartype;
Oid xfn1;
Form_pg_aggregate aggform;
Aggreg *aggreg;
HeapTuple theAggTuple;
theAggTuple = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggname),
ObjectIdGetDatum(basetype),
0, 0);
if (!HeapTupleIsValid(theAggTuple))
{
elog(WARN, "aggregate %s does not exist", aggname);
}
aggform = (Form_pg_aggregate) GETSTRUCT(theAggTuple);
fintype = aggform->aggfinaltype;
xfn1 = aggform->aggtransfn1;
if (nodeTag(target) != T_Var && nodeTag(target) != T_Expr)
elog(WARN, "parser: aggregate can only be applied on an attribute or expression");
/* only aggregates with transfn1 need a base type */
if (OidIsValid(xfn1))
{
basetype = aggform->aggbasetype;
if (nodeTag(target) == T_Var)
vartype = ((Var *) target)->vartype;
else
vartype = ((Expr *) target)->typeOid;
if (basetype != vartype)
{
Type tp1,
tp2;
tp1 = typeidType(basetype);
tp2 = typeidType(vartype);
elog(NOTICE, "Aggregate type mismatch:");
elog(WARN, "%s works on %s, not %s", aggname,
typeTypeName(tp1), typeTypeName(tp2));
}
}
aggreg = makeNode(Aggreg);
aggreg->aggname = pstrdup(aggname);
aggreg->basetype = aggform->aggbasetype;
aggreg->aggtype = fintype;
aggreg->target = target;
return aggreg;
}
/*
* Error message when aggregate lookup fails that gives details of the
* basetype
*/
void
agg_error(char *caller, char *aggname, Oid basetypeID)
{
/*
* basetypeID that is Invalid (zero) means aggregate over all types.
* (count)
*/
if (basetypeID == InvalidOid)
{
elog(WARN, "%s: aggregate '%s' for all types does not exist", caller, aggname);
}
else
{
elog(WARN, "%s: aggregate '%s' for '%s' does not exist", caller, aggname,
typeidTypeName(basetypeID));
}
}
/*-------------------------------------------------------------------------
*
* parse_clause.c--
* handle clauses in parser
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.1 1997/11/25 22:05:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "postgres.h"
#include "access/heapam.h"
#include "parser/parse_clause.h"
#include "parser/parse_expr.h"
#include "parser/parse_node.h"
#include "parser/parse_oper.h"
#include "parser/parse_relation.h"
#include "parser/parse_target.h"
#include "catalog/pg_type.h"
#ifdef 0
#include "nodes/nodes.h"
#include "nodes/params.h"
#include "nodes/primnodes.h"
#include "nodes/parsenodes.h"
#include "nodes/relation.h"
#include "parse.h" /* for AND, OR, etc. */
#include "catalog/pg_aggregate.h"
#include "catalog/pg_proc.h"
#include "utils/elog.h"
#include "utils/builtins.h" /* namecmp(), textout() */
#include "utils/lsyscache.h"
#include "utils/palloc.h"
#include "utils/mcxt.h"
#include "utils/syscache.h"
#include "utils/acl.h"
#include "nodes/makefuncs.h" /* for makeResdom(), etc. */
#include "nodes/nodeFuncs.h"
#include "commands/sequence.h"
#include "optimizer/clauses.h"
#include "miscadmin.h"
#include "port-protos.h" /* strdup() */
#endif
/*
* parseFromClause -
* turns the table references specified in the from-clause into a
* range table. The range table may grow as we transform the expressions
* in the target list. (Note that this happens because in POSTQUEL, we
* allow references to relations not specified in the from-clause. We
* also allow that in our POST-SQL)
*
*/
void
parseFromClause(ParseState *pstate, List *frmList)
{
List *fl;
foreach(fl, frmList)
{
RangeVar *r = lfirst(fl);
RelExpr *baserel = r->relExpr;
char *relname = baserel->relname;
char *refname = r->name;
RangeTblEntry *rte;
if (refname == NULL)
refname = relname;
/*
* marks this entry to indicate it comes from the FROM clause. In
* SQL, the target list can only refer to range variables
* specified in the from clause but we follow the more powerful
* POSTQUEL semantics and automatically generate the range
* variable if not specified. However there are times we need to
* know whether the entries are legitimate.
*
* eg. select * from foo f where f.x = 1; will generate wrong answer
* if we expand * to foo.x.
*/
rte = addRangeTableEntry(pstate, relname, refname, baserel->inh, TRUE);
}
}
/*
* makeRangeTable -
* make a range table with the specified relation (optional) and the
* from-clause.
*/
void
makeRangeTable(ParseState *pstate, char *relname, List *frmList)
{
RangeTblEntry *rte;
parseFromClause(pstate, frmList);
if (relname == NULL)
return;
if (refnameRangeTablePosn(pstate->p_rtable, relname) < 1)
rte = addRangeTableEntry(pstate, relname, relname, FALSE, FALSE);
else
rte = refnameRangeTableEntry(pstate->p_rtable, relname);
pstate->p_target_rangetblentry = rte;
Assert(pstate->p_target_relation == NULL);
pstate->p_target_relation = heap_open(rte->relid);
Assert(pstate->p_target_relation != NULL);
/* will close relation later */
}
/*****************************************************************************
*
* Where Clause
*
*****************************************************************************/
/*
* transformWhereClause -
* transforms the qualification and make sure it is of type Boolean
*
*/
Node *
transformWhereClause(ParseState *pstate, Node *a_expr)
{
Node *qual;
if (a_expr == NULL)
return (Node *) NULL; /* no qualifiers */
pstate->p_in_where_clause = true;
qual = transformExpr(pstate, a_expr, EXPR_COLUMN_FIRST);
pstate->p_in_where_clause = false;
if (exprType(qual) != BOOLOID)
{
elog(WARN,
"where clause must return type bool, not %s",
typeidTypeName(exprType(qual)));
}
return qual;
}
/*****************************************************************************
*
* Sort Clause
*
*****************************************************************************/
/*
* find_targetlist_entry -
* returns the Resdom in the target list matching the specified varname
* and range
*
*/
TargetEntry *
find_targetlist_entry(ParseState *pstate, SortGroupBy *sortgroupby, List *tlist)
{
List *i;
int real_rtable_pos = 0,
target_pos = 0;
TargetEntry *target_result = NULL;
if (sortgroupby->range)
real_rtable_pos = refnameRangeTablePosn(pstate->p_rtable,
sortgroupby->range);
foreach(i, tlist)
{
TargetEntry *target = (TargetEntry *) lfirst(i);
Resdom *resnode = target->resdom;
Var *var = (Var *) target->expr;
char *resname = resnode->resname;
int test_rtable_pos = var->varno;
#ifdef PARSEDEBUG
printf("find_targetlist_entry- target name is %s, position %d, resno %d\n",
(sortgroupby->name ? sortgroupby->name : "(null)"), target_pos + 1, sortgroupby->resno);
#endif
if (!sortgroupby->name)
{
if (sortgroupby->resno == ++target_pos)
{
target_result = target;
break;
}
}
else
{
if (!strcmp(resname, sortgroupby->name))
{
if (sortgroupby->range)
{
if (real_rtable_pos == test_rtable_pos)
{
if (target_result != NULL)
elog(WARN, "Order/Group By '%s' is ambiguous", sortgroupby->name);
else
target_result = target;
}
}
else
{
if (target_result != NULL)
elog(WARN, "Order/Group By '%s' is ambiguous", sortgroupby->name);
else
target_result = target;
}
}
}
}
return target_result;
}
/*
* transformGroupClause -
* transform a Group By clause
*
*/
List *
transformGroupClause(ParseState *pstate, List *grouplist, List *targetlist)
{
List *glist = NIL,
*gl = NIL;
while (grouplist != NIL)
{
GroupClause *grpcl = makeNode(GroupClause);
TargetEntry *restarget;
Resdom *resdom;
restarget = find_targetlist_entry(pstate, lfirst(grouplist), targetlist);
if (restarget == NULL)
elog(WARN, "The field being grouped by must appear in the target list");
grpcl->entry = restarget;
resdom = restarget->resdom;
grpcl->grpOpoid = oprid(oper("<",
resdom->restype,
resdom->restype, false));
if (glist == NIL)
gl = glist = lcons(grpcl, NIL);
else
{
List *i;
foreach (i, glist)
{
GroupClause *gcl = (GroupClause *) lfirst (i);
if ( gcl->entry == grpcl->entry )
break;
}
if ( i == NIL ) /* not in grouplist already */
{
lnext(gl) = lcons(grpcl, NIL);
gl = lnext(gl);
}
else
pfree (grpcl); /* get rid of this */
}
grouplist = lnext(grouplist);
}
return glist;
}
/*
* transformSortClause -
* transform an Order By clause
*
*/
List *
transformSortClause(ParseState *pstate,
List *orderlist, List *targetlist,
char *uniqueFlag)
{
List *sortlist = NIL;
List *s = NIL;
while (orderlist != NIL)
{
SortGroupBy *sortby = lfirst(orderlist);
SortClause *sortcl = makeNode(SortClause);
TargetEntry *restarget;
Resdom *resdom;
restarget = find_targetlist_entry(pstate, sortby, targetlist);
if (restarget == NULL)
elog(WARN, "The field being ordered by must appear in the target list");
sortcl->resdom = resdom = restarget->resdom;
sortcl->opoid = oprid(oper(sortby->useOp,
resdom->restype,
resdom->restype, false));
if (sortlist == NIL)
{
s = sortlist = lcons(sortcl, NIL);
}
else
{
List *i;
foreach (i, sortlist)
{
SortClause *scl = (SortClause *) lfirst (i);
if ( scl->resdom == sortcl->resdom )
break;
}
if ( i == NIL ) /* not in sortlist already */
{
lnext(s) = lcons(sortcl, NIL);
s = lnext(s);
}
else
pfree (sortcl); /* get rid of this */
}
orderlist = lnext(orderlist);
}
if (uniqueFlag)
{
List *i;
if (uniqueFlag[0] == '*')
{
/*
* concatenate all elements from target list that are not
* already in the sortby list
*/
foreach(i, targetlist)
{
TargetEntry *tlelt = (TargetEntry *) lfirst(i);
s = sortlist;
while (s != NIL)
{
SortClause *sortcl = lfirst(s);
if (sortcl->resdom == tlelt->resdom)
break;
s = lnext(s);
}
if (s == NIL)
{
/* not a member of the sortclauses yet */
SortClause *sortcl = makeNode(SortClause);
sortcl->resdom = tlelt->resdom;
sortcl->opoid = any_ordering_op(tlelt->resdom->restype);
sortlist = lappend(sortlist, sortcl);
}
}
}
else
{
TargetEntry *tlelt = NULL;
char *uniqueAttrName = uniqueFlag;
/* only create sort clause with the specified unique attribute */
foreach(i, targetlist)
{
tlelt = (TargetEntry *) lfirst(i);
if (strcmp(tlelt->resdom->resname, uniqueAttrName) == 0)
break;
}
if (i == NIL)
{
elog(WARN, "The field specified in the UNIQUE ON clause is not in the targetlist");
}
s = sortlist;
foreach(s, sortlist)
{
SortClause *sortcl = lfirst(s);
if (sortcl->resdom == tlelt->resdom)
break;
}
if (s == NIL)
{
/* not a member of the sortclauses yet */
SortClause *sortcl = makeNode(SortClause);
sortcl->resdom = tlelt->resdom;
sortcl->opoid = any_ordering_op(tlelt->resdom->restype);
sortlist = lappend(sortlist, sortcl);
}
}
}
return sortlist;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.7 1997/09/08 02:25:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.8 1997/11/25 22:05:55 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include "c.h"
#include "postgres.h" #include "postgres.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "utils/elog.h" #include "utils/elog.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.7 1997/10/25 05:37:07 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.8 1997/11/25 22:06:04 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
#include "utils/lsyscache.h" /* for get_typlen */ #include "utils/lsyscache.h" /* for get_typlen */
#include "nodes/pg_list.h" /* for Lisp support */ #include "nodes/pg_list.h" /* for Lisp support */
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "parser/catalog_utils.h" #include "parser/parse_relation.h"
#include "rewrite/locks.h" #include "rewrite/locks.h"
#include "rewrite/rewriteDefine.h" #include "rewrite/rewriteDefine.h"
#include "rewrite/rewriteRemove.h" #include "rewrite/rewriteRemove.h"
...@@ -107,7 +108,7 @@ InsertRule(char *rulname, ...@@ -107,7 +108,7 @@ InsertRule(char *rulname,
if (evslot == NULL) if (evslot == NULL)
evslot_index = -1; evslot_index = -1;
else else
evslot_index = varattno(eventrel, (char *) evslot); evslot_index = attnameAttNum(eventrel, (char *) evslot);
heap_close(eventrel); heap_close(eventrel);
if (evinstead) if (evinstead)
...@@ -221,8 +222,8 @@ DefineQueryRewrite(RuleStmt *stmt) ...@@ -221,8 +222,8 @@ DefineQueryRewrite(RuleStmt *stmt)
} }
else else
{ {
event_attno = varattno(event_relation, eslot_string); event_attno = attnameAttNum(event_relation, eslot_string);
event_attype = att_typeid(event_relation, event_attno); event_attype = attnumTypeId(event_relation, event_attno);
} }
heap_close(event_relation); heap_close(event_relation);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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