Error message editing in backend/optimizer, backend/rewrite.

This commit is contained in:
Tom Lane 2003-07-25 00:01:09 +00:00
parent cfa191f3b8
commit 45708f5ebc
29 changed files with 325 additions and 246 deletions

View File

@ -3,7 +3,7 @@
* geqo_erx.c * geqo_erx.c
* edge recombination crossover [ER] * edge recombination crossover [ER]
* *
* $Id: geqo_erx.c,v 1.17 2002/03/02 21:39:26 momjian Exp $ * $Id: geqo_erx.c,v 1.18 2003/07/25 00:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -333,7 +333,7 @@ gimme_gene(Edge edge, Edge *edge_table)
minimum_count = 1; minimum_count = 1;
} }
else if (minimum_count == -1) else if (minimum_count == -1)
elog(ERROR, "gimme_gene: Internal error - minimum_count not set"); elog(ERROR, "minimum_count not set");
else if (edge_table[(int) friend].unused_edges == minimum_edges) else if (edge_table[(int) friend].unused_edges == minimum_edges)
minimum_count++; minimum_count++;
@ -359,7 +359,7 @@ gimme_gene(Edge edge, Edge *edge_table)
} }
/* ... should never be reached */ /* ... should never be reached */
elog(ERROR, "gimme_gene: neither shared nor minimum number nor random edge found"); elog(ERROR, "neither shared nor minimum number nor random edge found");
return 0; /* to keep the compiler quiet */ return 0; /* to keep the compiler quiet */
} }
@ -419,15 +419,11 @@ edge_failure(Gene *gene, int index, Edge *edge_table, int num_gene)
} }
} }
elog(LOG, "edge_failure(1): no edge found via random decision and total_edges == 4"); elog(LOG, "no edge found via random decision and total_edges == 4");
} }
else if (remaining_edges != 0)
else
/* random decision of the gene with remaining edges */
if (remaining_edges != 0)
{ {
/* random decision of the gene with remaining edges */
rand_decision = (int) geqo_randint(remaining_edges - 1, 0); rand_decision = (int) geqo_randint(remaining_edges - 1, 0);
for (i = 1; i <= num_gene; i++) for (i = 1; i <= num_gene; i++)
@ -444,7 +440,7 @@ edge_failure(Gene *gene, int index, Edge *edge_table, int num_gene)
} }
} }
elog(LOG, "edge_failure(2): no edge found via random decision and remainig edges"); elog(LOG, "no edge found via random decision with remaining edges");
} }
/* /*
@ -462,11 +458,11 @@ edge_failure(Gene *gene, int index, Edge *edge_table, int num_gene)
if (edge_table[i].unused_edges >= 0) if (edge_table[i].unused_edges >= 0)
return (Gene) i; return (Gene) i;
elog(LOG, "edge_failure(3): no edge found via looking for the last ununsed point"); elog(LOG, "no edge found via looking for the last ununsed point");
} }
/* ... should never be reached */ /* ... should never be reached */
elog(ERROR, "edge_failure: no edge detected"); elog(ERROR, "no edge found");
return 0; /* to keep the compiler quiet */ return 0; /* to keep the compiler quiet */
} }

View File

@ -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/optimizer/geqo/geqo_eval.c,v 1.62 2003/05/02 20:54:34 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.63 2003/07/25 00:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -66,7 +66,7 @@ geqo_eval(Query *root, List *initial_rels, Gene *tour, int num_gene)
* Since geqo_eval() will be called many times, we can't afford to let * Since geqo_eval() will be called many times, we can't afford to let
* all that memory go unreclaimed until end of statement. Note we * all that memory go unreclaimed until end of statement. Note we
* make the temp context a child of the planner's normal context, so that * make the temp context a child of the planner's normal context, so that
* it will be freed even if we abort via elog(ERROR). * it will be freed even if we abort via ereport(ERROR).
*/ */
mycontext = AllocSetContextCreate(CurrentMemoryContext, mycontext = AllocSetContextCreate(CurrentMemoryContext,
"GEQO", "GEQO",

View File

@ -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
* *
* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_main.c,v 1.35 2003/05/27 17:49:46 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_main.c,v 1.36 2003/07/25 00:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -120,30 +120,30 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
daddy = alloc_chromo(pool->string_length); daddy = alloc_chromo(pool->string_length);
#if defined (ERX) #if defined (ERX)
elog(DEBUG2, "geqo_main: using edge recombination crossover [ERX]"); elog(DEBUG2, "using edge recombination crossover [ERX]");
/* allocate edge table memory */ /* allocate edge table memory */
edge_table = alloc_edge_table(pool->string_length); edge_table = alloc_edge_table(pool->string_length);
#elif defined(PMX) #elif defined(PMX)
elog(DEBUG2, "geqo_main: using partially matched crossover [PMX]"); elog(DEBUG2, "using partially matched crossover [PMX]");
/* allocate chromosome kid memory */ /* allocate chromosome kid memory */
kid = alloc_chromo(pool->string_length); kid = alloc_chromo(pool->string_length);
#elif defined(CX) #elif defined(CX)
elog(DEBUG2, "geqo_main: using cycle crossover [CX]"); elog(DEBUG2, "using cycle crossover [CX]");
/* allocate city table memory */ /* allocate city table memory */
kid = alloc_chromo(pool->string_length); kid = alloc_chromo(pool->string_length);
city_table = alloc_city_table(pool->string_length); city_table = alloc_city_table(pool->string_length);
#elif defined(PX) #elif defined(PX)
elog(DEBUG2, "geqo_main: using position crossover [PX]"); elog(DEBUG2, "using position crossover [PX]");
/* allocate city table memory */ /* allocate city table memory */
kid = alloc_chromo(pool->string_length); kid = alloc_chromo(pool->string_length);
city_table = alloc_city_table(pool->string_length); city_table = alloc_city_table(pool->string_length);
#elif defined(OX1) #elif defined(OX1)
elog(DEBUG2, "geqo_main: using order crossover [OX1]"); elog(DEBUG2, "using order crossover [OX1]");
/* allocate city table memory */ /* allocate city table memory */
kid = alloc_chromo(pool->string_length); kid = alloc_chromo(pool->string_length);
city_table = alloc_city_table(pool->string_length); city_table = alloc_city_table(pool->string_length);
#elif defined(OX2) #elif defined(OX2)
elog(DEBUG2, "geqo_main: using order crossover [OX2]"); elog(DEBUG2, "using order crossover [OX2]");
/* allocate city table memory */ /* allocate city table memory */
kid = alloc_chromo(pool->string_length); kid = alloc_chromo(pool->string_length);
city_table = alloc_city_table(pool->string_length); city_table = alloc_city_table(pool->string_length);
@ -211,7 +211,7 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
elog(LOG, "[GEQO] failures: %d, average: %d", elog(LOG, "[GEQO] failures: %d, average: %d",
edge_failures, (int) generation / edge_failures); edge_failures, (int) generation / edge_failures);
else else
elog(LOG, "[GEQO] No edge failures detected."); elog(LOG, "[GEQO] no edge failures detected");
#endif #endif
@ -219,7 +219,7 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
if (mutations != 0) if (mutations != 0)
elog(LOG, "[GEQO] mutations: %d, generations: %d", mutations, generation); elog(LOG, "[GEQO] mutations: %d, generations: %d", mutations, generation);
else else
elog(LOG, "[GEQO] No mutations processed."); elog(LOG, "[GEQO] no mutations processed");
#endif #endif
@ -239,7 +239,7 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
best_tour, pool->string_length); best_tour, pool->string_length);
if (best_rel == NULL) if (best_rel == NULL)
elog(ERROR, "geqo: failed to make a valid plan"); elog(ERROR, "failed to make a valid plan");
/* DBG: show the query plan */ /* DBG: show the query plan */
#ifdef NOT_USED #ifdef NOT_USED

View File

