aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/copy.c5
-rw-r--r--src/backend/commands/explain.c33
-rw-r--r--src/backend/commands/indexcmds.c6
-rw-r--r--src/backend/commands/tablecmds.c8
-rw-r--r--src/backend/commands/typecmds.c23
5 files changed, 43 insertions, 32 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 45749ab673a..41586331af0 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.184 2002/12/01 18:14:22 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.185 2002/12/12 15:49:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,6 +35,7 @@
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
+#include "optimizer/planmain.h"
#include "parser/parse_coerce.h"
#include "parser/parse_relation.h"
#include "rewrite/rewriteHandler.h"
@@ -839,6 +840,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
defexprs[num_defaults] = build_column_default(rel, i + 1);
if (defexprs[num_defaults] != NULL)
{
+ fix_opfuncids(defexprs[num_defaults]);
defmap[num_defaults] = i;
num_defaults++;
}
@@ -869,6 +871,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
/* check whether any constraints actually found */
if (node != (Node *) prm)
{
+ fix_opfuncids(node);
constraintexprs[i] = node;
hasConstraints = true;
}
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 0b5efaa319e..c587765bd5a 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.95 2002/12/06 19:28:03 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.96 2002/12/12 15:49:24 tgl Exp $
*
*/
@@ -417,20 +417,27 @@ explain_outNode(StringInfo str,
{
RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid,
es->rtable);
- Expr *expr;
- Func *funcnode;
- Oid funcid;
char *proname;
/* Assert it's on a RangeFunction */
Assert(rte->rtekind == RTE_FUNCTION);
- expr = (Expr *) rte->funcexpr;
- funcnode = (Func *) expr->oper;
- funcid = funcnode->funcid;
-
- /* We only show the func name, not schema name */
- proname = get_func_name(funcid);
+ /*
+ * If the expression is still a function call, we can get
+ * the real name of the function. Otherwise, punt (this
+ * can happen if the optimizer simplified away the function
+ * call, for example).
+ */
+ if (rte->funcexpr && IsA(rte->funcexpr, FuncExpr))
+ {
+ FuncExpr *funcexpr = (FuncExpr *) rte->funcexpr;
+ Oid funcid = funcexpr->funcid;
+
+ /* We only show the func name, not schema name */
+ proname = get_func_name(funcid);
+ }
+ else
+ proname = rte->eref->aliasname;
appendStringInfo(str, " on %s",
quote_identifier(proname));
@@ -583,7 +590,7 @@ explain_outNode(StringInfo str,
appendStringInfo(str, " InitPlan\n");
foreach(lst, plan->initPlan)
{
- SubPlan *subplan = (SubPlan *) lfirst(lst);
+ SubPlanExpr *subplan = (SubPlanExpr *) lfirst(lst);
SubPlanState *subplanstate = (SubPlanState *) lfirst(pslist);
es->rtable = subplan->rtable;
@@ -683,7 +690,7 @@ explain_outNode(StringInfo str,
foreach(lst, planstate->subPlan)
{
SubPlanState *sps = (SubPlanState *) lfirst(lst);
- SubPlan *sp = (SubPlan *) sps->ps.plan;
+ SubPlanExpr *sp = (SubPlanExpr *) sps->ps.plan;
es->rtable = sp->rtable;
for (i = 0; i < indent; i++)
@@ -870,7 +877,7 @@ show_sort_keys(List *tlist, int nkeys, const char *qlabel,
if (target->resdom->reskey == keyno)
{
/* Deparse the expression, showing any top-level cast */
- exprstr = deparse_expression(target->expr, context,
+ exprstr = deparse_expression((Node *) target->expr, context,
useprefix, true);
/* And add to str */
if (keyno > 1)
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 5447780b69e..d6ccdb92613 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.92 2002/10/21 22:06:19 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.93 2002/12/12 15:49:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -159,10 +159,10 @@ DefineIndex(RangeVar *heapRelation,
* While we are at it, we reduce it to a canonical (CNF or DNF) form
* to simplify the task of proving implications.
*/
- if (predicate != NULL && rangetable != NIL)
+ if (predicate)
{
cnfPred = canonicalize_qual((Expr *) copyObject(predicate), true);
- fix_opids((Node *) cnfPred);
+ fix_opfuncids((Node *) cnfPred);
CheckPredicate(cnfPred, rangetable, relationId);
}
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 8da1de580fb..19687737337 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.57 2002/11/23 18:26:45 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.58 2002/12/12 15:49:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2723,7 +2723,7 @@ AlterTableAddCheckConstraint(Relation rel, Constraint *constr)
/*
* We need to make a parse state and range
* table to allow us to transformExpr and
- * fix_opids to get a version of the
+ * fix_opfuncids to get a version of the
* expression we can pass to ExecQual
*/
pstate = make_parsestate(NULL);
@@ -2764,8 +2764,8 @@ AlterTableAddCheckConstraint(Relation rel, Constraint *constr)
*/
expr = eval_const_expressions(expr);
- /* And fix the opids */
- fix_opids(expr);
+ /* And fix the opfuncids */
+ fix_opfuncids(expr);
qual = makeList1(expr);
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index d5260ad1190..e16942acd72 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.21 2002/12/09 20:31:05 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.22 2002/12/12 15:49:24 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -1341,7 +1341,9 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
* the constraint is being added to.
*/
expr = stringToNode(ccbin);
+ fix_opfuncids(expr);
rels = get_rels_with_domain(domainoid);
+
foreach (rt, rels)
{
Relation typrel;
@@ -1522,7 +1524,7 @@ domainPermissionCheck(HeapTuple tup, TypeName *typename)
/*
- *
+ * domainAddConstraint
*/
char *
domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
@@ -1601,21 +1603,20 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
expr = eval_const_expressions(expr);
/*
- * Must fix opids in operator clauses.
+ * Convert to string form for storage.
*/
- fix_opids(expr);
-
ccbin = nodeToString(expr);
/*
- * Deparse it. Since VARNOs aren't allowed in domain
- * constraints, relation context isn't required as anything
- * other than a shell.
+ * Deparse it to produce text for consrc.
+ *
+ * Since VARNOs aren't allowed in domain constraints, relation context
+ * isn't required as anything other than a shell.
*/
ccsrc = deparse_expression(expr,
- deparse_context_for(domainName,
- InvalidOid),
- false, false);
+ deparse_context_for(domainName,
+ InvalidOid),
+ false, false);
/* Write the constraint */
CreateConstraintEntry(constr->name, /* Constraint Name */