@ -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/optimizer/geqo/geqo_misc.c,v 1.36 2002/12/16 21:30:29 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/geqo_misc.c,v 1.37 2003/07/25 00:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -38,7 +38,7 @@ avg_pool(Pool *pool)
double cumulative = 0.0; double cumulative = 0.0;
if (pool->size <= 0) if (pool->size <= 0)
elog(ERROR, "avg_pool: pool_size of zero"); elog(ERROR, "pool_size is zero");
/* /*
* Since the pool may contain multiple occurrences of DBL_MAX, divide * Since the pool may contain multiple occurrences of DBL_MAX, divide

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.103 2003/06/29 23:05:04 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.104 2003/07/25 00:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -209,7 +209,9 @@ set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
* do better? * do better?
*/ */
if (intMember(parentRTindex, root->rowMarks)) if (intMember(parentRTindex, root->rowMarks))
elog(ERROR, "SELECT FOR UPDATE is not supported for inherit queries"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SELECT FOR UPDATE is not supported for inherit queries")));
/* /*
* The executor will check the parent table's access permissions when * The executor will check the parent table's access permissions when
@ -642,7 +644,7 @@ recurse_pushdown_safe(Node *setOp, Query *topquery,
} }
else else
{ {
elog(ERROR, "recurse_pushdown_safe: unexpected node %d", elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(setOp)); (int) nodeTag(setOp));
} }
return true; return true;
@ -839,7 +841,7 @@ recurse_push_qual(Node *setOp, Query *topquery,
} }
else else
{ {
elog(ERROR, "recurse_push_qual: unexpected node %d", elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(setOp)); (int) nodeTag(setOp));
} }
} }

View File

@ -49,7 +49,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/path/costsize.c,v 1.110 2003/07/14 22:35:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.111 2003/07/25 00:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1513,7 +1513,7 @@ cost_qual_eval_walker(Node *node, QualCost *total)
else if (IsA(node, SubLink)) else if (IsA(node, SubLink))
{ {
/* This routine should not be applied to un-planned expressions */ /* This routine should not be applied to un-planned expressions */
elog(ERROR, "cost_qual_eval: can't handle unplanned sub-select"); elog(ERROR, "cannot handle unplanned sub-select");
} }
else if (IsA(node, SubPlan)) else if (IsA(node, SubPlan))
{ {
@ -1805,8 +1805,7 @@ set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
temp = inner_rel->rows; temp = inner_rel->rows;
break; break;
default: default:
elog(ERROR, "set_joinrel_size_estimates: unsupported join type %d", elog(ERROR, "unrecognized join type: %d", (int) jointype);
(int) jointype);
temp = 0; /* keep compiler quiet */ temp = 0; /* keep compiler quiet */
break; break;
} }

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.144 2003/06/15 22:51:45 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.145 2003/07/25 00:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -490,7 +490,7 @@ extract_or_indexqual_conditions(RelOptInfo *rel,
} while (!DoneMatchingIndexKeys(classes)); } while (!DoneMatchingIndexKeys(classes));
if (FastListValue(&quals) == NIL) if (FastListValue(&quals) == NIL)
elog(ERROR, "extract_or_indexqual_conditions: no matching clause"); elog(ERROR, "no matching OR clause");
return FastListValue(&quals); return FastListValue(&quals);
} }
@ -1245,7 +1245,7 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
if (!OidIsValid(test_op)) if (!OidIsValid(test_op))
{ {
/* This should not fail, else pg_amop entry is missing */ /* This should not fail, else pg_amop entry is missing */
elog(ERROR, "Missing pg_amop entry for opclass %u strategy %d", elog(ERROR, "missing pg_amop entry for opclass %u strategy %d",
opclass_id, test_strategy); opclass_id, test_strategy);
} }
@ -1281,7 +1281,7 @@ pred_test_simple_clause(Expr *predicate, Node *clause)
if (isNull) if (isNull)
{ {
/* Treat a null result as false ... but it's a tad fishy ... */ /* Treat a null result as false ... but it's a tad fishy ... */
elog(DEBUG2, "pred_test_simple_clause: null test result"); elog(DEBUG2, "null predicate test result");
return false; return false;
} }
return DatumGetBool(test_result); return DatumGetBool(test_result);
@ -2055,7 +2055,8 @@ prefix_quals(Node *leftop, Oid opclass,
break; break;
default: default:
elog(ERROR, "prefix_quals: unexpected opclass %u", opclass); /* shouldn't get here */
elog(ERROR, "unexpected opclass: %u", opclass);
return NIL; return NIL;
} }
@ -2078,7 +2079,7 @@ prefix_quals(Node *leftop, Oid opclass,
prefix_const->constvalue)); prefix_const->constvalue));
break; break;
default: default:
elog(ERROR, "prefix_quals: unexpected consttype %u", elog(ERROR, "unexpected const type: %u",
prefix_const->consttype); prefix_const->consttype);
return NIL; return NIL;
} }
@ -2093,7 +2094,7 @@ prefix_quals(Node *leftop, Oid opclass,
{ {
oproid = get_opclass_member(opclass, BTEqualStrategyNumber); oproid = get_opclass_member(opclass, BTEqualStrategyNumber);
if (oproid == InvalidOid) if (oproid == InvalidOid)
elog(ERROR, "prefix_quals: no operator = for opclass %u", opclass); elog(ERROR, "no = operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false, expr = make_opclause(oproid, BOOLOID, false,
(Expr *) leftop, (Expr *) prefix_const); (Expr *) leftop, (Expr *) prefix_const);
result = makeList1(expr); result = makeList1(expr);
@ -2107,7 +2108,7 @@ prefix_quals(Node *leftop, Oid opclass,
*/ */
oproid = get_opclass_member(opclass, BTGreaterEqualStrategyNumber); oproid = get_opclass_member(opclass, BTGreaterEqualStrategyNumber);
if (oproid == InvalidOid) if (oproid == InvalidOid)
elog(ERROR, "prefix_quals: no operator >= for opclass %u", opclass); elog(ERROR, "no >= operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false, expr = make_opclause(oproid, BOOLOID, false,
(Expr *) leftop, (Expr *) prefix_const); (Expr *) leftop, (Expr *) prefix_const);
result = makeList1(expr); result = makeList1(expr);
@ -2122,7 +2123,7 @@ prefix_quals(Node *leftop, Oid opclass,
{ {
oproid = get_opclass_member(opclass, BTLessStrategyNumber); oproid = get_opclass_member(opclass, BTLessStrategyNumber);
if (oproid == InvalidOid) if (oproid == InvalidOid)
elog(ERROR, "prefix_quals: no operator < for opclass %u", opclass); elog(ERROR, "no < operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false, expr = make_opclause(oproid, BOOLOID, false,
(Expr *) leftop, (Expr *) greaterstr); (Expr *) leftop, (Expr *) greaterstr);
result = lappend(result, expr); result = lappend(result, expr);
@ -2167,8 +2168,7 @@ network_prefix_quals(Node *leftop, Oid expr_op, Oid opclass, Datum rightop)
is_eq = true; is_eq = true;
break; break;
default: default:
elog(ERROR, "network_prefix_quals: unexpected operator %u", elog(ERROR, "unexpected operator: %u", expr_op);
expr_op);
return NIL; return NIL;
} }
@ -2180,15 +2180,13 @@ network_prefix_quals(Node *leftop, Oid expr_op, Oid opclass, Datum rightop)
{ {
opr1oid = get_opclass_member(opclass, BTGreaterEqualStrategyNumber); opr1oid = get_opclass_member(opclass, BTGreaterEqualStrategyNumber);
if (opr1oid == InvalidOid) if (opr1oid == InvalidOid)
elog(ERROR, "network_prefix_quals: no >= operator for opclass %u", elog(ERROR, "no >= operator for opclass %u", opclass);
opclass);
} }
else else
{ {
opr1oid = get_opclass_member(opclass, BTGreaterStrategyNumber); opr1oid = get_opclass_member(opclass, BTGreaterStrategyNumber);
if (opr1oid == InvalidOid) if (opr1oid == InvalidOid)
elog(ERROR, "network_prefix_quals: no > operator for opclass %u", elog(ERROR, "no > operator for opclass %u", opclass);
opclass);
} }
opr1right = network_scan_first(rightop); opr1right = network_scan_first(rightop);
@ -2203,8 +2201,7 @@ network_prefix_quals(Node *leftop, Oid expr_op, Oid opclass, Datum rightop)
opr2oid = get_opclass_member(opclass, BTLessEqualStrategyNumber); opr2oid = get_opclass_member(opclass, BTLessEqualStrategyNumber);
if (opr2oid == InvalidOid) if (opr2oid == InvalidOid)
elog(ERROR, "network_prefix_quals: no <= operator for opclass %u", elog(ERROR, "no <= operator for opclass %u", opclass);
opclass);
opr2right = network_scan_last(rightop); opr2right = network_scan_last(rightop);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.78 2003/02/08 20:20:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.79 2003/07/25 00:01:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -165,7 +165,7 @@ sort_inner_and_outer(Query *root,
useallclauses = true; useallclauses = true;
break; break;
default: default:
elog(ERROR, "sort_inner_and_outer: unexpected join type %d", elog(ERROR, "unrecognized join type: %d",
(int) jointype); (int) jointype);
useallclauses = false; /* keep compiler quiet */ useallclauses = false; /* keep compiler quiet */
break; break;
@ -363,7 +363,7 @@ match_unsorted_outer(Query *root,
useallclauses = true; useallclauses = true;
break; break;
default: default:
elog(ERROR, "match_unsorted_outer: unexpected join type %d", elog(ERROR, "unrecognized join type: %d",
(int) jointype); (int) jointype);
nestjoinOK = false; /* keep compiler quiet */ nestjoinOK = false; /* keep compiler quiet */
useallclauses = false; useallclauses = false;
@ -815,7 +815,9 @@ select_mergejoin_clauses(RelOptInfo *joinrel,
case JOIN_FULL: case JOIN_FULL:
if (restrictinfo->left_relids == NULL || if (restrictinfo->left_relids == NULL ||
restrictinfo->mergejoinoperator == InvalidOid) restrictinfo->mergejoinoperator == InvalidOid)
elog(ERROR, "FULL JOIN is only supported with mergejoinable join conditions"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("FULL JOIN is only supported with mergejoinable join conditions")));
break; break;
default: default:
/* otherwise, it's OK to have nonmergeable join quals */ /* otherwise, it's OK to have nonmergeable join quals */

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.60 2003/02/08 20:20:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.61 2003/07/25 00:01:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -227,8 +227,7 @@ make_rels_by_joins(Query *root, int level, List **joinrels)
} }
if (result_rels == NIL) if (result_rels == NIL)
elog(ERROR, "make_rels_by_joins: failed to build any %d-way joins", elog(ERROR, "failed to build any %d-way joins", level);
level);
} }
return result_rels; return result_rels;
@ -367,8 +366,8 @@ make_jointree_rel(Query *root, Node *jtnode)
/* Make this join rel */ /* Make this join rel */
rel = make_join_rel(root, lrel, rrel, j->jointype); rel = make_join_rel(root, lrel, rrel, j->jointype);
if (rel == NULL) if (rel == NULL) /* oops */
elog(ERROR, "make_jointree_rel: invalid join order!?"); elog(ERROR, "invalid join order");
/* /*
* Since we are only going to consider this one way to do it, * Since we are only going to consider this one way to do it,
@ -385,8 +384,8 @@ make_jointree_rel(Query *root, Node *jtnode)
return rel; return rel;
} }
else else
elog(ERROR, "make_jointree_rel: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }
@ -571,7 +570,7 @@ make_join_rel(Query *root, RelOptInfo *rel1, RelOptInfo *rel2,
restrictlist); restrictlist);
break; break;
default: default:
elog(ERROR, "make_join_rel: unsupported join type %d", elog(ERROR, "unrecognized join type: %d",
(int) jointype); (int) jointype);
break; break;
} }

View File

@ -11,7 +11,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/path/pathkeys.c,v 1.50 2003/06/29 23:05:04 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.51 2003/07/25 00:01:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1089,7 +1089,7 @@ make_pathkeys_for_mergeclauses(Query *root,
} }
else else
{ {
elog(ERROR, "make_pathkeys_for_mergeclauses: can't identify which side of mergeclause to use"); elog(ERROR, "could not identify which side of mergeclause to use");
pathkey = NIL; /* keep compiler quiet */ pathkey = NIL; /* keep compiler quiet */
} }

View File

@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.148 2003/07/14 22:35:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.149 2003/07/25 00:01:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -155,8 +155,8 @@ create_plan(Query *root, Path *best_path)
(UniquePath *) best_path); (UniquePath *) best_path);
break; break;
default: default:
elog(ERROR, "create_plan: unknown pathtype %d", elog(ERROR, "unrecognized node type: %d",
best_path->pathtype); (int) best_path->pathtype);
plan = NULL; /* keep compiler quiet */ plan = NULL; /* keep compiler quiet */
break; break;
} }
@ -252,8 +252,8 @@ create_scan_plan(Query *root, Path *best_path)
break; break;
default: default:
elog(ERROR, "create_scan_plan: unknown node type: %d", elog(ERROR, "unrecognized node type: %d",
best_path->pathtype); (int) best_path->pathtype);
plan = NULL; /* keep compiler quiet */ plan = NULL; /* keep compiler quiet */
break; break;
} }
@ -384,8 +384,8 @@ create_join_plan(Query *root, JoinPath *best_path)
inner_plan); inner_plan);
break; break;
default: default:
elog(ERROR, "unsupported node type %d", elog(ERROR, "unrecognized node type: %d",
best_path->path.pathtype); (int) best_path->path.pathtype);
plan = NULL; /* keep compiler quiet */ plan = NULL; /* keep compiler quiet */
break; break;
} }
@ -1172,7 +1172,7 @@ fix_indxqual_sublist(List *indexqual,
Oid opclass; Oid opclass;
if (!IsA(clause, OpExpr) || length(clause->args) != 2) if (!IsA(clause, OpExpr) || length(clause->args) != 2)
elog(ERROR, "fix_indxqual_sublist: indexqual clause is not binary opclause"); elog(ERROR, "indexqual clause is not binary opclause");
/* /*
* Make a copy that will become the fixed clause. * Make a copy that will become the fixed clause.
@ -1287,7 +1287,7 @@ fix_indxqual_operand(Node *node, int baserelid, IndexOptInfo *index,
} }
/* Ooops... */ /* Ooops... */
elog(ERROR, "fix_indxqual_operand: node is not index attribute"); elog(ERROR, "node is not an index attribute");
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }
@ -1804,7 +1804,7 @@ make_sort_from_pathkeys(Query *root, Plan *lefttree,
break; break;
} }
if (!j) if (!j)
elog(ERROR, "make_sort_from_pathkeys: cannot find pathkey item to sort"); elog(ERROR, "could not find pathkey item to sort");
/* /*
* Do we need to insert a Result node? * Do we need to insert a Result node?
* *

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.86 2003/06/29 23:05:04 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.87 2003/07/25 00:01:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -97,11 +97,13 @@ add_base_rels_to_query(Query *root, Node *jtnode)
* Safety check: join RTEs should not be SELECT FOR UPDATE targets * Safety check: join RTEs should not be SELECT FOR UPDATE targets
*/ */
if (intMember(j->rtindex, root->rowMarks)) if (intMember(j->rtindex, root->rowMarks))
elog(ERROR, "SELECT FOR UPDATE cannot be applied to a join"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SELECT FOR UPDATE cannot be applied to a join")));
} }
else else
elog(ERROR, "add_base_rels_to_query: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
} }
@ -284,11 +286,12 @@ distribute_quals_to_rels(Query *root, Node *jtnode)
* This is where we fail if upper levels of planner * This is where we fail if upper levels of planner
* haven't rewritten UNION JOIN as an Append ... * haven't rewritten UNION JOIN as an Append ...
*/ */
elog(ERROR, "UNION JOIN is not implemented yet"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("UNION JOIN is not implemented yet")));
break; break;
default: default:
elog(ERROR, elog(ERROR, "unrecognized join type: %d",
"distribute_quals_to_rels: unsupported join type %d",
(int) j->jointype); (int) j->jointype);
break; break;
} }
@ -302,8 +305,8 @@ distribute_quals_to_rels(Query *root, Node *jtnode)
mark_baserels_for_outer_join(root, nullable_rels, result); mark_baserels_for_outer_join(root, nullable_rels, result);
} }
else else
elog(ERROR, "distribute_quals_to_rels: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
return result; return result;
} }
@ -340,7 +343,9 @@ mark_baserels_for_outer_join(Query *root, Relids rels, Relids outerrels)
if (rel->outerjoinset == NULL) if (rel->outerjoinset == NULL)
{ {
if (intMember(relno, root->rowMarks)) if (intMember(relno, root->rowMarks))
elog(ERROR, "SELECT FOR UPDATE cannot be applied to the nullable side of an OUTER JOIN"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SELECT FOR UPDATE cannot be applied to the nullable side of an OUTER JOIN")));
} }
rel->outerjoinset = outerrels; rel->outerjoinset = outerrels;
@ -603,7 +608,7 @@ distribute_qual_to_rels(Query *root, Node *clause,
* 'clause' references no rels, and therefore we have no place to * 'clause' references no rels, and therefore we have no place to
* attach it. Shouldn't get here if callers are working properly. * attach it. Shouldn't get here if callers are working properly.
*/ */
elog(ERROR, "distribute_qual_to_rels: can't cope with variable-free clause"); elog(ERROR, "cannot cope with variable-free clause");
break; break;
} }
@ -745,8 +750,10 @@ process_implied_equality(Query *root,
* we have no suitable equality operator for the combination of * we have no suitable equality operator for the combination of
* datatypes? NO, because sortkey selection may screw up anyway. * datatypes? NO, because sortkey selection may screw up anyway.
*/ */
elog(ERROR, "Unable to identify an equality operator for types '%s' and '%s'", ereport(ERROR,
format_type_be(ltype), format_type_be(rtype)); (errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("unable to identify an equality operator for types %s and %s",
format_type_be(ltype), format_type_be(rtype))));
} }
pgopform = (Form_pg_operator) GETSTRUCT(eq_operator); pgopform = (Form_pg_operator) GETSTRUCT(eq_operator);
@ -756,8 +763,10 @@ process_implied_equality(Query *root,
if (pgopform->oprlsortop != sortop1 || if (pgopform->oprlsortop != sortop1 ||
pgopform->oprrsortop != sortop2 || pgopform->oprrsortop != sortop2 ||
pgopform->oprresult != BOOLOID) pgopform->oprresult != BOOLOID)
elog(ERROR, "Equality operator for types '%s' and '%s' should be mergejoinable, but isn't", ereport(ERROR,
format_type_be(ltype), format_type_be(rtype)); (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("equality operator for types %s and %s should be mergejoinable, but isn't",
format_type_be(ltype), format_type_be(rtype))));
clause = make_opclause(oprid(eq_operator), /* opno */ clause = make_opclause(oprid(eq_operator), /* opno */
BOOLOID, /* opresulttype */ BOOLOID, /* opresulttype */

View File

@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.75 2003/03/10 03:53:50 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.76 2003/07/25 00:01:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -154,7 +154,7 @@ query_planner(Query *root, List *tlist, double tuple_fraction,
final_rel = make_one_rel(root); final_rel = make_one_rel(root);
if (!final_rel || !final_rel->cheapest_total_path) if (!final_rel || !final_rel->cheapest_total_path)
elog(ERROR, "query_planner: failed to construct a relation"); elog(ERROR, "failed to construct the join relation");
/* /*
* Now that we have an estimate of the final rel's size, we can * Now that we have an estimate of the final rel's size, we can

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.156 2003/07/03 19:07:20 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.157 2003/07/25 00:01:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -448,8 +448,8 @@ preprocess_qual_conditions(Query *parse, Node *jtnode)
j->quals = preprocess_expression(parse, j->quals, EXPRKIND_QUAL); j->quals = preprocess_expression(parse, j->quals, EXPRKIND_QUAL);
} }
else else
elog(ERROR, "preprocess_qual_conditions: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
} }
/*-------------------- /*--------------------
@ -582,7 +582,9 @@ grouping_planner(Query *parse, double tuple_fraction)
* already, but let's make sure). * already, but let's make sure).
*/ */
if (parse->rowMarks) if (parse->rowMarks)
elog(ERROR, "SELECT FOR UPDATE is not allowed with UNION/INTERSECT/EXCEPT"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SELECT FOR UPDATE is not allowed with UNION/INTERSECT/EXCEPT")));
/* /*
* We set current_pathkeys NIL indicating we do not know sort * We set current_pathkeys NIL indicating we do not know sort
@ -646,7 +648,9 @@ grouping_planner(Query *parse, double tuple_fraction)
* level * level
*/ */
if (PlannerQueryLevel > 1) if (PlannerQueryLevel > 1)
elog(ERROR, "SELECT FOR UPDATE is not allowed in subselects"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SELECT FOR UPDATE is not allowed in subselects")));
foreach(l, parse->rowMarks) foreach(l, parse->rowMarks)
{ {
@ -1491,7 +1495,7 @@ locate_grouping_columns(Query *parse,
break; break;
} }
if (!sl) if (!sl)
elog(ERROR, "locate_grouping_columns: failed"); elog(ERROR, "failed to locate grouping columns");
groupColIdx[keyno++] = te->resdom->resno; groupColIdx[keyno++] = te->resdom->resno;
} }
@ -1504,7 +1508,7 @@ locate_grouping_columns(Query *parse,
* We need to transpose sort key info from the orig_tlist into new_tlist. * We need to transpose sort key info from the orig_tlist into new_tlist.
* NOTE: this would not be good enough if we supported resjunk sort keys * NOTE: this would not be good enough if we supported resjunk sort keys
* for results of set operations --- then, we'd need to project a whole * for results of set operations --- then, we'd need to project a whole
* new tlist to evaluate the resjunk columns. For now, just elog if we * new tlist to evaluate the resjunk columns. For now, just ereport if we
* find any resjunk columns in orig_tlist. * find any resjunk columns in orig_tlist.
*/ */
static List * static List *
@ -1524,13 +1528,13 @@ postprocess_setop_tlist(List *new_tlist, List *orig_tlist)
Assert(orig_tlist != NIL); Assert(orig_tlist != NIL);
orig_tle = (TargetEntry *) lfirst(orig_tlist); orig_tle = (TargetEntry *) lfirst(orig_tlist);
orig_tlist = lnext(orig_tlist); orig_tlist = lnext(orig_tlist);
if (orig_tle->resdom->resjunk) if (orig_tle->resdom->resjunk) /* should not happen */
elog(ERROR, "postprocess_setop_tlist: resjunk output columns not implemented"); elog(ERROR, "resjunk output columns are not implemented");
Assert(new_tle->resdom->resno == orig_tle->resdom->resno); Assert(new_tle->resdom->resno == orig_tle->resdom->resno);
Assert(new_tle->resdom->restype == orig_tle->resdom->restype); Assert(new_tle->resdom->restype == orig_tle->resdom->restype);
new_tle->resdom->ressortgroupref = orig_tle->resdom->ressortgroupref; new_tle->resdom->ressortgroupref = orig_tle->resdom->ressortgroupref;
} }
if (orig_tlist != NIL) if (orig_tlist != NIL)
elog(ERROR, "postprocess_setop_tlist: resjunk output columns not implemented"); elog(ERROR, "resjunk output columns are not implemented");
return new_tlist; return new_tlist;
} }

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.93 2003/06/29 00:33:43 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.94 2003/07/25 00:01:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -233,8 +233,8 @@ set_plan_references(Plan *plan, List *rtable)
set_plan_references((Plan *) lfirst(pl), rtable); set_plan_references((Plan *) lfirst(pl), rtable);
break; break;
default: default:
elog(ERROR, "set_plan_references: unknown plan type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(plan)); (int) nodeTag(plan));
break; break;
} }
@ -584,7 +584,7 @@ join_references_mutator(Node *node,
return (Node *) copyObject(var); return (Node *) copyObject(var);
/* No referent found for Var */ /* No referent found for Var */
elog(ERROR, "join_references: variable not in subplan target lists"); elog(ERROR, "variable not found in subplan target lists");
} }
/* Try matching more complex expressions too, if tlists have any */ /* Try matching more complex expressions too, if tlists have any */
if (context->tlists_have_non_vars) if (context->tlists_have_non_vars)
@ -680,7 +680,7 @@ replace_vars_with_subplan_refs_mutator(Node *node,
resdom = tlist_member((Node *) var, context->subplan_targetlist); resdom = tlist_member((Node *) var, context->subplan_targetlist);
if (!resdom) if (!resdom)
elog(ERROR, "replace_vars_with_subplan_refs: variable not in subplan target list"); elog(ERROR, "variable not found in subplan target list");
newvar = (Var *) copyObject(var); newvar = (Var *) copyObject(var);
newvar->varno = context->subvarno; newvar->varno = context->subvarno;
newvar->varattno = resdom->resno; newvar->varattno = resdom->resno;

View File

@ -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.78 2003/06/25 21:30:30 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.79 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -359,7 +359,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
Assert(!te->resdom->resjunk); Assert(!te->resdom->resjunk);
arraytype = get_array_type(te->resdom->restype); arraytype = get_array_type(te->resdom->restype);
if (!OidIsValid(arraytype)) if (!OidIsValid(arraytype))
elog(ERROR, "Cannot find array type for datatype %s", elog(ERROR, "could not find array type for datatype %s",
format_type_be(te->resdom->restype)); format_type_be(te->resdom->restype));
prm = generate_new_param(arraytype, -1); prm = generate_new_param(arraytype, -1);
node->setParam = makeListi1(prm->paramid); node->setParam = makeListi1(prm->paramid);
@ -1012,8 +1012,8 @@ finalize_plan(Plan *plan, List *rtable,
break; break;
default: default:
elog(ERROR, "finalize_plan: node %d unsupported", elog(ERROR, "unrecognized node type: %d",
nodeTag(plan)); (int) nodeTag(plan));
} }
/* Process left and right child plans, if any */ /* Process left and right child plans, if any */
@ -1032,7 +1032,7 @@ finalize_plan(Plan *plan, List *rtable,
/* Now we have all the paramids */ /* Now we have all the paramids */
if (!bms_is_subset(context.paramids, valid_params)) if (!bms_is_subset(context.paramids, valid_params))
elog(ERROR, "finalize_plan: plan shouldn't reference subplan's variable"); elog(ERROR, "plan should not reference subplan's variable");
plan->extParam = bms_intersect(context.paramids, outer_params); plan->extParam = bms_intersect(context.paramids, outer_params);
plan->allParam = context.paramids; plan->allParam = context.paramids;

View File

@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.7 2003/03/10 03:53:50 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.8 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -334,17 +334,19 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join)
* This is where we fail if upper levels of planner * This is where we fail if upper levels of planner
* haven't rewritten UNION JOIN as an Append ... * haven't rewritten UNION JOIN as an Append ...
*/ */
elog(ERROR, "UNION JOIN is not implemented yet"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("UNION JOIN is not implemented yet")));
break; break;
default: default:
elog(ERROR, "pull_up_subqueries: unexpected join type %d", elog(ERROR, "unrecognized join type: %d",
j->jointype); (int) j->jointype);
break; break;
} }
} }
else else
elog(ERROR, "pull_up_subqueries: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
return jtnode; return jtnode;
} }
@ -363,7 +365,7 @@ is_simple_subquery(Query *subquery)
subquery->commandType != CMD_SELECT || subquery->commandType != CMD_SELECT ||
subquery->resultRelation != 0 || subquery->resultRelation != 0 ||
subquery->into != NULL) subquery->into != NULL)
elog(ERROR, "is_simple_subquery: subquery is bogus"); elog(ERROR, "subquery is bogus");
/* /*
* Can't currently pull up a query with setops. Maybe after querytree * Can't currently pull up a query with setops. Maybe after querytree
@ -478,8 +480,8 @@ resolvenew_in_jointree(Node *jtnode, int varno, List *subtlist)
*/ */
} }
else else
elog(ERROR, "resolvenew_in_jointree: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
} }
/* /*
@ -524,7 +526,7 @@ reduce_outer_joins(Query *parse)
/* planner.c shouldn't have called me if no outer joins */ /* planner.c shouldn't have called me if no outer joins */
if (state == NULL || !state->contains_outer) if (state == NULL || !state->contains_outer)
elog(ERROR, "reduce_outer_joins: so where are the outer joins?"); elog(ERROR, "so where are the outer joins?");
reduce_outer_joins_pass2((Node *) parse->jointree, state, parse, NULL); reduce_outer_joins_pass2((Node *) parse->jointree, state, parse, NULL);
} }
@ -591,8 +593,8 @@ reduce_outer_joins_pass1(Node *jtnode)
result->sub_states = lappend(result->sub_states, sub_state); result->sub_states = lappend(result->sub_states, sub_state);
} }
else else
elog(ERROR, "reduce_outer_joins_pass1: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
return result; return result;
} }
@ -615,10 +617,10 @@ reduce_outer_joins_pass2(Node *jtnode,
* because it's only called on subtrees marked as contains_outer. * because it's only called on subtrees marked as contains_outer.
*/ */
if (jtnode == NULL) if (jtnode == NULL)
elog(ERROR, "reduce_outer_joins_pass2: reached empty jointree"); elog(ERROR, "reached empty jointree");
if (IsA(jtnode, RangeTblRef)) if (IsA(jtnode, RangeTblRef))
{ {
elog(ERROR, "reduce_outer_joins_pass2: reached base rel"); elog(ERROR, "reached base rel");
} }
else if (IsA(jtnode, FromExpr)) else if (IsA(jtnode, FromExpr))
{ {
@ -735,8 +737,8 @@ reduce_outer_joins_pass2(Node *jtnode,
} }
} }
else else
elog(ERROR, "reduce_outer_joins_pass2: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
} }
/* /*
@ -972,8 +974,8 @@ simplify_jointree(Query *parse, Node *jtnode)
} }
} }
else else
elog(ERROR, "simplify_jointree: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
return jtnode; return jtnode;
} }
@ -1043,8 +1045,8 @@ get_relids_in_jointree(Node *jtnode)
result = bms_join(result, get_relids_in_jointree(j->rarg)); result = bms_join(result, get_relids_in_jointree(j->rarg));
} }
else else
elog(ERROR, "get_relids_in_jointree: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
return result; return result;
} }
@ -1061,7 +1063,7 @@ get_relids_for_join(Query *parse, int joinrelid)
jtnode = find_jointree_node_for_rel((Node *) parse->jointree, joinrelid); jtnode = find_jointree_node_for_rel((Node *) parse->jointree, joinrelid);
if (!jtnode) if (!jtnode)
elog(ERROR, "get_relids_for_join: join node %d not found", joinrelid); elog(ERROR, "could not find join node %d", joinrelid);
return get_relids_in_jointree(jtnode); return get_relids_in_jointree(jtnode);
} }
@ -1108,7 +1110,7 @@ find_jointree_node_for_rel(Node *jtnode, int relid)
return jtnode; return jtnode;
} }
else else
elog(ERROR, "find_jointree_node_for_rel: unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(jtnode)); (int) nodeTag(jtnode));
return NULL; return NULL;
} }

View File

@ -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/optimizer/prep/preptlist.c,v 1.61 2003/05/12 00:17:03 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.62 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -55,7 +55,7 @@ preprocess_targetlist(List *tlist,
RangeTblEntry *rte = rt_fetch(result_relation, range_table); RangeTblEntry *rte = rt_fetch(result_relation, range_table);
if (rte->subquery != NULL || rte->relid == InvalidOid) if (rte->subquery != NULL || rte->relid == InvalidOid)
elog(ERROR, "preprocess_targetlist: subquery cannot be result relation"); elog(ERROR, "subquery cannot be result relation");
} }
/* /*
@ -236,7 +236,8 @@ expand_targetlist(List *tlist, int command_type,
} }
break; break;
default: default:
elog(ERROR, "expand_targetlist: unexpected command_type"); elog(ERROR, "unrecognized command_type: %d",
(int) command_type);
new_expr = NULL; /* keep compiler quiet */ new_expr = NULL; /* keep compiler quiet */
break; break;
} }
@ -266,7 +267,7 @@ expand_targetlist(List *tlist, int command_type,
Resdom *resdom = old_tle->resdom; Resdom *resdom = old_tle->resdom;
if (!resdom->resjunk) if (!resdom->resjunk)
elog(ERROR, "expand_targetlist: targetlist is not sorted correctly"); elog(ERROR, "targetlist is not sorted correctly");
/* Get the resno right, but don't copy unnecessarily */ /* Get the resno right, but don't copy unnecessarily */
if (resdom->resno != attrno) if (resdom->resno != attrno)
{ {

View File

@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.99 2003/07/20 21:56:34 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.100 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -195,7 +195,7 @@ recurse_set_operations(Node *setOp, Query *parse,
} }
else else
{ {
elog(ERROR, "recurse_set_operations: unexpected node %d", elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(setOp)); (int) nodeTag(setOp));
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }
@ -312,7 +312,8 @@ generate_nonunion_plan(SetOperationStmt *op, Query *parse,
cmd = op->all ? SETOPCMD_EXCEPT_ALL : SETOPCMD_EXCEPT; cmd = op->all ? SETOPCMD_EXCEPT_ALL : SETOPCMD_EXCEPT;
break; break;
default: default:
elog(ERROR, "generate_nonunion_plan: bogus operation code"); elog(ERROR, "unrecognized set operation code: %d",
(int) op->op);
cmd = SETOPCMD_INTERSECT; /* keep compiler quiet */ cmd = SETOPCMD_INTERSECT; /* keep compiler quiet */
break; break;
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.146 2003/07/03 19:07:25 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.147 2003/07/25 00:01:08 tgl Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
@ -404,7 +404,9 @@ count_agg_clause_walker(Node *node, int *count)
* nested agg functions are semantically nonsensical. * nested agg functions are semantically nonsensical.
*/ */
if (contain_agg_clause((Node *) ((Aggref *) node)->target)) if (contain_agg_clause((Node *) ((Aggref *) node)->target))
elog(ERROR, "Aggregate function calls may not be nested"); ereport(ERROR,
(errcode(ERRCODE_GROUPING_ERROR),
errmsg("aggregate function calls may not be nested")));
/* /*
* Having checked that, we need not recurse into the argument. * Having checked that, we need not recurse into the argument.
@ -982,14 +984,15 @@ CommuteClause(OpExpr *clause)
Oid opoid; Oid opoid;
Node *temp; Node *temp;
/* Sanity checks: caller is at fault if these fail */
if (!is_opclause(clause) || if (!is_opclause(clause) ||
length(clause->args) != 2) length(clause->args) != 2)
elog(ERROR, "CommuteClause: applied to non-binary-operator clause"); elog(ERROR, "cannot commute non-binary-operator clause");
opoid = get_commutator(clause->opno); opoid = get_commutator(clause->opno);
if (!OidIsValid(opoid)) if (!OidIsValid(opoid))
elog(ERROR, "CommuteClause: no commutator for operator %u", elog(ERROR, "could not find commutator for operator %u",
clause->opno); clause->opno);
/* /*
@ -1346,7 +1349,7 @@ eval_const_expressions_mutator(Node *node, List *active_fns)
/* Else we still need a NOT node */ /* Else we still need a NOT node */
return (Node *) make_notclause(lfirst(args)); return (Node *) make_notclause(lfirst(args));
default: default:
elog(ERROR, "eval_const_expressions: unexpected boolop %d", elog(ERROR, "unrecognized boolop: %d",
(int) expr->boolop); (int) expr->boolop);
break; break;
} }
@ -1357,7 +1360,7 @@ eval_const_expressions_mutator(Node *node, List *active_fns)
* Return a SubPlan unchanged --- too late to do anything * Return a SubPlan unchanged --- too late to do anything
* with it. * with it.
* *
* XXX should we elog() here instead? Probably this routine * XXX should we ereport() here instead? Probably this routine
* should never be invoked after SubPlan creation. * should never be invoked after SubPlan creation.
*/ */
return node; return node;
@ -1610,7 +1613,7 @@ simplify_function(Oid funcid, Oid result_type, List *args,
ObjectIdGetDatum(funcid), ObjectIdGetDatum(funcid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(func_tuple)) if (!HeapTupleIsValid(func_tuple))
elog(ERROR, "Function OID %u does not exist", funcid); elog(ERROR, "cache lookup failed for function %u", funcid);
newexpr = evaluate_function(funcid, result_type, args, func_tuple); newexpr = evaluate_function(funcid, result_type, args, func_tuple);
@ -1794,8 +1797,7 @@ inline_function(Oid funcid, Oid result_type, List *args,
Anum_pg_proc_prosrc, Anum_pg_proc_prosrc,
&isNull); &isNull);
if (isNull) if (isNull)
elog(ERROR, "inline_function: null prosrc for procedure %u", elog(ERROR, "null prosrc for function %u", funcid);
funcid);
src = DatumGetCString(DirectFunctionCall1(textout, tmp)); src = DatumGetCString(DirectFunctionCall1(textout, tmp));
/* /*
@ -1961,9 +1963,9 @@ substitute_actual_parameters_mutator(Node *node,
Param *param = (Param *) node; Param *param = (Param *) node;
if (param->paramkind != PARAM_NUM) if (param->paramkind != PARAM_NUM)
elog(ERROR, "substitute_actual_parameters_mutator: unexpected paramkind"); elog(ERROR, "unexpected paramkind: %d", param->paramkind);
if (param->paramid <= 0 || param->paramid > context->nargs) if (param->paramid <= 0 || param->paramid > context->nargs)
elog(ERROR, "substitute_actual_parameters_mutator: unexpected paramid"); elog(ERROR, "invalid paramid: %d", param->paramid);
/* Count usage of parameter */ /* Count usage of parameter */
context->usecounts[param->paramid - 1]++; context->usecounts[param->paramid - 1]++;
@ -2350,8 +2352,8 @@ expression_tree_walker(Node *node,
} }
break; break;
default: default:
elog(ERROR, "expression_tree_walker: Unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(node)); (int) nodeTag(node));
break; break;
} }
return false; return false;
@ -2816,8 +2818,8 @@ expression_tree_mutator(Node *node,
} }
break; break;
default: default:
elog(ERROR, "expression_tree_mutator: Unexpected node type %d", elog(ERROR, "unrecognized node type: %d",
nodeTag(node)); (int) nodeTag(node));
break; break;
} }
/* can't get here, but keep compiler happy */ /* can't get here, but keep compiler happy */

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.92 2003/07/14 22:35:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.93 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -133,7 +133,7 @@ set_cheapest(RelOptInfo *parent_rel)
Assert(IsA(parent_rel, RelOptInfo)); Assert(IsA(parent_rel, RelOptInfo));
if (pathlist == NIL) if (pathlist == NIL)
elog(ERROR, "Unable to devise a query plan for the given query"); elog(ERROR, "could not devise a query plan for the given query");
cheapest_startup_path = cheapest_total_path = (Path *) lfirst(pathlist); cheapest_startup_path = cheapest_total_path = (Path *) lfirst(pathlist);

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.84 2003/06/29 23:05:04 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.85 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -258,7 +258,7 @@ restriction_selectivity(Query *root,
Int32GetDatum(varRelid))); Int32GetDatum(varRelid)));
if (result < 0.0 || result > 1.0) if (result < 0.0 || result > 1.0)
elog(ERROR, "restriction_selectivity: bad value %f", result); elog(ERROR, "invalid restriction selectivity: %f", result);
return (Selectivity) result; return (Selectivity) result;
} }
@ -293,7 +293,7 @@ join_selectivity(Query *root,
Int16GetDatum(jointype))); Int16GetDatum(jointype)));
if (result < 0.0 || result > 1.0) if (result < 0.0 || result > 1.0)
elog(ERROR, "join_selectivity: bad value %f", result); elog(ERROR, "invalid join selectivity: %f", result);
return (Selectivity) result; return (Selectivity) result;
} }
@ -365,7 +365,7 @@ has_subclass(Oid relationId)
ObjectIdGetDatum(relationId), ObjectIdGetDatum(relationId),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "has_subclass: Relation %u not found", relationId); elog(ERROR, "cache lookup failed for relation %u", relationId);
result = ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass; result = ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass;
ReleaseSysCache(tuple); ReleaseSysCache(tuple);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.49 2003/06/29 23:05:04 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.50 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -55,7 +55,7 @@ build_base_rel(Query *root, int relid)
{ {
rel = (RelOptInfo *) lfirst(rels); rel = (RelOptInfo *) lfirst(rels);
if (relid == rel->relid) if (relid == rel->relid)
elog(ERROR, "build_base_rel: rel already exists"); elog(ERROR, "rel already exists");
} }
/* It should not exist as an "other" rel, either */ /* It should not exist as an "other" rel, either */
@ -63,7 +63,7 @@ build_base_rel(Query *root, int relid)
{ {
rel = (RelOptInfo *) lfirst(rels); rel = (RelOptInfo *) lfirst(rels);
if (relid == rel->relid) if (relid == rel->relid)
elog(ERROR, "build_base_rel: rel already exists as 'other' rel"); elog(ERROR, "rel already exists as \"other\" rel");
} }
/* No existing RelOptInfo for this base rel, so make a new one */ /* No existing RelOptInfo for this base rel, so make a new one */
@ -98,7 +98,7 @@ build_other_rel(Query *root, int relid)
{ {
rel = (RelOptInfo *) lfirst(rels); rel = (RelOptInfo *) lfirst(rels);
if (relid == rel->relid) if (relid == rel->relid)
elog(ERROR, "build_other_rel: rel already exists as base rel"); elog(ERROR, "rel already exists as base rel");
} }
/* No existing RelOptInfo for this other rel, so make a new one */ /* No existing RelOptInfo for this other rel, so make a new one */
@ -165,7 +165,7 @@ make_base_rel(Query *root, int relid)
rel->max_attr = length(rte->eref->colnames); rel->max_attr = length(rte->eref->colnames);
break; break;
default: default:
elog(ERROR, "make_base_rel: unsupported RTE kind %d", elog(ERROR, "unrecognized RTE kind: %d",
(int) rte->rtekind); (int) rte->rtekind);
break; break;
} }
@ -211,7 +211,7 @@ find_base_rel(Query *root, int relid)
return rel; return rel;
} }
elog(ERROR, "find_base_rel: no relation entry for relid %d", relid); elog(ERROR, "no relation entry for relid %d", relid);
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.57 2003/06/29 23:05:05 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.58 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -183,7 +183,7 @@ get_sortgroupclause_tle(SortClause *sortClause,
return tle; return tle;
} }
elog(ERROR, "get_sortgroupclause_tle: ORDER/GROUP BY expression not found in targetlist"); elog(ERROR, "ORDER/GROUP BY expression not found in targetlist");
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.82 2003/01/17 02:01:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.83 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -29,6 +29,7 @@
#include "storage/smgr.h" #include "storage/smgr.h"
#include "utils/acl.h" #include "utils/acl.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h" #include "utils/syscache.h"
@ -97,8 +98,10 @@ InsertRule(char *rulname,
if (HeapTupleIsValid(oldtup)) if (HeapTupleIsValid(oldtup))
{ {
if (!replace) if (!replace)
elog(ERROR, "Attempt to insert rule \"%s\" failed: already exists", ereport(ERROR,
rulname); (errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("rule \"%s\" for relation \"%s\" already exists",
rulname, get_rel_name(eventrel_oid))));
/* /*
* When replacing, we don't need to replace every attribute * When replacing, we don't need to replace every attribute
@ -224,11 +227,15 @@ DefineQueryRewrite(RuleStmt *stmt)
if (query != getInsertSelectQuery(query, NULL)) if (query != getInsertSelectQuery(query, NULL))
continue; continue;
if (query->resultRelation == PRS2_OLD_VARNO) if (query->resultRelation == PRS2_OLD_VARNO)
elog(ERROR, "rule actions on OLD currently not supported" ereport(ERROR,
"\n\tuse views or triggers instead"); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("rule actions on OLD are not implemented"),
errhint("Use views or triggers instead.")));
if (query->resultRelation == PRS2_NEW_VARNO) if (query->resultRelation == PRS2_NEW_VARNO)
elog(ERROR, "rule actions on NEW currently not supported" ereport(ERROR,
"\n\tuse triggers instead"); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("rule actions on NEW are not implemented"),
errhint("Use triggers instead.")));
} }
/* /*
@ -243,29 +250,35 @@ DefineQueryRewrite(RuleStmt *stmt)
* So there cannot be INSTEAD NOTHING, ... * So there cannot be INSTEAD NOTHING, ...
*/ */
if (length(action) == 0) if (length(action) == 0)
{ ereport(ERROR,
elog(ERROR, "instead nothing rules on select currently not supported" (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
"\n\tuse views instead"); errmsg("INSTEAD NOTHING rules on select are not implemented"),
} errhint("Use views instead.")));
/* /*
* ... there cannot be multiple actions, ... * ... there cannot be multiple actions, ...
*/ */
if (length(action) > 1) if (length(action) > 1)
elog(ERROR, "multiple action rules on select currently not supported"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("multiple action rules on select are not implemented")));
/* /*
* ... the one action must be a SELECT, ... * ... the one action must be a SELECT, ...
*/ */
query = (Query *) lfirst(action); query = (Query *) lfirst(action);
if (!is_instead || query->commandType != CMD_SELECT) if (!is_instead || query->commandType != CMD_SELECT)
elog(ERROR, "only instead-select rules currently supported on select"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("only instead-select rules are currently supported on select")));
/* /*
* ... there can be no rule qual, ... * ... there can be no rule qual, ...
*/ */
if (event_qual != NULL) if (event_qual != NULL)
elog(ERROR, "event qualifications not supported for rules on select"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("event qualifications are not implemented for rules on select")));
/* /*
* ... the targetlist of the SELECT action must exactly match the * ... the targetlist of the SELECT action must exactly match the
@ -283,7 +296,9 @@ DefineQueryRewrite(RuleStmt *stmt)
continue; continue;
i++; i++;
if (i > event_relation->rd_att->natts) if (i > event_relation->rd_att->natts)
elog(ERROR, "select rule's target list has too many entries"); ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("select rule's target list has too many entries")));
attr = event_relation->rd_att->attrs[i - 1]; attr = event_relation->rd_att->attrs[i - 1];
attname = NameStr(attr->attname); attname = NameStr(attr->attname);
@ -297,13 +312,19 @@ DefineQueryRewrite(RuleStmt *stmt)
* positions. * positions.
*/ */
if (attr->attisdropped) if (attr->attisdropped)
elog(ERROR, "cannot convert relation containing dropped columns to view"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert relation containing dropped columns to view")));
if (strcmp(resdom->resname, attname) != 0) if (strcmp(resdom->resname, attname) != 0)
elog(ERROR, "select rule's target entry %d has different column name from %s", i, attname); ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("select rule's target entry %d has different column name from \"%s\"", i, attname)));
if (attr->atttypid != resdom->restype) if (attr->atttypid != resdom->restype)
elog(ERROR, "select rule's target entry %d has different type from attribute %s", i, attname); ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("select rule's target entry %d has different type from attribute \"%s\"", i, attname)));
/* /*
* Allow typmods to be different only if one of them is -1, * Allow typmods to be different only if one of them is -1,
@ -314,11 +335,15 @@ DefineQueryRewrite(RuleStmt *stmt)
*/ */
if (attr->atttypmod != resdom->restypmod && if (attr->atttypmod != resdom->restypmod &&
attr->atttypmod != -1 && resdom->restypmod != -1) attr->atttypmod != -1 && resdom->restypmod != -1)
elog(ERROR, "select rule's target entry %d has different size from attribute %s", i, attname); ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("select rule's target entry %d has different size from attribute \"%s\"", i, attname)));
} }
if (i != event_relation->rd_att->natts) if (i != event_relation->rd_att->natts)
elog(ERROR, "select rule's target list has too few entries"); ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("select rule's target list has too few entries")));
/* /*
* ... there must not be another ON SELECT rule already ... * ... there must not be another ON SELECT rule already ...
@ -331,8 +356,10 @@ DefineQueryRewrite(RuleStmt *stmt)
rule = event_relation->rd_rules->rules[i]; rule = event_relation->rd_rules->rules[i];
if (rule->event == CMD_SELECT) if (rule->event == CMD_SELECT)
elog(ERROR, "\"%s\" is already a view", ereport(ERROR,
RelationGetRelationName(event_relation)); (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("\"%s\" is already a view",
RelationGetRelationName(event_relation))));
} }
} }
@ -353,8 +380,10 @@ DefineQueryRewrite(RuleStmt *stmt)
if (strncmp(stmt->rulename, "_RET", 4) != 0 || if (strncmp(stmt->rulename, "_RET", 4) != 0 ||
strncmp(stmt->rulename + 4, event_obj->relname, strncmp(stmt->rulename + 4, event_obj->relname,
NAMEDATALEN - 4 - 4) != 0) NAMEDATALEN - 4 - 4) != 0)
elog(ERROR, "view rule for \"%s\" must be named \"%s\"", ereport(ERROR,
event_obj->relname, ViewSelectRuleName); (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("view rule for \"%s\" must be named \"%s\"",
event_obj->relname, ViewSelectRuleName)));
stmt->rulename = pstrdup(ViewSelectRuleName); stmt->rulename = pstrdup(ViewSelectRuleName);
} }
@ -370,8 +399,10 @@ DefineQueryRewrite(RuleStmt *stmt)
scanDesc = heap_beginscan(event_relation, SnapshotNow, 0, NULL); scanDesc = heap_beginscan(event_relation, SnapshotNow, 0, NULL);
if (heap_getnext(scanDesc, ForwardScanDirection) != NULL) if (heap_getnext(scanDesc, ForwardScanDirection) != NULL)
elog(ERROR, "Relation \"%s\" is not empty. Cannot convert it to view", ereport(ERROR,
event_obj->relname); (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot convert non-empty table \"%s\" to a view",
event_obj->relname)));
heap_endscan(scanDesc); heap_endscan(scanDesc);
RelisBecomingView = true; RelisBecomingView = true;
@ -509,12 +540,17 @@ RenameRewriteRule(Oid owningRel, const char *oldName,
PointerGetDatum(oldName), PointerGetDatum(oldName),
0, 0); 0, 0);
if (!HeapTupleIsValid(ruletup)) if (!HeapTupleIsValid(ruletup))
elog(ERROR, "RenameRewriteRule: rule \"%s\" does not exist", oldName); ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("rule \"%s\" for relation \"%s\" does not exist",
oldName, get_rel_name(owningRel))));
/* should not already exist */ /* should not already exist */
if (IsDefinedRewriteRule(owningRel, newName)) if (IsDefinedRewriteRule(owningRel, newName))
elog(ERROR, "Attempt to rename rule \"%s\" failed: \"%s\" already exists", ereport(ERROR,
oldName, newName); (errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("rule \"%s\" for relation \"%s\" already exists",
newName, get_rel_name(owningRel))));
namestrcpy(&(((Form_pg_rewrite) GETSTRUCT(ruletup))->rulename), newName); namestrcpy(&(((Form_pg_rewrite) GETSTRUCT(ruletup))->rulename), newName);

View File

@ -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/rewrite/rewriteHandler.c,v 1.123 2003/07/16 17:25:48 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.124 2003/07/25 00:01:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -168,7 +168,9 @@ rewriteRuleAction(Query *parsetree,
* member statements of the setop?) * member statements of the setop?)
*/ */
if (sub_action->setOperations != NULL) if (sub_action->setOperations != NULL)
elog(ERROR, "Conditional UNION/INTERSECT/EXCEPT statements are not implemented"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
sub_action->jointree->fromlist = sub_action->jointree->fromlist =
nconc(newjointree, sub_action->jointree->fromlist); nconc(newjointree, sub_action->jointree->fromlist);
@ -407,8 +409,7 @@ rewriteTargetList(Query *parsetree, Relation target_relation)
{ {
/* Let's just make sure we processed all the non-junk items */ /* Let's just make sure we processed all the non-junk items */
if (resdom->resno < 1 || resdom->resno > numattrs) if (resdom->resno < 1 || resdom->resno > numattrs)
elog(ERROR, "rewriteTargetList: bogus resno %d in targetlist", elog(ERROR, "bogus resno %d in targetlist", resdom->resno);
resdom->resno);
} }
} }
@ -449,8 +450,10 @@ process_matched_tle(TargetEntry *src_tle,
((ArrayRef *) prior_tle->expr)->refassgnexpr == NULL || ((ArrayRef *) prior_tle->expr)->refassgnexpr == NULL ||
((ArrayRef *) src_tle->expr)->refrestype != ((ArrayRef *) src_tle->expr)->refrestype !=
((ArrayRef *) prior_tle->expr)->refrestype) ((ArrayRef *) prior_tle->expr)->refrestype)
elog(ERROR, "Multiple assignments to same attribute \"%s\"", ereport(ERROR,
resdom->resname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("multiple assignments to same attribute \"%s\"",
resdom->resname)));
/* /*
* Prior TLE could be a nest of ArrayRefs if we do this more than * Prior TLE could be a nest of ArrayRefs if we do this more than
@ -461,8 +464,10 @@ process_matched_tle(TargetEntry *src_tle,
((ArrayRef *) priorbottom)->refassgnexpr != NULL) ((ArrayRef *) priorbottom)->refassgnexpr != NULL)
priorbottom = (Node *) ((ArrayRef *) priorbottom)->refexpr; priorbottom = (Node *) ((ArrayRef *) priorbottom)->refexpr;
if (!equal(priorbottom, ((ArrayRef *) src_tle->expr)->refexpr)) if (!equal(priorbottom, ((ArrayRef *) src_tle->expr)->refexpr))
elog(ERROR, "Multiple assignments to same attribute \"%s\"", ereport(ERROR,
resdom->resname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("multiple assignments to same attribute \"%s\"",
resdom->resname)));
/* /*
* Looks OK to nest 'em. * Looks OK to nest 'em.
@ -550,12 +555,14 @@ build_column_default(Relation rel, int attrno)
* type when it was created ... * type when it was created ...
*/ */
if (expr == NULL) if (expr == NULL)
elog(ERROR, "Column \"%s\" is of type %s" ereport(ERROR,
" but default expression is of type %s" (errcode(ERRCODE_DATATYPE_MISMATCH),
"\n\tYou will need to rewrite or cast the expression", errmsg("column \"%s\" is of type %s"
NameStr(att_tup->attname), " but default expression is of type %s",
format_type_be(atttype), NameStr(att_tup->attname),
format_type_be(exprtype)); format_type_be(atttype),
format_type_be(exprtype)),
errhint("You will need to rewrite or cast the expression.")));
return expr; return expr;
} }
@ -619,11 +626,11 @@ ApplyRetrieveRule(Query *parsetree,
*subrte; *subrte;
if (length(rule->actions) != 1) if (length(rule->actions) != 1)
elog(ERROR, "ApplyRetrieveRule: expected just one rule action"); elog(ERROR, "expected just one rule action");
if (rule->qual != NULL) if (rule->qual != NULL)
elog(ERROR, "ApplyRetrieveRule: can't handle qualified ON SELECT rule"); elog(ERROR, "cannot handle qualified ON SELECT rule");
if (!relation_level) if (!relation_level)
elog(ERROR, "ApplyRetrieveRule: can't handle per-attribute ON SELECT rule"); elog(ERROR, "cannot handle per-attribute ON SELECT rule");
/* /*
* Make a modifiable copy of the view query, and recursively expand * Make a modifiable copy of the view query, and recursively expand
@ -872,8 +879,10 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
List *l; List *l;
if (oidMember(RelationGetRelid(rel), activeRIRs)) if (oidMember(RelationGetRelid(rel), activeRIRs))
elog(ERROR, "Infinite recursion detected in rules for relation %s", ereport(ERROR,
RelationGetRelationName(rel)); (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("infinite recursion detected in rules for relation \"%s\"",
RelationGetRelationName(rel))));
newActiveRIRs = lconso(RelationGetRelid(rel), activeRIRs); newActiveRIRs = lconso(RelationGetRelid(rel), activeRIRs);
foreach(l, locks) foreach(l, locks)
@ -913,7 +922,7 @@ fireRIRrules(Query *parsetree, List *activeRIRs)
parsetree->hasAggs = checkExprHasAggs((Node *) parsetree); parsetree->hasAggs = checkExprHasAggs((Node *) parsetree);
if (parsetree->hasAggs) if (parsetree->hasAggs)
if (checkExprHasAggs((Node *) parsetree->jointree)) if (checkExprHasAggs((Node *) parsetree->jointree))
elog(ERROR, "fireRIRrules: failed to remove aggs from qual"); elog(ERROR, "failed to remove aggregates from qual");
} }
if (parsetree->hasSubLinks) if (parsetree->hasSubLinks)
parsetree->hasSubLinks = checkExprHasSubLink((Node *) parsetree); parsetree->hasSubLinks = checkExprHasSubLink((Node *) parsetree);
@ -1151,8 +1160,10 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
rev = (rewrite_event *) lfirst(n); rev = (rewrite_event *) lfirst(n);
if (rev->relation == RelationGetRelid(rt_entry_relation) && if (rev->relation == RelationGetRelid(rt_entry_relation) &&
rev->event == event) rev->event == event)
elog(ERROR, "Infinite recursion detected in rules for relation %s", ereport(ERROR,
RelationGetRelationName(rt_entry_relation)); (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("infinite recursion detected in rules for relation \"%s\"",
RelationGetRelationName(rt_entry_relation))));
} }
rev = (rewrite_event *) palloc(sizeof(rewrite_event)); rev = (rewrite_event *) palloc(sizeof(rewrite_event));
@ -1259,19 +1270,25 @@ QueryRewrite(Query *parsetree)
switch (query->commandType) switch (query->commandType)
{ {
case CMD_INSERT: case CMD_INSERT:
elog(ERROR, "Cannot insert into a view" ereport(ERROR,
"\n\tYou need an unconditional ON INSERT DO INSTEAD rule"); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot insert into a view"),
errhint("You need an unconditional ON INSERT DO INSTEAD rule.")));
break; break;
case CMD_UPDATE: case CMD_UPDATE:
elog(ERROR, "Cannot update a view" ereport(ERROR,
"\n\tYou need an unconditional ON UPDATE DO INSTEAD rule"); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot update a view"),
errhint("You need an unconditional ON UPDATE DO INSTEAD rule.")));
break; break;
case CMD_DELETE: case CMD_DELETE:
elog(ERROR, "Cannot delete from a view" ereport(ERROR,
"\n\tYou need an unconditional ON DELETE DO INSTEAD rule"); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot delete from a view"),
errhint("You need an unconditional ON DELETE DO INSTEAD rule.")));
break; break;
default: default:
elog(ERROR, "QueryRewrite: unexpected commandType %d", elog(ERROR, "unrecognized commandType: %d",
(int) query->commandType); (int) query->commandType);
break; break;
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.73 2003/07/16 17:25:48 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.74 2003/07/25 00:01:09 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -678,14 +678,14 @@ getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
return parsetree; return parsetree;
Assert(parsetree->jointree && IsA(parsetree->jointree, FromExpr)); Assert(parsetree->jointree && IsA(parsetree->jointree, FromExpr));
if (length(parsetree->jointree->fromlist) != 1) if (length(parsetree->jointree->fromlist) != 1)
elog(ERROR, "getInsertSelectQuery: expected to find SELECT subquery"); elog(ERROR, "expected to find SELECT subquery");
rtr = (RangeTblRef *) lfirst(parsetree->jointree->fromlist); rtr = (RangeTblRef *) lfirst(parsetree->jointree->fromlist);
Assert(IsA(rtr, RangeTblRef)); Assert(IsA(rtr, RangeTblRef));
selectrte = rt_fetch(rtr->rtindex, parsetree->rtable); selectrte = rt_fetch(rtr->rtindex, parsetree->rtable);
selectquery = selectrte->subquery; selectquery = selectrte->subquery;
if (!(selectquery && IsA(selectquery, Query) && if (!(selectquery && IsA(selectquery, Query) &&
selectquery->commandType == CMD_SELECT)) selectquery->commandType == CMD_SELECT))
elog(ERROR, "getInsertSelectQuery: expected to find SELECT subquery"); elog(ERROR, "expected to find SELECT subquery");
if (length(selectquery->rtable) >= 2 && if (length(selectquery->rtable) >= 2 &&
strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->aliasname, strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->aliasname,
"*OLD*") == 0 && "*OLD*") == 0 &&
@ -696,7 +696,7 @@ getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
*subquery_ptr = &(selectrte->subquery); *subquery_ptr = &(selectrte->subquery);
return selectquery; return selectquery;
} }
elog(ERROR, "getInsertSelectQuery: can't find rule placeholders"); elog(ERROR, "could not find rule placeholders");
return NULL; /* not reached */ return NULL; /* not reached */
} }
@ -730,7 +730,9 @@ AddQual(Query *parsetree, Node *qual)
if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt)) if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt))
return; return;
else else
elog(ERROR, "Conditional utility statements are not implemented"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conditional utility statements are not implemented")));
} }
if (parsetree->setOperations != NULL) if (parsetree->setOperations != NULL)
@ -740,7 +742,9 @@ AddQual(Query *parsetree, Node *qual)
* (This could be fixed, but right now the planner simply ignores * (This could be fixed, but right now the planner simply ignores
* any qual condition on a setop query.) * any qual condition on a setop query.)
*/ */
elog(ERROR, "Conditional UNION/INTERSECT/EXCEPT statements are not implemented"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
} }
/* INTERSECT want's the original, but we need to copy - Jan */ /* INTERSECT want's the original, but we need to copy - Jan */
@ -780,7 +784,9 @@ AddHavingQual(Query *parsetree, Node *havingQual)
if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt)) if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt))
return; return;
else else
elog(ERROR, "Conditional utility statements are not implemented"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conditional utility statements are not implemented")));
} }
if (parsetree->setOperations != NULL) if (parsetree->setOperations != NULL)
@ -790,7 +796,9 @@ AddHavingQual(Query *parsetree, Node *havingQual)
* (This could be fixed, but right now the planner simply ignores * (This could be fixed, but right now the planner simply ignores
* any qual condition on a setop query.) * any qual condition on a setop query.)
*/ */
elog(ERROR, "Conditional UNION/INTERSECT/EXCEPT statements are not implemented"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
} }
/* INTERSECT want's the original, but we need to copy - Jan */ /* INTERSECT want's the original, but we need to copy - Jan */
@ -905,7 +913,9 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context)
/* band-aid: don't do the wrong thing with a whole-tuple Var */ /* band-aid: don't do the wrong thing with a whole-tuple Var */
if (var->varattno == InvalidAttrNumber) if (var->varattno == InvalidAttrNumber)
elog(ERROR, "ResolveNew: can't handle whole-tuple reference"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot handle whole-tuple reference")));
n = FindMatchingNew(context->targetlist, var->varattno); n = FindMatchingNew(context->targetlist, var->varattno);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.53 2002/09/04 20:31:25 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.54 2003/07/25 00:01:09 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -54,7 +54,10 @@ RemoveRewriteRule(Oid owningRel, const char *ruleName, DropBehavior behavior)
* complain if no rule with such name exists * complain if no rule with such name exists
*/ */
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "Rule \"%s\" not found", ruleName); ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("rule \"%s\" for relation \"%s\" does not exist",
ruleName, get_rel_name(owningRel))));
/* /*
* Verify user has appropriate permissions. * Verify user has appropriate permissions.
@ -110,8 +113,7 @@ RemoveRewriteRuleById(Oid ruleOid)
tuple = systable_getnext(rcscan); tuple = systable_getnext(rcscan);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "RemoveRewriteRuleById: Rule %u does not exist", elog(ERROR, "could not find tuple for rule %u", ruleOid);
ruleOid);
/* /*
* We had better grab AccessExclusiveLock so that we know no other * We had better grab AccessExclusiveLock so that we know no other

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.54 2002/08/05 03:29:17 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.55 2003/07/25 00:01:09 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -65,7 +65,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules,
ObjectIdGetDatum(relationId), ObjectIdGetDatum(relationId),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "SetRelationRuleStatus: cache lookup failed for relation %u", relationId); elog(ERROR, "cache lookup failed for relation %u", relationId);
classForm = (Form_pg_class) GETSTRUCT(tuple); classForm = (Form_pg_class) GETSTRUCT(tuple);
if (classForm->relhasrules != relHasRules || if (classForm->relhasrules != relHasRules ||