mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Another round of error message editing, covering backend/parser/.
This commit is contained in:
parent
0230380666
commit
a56ff9a0bd
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.280 2003/07/18 23:20:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.281 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -357,7 +357,9 @@ transformStmt(ParseState *pstate, Node *parseTree,
|
||||
}
|
||||
|
||||
if (aliaslist != NIL)
|
||||
elog(ERROR, "CREATE VIEW specifies more column names than columns");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("CREATE VIEW specifies more column names than columns")));
|
||||
}
|
||||
result = makeNode(Query);
|
||||
result->commandType = CMD_UTILITY;
|
||||
@ -565,7 +567,9 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
|
||||
Assert(IsA(selectQuery, Query));
|
||||
Assert(selectQuery->commandType == CMD_SELECT);
|
||||
if (selectQuery->into)
|
||||
elog(ERROR, "INSERT ... SELECT may not specify INTO");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("INSERT ... SELECT may not specify INTO")));
|
||||
|
||||
/*
|
||||
* Make the source be a subquery in the INSERT's rangetable, and
|
||||
@ -655,7 +659,9 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
|
||||
tl = lnext(tl);
|
||||
|
||||
if (icolumns == NIL || attnos == NIL)
|
||||
elog(ERROR, "INSERT has more expressions than target columns");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("INSERT has more expressions than target columns")));
|
||||
|
||||
col = (ResTarget *) lfirst(icolumns);
|
||||
Assert(IsA(col, ResTarget));
|
||||
@ -675,7 +681,9 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
|
||||
* statements.
|
||||
*/
|
||||
if (stmt->cols != NIL && (icolumns != NIL || attnos != NIL))
|
||||
elog(ERROR, "INSERT has more target columns than expressions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("INSERT has more target columns than expressions")));
|
||||
|
||||
/* done building the range table and jointree */
|
||||
qry->rtable = pstate->p_rtable;
|
||||
@ -876,7 +884,9 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt,
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "parser: unrecognized node (internal error)");
|
||||
elog(ERROR, "unrecognized node type: %d",
|
||||
(int) nodeTag(element));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -958,8 +968,10 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
||||
sname = makeObjectName(cxt->relation->relname, column->colname, "seq");
|
||||
snamespace = get_namespace_name(RangeVarGetCreationNamespace(cxt->relation));
|
||||
|
||||
elog(NOTICE, "%s will create implicit sequence '%s' for SERIAL column '%s.%s'",
|
||||
cxt->stmtType, sname, cxt->relation->relname, column->colname);
|
||||
ereport(NOTICE,
|
||||
(errmsg("%s will create implicit sequence \"%s\" for SERIAL column \"%s.%s\"",
|
||||
cxt->stmtType, sname,
|
||||
cxt->relation->relname, column->colname)));
|
||||
|
||||
/*
|
||||
* Build a CREATE SEQUENCE command to create the sequence object,
|
||||
@ -1039,24 +1051,30 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
||||
{
|
||||
case CONSTR_NULL:
|
||||
if (saw_nullable && column->is_not_null)
|
||||
elog(ERROR, "%s/(NOT) NULL conflicting declaration for '%s.%s'",
|
||||
cxt->stmtType, cxt->relation->relname, column->colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting NULL/NOT NULL declarations for \"%s.%s\"",
|
||||
cxt->relation->relname, column->colname)));
|
||||
column->is_not_null = FALSE;
|
||||
saw_nullable = true;
|
||||
break;
|
||||
|
||||
case CONSTR_NOTNULL:
|
||||
if (saw_nullable && !column->is_not_null)
|
||||
elog(ERROR, "%s/(NOT) NULL conflicting declaration for '%s.%s'",
|
||||
cxt->stmtType, cxt->relation->relname, column->colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting NULL/NOT NULL declarations for \"%s.%s\"",
|
||||
cxt->relation->relname, column->colname)));
|
||||
column->is_not_null = TRUE;
|
||||
saw_nullable = true;
|
||||
break;
|
||||
|
||||
case CONSTR_DEFAULT:
|
||||
if (column->raw_default != NULL)
|
||||
elog(ERROR, "%s/DEFAULT multiple values specified for '%s.%s'",
|
||||
cxt->stmtType, cxt->relation->relname, column->colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple DEFAULT values specified for \"%s.%s\"",
|
||||
cxt->relation->relname, column->colname)));
|
||||
column->raw_default = constraint->raw_expr;
|
||||
Assert(constraint->cooked_expr == NULL);
|
||||
break;
|
||||
@ -1097,7 +1115,8 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "parser: unrecognized constraint (internal error)");
|
||||
elog(ERROR, "unrecognized constraint type: %d",
|
||||
constraint->contype);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1132,11 +1151,13 @@ transformTableConstraint(ParseState *pstate, CreateStmtContext *cxt,
|
||||
case CONSTR_ATTR_NOT_DEFERRABLE:
|
||||
case CONSTR_ATTR_DEFERRED:
|
||||
case CONSTR_ATTR_IMMEDIATE:
|
||||
elog(ERROR, "parser: illegal context for constraint (internal error)");
|
||||
elog(ERROR, "illegal context for constraint type %d",
|
||||
constraint->contype);
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "parser: unrecognized constraint (internal error)");
|
||||
elog(ERROR, "unrecognized constraint type: %d",
|
||||
constraint->contype);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1161,8 +1182,10 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
|
||||
relation = heap_openrv(inhRelation->relation, AccessShareLock);
|
||||
|
||||
if (relation->rd_rel->relkind != RELKIND_RELATION)
|
||||
elog(ERROR, "CREATE TABLE: inherited relation \"%s\" is not a table",
|
||||
inhRelation->relation->relname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("inherited relation \"%s\" is not a table",
|
||||
inhRelation->relation->relname)));
|
||||
|
||||
/*
|
||||
* Check for SELECT privilages
|
||||
@ -1293,9 +1316,10 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
|
||||
if (cxt->pkey != NULL ||
|
||||
(OidIsValid(cxt->relOid) &&
|
||||
relationHasPrimaryKey(cxt->relOid)))
|
||||
elog(ERROR, "%s / PRIMARY KEY multiple primary keys"
|
||||
" for table '%s' are not allowed",
|
||||
cxt->stmtType, cxt->relation->relname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
||||
errmsg("multiple primary keys for table \"%s\" are not allowed",
|
||||
cxt->relation->relname)));
|
||||
cxt->pkey = index;
|
||||
}
|
||||
index->isconstraint = true;
|
||||
@ -1363,8 +1387,10 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
|
||||
Assert(IsA(inh, RangeVar));
|
||||
rel = heap_openrv(inh, AccessShareLock);
|
||||
if (rel->rd_rel->relkind != RELKIND_RELATION)
|
||||
elog(ERROR, "inherited table \"%s\" is not a relation",
|
||||
inh->relname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("inherited table \"%s\" is not a relation",
|
||||
inh->relname)));
|
||||
for (count = 0; count < rel->rd_att->natts; count++)
|
||||
{
|
||||
Form_pg_attribute inhattr = rel->rd_att->attrs[count];
|
||||
@ -1407,17 +1433,22 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
|
||||
}
|
||||
|
||||
if (!found)
|
||||
elog(ERROR, "%s: column \"%s\" named in key does not exist",
|
||||
cxt->stmtType, key);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("column \"%s\" named in key does not exist",
|
||||
key)));
|
||||
|
||||
/* Check for PRIMARY KEY(foo, foo) */
|
||||
foreach(columns, index->indexParams)
|
||||
{
|
||||
iparam = (IndexElem *) lfirst(columns);
|
||||
if (iparam->name && strcmp(key, iparam->name) == 0)
|
||||
elog(ERROR, "%s: column \"%s\" appears twice in %s constraint",
|
||||
cxt->stmtType, key,
|
||||
index->primary ? "PRIMARY KEY" : "UNIQUE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_COLUMN),
|
||||
/* translator: second %s is PRIMARY KEY or UNIQUE */
|
||||
errmsg("column \"%s\" appears twice in %s constraint",
|
||||
key,
|
||||
index->primary ? "PRIMARY KEY" : "UNIQUE")));
|
||||
}
|
||||
|
||||
/* OK, add it to the index definition */
|
||||
@ -1506,14 +1537,14 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
|
||||
cxt->alist);
|
||||
}
|
||||
if (index->idxname == NULL) /* should not happen */
|
||||
elog(ERROR, "%s: failed to make implicit index name",
|
||||
cxt->stmtType);
|
||||
elog(ERROR, "failed to make implicit index name");
|
||||
|
||||
elog(NOTICE, "%s / %s%s will create implicit index '%s' for table '%s'",
|
||||
cxt->stmtType,
|
||||
(strcmp(cxt->stmtType, "ALTER TABLE") == 0) ? "ADD " : "",
|
||||
(index->primary ? "PRIMARY KEY" : "UNIQUE"),
|
||||
index->idxname, cxt->relation->relname);
|
||||
ereport(NOTICE,
|
||||
(errmsg("%s / %s%s will create implicit index \"%s\" for table \"%s\"",
|
||||
cxt->stmtType,
|
||||
(strcmp(cxt->stmtType, "ALTER TABLE") == 0) ? "ADD " : "",
|
||||
(index->primary ? "PRIMARY KEY" : "UNIQUE"),
|
||||
index->idxname, cxt->relation->relname)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1524,8 +1555,9 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt,
|
||||
if (cxt->fkconstraints == NIL)
|
||||
return;
|
||||
|
||||
elog(NOTICE, "%s will create implicit trigger(s) for FOREIGN KEY check(s)",
|
||||
cxt->stmtType);
|
||||
ereport(NOTICE,
|
||||
(errmsg("%s will create implicit trigger(s) for FOREIGN KEY check(s)",
|
||||
cxt->stmtType)));
|
||||
|
||||
/*
|
||||
* For ALTER TABLE ADD CONSTRAINT, nothing to do. For CREATE TABLE or
|
||||
@ -1614,7 +1646,9 @@ transformIndexStmt(ParseState *pstate, IndexStmt *stmt)
|
||||
* the predicate. DefineIndex() will make more checks.
|
||||
*/
|
||||
if (expression_returns_set(ielem->expr))
|
||||
elog(ERROR, "index expression may not return a set");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("index expression may not return a set")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1694,7 +1728,7 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
|
||||
addRTEtoQuery(pstate, oldrte, false, true);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "transformRuleStmt: unexpected event type %d",
|
||||
elog(ERROR, "unrecognized event type: %d",
|
||||
(int) stmt->event);
|
||||
break;
|
||||
}
|
||||
@ -1704,11 +1738,15 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
|
||||
"WHERE");
|
||||
|
||||
if (length(pstate->p_rtable) != 2) /* naughty, naughty... */
|
||||
elog(ERROR, "Rule WHERE condition may not contain references to other relations");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("rule WHERE condition may not contain references to other relations")));
|
||||
|
||||
/* aggregates not allowed (but subselects are okay) */
|
||||
if (pstate->p_hasAggs)
|
||||
elog(ERROR, "Rule WHERE condition may not contain aggregate functions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("rule WHERE condition may not contain aggregate functions")));
|
||||
|
||||
/* save info about sublinks in where clause */
|
||||
qry->hasSubLinks = pstate->p_hasSubLinks;
|
||||
@ -1777,7 +1815,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
|
||||
*/
|
||||
if (top_subqry->commandType == CMD_UTILITY &&
|
||||
stmt->whereClause != NULL)
|
||||
elog(ERROR, "Rules with WHERE conditions may only have SELECT, INSERT, UPDATE, or DELETE actions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("rules with WHERE conditions may only have SELECT, INSERT, UPDATE, or DELETE actions")));
|
||||
|
||||
/*
|
||||
* If the action is INSERT...SELECT, OLD/NEW have been pushed
|
||||
@ -1794,7 +1834,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
|
||||
* such a rule immediately.
|
||||
*/
|
||||
if (sub_qry->setOperations != NULL && stmt->whereClause != 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")));
|
||||
|
||||
/*
|
||||
* Validate action's use of OLD/NEW, qual too
|
||||
@ -1810,23 +1852,31 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
|
||||
{
|
||||
case CMD_SELECT:
|
||||
if (has_old)
|
||||
elog(ERROR, "ON SELECT rule may not use OLD");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("ON SELECT rule may not use OLD")));
|
||||
if (has_new)
|
||||
elog(ERROR, "ON SELECT rule may not use NEW");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("ON SELECT rule may not use NEW")));
|
||||
break;
|
||||
case CMD_UPDATE:
|
||||
/* both are OK */
|
||||
break;
|
||||
case CMD_INSERT:
|
||||
if (has_old)
|
||||
elog(ERROR, "ON INSERT rule may not use OLD");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("ON INSERT rule may not use OLD")));
|
||||
break;
|
||||
case CMD_DELETE:
|
||||
if (has_new)
|
||||
elog(ERROR, "ON DELETE rule may not use NEW");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("ON DELETE rule may not use NEW")));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "transformRuleStmt: unexpected event type %d",
|
||||
elog(ERROR, "unrecognized event type: %d",
|
||||
(int) stmt->event);
|
||||
break;
|
||||
}
|
||||
@ -1856,7 +1906,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
|
||||
* should be a can't-happen case because of prior tests.)
|
||||
*/
|
||||
if (sub_qry->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")));
|
||||
/* hack so we can use addRTEtoQuery() */
|
||||
sub_pstate->p_rtable = sub_qry->rtable;
|
||||
sub_pstate->p_joinlist = sub_qry->jointree->fromlist;
|
||||
@ -2026,7 +2078,9 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
||||
|
||||
/* We don't support forUpdate with set ops at the moment. */
|
||||
if (forUpdate)
|
||||
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")));
|
||||
|
||||
/*
|
||||
* Recursively transform the components of the tree.
|
||||
@ -2143,7 +2197,9 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
||||
pstate->p_rtable = sv_rtable;
|
||||
|
||||
if (tllen != length(qry->targetList))
|
||||
elog(ERROR, "ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of the result columns");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of the result columns")));
|
||||
|
||||
qry->limitOffset = transformLimitClause(pstate, limitOffset,
|
||||
"OFFSET");
|
||||
@ -2179,10 +2235,14 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
|
||||
* Validity-check both leaf and internal SELECTs for disallowed ops.
|
||||
*/
|
||||
if (stmt->into)
|
||||
elog(ERROR, "INTO is only allowed on first SELECT of UNION/INTERSECT/EXCEPT");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("INTO is only allowed on first SELECT of UNION/INTERSECT/EXCEPT")));
|
||||
/* We don't support forUpdate with set ops at the moment. */
|
||||
if (stmt->forUpdate)
|
||||
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")));
|
||||
|
||||
/*
|
||||
* If an internal node of a set-op tree has ORDER BY, UPDATE, or LIMIT
|
||||
@ -2236,13 +2296,16 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
|
||||
if (pstate->p_namespace)
|
||||
{
|
||||
if (contain_vars_of_level((Node *) selectQuery, 1))
|
||||
elog(ERROR, "UNION/INTERSECT/EXCEPT member statement may not refer to other relations of same query level");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("UNION/INTERSECT/EXCEPT member statement may not refer to other relations of same query level")));
|
||||
}
|
||||
|
||||
/*
|
||||
* Make the leaf query be a subquery in the top-level rangetable.
|
||||
*/
|
||||
snprintf(selectName, sizeof(selectName), "*SELECT* %d", length(pstate->p_rtable) + 1);
|
||||
snprintf(selectName, sizeof(selectName), "*SELECT* %d",
|
||||
length(pstate->p_rtable) + 1);
|
||||
rte = addRangeTableEntryForSubquery(pstate,
|
||||
selectQuery,
|
||||
makeAlias(selectName, NIL),
|
||||
@ -2286,8 +2349,10 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
|
||||
lcoltypes = getSetColTypes(pstate, op->larg);
|
||||
rcoltypes = getSetColTypes(pstate, op->rarg);
|
||||
if (length(lcoltypes) != length(rcoltypes))
|
||||
elog(ERROR, "Each %s query must have the same number of columns",
|
||||
context);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("each %s query must have the same number of columns",
|
||||
context)));
|
||||
op->colTypes = NIL;
|
||||
while (lcoltypes != NIL)
|
||||
{
|
||||
@ -2344,8 +2409,7 @@ getSetColTypes(ParseState *pstate, Node *node)
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "getSetColTypes: unexpected node %d",
|
||||
(int) nodeTag(node));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
|
||||
return NIL; /* keep compiler quiet */
|
||||
}
|
||||
}
|
||||
@ -2355,7 +2419,9 @@ static void
|
||||
applyColumnNames(List *dst, List *src)
|
||||
{
|
||||
if (length(src) > length(dst))
|
||||
elog(ERROR, "CREATE TABLE AS specifies too many column names");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("CREATE TABLE AS specifies too many column names")));
|
||||
|
||||
while (src != NIL && dst != NIL)
|
||||
{
|
||||
@ -2535,7 +2601,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt,
|
||||
else if (IsA(stmt->def, FkConstraint))
|
||||
cxt.fkconstraints = lappend(cxt.fkconstraints, stmt->def);
|
||||
else
|
||||
elog(ERROR, "Unexpected node type in ALTER TABLE ADD CONSTRAINT");
|
||||
elog(ERROR, "unrecognized node type: %d",
|
||||
(int) nodeTag(stmt->def));
|
||||
|
||||
transformIndexConstraints(pstate, &cxt);
|
||||
transformFKConstraints(pstate, &cxt, true);
|
||||
@ -2584,14 +2651,16 @@ transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
|
||||
*/
|
||||
if ((stmt->options & CURSOR_OPT_SCROLL) &&
|
||||
(stmt->options & CURSOR_OPT_NO_SCROLL))
|
||||
elog(ERROR, "Cannot specify both SCROLL and NO SCROLL");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
|
||||
errmsg("cannot specify both SCROLL and NO SCROLL")));
|
||||
|
||||
stmt->query = (Node *) transformStmt(pstate, stmt->query,
|
||||
&extras_before, &extras_after);
|
||||
|
||||
/* Shouldn't get any extras, since grammar only allows SelectStmt */
|
||||
if (extras_before || extras_after)
|
||||
elog(ERROR, "transformDeclareCursorStmt: internal error");
|
||||
elog(ERROR, "unexpected extra stuff in cursor statement");
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -2642,7 +2711,7 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
|
||||
* OptimizableStmt
|
||||
*/
|
||||
if (length(queries) != 1)
|
||||
elog(ERROR, "transformPrepareStmt: internal error");
|
||||
elog(ERROR, "unexpected extra stuff in prepared statement");
|
||||
|
||||
stmt->query = lfirst(queries);
|
||||
|
||||
@ -2668,8 +2737,12 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt)
|
||||
int i = 1;
|
||||
|
||||
if (nparams != nexpected)
|
||||
elog(ERROR, "Wrong number of parameters, expected %d but got %d",
|
||||
nexpected, nparams);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("wrong number of parameters for prepared statement \"%s\"",
|
||||
stmt->name),
|
||||
errdetail("Expected %d parameters but got %d.",
|
||||
nexpected, nparams)));
|
||||
|
||||
foreach(l, stmt->params)
|
||||
{
|
||||
@ -2681,9 +2754,13 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt)
|
||||
|
||||
/* Cannot contain subselects or aggregates */
|
||||
if (pstate->p_hasSubLinks)
|
||||
elog(ERROR, "Cannot use subselects in EXECUTE parameters");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot use sub-selects in EXECUTE parameters")));
|
||||
if (pstate->p_hasAggs)
|
||||
elog(ERROR, "Cannot use aggregates in EXECUTE parameters");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("cannot use aggregates in EXECUTE parameters")));
|
||||
|
||||
given_type_id = exprType(expr);
|
||||
expected_type_id = lfirsto(paramtypes);
|
||||
@ -2694,11 +2771,13 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt)
|
||||
COERCE_IMPLICIT_CAST);
|
||||
|
||||
if (expr == NULL)
|
||||
elog(ERROR, "Parameter $%d of type %s cannot be coerced into the expected type %s"
|
||||
"\n\tYou will need to rewrite or cast the expression",
|
||||
i,
|
||||
format_type_be(given_type_id),
|
||||
format_type_be(expected_type_id));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("parameter $%d of type %s cannot be coerced to the expected type %s",
|
||||
i,
|
||||
format_type_be(given_type_id),
|
||||
format_type_be(expected_type_id)),
|
||||
errhint("You will need to rewrite or cast the expression.")));
|
||||
|
||||
lfirst(l) = expr;
|
||||
|
||||
@ -2715,13 +2794,21 @@ void
|
||||
CheckSelectForUpdate(Query *qry)
|
||||
{
|
||||
if (qry->setOperations)
|
||||
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")));
|
||||
if (qry->distinctClause != NIL)
|
||||
elog(ERROR, "SELECT FOR UPDATE is not allowed with DISTINCT clause");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("SELECT FOR UPDATE is not allowed with DISTINCT clause")));
|
||||
if (qry->groupClause != NIL)
|
||||
elog(ERROR, "SELECT FOR UPDATE is not allowed with GROUP BY clause");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("SELECT FOR UPDATE is not allowed with GROUP BY clause")));
|
||||
if (qry->hasAggs)
|
||||
elog(ERROR, "SELECT FOR UPDATE is not allowed with AGGREGATE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("SELECT FOR UPDATE is not allowed with AGGREGATE")));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2786,8 +2873,10 @@ transformForUpdate(Query *qry, List *forUpdate)
|
||||
}
|
||||
}
|
||||
if (rt == NIL)
|
||||
elog(ERROR, "FOR UPDATE: relation \"%s\" not found in FROM clause",
|
||||
relname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
errmsg("relation \"%s\" in FOR UPDATE clause not found in FROM clause",
|
||||
relname)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2825,9 +2914,8 @@ relationHasPrimaryKey(Oid relationOid)
|
||||
indexTuple = SearchSysCache(INDEXRELID,
|
||||
ObjectIdGetDatum(indexoid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(indexTuple))
|
||||
elog(ERROR, "relationHasPrimaryKey: index %u not found",
|
||||
indexoid);
|
||||
if (!HeapTupleIsValid(indexTuple)) /* should not happen */
|
||||
elog(ERROR, "cache lookup failed for index %u", indexoid);
|
||||
result = ((Form_pg_index) GETSTRUCT(indexTuple))->indisprimary;
|
||||
ReleaseSysCache(indexTuple);
|
||||
if (result)
|
||||
@ -2877,30 +2965,44 @@ transformConstraintAttrs(List *constraintList)
|
||||
case CONSTR_ATTR_DEFERRABLE:
|
||||
if (lastprimarynode == NULL ||
|
||||
!IsA(lastprimarynode, FkConstraint))
|
||||
elog(ERROR, "Misplaced DEFERRABLE clause");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("misplaced DEFERRABLE clause")));
|
||||
if (saw_deferrability)
|
||||
elog(ERROR, "Multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed")));
|
||||
saw_deferrability = true;
|
||||
((FkConstraint *) lastprimarynode)->deferrable = true;
|
||||
break;
|
||||
case CONSTR_ATTR_NOT_DEFERRABLE:
|
||||
if (lastprimarynode == NULL ||
|
||||
!IsA(lastprimarynode, FkConstraint))
|
||||
elog(ERROR, "Misplaced NOT DEFERRABLE clause");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("misplaced NOT DEFERRABLE clause")));
|
||||
if (saw_deferrability)
|
||||
elog(ERROR, "Multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple DEFERRABLE/NOT DEFERRABLE clauses not allowed")));
|
||||
saw_deferrability = true;
|
||||
((FkConstraint *) lastprimarynode)->deferrable = false;
|
||||
if (saw_initially &&
|
||||
((FkConstraint *) lastprimarynode)->initdeferred)
|
||||
elog(ERROR, "INITIALLY DEFERRED constraint must be DEFERRABLE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("INITIALLY DEFERRED constraint must be DEFERRABLE")));
|
||||
break;
|
||||
case CONSTR_ATTR_DEFERRED:
|
||||
if (lastprimarynode == NULL ||
|
||||
!IsA(lastprimarynode, FkConstraint))
|
||||
elog(ERROR, "Misplaced INITIALLY DEFERRED clause");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("misplaced INITIALLY DEFERRED clause")));
|
||||
if (saw_initially)
|
||||
elog(ERROR, "Multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed")));
|
||||
saw_initially = true;
|
||||
((FkConstraint *) lastprimarynode)->initdeferred = true;
|
||||
|
||||
@ -2911,14 +3013,20 @@ transformConstraintAttrs(List *constraintList)
|
||||
if (!saw_deferrability)
|
||||
((FkConstraint *) lastprimarynode)->deferrable = true;
|
||||
else if (!((FkConstraint *) lastprimarynode)->deferrable)
|
||||
elog(ERROR, "INITIALLY DEFERRED constraint must be DEFERRABLE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("INITIALLY DEFERRED constraint must be DEFERRABLE")));
|
||||
break;
|
||||
case CONSTR_ATTR_IMMEDIATE:
|
||||
if (lastprimarynode == NULL ||
|
||||
!IsA(lastprimarynode, FkConstraint))
|
||||
elog(ERROR, "Misplaced INITIALLY IMMEDIATE clause");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("misplaced INITIALLY IMMEDIATE clause")));
|
||||
if (saw_initially)
|
||||
elog(ERROR, "Multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple INITIALLY IMMEDIATE/DEFERRED clauses not allowed")));
|
||||
saw_initially = true;
|
||||
((FkConstraint *) lastprimarynode)->initdeferred = false;
|
||||
break;
|
||||
@ -3025,9 +3133,11 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt)
|
||||
if (elp->relation->schemaname == NULL)
|
||||
elp->relation->schemaname = cxt.schemaname;
|
||||
else if (strcmp(cxt.schemaname, elp->relation->schemaname) != 0)
|
||||
elog(ERROR, "New table specifies a schema (%s)"
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_SCHEMA_DEFINITION),
|
||||
errmsg("CREATE specifies a schema (%s)"
|
||||
" different from the one being created (%s)",
|
||||
elp->relation->schemaname, cxt.schemaname);
|
||||
elp->relation->schemaname, cxt.schemaname)));
|
||||
|
||||
/*
|
||||
* XXX todo: deal with constraints
|
||||
@ -3044,9 +3154,11 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt)
|
||||
if (elp->view->schemaname == NULL)
|
||||
elp->view->schemaname = cxt.schemaname;
|
||||
else if (strcmp(cxt.schemaname, elp->view->schemaname) != 0)
|
||||
elog(ERROR, "New view specifies a schema (%s)"
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_SCHEMA_DEFINITION),
|
||||
errmsg("CREATE specifies a schema (%s)"
|
||||
" different from the one being created (%s)",
|
||||
elp->view->schemaname, cxt.schemaname);
|
||||
elp->view->schemaname, cxt.schemaname)));
|
||||
|
||||
/*
|
||||
* XXX todo: deal with references between views
|
||||
@ -3061,7 +3173,8 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt)
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "parser: unsupported schema node (internal error)");
|
||||
elog(ERROR, "unrecognized node type: %d",
|
||||
(int) nodeTag(element));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.426 2003/07/03 19:07:36 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.427 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -956,9 +956,9 @@ zone_value:
|
||||
if ($3 != INTERVAL_FULL_RANGE)
|
||||
{
|
||||
if (($3 & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
|
||||
elog(ERROR,
|
||||
"Time zone interval"
|
||||
" must be HOUR or HOUR TO MINUTE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("time zone interval must be HOUR or HOUR TO MINUTE")));
|
||||
n->typename->typmod = INTERVAL_TYPMOD(INTERVAL_FULL_PRECISION, $3);
|
||||
}
|
||||
$$ = (Node *)n;
|
||||
@ -967,22 +967,24 @@ zone_value:
|
||||
{
|
||||
A_Const *n = (A_Const *) makeStringConst($5, $1);
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"INTERVAL(%d) precision must not be negative",
|
||||
$3);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("INTERVAL(%d) precision must not be negative",
|
||||
$3)));
|
||||
if ($3 > MAX_INTERVAL_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"INTERVAL(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_INTERVAL_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_INTERVAL_PRECISION)));
|
||||
$3 = MAX_INTERVAL_PRECISION;
|
||||
}
|
||||
|
||||
if (($6 != INTERVAL_FULL_RANGE)
|
||||
&& (($6 & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0))
|
||||
elog(ERROR,
|
||||
"Time zone interval"
|
||||
" must be HOUR or HOUR TO MINUTE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("time zone interval must be HOUR or HOUR TO MINUTE")));
|
||||
|
||||
n->typename->typmod = INTERVAL_TYPMOD($3, $6);
|
||||
|
||||
@ -1467,9 +1469,9 @@ columnDef: ColId Typename ColQualList opt_collate
|
||||
n->is_local = true;
|
||||
|
||||
if ($4 != NULL)
|
||||
elog(NOTICE,
|
||||
"CREATE TABLE / COLLATE %s not yet implemented; "
|
||||
"clause ignored", $4);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("CREATE TABLE / COLLATE is not yet implemented; clause ignored")));
|
||||
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@ -1769,7 +1771,9 @@ key_match: MATCH FULL
|
||||
}
|
||||
| MATCH PARTIAL
|
||||
{
|
||||
elog(ERROR, "FOREIGN KEY/MATCH PARTIAL not yet implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("FOREIGN KEY/MATCH PARTIAL is not yet implemented")));
|
||||
$$ = FKCONSTR_MATCH_PARTIAL;
|
||||
}
|
||||
| MATCH SIMPLE
|
||||
@ -1849,7 +1853,9 @@ CreateAsStmt:
|
||||
*/
|
||||
SelectStmt *n = findLeftmostSelect((SelectStmt *) $7);
|
||||
if (n->into != NULL)
|
||||
elog(ERROR, "CREATE TABLE AS may not specify INTO");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("CREATE TABLE AS may not specify INTO")));
|
||||
$4->istemp = $2;
|
||||
n->into = $4;
|
||||
n->intoColNames = $5;
|
||||
@ -2188,8 +2194,9 @@ ConstraintAttributeSpec:
|
||||
| ConstraintDeferrabilitySpec ConstraintTimeSpec
|
||||
{
|
||||
if ($1 == 0 && $2 != 0)
|
||||
elog(ERROR,
|
||||
"INITIALLY DEFERRED constraint must be DEFERRABLE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("INITIALLY DEFERRED constraint must be DEFERRABLE")));
|
||||
$$ = $1 | $2;
|
||||
}
|
||||
| ConstraintTimeSpec
|
||||
@ -2202,8 +2209,9 @@ ConstraintAttributeSpec:
|
||||
| ConstraintTimeSpec ConstraintDeferrabilitySpec
|
||||
{
|
||||
if ($2 == 0 && $1 != 0)
|
||||
elog(ERROR,
|
||||
"INITIALLY DEFERRED constraint must be DEFERRABLE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("INITIALLY DEFERRED constraint must be DEFERRABLE")));
|
||||
$$ = $1 | $2;
|
||||
}
|
||||
| /*EMPTY*/
|
||||
@ -2253,7 +2261,9 @@ CreateAssertStmt:
|
||||
n->deferrable = ($8 & 1) != 0;
|
||||
n->initdeferred = ($8 & 2) != 0;
|
||||
|
||||
elog(ERROR, "CREATE ASSERTION is not yet supported");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("CREATE ASSERTION is not yet implemented")));
|
||||
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@ -2267,7 +2277,9 @@ DropAssertStmt:
|
||||
n->property = $3;
|
||||
n->behavior = $4;
|
||||
n->removeType = OBJECT_TRIGGER; /* XXX */
|
||||
elog(ERROR, "DROP ASSERTION is not yet supported");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("DROP ASSERTION is not yet implemented")));
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
;
|
||||
@ -2329,9 +2341,10 @@ DefineStmt:
|
||||
r->relname = strVal(lthird($3));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR,
|
||||
"Improper qualified name (too many dotted names): %s",
|
||||
NameListToString($3));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("improper qualified name (too many dotted names): %s",
|
||||
NameListToString($3))));
|
||||
break;
|
||||
}
|
||||
n->typevar = r;
|
||||
@ -3074,14 +3087,16 @@ func_arg: opt_arg func_type
|
||||
opt_arg: IN_P { $$ = FALSE; }
|
||||
| OUT_P
|
||||
{
|
||||
elog(ERROR,
|
||||
"CREATE FUNCTION / OUT parameters are not supported");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("CREATE FUNCTION / OUT parameters are not implemented")));
|
||||
$$ = TRUE;
|
||||
}
|
||||
| INOUT
|
||||
{
|
||||
elog(ERROR,
|
||||
"CREATE FUNCTION / INOUT parameters are not supported");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("CREATE FUNCTION / INOUT parameters are not implemented")));
|
||||
$$ = FALSE;
|
||||
}
|
||||
;
|
||||
@ -3233,7 +3248,9 @@ RemoveOperStmt:
|
||||
oper_argtypes:
|
||||
Typename
|
||||
{
|
||||
elog(ERROR, "parser: argument type missing (use NONE for unary operators)");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("argument type missing (use NONE for unary operators)")));
|
||||
}
|
||||
| Typename ',' Typename
|
||||
{ $$ = makeList2($1, $3); }
|
||||
@ -3833,8 +3850,9 @@ CreateDomainStmt:
|
||||
n->constraints = $6;
|
||||
|
||||
if ($7 != NULL)
|
||||
elog(NOTICE,"CREATE DOMAIN / COLLATE %s not yet "
|
||||
"implemented; clause ignored", $7);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("CREATE DOMAIN / COLLATE is not yet implemented; clause ignored")));
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
;
|
||||
@ -4137,7 +4155,9 @@ ExecuteStmt: EXECUTE name execute_param_clause
|
||||
$4->istemp = $2;
|
||||
n->into = $4;
|
||||
if ($5)
|
||||
elog(ERROR, "column name list not allowed in CREATE TABLE / AS EXECUTE");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("column name list not allowed in CREATE TABLE / AS EXECUTE")));
|
||||
/* ... because it's not implemented, but it could be */
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
@ -4587,8 +4607,10 @@ select_limit:
|
||||
| LIMIT select_limit_value ',' select_offset_value
|
||||
{
|
||||
/* Disabled because it was too confusing, bjm 2002-02-18 */
|
||||
elog(ERROR,
|
||||
"LIMIT #,# syntax not supported.\n\tUse separate LIMIT and OFFSET clauses.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("LIMIT #,# syntax is not supported"),
|
||||
errhint("Use separate LIMIT and OFFSET clauses.")));
|
||||
}
|
||||
;
|
||||
|
||||
@ -4735,8 +4757,10 @@ table_ref: relation_expr
|
||||
* However, it does seem like a good idea to emit
|
||||
* an error message that's better than "syntax error".
|
||||
*/
|
||||
elog(ERROR, "sub-SELECT in FROM must have an alias"
|
||||
"\n\tFor example, FROM (SELECT ...) [AS] foo");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("sub-select in FROM must have an alias"),
|
||||
errhint("For example, FROM (SELECT ...) [AS] foo.")));
|
||||
$$ = NULL;
|
||||
}
|
||||
| select_with_parens alias_clause
|
||||
@ -5058,14 +5082,16 @@ SimpleTypename:
|
||||
{
|
||||
$$ = $1;
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"INTERVAL(%d) precision must not be negative",
|
||||
$3);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("INTERVAL(%d) precision must not be negative",
|
||||
$3)));
|
||||
if ($3 > MAX_INTERVAL_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"INTERVAL(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_INTERVAL_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_INTERVAL_PRECISION)));
|
||||
$3 = MAX_INTERVAL_PRECISION;
|
||||
}
|
||||
$$->typmod = INTERVAL_TYPMOD($3, $5);
|
||||
@ -5159,15 +5185,17 @@ Numeric: INT_P
|
||||
opt_float: '(' Iconst ')'
|
||||
{
|
||||
if ($2 < 1)
|
||||
elog(ERROR,
|
||||
"precision for FLOAT must be at least 1 bit");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("precision for FLOAT must be at least 1 bit")));
|
||||
else if ($2 <= 24)
|
||||
$$ = SystemTypeName("float4");
|
||||
else if ($2 <= 53)
|
||||
$$ = SystemTypeName("float8");
|
||||
else
|
||||
elog(ERROR,
|
||||
"precision for FLOAT must be less than 54 bits");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("precision for FLOAT must be less than 54 bits")));
|
||||
}
|
||||
| /*EMPTY*/
|
||||
{
|
||||
@ -5179,22 +5207,25 @@ opt_numeric:
|
||||
'(' Iconst ',' Iconst ')'
|
||||
{
|
||||
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
|
||||
elog(ERROR,
|
||||
"NUMERIC precision %d must be between 1 and %d",
|
||||
$2, NUMERIC_MAX_PRECISION);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("NUMERIC precision %d must be between 1 and %d",
|
||||
$2, NUMERIC_MAX_PRECISION)));
|
||||
if ($4 < 0 || $4 > $2)
|
||||
elog(ERROR,
|
||||
"NUMERIC scale %d must be between 0 and precision %d",
|
||||
$4,$2);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("NUMERIC scale %d must be between 0 and precision %d",
|
||||
$4, $2)));
|
||||
|
||||
$$ = (($2 << 16) | $4) + VARHDRSZ;
|
||||
}
|
||||
| '(' Iconst ')'
|
||||
{
|
||||
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
|
||||
elog(ERROR,
|
||||
"NUMERIC precision %d must be between 1 and %d",
|
||||
$2, NUMERIC_MAX_PRECISION);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("NUMERIC precision %d must be between 1 and %d",
|
||||
$2, NUMERIC_MAX_PRECISION)));
|
||||
|
||||
$$ = ($2 << 16) + VARHDRSZ;
|
||||
}
|
||||
@ -5209,22 +5240,25 @@ opt_decimal:
|
||||
'(' Iconst ',' Iconst ')'
|
||||
{
|
||||
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
|
||||
elog(ERROR,
|
||||
"DECIMAL precision %d must be between 1 and %d",
|
||||
$2, NUMERIC_MAX_PRECISION);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("DECIMAL precision %d must be between 1 and %d",
|
||||
$2, NUMERIC_MAX_PRECISION)));
|
||||
if ($4 < 0 || $4 > $2)
|
||||
elog(ERROR,
|
||||
"DECIMAL scale %d must be between 0 and precision %d",
|
||||
$4,$2);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("DECIMAL scale %d must be between 0 and precision %d",
|
||||
$4, $2)));
|
||||
|
||||
$$ = (($2 << 16) | $4) + VARHDRSZ;
|
||||
}
|
||||
| '(' Iconst ')'
|
||||
{
|
||||
if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
|
||||
elog(ERROR,
|
||||
"DECIMAL precision %d must be between 1 and %d",
|
||||
$2, NUMERIC_MAX_PRECISION);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("DECIMAL precision %d must be between 1 and %d",
|
||||
$2, NUMERIC_MAX_PRECISION)));
|
||||
|
||||
$$ = ($2 << 16) + VARHDRSZ;
|
||||
}
|
||||
@ -5271,11 +5305,15 @@ BitWithLength:
|
||||
typname = $2 ? "varbit" : "bit";
|
||||
$$ = SystemTypeName(typname);
|
||||
if ($4 < 1)
|
||||
elog(ERROR, "length for type '%s' must be at least 1",
|
||||
typname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("length for type %s must be at least 1",
|
||||
typname)));
|
||||
else if ($4 > (MaxAttrSize * BITS_PER_BYTE))
|
||||
elog(ERROR, "length for type '%s' cannot exceed %d",
|
||||
typname, (MaxAttrSize * BITS_PER_BYTE));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("length for type %s cannot exceed %d",
|
||||
typname, MaxAttrSize * BITS_PER_BYTE)));
|
||||
$$->typmod = $4;
|
||||
}
|
||||
;
|
||||
@ -5345,11 +5383,15 @@ CharacterWithLength: character '(' Iconst ')' opt_charset
|
||||
$$ = SystemTypeName($1);
|
||||
|
||||
if ($3 < 1)
|
||||
elog(ERROR, "length for type '%s' must be at least 1",
|
||||
$1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("length for type %s must be at least 1",
|
||||
$1)));
|
||||
else if ($3 > MaxAttrSize)
|
||||
elog(ERROR, "length for type '%s' cannot exceed %d",
|
||||
$1, MaxAttrSize);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("length for type %s cannot exceed %d",
|
||||
$1, MaxAttrSize)));
|
||||
|
||||
/* we actually implement these like a varlen, so
|
||||
* the first 4 bytes is the length. (the difference
|
||||
@ -5424,15 +5466,17 @@ ConstDatetime:
|
||||
*/
|
||||
$$->timezone = $5;
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"TIMESTAMP(%d)%s precision must not be negative",
|
||||
$3, ($5 ? " WITH TIME ZONE": ""));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIMESTAMP(%d)%s precision must not be negative",
|
||||
$3, ($5 ? " WITH TIME ZONE": ""))));
|
||||
if ($3 > MAX_TIMESTAMP_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"TIMESTAMP(%d)%s precision reduced to maximum allowed, %d",
|
||||
$3, ($5 ? " WITH TIME ZONE": ""),
|
||||
MAX_TIMESTAMP_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIMESTAMP(%d)%s precision reduced to maximum allowed, %d",
|
||||
$3, ($5 ? " WITH TIME ZONE": ""),
|
||||
MAX_TIMESTAMP_PRECISION)));
|
||||
$3 = MAX_TIMESTAMP_PRECISION;
|
||||
}
|
||||
$$->typmod = $3;
|
||||
@ -5463,15 +5507,17 @@ ConstDatetime:
|
||||
else
|
||||
$$ = SystemTypeName("time");
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"TIME(%d)%s precision must not be negative",
|
||||
$3, ($5 ? " WITH TIME ZONE": ""));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIME(%d)%s precision must not be negative",
|
||||
$3, ($5 ? " WITH TIME ZONE": ""))));
|
||||
if ($3 > MAX_TIME_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"TIME(%d)%s precision reduced to maximum allowed, %d",
|
||||
$3, ($5 ? " WITH TIME ZONE": ""),
|
||||
MAX_TIME_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("TIME(%d)%s precision reduced to maximum allowed, %d",
|
||||
$3, ($5 ? " WITH TIME ZONE": ""),
|
||||
MAX_TIME_PRECISION)));
|
||||
$3 = MAX_TIME_PRECISION;
|
||||
}
|
||||
$$->typmod = $3;
|
||||
@ -5613,7 +5659,9 @@ r_expr: row IN_P select_with_parens
|
||||
/* lengths don't match? then complain */
|
||||
if (length(largs) != length(rargs))
|
||||
{
|
||||
elog(ERROR, "Unequal number of entries in row expression");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("unequal number of entries in row expression")));
|
||||
}
|
||||
/* both are zero-length rows? then they are not distinct */
|
||||
else if (length(largs) <= 0)
|
||||
@ -6033,7 +6081,9 @@ a_expr: c_expr { $$ = $1; }
|
||||
* entire result equal to one.
|
||||
* But, will probably implement a separate node in the executor.
|
||||
*/
|
||||
elog(ERROR, "UNIQUE predicate is not yet implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("UNIQUE predicate is not yet implemented")));
|
||||
}
|
||||
| r_expr
|
||||
{ $$ = $1; }
|
||||
@ -6273,14 +6323,16 @@ c_expr: columnref { $$ = (Node *) $1; }
|
||||
s->typename = SystemTypeName("text");
|
||||
d = SystemTypeName("timetz");
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"CURRENT_TIME(%d) precision must not be negative",
|
||||
$3);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("CURRENT_TIME(%d) precision must not be negative",
|
||||
$3)));
|
||||
if ($3 > MAX_TIME_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"CURRENT_TIME(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_TIME_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("CURRENT_TIME(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_TIME_PRECISION)));
|
||||
$3 = MAX_TIME_PRECISION;
|
||||
}
|
||||
d->typmod = $3;
|
||||
@ -6325,14 +6377,16 @@ c_expr: columnref { $$ = (Node *) $1; }
|
||||
|
||||
d = SystemTypeName("timestamptz");
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"CURRENT_TIMESTAMP(%d) precision must not be negative",
|
||||
$3);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("CURRENT_TIMESTAMP(%d) precision must not be negative",
|
||||
$3)));
|
||||
if ($3 > MAX_TIMESTAMP_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"CURRENT_TIMESTAMP(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_TIMESTAMP_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("CURRENT_TIMESTAMP(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_TIMESTAMP_PRECISION)));
|
||||
$3 = MAX_TIMESTAMP_PRECISION;
|
||||
}
|
||||
d->typmod = $3;
|
||||
@ -6376,14 +6430,16 @@ c_expr: columnref { $$ = (Node *) $1; }
|
||||
s->typename = SystemTypeName("text");
|
||||
d = SystemTypeName("time");
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"LOCALTIME(%d) precision must not be negative",
|
||||
$3);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("LOCALTIME(%d) precision must not be negative",
|
||||
$3)));
|
||||
if ($3 > MAX_TIME_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"LOCALTIME(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_TIME_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("LOCALTIME(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_TIME_PRECISION)));
|
||||
$3 = MAX_TIME_PRECISION;
|
||||
}
|
||||
d->typmod = $3;
|
||||
@ -6428,14 +6484,16 @@ c_expr: columnref { $$ = (Node *) $1; }
|
||||
|
||||
d = SystemTypeName("timestamp");
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"LOCALTIMESTAMP(%d) precision must not be negative",
|
||||
$3);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("LOCALTIMESTAMP(%d) precision must not be negative",
|
||||
$3)));
|
||||
if ($3 > MAX_TIMESTAMP_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"LOCALTIMESTAMP(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_TIMESTAMP_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("LOCALTIMESTAMP(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_TIMESTAMP_PRECISION)));
|
||||
$3 = MAX_TIMESTAMP_PRECISION;
|
||||
}
|
||||
d->typmod = $3;
|
||||
@ -7020,10 +7078,10 @@ qualified_name:
|
||||
$$->relname = strVal(lthird($1));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR,
|
||||
"Improper qualified name "
|
||||
"(too many dotted names): %s",
|
||||
NameListToString($1));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("improper qualified name (too many dotted names): %s",
|
||||
NameListToString($1))));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -7126,14 +7184,16 @@ AexprConst: Iconst
|
||||
n->val.val.str = $5;
|
||||
/* precision specified, and fields may be... */
|
||||
if ($3 < 0)
|
||||
elog(ERROR,
|
||||
"INTERVAL(%d) precision must not be negative",
|
||||
$3);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("INTERVAL(%d) precision must not be negative",
|
||||
$3)));
|
||||
if ($3 > MAX_INTERVAL_PRECISION)
|
||||
{
|
||||
elog(NOTICE,
|
||||
"INTERVAL(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_INTERVAL_PRECISION);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("INTERVAL(%d) precision reduced to maximum allowed, %d",
|
||||
$3, MAX_INTERVAL_PRECISION)));
|
||||
$3 = MAX_INTERVAL_PRECISION;
|
||||
}
|
||||
n->typename->typmod = INTERVAL_TYPMOD($3, $6);
|
||||
@ -7571,14 +7631,18 @@ SpecialRuleRelation:
|
||||
if (QueryIsRule)
|
||||
$$ = "*OLD*";
|
||||
else
|
||||
elog(ERROR, "OLD used in non-rule query");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("OLD used in non-rule query")));
|
||||
}
|
||||
| NEW
|
||||
{
|
||||
if (QueryIsRule)
|
||||
$$ = "*NEW*";
|
||||
else
|
||||
elog(ERROR, "NEW used in non-rule query");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("NEW used in non-rule query")));
|
||||
}
|
||||
;
|
||||
|
||||
@ -7698,7 +7762,9 @@ makeRowExpr(List *opr, List *largs, List *rargs)
|
||||
char *oprname;
|
||||
|
||||
if (length(largs) != length(rargs))
|
||||
elog(ERROR, "Unequal number of entries in row expression");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("unequal number of entries in row expression")));
|
||||
|
||||
if (lnext(largs) != NIL)
|
||||
expr = makeRowExpr(opr, lnext(largs), lnext(rargs));
|
||||
@ -7732,8 +7798,10 @@ makeRowExpr(List *opr, List *largs, List *rargs)
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "Operator '%s' not implemented for row expressions",
|
||||
oprname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("operator %s is not supported for row expressions",
|
||||
oprname)));
|
||||
}
|
||||
|
||||
return expr;
|
||||
@ -7750,7 +7818,9 @@ makeDistinctExpr(List *largs, List *rargs)
|
||||
Node *larg, *rarg;
|
||||
|
||||
if (length(largs) != length(rargs))
|
||||
elog(ERROR, "Unequal number of entries in row expression");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("unequal number of entries in row expression")));
|
||||
|
||||
if (lnext(largs) != NIL)
|
||||
expr = makeDistinctExpr(lnext(largs), lnext(rargs));
|
||||
@ -7805,13 +7875,15 @@ makeOverlaps(List *largs, List *rargs)
|
||||
if (length(largs) == 1)
|
||||
largs = lappend(largs, largs);
|
||||
else if (length(largs) != 2)
|
||||
elog(ERROR, "Wrong number of parameters"
|
||||
" on left side of OVERLAPS expression");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("wrong number of parameters on left side of OVERLAPS expression")));
|
||||
if (length(rargs) == 1)
|
||||
rargs = lappend(rargs, rargs);
|
||||
else if (length(rargs) != 2)
|
||||
elog(ERROR, "Wrong number of parameters"
|
||||
" on right side of OVERLAPS expression");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("wrong number of parameters on right side of OVERLAPS expression")));
|
||||
n->args = nconc(largs, rargs);
|
||||
n->agg_star = FALSE;
|
||||
n->agg_distinct = FALSE;
|
||||
@ -7847,25 +7919,33 @@ insertSelectOptions(SelectStmt *stmt,
|
||||
if (sortClause)
|
||||
{
|
||||
if (stmt->sortClause)
|
||||
elog(ERROR, "Multiple ORDER BY clauses not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple ORDER BY clauses not allowed")));
|
||||
stmt->sortClause = sortClause;
|
||||
}
|
||||
if (forUpdate)
|
||||
{
|
||||
if (stmt->forUpdate)
|
||||
elog(ERROR, "Multiple FOR UPDATE clauses not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple FOR UPDATE clauses not allowed")));
|
||||
stmt->forUpdate = forUpdate;
|
||||
}
|
||||
if (limitOffset)
|
||||
{
|
||||
if (stmt->limitOffset)
|
||||
elog(ERROR, "Multiple OFFSET clauses not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple OFFSET clauses not allowed")));
|
||||
stmt->limitOffset = limitOffset;
|
||||
}
|
||||
if (limitCount)
|
||||
{
|
||||
if (stmt->limitCount)
|
||||
elog(ERROR, "Multiple LIMIT clauses not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multiple LIMIT clauses not allowed")));
|
||||
stmt->limitCount = limitCount;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.54 2003/07/01 19:10:52 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.55 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -69,7 +69,9 @@ transformAggregateCall(ParseState *pstate, Aggref *agg)
|
||||
if (min_varlevel == 0)
|
||||
{
|
||||
if (checkExprHasAggs((Node *) agg->target))
|
||||
elog(ERROR, "aggregate function calls may not be nested");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("aggregate function calls may not be nested")));
|
||||
}
|
||||
|
||||
if (min_varlevel < 0)
|
||||
@ -113,9 +115,13 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
|
||||
* problem is in WHERE.)
|
||||
*/
|
||||
if (checkExprHasAggs(qry->jointree->quals))
|
||||
elog(ERROR, "Aggregates not allowed in WHERE clause");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("aggregates not allowed in WHERE clause")));
|
||||
if (checkExprHasAggs((Node *) qry->jointree->fromlist))
|
||||
elog(ERROR, "Aggregates not allowed in JOIN conditions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("aggregates not allowed in JOIN conditions")));
|
||||
|
||||
/*
|
||||
* No aggregates allowed in GROUP BY clauses, either.
|
||||
@ -134,7 +140,9 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
|
||||
if (expr == NULL)
|
||||
continue; /* probably cannot happen */
|
||||
if (checkExprHasAggs(expr))
|
||||
elog(ERROR, "Aggregates not allowed in GROUP BY clause");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("aggregates not allowed in GROUP BY clause")));
|
||||
groupClauses = lcons(expr, groupClauses);
|
||||
if (!IsA(expr, Var))
|
||||
have_non_var_grouping = true;
|
||||
@ -291,11 +299,15 @@ check_ungrouped_columns_walker(Node *node,
|
||||
rte = rt_fetch(var->varno, context->pstate->p_rtable);
|
||||
attname = get_rte_attribute_name(rte, var->varattno);
|
||||
if (context->sublevels_up == 0)
|
||||
elog(ERROR, "Attribute %s.%s must be GROUPed or used in an aggregate function",
|
||||
rte->eref->aliasname, attname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("attribute \"%s.%s\" must be GROUPed or used in an aggregate function",
|
||||
rte->eref->aliasname, attname)));
|
||||
else
|
||||
elog(ERROR, "Sub-SELECT uses un-GROUPed attribute %s.%s from outer query",
|
||||
rte->eref->aliasname, attname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("sub-select uses un-GROUPed attribute \"%s.%s\" from outer query",
|
||||
rte->eref->aliasname, attname)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.117 2003/07/03 19:07:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.118 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -192,7 +192,7 @@ interpretInhOption(InhOption inhOpt)
|
||||
case INH_DEFAULT:
|
||||
return SQL_inheritance;
|
||||
}
|
||||
elog(ERROR, "Bogus InhOption value");
|
||||
elog(ERROR, "bogus InhOption value");
|
||||
return false; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -334,8 +334,10 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j,
|
||||
{
|
||||
if (!intMember(varno, containedRels))
|
||||
{
|
||||
elog(ERROR, "JOIN/ON clause refers to \"%s\", which is not part of JOIN",
|
||||
rt_fetch(varno, pstate->p_rtable)->eref->aliasname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("JOIN/ON clause refers to \"%s\", which is not part of JOIN",
|
||||
rt_fetch(varno, pstate->p_rtable)->eref->aliasname)));
|
||||
}
|
||||
}
|
||||
bms_free(clause_varnos);
|
||||
@ -392,7 +394,9 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
|
||||
* an unlabeled subselect.
|
||||
*/
|
||||
if (r->alias == NULL)
|
||||
elog(ERROR, "sub-select in FROM must have an alias");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("sub-select in FROM must have an alias")));
|
||||
|
||||
/*
|
||||
* Analyze and transform the subquery.
|
||||
@ -400,20 +404,22 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
|
||||
parsetrees = parse_sub_analyze(r->subquery, pstate);
|
||||
|
||||
/*
|
||||
* Check that we got something reasonable. Some of these conditions
|
||||
* Check that we got something reasonable. Most of these conditions
|
||||
* are probably impossible given restrictions of the grammar, but
|
||||
* check 'em anyway.
|
||||
*/
|
||||
if (length(parsetrees) != 1)
|
||||
elog(ERROR, "Unexpected parse analysis result for subselect in FROM");
|
||||
elog(ERROR, "unexpected parse analysis result for sub-select in FROM");
|
||||
query = (Query *) lfirst(parsetrees);
|
||||
if (query == NULL || !IsA(query, Query))
|
||||
elog(ERROR, "Unexpected parse analysis result for subselect in FROM");
|
||||
elog(ERROR, "unexpected parse analysis result for sub-select in FROM");
|
||||
|
||||
if (query->commandType != CMD_SELECT)
|
||||
elog(ERROR, "Expected SELECT query from subselect in FROM");
|
||||
elog(ERROR, "expected SELECT query from sub-select in FROM");
|
||||
if (query->resultRelation != 0 || query->into != NULL)
|
||||
elog(ERROR, "Subselect in FROM may not have SELECT INTO");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("sub-select in FROM may not have SELECT INTO")));
|
||||
|
||||
/*
|
||||
* The subquery cannot make use of any variables from FROM items created
|
||||
@ -431,7 +437,9 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
|
||||
if (pstate->p_namespace)
|
||||
{
|
||||
if (contain_vars_of_level((Node *) query, 1))
|
||||
elog(ERROR, "Subselect in FROM may not refer to other relations of same query level");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("sub-select in FROM may not refer to other relations of same query level")));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -484,7 +492,9 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
|
||||
if (pstate->p_namespace)
|
||||
{
|
||||
if (contain_vars_of_level(funcexpr, 0))
|
||||
elog(ERROR, "FROM function expression may not refer to other relations of same query level");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("function expression in FROM may not refer to other relations of same query level")));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -494,7 +504,9 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
|
||||
if (pstate->p_hasAggs)
|
||||
{
|
||||
if (checkExprHasAggs(funcexpr))
|
||||
elog(ERROR, "cannot use aggregate function in FROM function expression");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
errmsg("cannot use aggregate function in function expression in FROM")));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -617,7 +629,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
||||
leftrti = ((JoinExpr *) j->larg)->rtindex;
|
||||
else
|
||||
{
|
||||
elog(ERROR, "transformFromClauseItem: unexpected subtree type");
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(j->larg));
|
||||
leftrti = 0; /* keep compiler quiet */
|
||||
}
|
||||
rte = rt_fetch(leftrti, pstate->p_rtable);
|
||||
@ -629,7 +641,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
||||
rightrti = ((JoinExpr *) j->rarg)->rtindex;
|
||||
else
|
||||
{
|
||||
elog(ERROR, "transformFromClauseItem: unexpected subtree type");
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(j->rarg));
|
||||
rightrti = 0; /* keep compiler quiet */
|
||||
}
|
||||
rte = rt_fetch(rightrti, pstate->p_rtable);
|
||||
@ -712,7 +724,10 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
||||
char *res_colname = strVal(lfirst(col));
|
||||
|
||||
if (strcmp(res_colname, u_colname) == 0)
|
||||
elog(ERROR, "USING column name \"%s\" appears more than once", u_colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_COLUMN),
|
||||
errmsg("USING column name \"%s\" appears more than once",
|
||||
u_colname)));
|
||||
}
|
||||
|
||||
/* Find it in left input */
|
||||
@ -724,14 +739,19 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
||||
if (strcmp(l_colname, u_colname) == 0)
|
||||
{
|
||||
if (l_index >= 0)
|
||||
elog(ERROR, "Common column name \"%s\" appears more than once in left table", u_colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_COLUMN),
|
||||
errmsg("common column name \"%s\" appears more than once in left table",
|
||||
u_colname)));
|
||||
l_index = ndx;
|
||||
}
|
||||
ndx++;
|
||||
}
|
||||
if (l_index < 0)
|
||||
elog(ERROR, "JOIN/USING column \"%s\" not found in left table",
|
||||
u_colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("JOIN/USING column \"%s\" not found in left table",
|
||||
u_colname)));
|
||||
|
||||
/* Find it in right input */
|
||||
ndx = 0;
|
||||
@ -742,14 +762,19 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
||||
if (strcmp(r_colname, u_colname) == 0)
|
||||
{
|
||||
if (r_index >= 0)
|
||||
elog(ERROR, "Common column name \"%s\" appears more than once in right table", u_colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_COLUMN),
|
||||
errmsg("common column name \"%s\" appears more than once in right table",
|
||||
u_colname)));
|
||||
r_index = ndx;
|
||||
}
|
||||
ndx++;
|
||||
}
|
||||
if (r_index < 0)
|
||||
elog(ERROR, "JOIN/USING column \"%s\" not found in right table",
|
||||
u_colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("JOIN/USING column \"%s\" not found in right table",
|
||||
u_colname)));
|
||||
|
||||
l_colvar = nth(l_index, l_colvars);
|
||||
l_usingvars = lappend(l_usingvars, l_colvar);
|
||||
@ -798,8 +823,10 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
||||
if (j->alias->colnames != NIL)
|
||||
{
|
||||
if (length(j->alias->colnames) > length(res_colnames))
|
||||
elog(ERROR, "Column alias list for \"%s\" has too many entries",
|
||||
j->alias->aliasname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("column alias list for \"%s\" has too many entries",
|
||||
j->alias->aliasname)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -825,10 +852,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
||||
return (Node *) j;
|
||||
}
|
||||
else
|
||||
elog(ERROR, "transformFromClauseItem: unexpected node (internal error)"
|
||||
"\n\t%s", nodeToString(n));
|
||||
return NULL; /* can't get here, just keep compiler
|
||||
* quiet */
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(n));
|
||||
return NULL; /* can't get here, keep compiler quiet */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -930,8 +955,7 @@ buildMergedJoinVar(ParseState *pstate, JoinType jointype,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
elog(ERROR, "buildMergedJoinVar: unexpected jointype %d",
|
||||
(int) jointype);
|
||||
elog(ERROR, "unrecognized join type: %d", (int) jointype);
|
||||
res_node = NULL; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -991,21 +1015,27 @@ transformLimitClause(ParseState *pstate, Node *clause,
|
||||
*/
|
||||
if (contain_vars_of_level(qual, 0))
|
||||
{
|
||||
/* translator: %s is name of a SQL construct, eg LIMIT */
|
||||
elog(ERROR, "argument of %s must not contain variables",
|
||||
constructName);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
/* translator: %s is name of a SQL construct, eg LIMIT */
|
||||
errmsg("argument of %s must not contain variables",
|
||||
constructName)));
|
||||
}
|
||||
if (checkExprHasAggs(qual))
|
||||
{
|
||||
/* translator: %s is name of a SQL construct, eg LIMIT */
|
||||
elog(ERROR, "argument of %s must not contain aggregates",
|
||||
constructName);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_GROUPING_ERROR),
|
||||
/* translator: %s is name of a SQL construct, eg LIMIT */
|
||||
errmsg("argument of %s must not contain aggregates",
|
||||
constructName)));
|
||||
}
|
||||
if (contain_subplans(qual))
|
||||
{
|
||||
/* translator: %s is name of a SQL construct, eg LIMIT */
|
||||
elog(ERROR, "argument of %s must not contain subselects",
|
||||
constructName);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/* translator: %s is name of a SQL construct, eg LIMIT */
|
||||
errmsg("argument of %s must not contain sub-selects",
|
||||
constructName)));
|
||||
}
|
||||
|
||||
return qual;
|
||||
@ -1083,7 +1113,7 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
|
||||
* is a matching column. If so, fall through to let
|
||||
* transformExpr() do the rest. NOTE: if name could refer
|
||||
* ambiguously to more than one column name exposed by FROM,
|
||||
* colnameToVar will elog(ERROR). That's just what we want
|
||||
* colnameToVar will ereport(ERROR). That's just what we want
|
||||
* here.
|
||||
*/
|
||||
if (colnameToVar(pstate, name) != NULL)
|
||||
@ -1103,8 +1133,11 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
|
||||
if (target_result != NULL)
|
||||
{
|
||||
if (!equal(target_result->expr, tle->expr))
|
||||
elog(ERROR, "%s '%s' is ambiguous",
|
||||
clauseText[clause], name);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_COLUMN),
|
||||
/* translator: first %s is name of a SQL construct, eg ORDER BY */
|
||||
errmsg("%s \"%s\" is ambiguous",
|
||||
clauseText[clause], name)));
|
||||
}
|
||||
else
|
||||
target_result = tle;
|
||||
@ -1122,7 +1155,11 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
|
||||
int target_pos;
|
||||
|
||||
if (!IsA(val, Integer))
|
||||
elog(ERROR, "Non-integer constant in %s", clauseText[clause]);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
/* translator: %s is name of a SQL construct, eg ORDER BY */
|
||||
errmsg("non-integer constant in %s",
|
||||
clauseText[clause])));
|
||||
target_pos = intVal(val);
|
||||
foreach(tl, tlist)
|
||||
{
|
||||
@ -1135,8 +1172,11 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
|
||||
return tle; /* return the unique match */
|
||||
}
|
||||
}
|
||||
elog(ERROR, "%s position %d is not in target list",
|
||||
clauseText[clause], target_pos);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
/* translator: %s is name of a SQL construct, eg ORDER BY */
|
||||
errmsg("%s position %d is not in target list",
|
||||
clauseText[clause], target_pos)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1316,7 +1356,9 @@ transformDistinctClause(ParseState *pstate, List *distinctlist,
|
||||
TargetEntry *tle = get_sortgroupclause_tle(scl, targetlist);
|
||||
|
||||
if (tle->resdom->resjunk)
|
||||
elog(ERROR, "For SELECT DISTINCT, ORDER BY expressions must appear in target list");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("for SELECT DISTINCT, ORDER BY expressions must appear in target list")));
|
||||
else
|
||||
result = lappend(result, copyObject(scl));
|
||||
}
|
||||
@ -1354,7 +1396,9 @@ transformDistinctClause(ParseState *pstate, List *distinctlist,
|
||||
SortClause *scl = (SortClause *) lfirst(nextsortlist);
|
||||
|
||||
if (tle->resdom->ressortgroupref != scl->tleSortGroupRef)
|
||||
elog(ERROR, "SELECT DISTINCT ON expressions must match initial ORDER BY expressions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("SELECT DISTINCT ON expressions must match initial ORDER BY expressions")));
|
||||
result = lappend(result, copyObject(scl));
|
||||
nextsortlist = lnext(nextsortlist);
|
||||
}
|
||||
@ -1378,8 +1422,8 @@ transformDistinctClause(ParseState *pstate, List *distinctlist,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (slitem == NIL)
|
||||
elog(ERROR, "transformDistinctClause: failed to add DISTINCT ON clause to target list");
|
||||
if (slitem == NIL) /* should not happen */
|
||||
elog(ERROR, "failed to add DISTINCT ON clause to target list");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.104 2003/07/18 23:20:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.105 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -44,7 +44,7 @@ static Node *coerce_type_typmod(Node *node,
|
||||
* cases (eg, when the conversion is expected to succeed).
|
||||
*
|
||||
* Returns the possibly-transformed expression tree, or NULL if the type
|
||||
* conversion is not possible. (We do this, rather than elog'ing directly,
|
||||
* conversion is not possible. (We do this, rather than ereport'ing directly,
|
||||
* so that callers can generate custom error messages indicating context.)
|
||||
*
|
||||
* pstate - parse state (can be NULL, see coerce_type)
|
||||
@ -248,7 +248,7 @@ coerce_type(ParseState *pstate, Node *node,
|
||||
(errcode(ERRCODE_AMBIGUOUS_PARAMETER),
|
||||
errmsg("inconsistent types deduced for parameter $%d",
|
||||
paramno),
|
||||
errdetail("Could be either %s or %s.",
|
||||
errdetail("%s versus %s",
|
||||
format_type_be(toppstate->p_paramtypes[paramno-1]),
|
||||
format_type_be(targetTypeId))));
|
||||
}
|
||||
@ -330,7 +330,7 @@ coerce_type(ParseState *pstate, Node *node,
|
||||
cformat);
|
||||
}
|
||||
/* If we get here, caller blew it */
|
||||
elog(ERROR, "coerce_type: no conversion function from %s to %s",
|
||||
elog(ERROR, "failed to find conversion function from %s to %s",
|
||||
format_type_be(inputTypeId), format_type_be(targetTypeId));
|
||||
return NULL; /* keep compiler quiet */
|
||||
}
|
||||
@ -566,19 +566,19 @@ coerce_to_boolean(ParseState *pstate, Node *node,
|
||||
COERCION_ASSIGNMENT,
|
||||
COERCE_IMPLICIT_CAST);
|
||||
if (node == NULL)
|
||||
{
|
||||
/* translator: first %s is name of a SQL construct, eg WHERE */
|
||||
elog(ERROR, "argument of %s must be type boolean, not type %s",
|
||||
constructName, format_type_be(inputTypeId));
|
||||
}
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
/* translator: first %s is name of a SQL construct, eg WHERE */
|
||||
errmsg("argument of %s must be type boolean, not type %s",
|
||||
constructName, format_type_be(inputTypeId))));
|
||||
}
|
||||
|
||||
if (expression_returns_set(node))
|
||||
{
|
||||
/* translator: %s is name of a SQL construct, eg WHERE */
|
||||
elog(ERROR, "argument of %s must not be a set function",
|
||||
constructName);
|
||||
}
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
/* translator: %s is name of a SQL construct, eg WHERE */
|
||||
errmsg("argument of %s must not return a set",
|
||||
constructName)));
|
||||
|
||||
return node;
|
||||
}
|
||||
@ -605,19 +605,19 @@ coerce_to_integer(ParseState *pstate, Node *node,
|
||||
COERCION_ASSIGNMENT,
|
||||
COERCE_IMPLICIT_CAST);
|
||||
if (node == NULL)
|
||||
{
|
||||
/* translator: first %s is name of a SQL construct, eg LIMIT */
|
||||
elog(ERROR, "argument of %s must be type integer, not type %s",
|
||||
constructName, format_type_be(inputTypeId));
|
||||
}
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
/* translator: first %s is name of a SQL construct, eg LIMIT */
|
||||
errmsg("argument of %s must be type integer, not type %s",
|
||||
constructName, format_type_be(inputTypeId))));
|
||||
}
|
||||
|
||||
if (expression_returns_set(node))
|
||||
{
|
||||
/* translator: %s is name of a SQL construct, eg LIMIT */
|
||||
elog(ERROR, "argument of %s must not be a set function",
|
||||
constructName);
|
||||
}
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
/* translator: %s is name of a SQL construct, eg LIMIT */
|
||||
errmsg("argument of %s must not return a set",
|
||||
constructName)));
|
||||
|
||||
return node;
|
||||
}
|
||||
@ -662,8 +662,13 @@ select_common_type(List *typeids, const char *context)
|
||||
* both types in different categories? then not much
|
||||
* hope...
|
||||
*/
|
||||
elog(ERROR, "%s types '%s' and '%s' not matched",
|
||||
context, format_type_be(ptype), format_type_be(ntype));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
/* translator: first %s is name of a SQL construct, eg CASE */
|
||||
errmsg("%s types %s and %s cannot be matched",
|
||||
context,
|
||||
format_type_be(ptype),
|
||||
format_type_be(ntype))));
|
||||
}
|
||||
else if (!IsPreferredType(pcategory, ptype) &&
|
||||
can_coerce_type(1, &ptype, &ntype, COERCION_IMPLICIT) &&
|
||||
@ -718,8 +723,13 @@ coerce_to_common_type(ParseState *pstate, Node *node,
|
||||
node = coerce_type(pstate, node, inputTypeId, targetTypeId,
|
||||
COERCION_IMPLICIT, COERCE_IMPLICIT_CAST);
|
||||
else
|
||||
elog(ERROR, "%s unable to convert to type %s",
|
||||
context, format_type_be(targetTypeId));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CANNOT_COERCE),
|
||||
/* translator: first %s is name of a SQL construct, eg CASE */
|
||||
errmsg("%s unable to convert type %s to %s",
|
||||
context,
|
||||
format_type_be(inputTypeId),
|
||||
format_type_be(targetTypeId))));
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -740,7 +750,7 @@ coerce_to_common_type(ParseState *pstate, Node *node,
|
||||
* If we have UNKNOWN input (ie, an untyped literal) for any ANYELEMENT
|
||||
* or ANYARRAY argument, assume it is okay.
|
||||
*
|
||||
* We do not elog here, but just return FALSE if a rule is violated.
|
||||
* We do not ereport here, but just return FALSE if a rule is violated.
|
||||
*/
|
||||
bool
|
||||
check_generic_type_consistency(Oid *actual_arg_types,
|
||||
@ -870,9 +880,12 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
|
||||
continue;
|
||||
}
|
||||
if (OidIsValid(elem_typeid) && actual_type != elem_typeid)
|
||||
elog(ERROR, "Arguments declared ANYELEMENT are not all alike: %s vs %s",
|
||||
format_type_be(elem_typeid),
|
||||
format_type_be(actual_type));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("arguments declared ANYELEMENT are not all alike"),
|
||||
errdetail("%s versus %s",
|
||||
format_type_be(elem_typeid),
|
||||
format_type_be(actual_type))));
|
||||
elem_typeid = actual_type;
|
||||
}
|
||||
else if (declared_arg_types[j] == ANYARRAYOID)
|
||||
@ -884,9 +897,12 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
|
||||
continue;
|
||||
}
|
||||
if (OidIsValid(array_typeid) && actual_type != array_typeid)
|
||||
elog(ERROR, "Arguments declared ANYARRAY are not all alike: %s vs %s",
|
||||
format_type_be(array_typeid),
|
||||
format_type_be(actual_type));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("arguments declared ANYARRAY are not all alike"),
|
||||
errdetail("%s versus %s",
|
||||
format_type_be(array_typeid),
|
||||
format_type_be(actual_type))));
|
||||
array_typeid = actual_type;
|
||||
}
|
||||
}
|
||||
@ -903,8 +919,10 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
|
||||
{
|
||||
array_typelem = get_element_type(array_typeid);
|
||||
if (!OidIsValid(array_typelem))
|
||||
elog(ERROR, "Argument declared ANYARRAY is not an array: %s",
|
||||
format_type_be(array_typeid));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("argument declared ANYARRAY is not an array but %s",
|
||||
format_type_be(array_typeid))));
|
||||
|
||||
if (!OidIsValid(elem_typeid))
|
||||
{
|
||||
@ -914,16 +932,20 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
|
||||
else if (array_typelem != elem_typeid)
|
||||
{
|
||||
/* otherwise, they better match */
|
||||
elog(ERROR, "Argument declared ANYARRAY is not consistent with "
|
||||
"argument declared ANYELEMENT: %s vs %s",
|
||||
format_type_be(array_typeid),
|
||||
format_type_be(elem_typeid));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("argument declared ANYARRAY is not consistent with argument declared ANYELEMENT"),
|
||||
errdetail("%s versus %s",
|
||||
format_type_be(array_typeid),
|
||||
format_type_be(elem_typeid))));
|
||||
}
|
||||
}
|
||||
else if (!OidIsValid(elem_typeid))
|
||||
{
|
||||
/* Only way to get here is if all the generic args are UNKNOWN */
|
||||
elog(ERROR, "Cannot determine ANYARRAY/ANYELEMENT type because input is UNKNOWN");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("cannot determine ANYARRAY/ANYELEMENT type because input is UNKNOWN")));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -948,8 +970,10 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
|
||||
{
|
||||
array_typeid = get_array_type(elem_typeid);
|
||||
if (!OidIsValid(array_typeid))
|
||||
elog(ERROR, "Cannot find array type for datatype %s",
|
||||
format_type_be(elem_typeid));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("cannot find array type for datatype %s",
|
||||
format_type_be(elem_typeid))));
|
||||
}
|
||||
declared_arg_types[j] = array_typeid;
|
||||
}
|
||||
@ -963,8 +987,10 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
|
||||
{
|
||||
array_typeid = get_array_type(elem_typeid);
|
||||
if (!OidIsValid(array_typeid))
|
||||
elog(ERROR, "Cannot find array type for datatype %s",
|
||||
format_type_be(elem_typeid));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("cannot find array type for datatype %s",
|
||||
format_type_be(elem_typeid))));
|
||||
}
|
||||
return array_typeid;
|
||||
}
|
||||
@ -1003,8 +1029,10 @@ resolve_generic_type(Oid declared_type,
|
||||
Oid array_typelem = get_element_type(context_actual_type);
|
||||
|
||||
if (!OidIsValid(array_typelem))
|
||||
elog(ERROR, "Argument declared ANYARRAY is not an array: %s",
|
||||
format_type_be(context_actual_type));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("argument declared ANYARRAY is not an array but %s",
|
||||
format_type_be(context_actual_type))));
|
||||
return context_actual_type;
|
||||
}
|
||||
else if (context_declared_type == ANYELEMENTOID)
|
||||
@ -1013,8 +1041,10 @@ resolve_generic_type(Oid declared_type,
|
||||
Oid array_typeid = get_array_type(context_actual_type);
|
||||
|
||||
if (!OidIsValid(array_typeid))
|
||||
elog(ERROR, "Cannot find array type for datatype %s",
|
||||
format_type_be(context_actual_type));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("cannot find array type for datatype %s",
|
||||
format_type_be(context_actual_type))));
|
||||
return array_typeid;
|
||||
}
|
||||
}
|
||||
@ -1026,8 +1056,10 @@ resolve_generic_type(Oid declared_type,
|
||||
Oid array_typelem = get_element_type(context_actual_type);
|
||||
|
||||
if (!OidIsValid(array_typelem))
|
||||
elog(ERROR, "Argument declared ANYARRAY is not an array: %s",
|
||||
format_type_be(context_actual_type));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("argument declared ANYARRAY is not an array but %s",
|
||||
format_type_be(context_actual_type))));
|
||||
return array_typelem;
|
||||
}
|
||||
else if (context_declared_type == ANYELEMENTOID)
|
||||
@ -1043,7 +1075,7 @@ resolve_generic_type(Oid declared_type,
|
||||
}
|
||||
/* If we get here, declared_type is polymorphic and context isn't */
|
||||
/* NB: this is a calling-code logic error, not a user error */
|
||||
elog(ERROR, "Cannot determine ANYARRAY/ANYELEMENT type because context isn't polymorphic");
|
||||
elog(ERROR, "cannot determine ANYARRAY/ANYELEMENT type because context isn't polymorphic");
|
||||
return InvalidOid; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -1234,7 +1266,7 @@ IsPreferredType(CATEGORY category, Oid type)
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "IsPreferredType: unknown category");
|
||||
elog(ERROR, "unrecognized type category: %d", (int) category);
|
||||
preftype = UNKNOWNOID;
|
||||
break;
|
||||
}
|
||||
@ -1365,8 +1397,8 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
|
||||
castcontext = COERCION_EXPLICIT;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "find_coercion_pathway: bogus castcontext %c",
|
||||
castForm->castcontext);
|
||||
elog(ERROR, "unrecognized castcontext: %d",
|
||||
(int) castForm->castcontext);
|
||||
castcontext = 0; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.156 2003/07/18 23:20:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.157 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -51,7 +51,7 @@ static Node *transformIndirection(ParseState *pstate, Node *basenode,
|
||||
* Initialize for parsing a new query.
|
||||
*
|
||||
* We reset the expression depth counter here, in case it was left nonzero
|
||||
* due to elog()'ing out of the last parsing operation.
|
||||
* due to ereport()'ing out of the last parsing operation.
|
||||
*/
|
||||
void
|
||||
parse_expr_init(void)
|
||||
@ -100,8 +100,11 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
* to be able to crash the backend quite that easily...
|
||||
*/
|
||||
if (++expr_depth_counter > max_expr_depth)
|
||||
elog(ERROR, "Expression too complex: nesting depth exceeds max_expr_depth = %d",
|
||||
max_expr_depth);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
|
||||
errmsg("expression too complex"),
|
||||
errdetail("Nesting depth exceeds MAX_EXPR_DEPTH = %d.",
|
||||
max_expr_depth)));
|
||||
|
||||
switch (nodeTag(expr))
|
||||
{
|
||||
@ -343,7 +346,9 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
lexpr,
|
||||
rexpr);
|
||||
if (((OpExpr *) result)->opresulttype != BOOLOID)
|
||||
elog(ERROR, "IS DISTINCT FROM requires = operator to yield boolean");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("IS DISTINCT FROM requires = operator to yield boolean")));
|
||||
/*
|
||||
* We rely on DistinctExpr and OpExpr being same struct
|
||||
*/
|
||||
@ -362,7 +367,9 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
lexpr,
|
||||
rexpr);
|
||||
if (((OpExpr *) result)->opresulttype != BOOLOID)
|
||||
elog(ERROR, "NULLIF requires = operator to yield boolean");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("NULLIF requires = operator to yield boolean")));
|
||||
/*
|
||||
* We rely on NullIfExpr and OpExpr being same struct
|
||||
*/
|
||||
@ -451,11 +458,11 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
pstate->p_hasSubLinks = true;
|
||||
qtrees = parse_sub_analyze(sublink->subselect, pstate);
|
||||
if (length(qtrees) != 1)
|
||||
elog(ERROR, "Bad query in subselect");
|
||||
elog(ERROR, "bad query in sub-select");
|
||||
qtree = (Query *) lfirst(qtrees);
|
||||
if (qtree->commandType != CMD_SELECT ||
|
||||
qtree->resultRelation != 0)
|
||||
elog(ERROR, "Bad query in subselect");
|
||||
elog(ERROR, "bad query in sub-select");
|
||||
sublink->subselect = (Node *) qtree;
|
||||
|
||||
if (sublink->subLinkType == EXISTS_SUBLINK)
|
||||
@ -480,11 +487,15 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
*/
|
||||
if (tlist == NIL ||
|
||||
((TargetEntry *) lfirst(tlist))->resdom->resjunk)
|
||||
elog(ERROR, "Subselect must have a field");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("sub-select must return a column")));
|
||||
while ((tlist = lnext(tlist)) != NIL)
|
||||
{
|
||||
if (!((TargetEntry *) lfirst(tlist))->resdom->resjunk)
|
||||
elog(ERROR, "Subselect must have only one field");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("sub-select must return only one column")));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -536,8 +547,10 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
if (row_length != 1 &&
|
||||
strcmp(opname, "=") != 0 &&
|
||||
strcmp(opname, "<>") != 0)
|
||||
elog(ERROR, "Row comparison cannot use operator %s",
|
||||
opname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("row comparison cannot use operator %s",
|
||||
opname)));
|
||||
|
||||
/*
|
||||
* To build the list of combining operator OIDs, we must
|
||||
@ -561,7 +574,9 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
continue;
|
||||
|
||||
if (left_list == NIL)
|
||||
elog(ERROR, "Subselect has too many fields");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("sub-select has too many columns")));
|
||||
lexpr = lfirst(left_list);
|
||||
left_list = lnext(left_list);
|
||||
|
||||
@ -577,15 +592,19 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
opform = (Form_pg_operator) GETSTRUCT(optup);
|
||||
|
||||
if (opform->oprresult != BOOLOID)
|
||||
elog(ERROR, "%s has result type of %s, but must return %s"
|
||||
" to be used with quantified predicate subquery",
|
||||
opname, format_type_be(opform->oprresult),
|
||||
format_type_be(BOOLOID));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("operator %s must return boolean, not type %s",
|
||||
opname,
|
||||
format_type_be(opform->oprresult)),
|
||||
errhint("The operator of a quantified predicate subquery must return boolean.")));
|
||||
|
||||
if (get_func_retset(opform->oprcode))
|
||||
elog(ERROR, "%s must not return a set"
|
||||
" to be used with quantified predicate subquery",
|
||||
opname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("operator %s must not return a set",
|
||||
opname),
|
||||
errhint("The operator of a quantified predicate subquery must return boolean.")));
|
||||
|
||||
sublink->operOids = lappendo(sublink->operOids,
|
||||
oprid(optup));
|
||||
@ -593,7 +612,9 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
ReleaseSysCache(optup);
|
||||
}
|
||||
if (left_list != NIL)
|
||||
elog(ERROR, "Subselect has too few fields");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("sub-select has too few columns")));
|
||||
|
||||
if (needNot)
|
||||
{
|
||||
@ -762,8 +783,10 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
array_type = element_type;
|
||||
element_type = get_element_type(array_type);
|
||||
if (!OidIsValid(element_type))
|
||||
elog(ERROR, "Cannot find array type for datatype %s",
|
||||
format_type_be(array_type));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("cannot find array type for datatype %s",
|
||||
format_type_be(array_type))));
|
||||
|
||||
/*
|
||||
* make sure the element expressions all have the same
|
||||
@ -775,15 +798,19 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
ArrayExpr *e = (ArrayExpr *) lfirst(element);
|
||||
|
||||
if (!IsA(e, ArrayExpr))
|
||||
elog(ERROR, "Multidimensional ARRAY[] must be built from nested array expressions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("multidimensional ARRAY[] must be built from nested array expressions")));
|
||||
if (ndims == 0)
|
||||
ndims = e->ndims;
|
||||
else if (e->ndims != ndims)
|
||||
elog(ERROR, "Nested array expressions must have "
|
||||
"common number of dimensions");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("nested array expressions must have common number of dimensions")));
|
||||
if (e->element_typeid != element_type)
|
||||
elog(ERROR, "Nested array expressions must have "
|
||||
"common element type");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("nested array expressions must have common element type")));
|
||||
|
||||
}
|
||||
/* increment the number of dimensions */
|
||||
@ -791,9 +818,10 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
|
||||
/* make sure we don't have too many dimensions now */
|
||||
if (ndims > MAXDIM)
|
||||
elog(ERROR, "Number of array dimensions, %d, "
|
||||
"exceeds the maximum allowed %d",
|
||||
ndims, MAXDIM);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("number of array dimensions exceeds the maximum allowed, %d",
|
||||
MAXDIM)));
|
||||
}
|
||||
|
||||
newa->array_typeid = array_type;
|
||||
@ -879,7 +907,7 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
clausename = "IS NOT UNKNOWN";
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "transformExpr: unexpected booltesttype %d",
|
||||
elog(ERROR, "unrecognized booltesttype: %d",
|
||||
(int) b->booltesttype);
|
||||
clausename = NULL; /* keep compiler quiet */
|
||||
}
|
||||
@ -925,8 +953,7 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
|
||||
default:
|
||||
/* should not reach here */
|
||||
elog(ERROR, "transformExpr: does not know how to transform node %d"
|
||||
" (internal error)", nodeTag(expr));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1030,7 +1057,9 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
|
||||
node = (Node *) rv;
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Attribute \"%s\" not found", name);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("attribute \"%s\" not found", name)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1112,7 +1141,9 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
|
||||
* We check the catalog name and then ignore it.
|
||||
*/
|
||||
if (strcmp(name1, get_database_name(MyDatabaseId)) != 0)
|
||||
elog(ERROR, "Cross-database references are not implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cross-database references are not implemented")));
|
||||
|
||||
/* Whole-row reference? */
|
||||
if (strcmp(name4, "*") == 0)
|
||||
@ -1142,7 +1173,10 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
elog(ERROR, "Invalid qualified name syntax (too many names)");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("improper qualified name (too many dotted names): %s",
|
||||
NameListToString(cref->fields))));
|
||||
node = NULL; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -1206,7 +1240,7 @@ exprType(Node *expr)
|
||||
TargetEntry *tent;
|
||||
|
||||
if (!qtree || !IsA(qtree, Query))
|
||||
elog(ERROR, "exprType: Cannot get type for untransformed sublink");
|
||||
elog(ERROR, "cannot get type for untransformed sublink");
|
||||
tent = (TargetEntry *) lfirst(qtree->targetList);
|
||||
Assert(IsA(tent, TargetEntry));
|
||||
Assert(!tent->resdom->resjunk);
|
||||
@ -1216,8 +1250,10 @@ exprType(Node *expr)
|
||||
{
|
||||
type = get_array_type(tent->resdom->restype);
|
||||
if (!OidIsValid(type))
|
||||
elog(ERROR, "Cannot find array type for datatype %s",
|
||||
format_type_be(tent->resdom->restype));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("cannot find array type for datatype %s",
|
||||
format_type_be(tent->resdom->restype))));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1251,8 +1287,10 @@ exprType(Node *expr)
|
||||
{
|
||||
type = get_array_type(tent->resdom->restype);
|
||||
if (!OidIsValid(type))
|
||||
elog(ERROR, "Cannot find array type for datatype %s",
|
||||
format_type_be(tent->resdom->restype));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("cannot find array type for datatype %s",
|
||||
format_type_be(tent->resdom->restype))));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1304,13 +1342,14 @@ exprType(Node *expr)
|
||||
* we will likely first notice a problem here (see comments in
|
||||
* transformColumnRef()). Issue an appropriate error message.
|
||||
*/
|
||||
elog(ERROR, "Relation reference \"%s\" cannot be used in an expression",
|
||||
((RangeVar *) expr)->relname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("relation reference \"%s\" cannot be used in an expression",
|
||||
((RangeVar *) expr)->relname)));
|
||||
type = InvalidOid; /* keep compiler quiet */
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "exprType: Do not know how to get type for %d node",
|
||||
nodeTag(expr));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
|
||||
type = InvalidOid; /* keep compiler quiet */
|
||||
break;
|
||||
}
|
||||
@ -1511,9 +1550,11 @@ typecast_expression(ParseState *pstate, Node *expr, TypeName *typename)
|
||||
COERCION_EXPLICIT,
|
||||
COERCE_EXPLICIT_CAST);
|
||||
if (expr == NULL)
|
||||
elog(ERROR, "Cannot cast type %s to %s",
|
||||
format_type_be(inputType),
|
||||
format_type_be(targetType));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CANNOT_COERCE),
|
||||
errmsg("cannot cast type %s to %s",
|
||||
format_type_be(inputType),
|
||||
format_type_be(targetType))));
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.154 2003/07/18 23:20:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.155 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -179,7 +179,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
case RTE_RELATION:
|
||||
toid = get_rel_type_id(rte->relid);
|
||||
if (!OidIsValid(toid))
|
||||
elog(ERROR, "cannot find type OID for relation %u",
|
||||
elog(ERROR, "could not find type OID for relation %u",
|
||||
rte->relid);
|
||||
/* replace RangeVar in the arg list */
|
||||
lfirst(i) = makeVar(vnum,
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.78 2003/04/29 22:13:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.79 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -114,14 +114,15 @@ transformArraySubscripts(ParseState *pstate,
|
||||
ObjectIdGetDatum(arrayType),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(type_tuple_array))
|
||||
elog(ERROR, "transformArraySubscripts: Cache lookup failed for array type %u",
|
||||
arrayType);
|
||||
elog(ERROR, "cache lookup failed for type %u", arrayType);
|
||||
type_struct_array = (Form_pg_type) GETSTRUCT(type_tuple_array);
|
||||
|
||||
elementType = type_struct_array->typelem;
|
||||
if (elementType == InvalidOid)
|
||||
elog(ERROR, "transformArraySubscripts: type %s is not an array",
|
||||
NameStr(type_struct_array->typname));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("cannot subscript type %s because it is not an array",
|
||||
format_type_be(arrayType))));
|
||||
|
||||
/*
|
||||
* A list containing only single subscripts refers to a single array
|
||||
@ -177,7 +178,9 @@ transformArraySubscripts(ParseState *pstate,
|
||||
COERCION_ASSIGNMENT,
|
||||
COERCE_IMPLICIT_CAST);
|
||||
if (subexpr == NULL)
|
||||
elog(ERROR, "array index expressions must be integers");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("array subscript must have type integer")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -198,7 +201,9 @@ transformArraySubscripts(ParseState *pstate,
|
||||
COERCION_ASSIGNMENT,
|
||||
COERCE_IMPLICIT_CAST);
|
||||
if (subexpr == NULL)
|
||||
elog(ERROR, "array index expressions must be integers");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("array subscript must have type integer")));
|
||||
upperIndexpr = lappend(upperIndexpr, subexpr);
|
||||
}
|
||||
|
||||
@ -218,11 +223,13 @@ transformArraySubscripts(ParseState *pstate,
|
||||
COERCION_ASSIGNMENT,
|
||||
COERCE_IMPLICIT_CAST);
|
||||
if (assignFrom == NULL)
|
||||
elog(ERROR, "Array assignment requires type %s"
|
||||
" but expression is of type %s"
|
||||
"\n\tYou will need to rewrite or cast the expression",
|
||||
format_type_be(typeneeded),
|
||||
format_type_be(typesource));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("array assignment requires type %s"
|
||||
" but expression is of type %s",
|
||||
format_type_be(typeneeded),
|
||||
format_type_be(typesource)),
|
||||
errhint("You will need to rewrite or cast the expression.")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,18 +330,18 @@ make_const(Value *value)
|
||||
typebyval = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(WARNING, "make_const: unknown type %d", nodeTag(value));
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case T_Null:
|
||||
/* return a null const */
|
||||
con = makeConst(UNKNOWNOID,
|
||||
-1,
|
||||
(Datum) NULL,
|
||||
(Datum) 0,
|
||||
true,
|
||||
false);
|
||||
return con;
|
||||
|
||||
default:
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(value));
|
||||
return NULL; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
con = makeConst(typeid,
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.83 2003/06/15 17:59:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.84 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -62,7 +62,8 @@ static void warnAutoRange(ParseState *pstate, RangeVar *relation);
|
||||
* An unqualified refname (schemaname == NULL) can match any RTE with matching
|
||||
* alias, or matching unqualified relname in the case of alias-less relation
|
||||
* RTEs. It is possible that such a refname matches multiple RTEs in the
|
||||
* nearest nesting level that has a match; if so, we report an error via elog.
|
||||
* nearest nesting level that has a match; if so, we report an error via
|
||||
* ereport().
|
||||
*
|
||||
* A qualified refname (schemaname != NULL) can only match a relation RTE
|
||||
* that (a) has no alias and (b) is for the same relation identified by
|
||||
@ -168,7 +169,10 @@ scanNameSpaceForRefname(ParseState *pstate, Node *nsnode,
|
||||
if (!result)
|
||||
result = newresult;
|
||||
else if (newresult)
|
||||
elog(ERROR, "Table reference \"%s\" is ambiguous", refname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_ALIAS),
|
||||
errmsg("table reference \"%s\" is ambiguous",
|
||||
refname)));
|
||||
}
|
||||
else if (IsA(nsnode, List))
|
||||
{
|
||||
@ -180,12 +184,14 @@ scanNameSpaceForRefname(ParseState *pstate, Node *nsnode,
|
||||
if (!result)
|
||||
result = newresult;
|
||||
else if (newresult)
|
||||
elog(ERROR, "Table reference \"%s\" is ambiguous", refname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_ALIAS),
|
||||
errmsg("table reference \"%s\" is ambiguous",
|
||||
refname)));
|
||||
}
|
||||
}
|
||||
else
|
||||
elog(ERROR, "scanNameSpaceForRefname: unexpected node type %d",
|
||||
nodeTag(nsnode));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(nsnode));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -238,7 +244,10 @@ scanNameSpaceForRelid(ParseState *pstate, Node *nsnode, Oid relid)
|
||||
if (!result)
|
||||
result = newresult;
|
||||
else if (newresult)
|
||||
elog(ERROR, "Table reference %u is ambiguous", relid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_ALIAS),
|
||||
errmsg("table reference %u is ambiguous",
|
||||
relid)));
|
||||
}
|
||||
else if (IsA(nsnode, List))
|
||||
{
|
||||
@ -250,12 +259,14 @@ scanNameSpaceForRelid(ParseState *pstate, Node *nsnode, Oid relid)
|
||||
if (!result)
|
||||
result = newresult;
|
||||
else if (newresult)
|
||||
elog(ERROR, "Table reference %u is ambiguous", relid);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_ALIAS),
|
||||
errmsg("table reference %u is ambiguous",
|
||||
relid)));
|
||||
}
|
||||
}
|
||||
else
|
||||
elog(ERROR, "scanNameSpaceForRelid: unexpected node type %d",
|
||||
nodeTag(nsnode));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(nsnode));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -318,8 +329,7 @@ checkNameSpaceConflicts(ParseState *pstate, Node *namespace1,
|
||||
checkNameSpaceConflicts(pstate, lfirst(l), namespace2);
|
||||
}
|
||||
else
|
||||
elog(ERROR, "checkNameSpaceConflicts: unexpected node type %d",
|
||||
nodeTag(namespace1));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(namespace1));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -341,8 +351,10 @@ scanNameSpaceForConflict(ParseState *pstate, Node *nsnode,
|
||||
if (rte->rtekind == RTE_RELATION && rte->alias == NULL &&
|
||||
rte1 != NULL && rte->relid != rte1->relid)
|
||||
return; /* no conflict per SQL92 rule */
|
||||
elog(ERROR, "Table name \"%s\" specified more than once",
|
||||
aliasname1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_ALIAS),
|
||||
errmsg("table name \"%s\" specified more than once",
|
||||
aliasname1)));
|
||||
}
|
||||
else if (IsA(nsnode, JoinExpr))
|
||||
{
|
||||
@ -351,8 +363,10 @@ scanNameSpaceForConflict(ParseState *pstate, Node *nsnode,
|
||||
if (j->alias)
|
||||
{
|
||||
if (strcmp(j->alias->aliasname, aliasname1) == 0)
|
||||
elog(ERROR, "Table name \"%s\" specified more than once",
|
||||
aliasname1);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_ALIAS),
|
||||
errmsg("table name \"%s\" specified more than once",
|
||||
aliasname1)));
|
||||
|
||||
/*
|
||||
* Tables within an aliased join are invisible from outside
|
||||
@ -372,8 +386,7 @@ scanNameSpaceForConflict(ParseState *pstate, Node *nsnode,
|
||||
scanNameSpaceForConflict(pstate, lfirst(l), rte1, aliasname1);
|
||||
}
|
||||
else
|
||||
elog(ERROR, "scanNameSpaceForConflict: unexpected node type %d",
|
||||
nodeTag(nsnode));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(nsnode));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -407,7 +420,7 @@ RTERangeTablePosn(ParseState *pstate, RangeTblEntry *rte, int *sublevels_up)
|
||||
break;
|
||||
}
|
||||
|
||||
elog(ERROR, "RTERangeTablePosn: RTE not found (internal error)");
|
||||
elog(ERROR, "RTE not found (internal error)");
|
||||
return 0; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -459,7 +472,10 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname)
|
||||
get_rte_attribute_is_dropped(rte, attnum))
|
||||
continue;
|
||||
if (result)
|
||||
elog(ERROR, "Column reference \"%s\" is ambiguous", colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_COLUMN),
|
||||
errmsg("column reference \"%s\" is ambiguous",
|
||||
colname)));
|
||||
result = (Node *) make_var(pstate, rte, attnum);
|
||||
rte->checkForRead = true;
|
||||
}
|
||||
@ -546,14 +562,16 @@ colnameToVar(ParseState *pstate, char *colname)
|
||||
newresult = scanRTEForColumn(orig_pstate, rte, colname);
|
||||
}
|
||||
else
|
||||
elog(ERROR, "colnameToVar: unexpected node type %d",
|
||||
nodeTag(nsnode));
|
||||
elog(ERROR, "unrecognized node type: %d",
|
||||
(int) nodeTag(nsnode));
|
||||
|
||||
if (newresult)
|
||||
{
|
||||
if (result)
|
||||
elog(ERROR, "Column reference \"%s\" is ambiguous",
|
||||
colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_AMBIGUOUS_COLUMN),
|
||||
errmsg("column reference \"%s\" is ambiguous",
|
||||
colname)));
|
||||
result = newresult;
|
||||
}
|
||||
}
|
||||
@ -645,8 +663,10 @@ addRangeTableEntry(ParseState *pstate,
|
||||
*/
|
||||
maxattrs = RelationGetNumberOfAttributes(rel);
|
||||
if (maxattrs < numaliases)
|
||||
elog(ERROR, "Table \"%s\" has %d columns available but %d columns specified",
|
||||
RelationGetRelationName(rel), maxattrs, numaliases);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("table \"%s\" has %d columns available but %d columns specified",
|
||||
RelationGetRelationName(rel), maxattrs, numaliases)));
|
||||
|
||||
/* fill in any unspecified alias columns using actual column names */
|
||||
for (varattno = numaliases; varattno < maxattrs; varattno++)
|
||||
@ -738,8 +758,10 @@ addRangeTableEntryForRelation(ParseState *pstate,
|
||||
*/
|
||||
maxattrs = RelationGetNumberOfAttributes(rel);
|
||||
if (maxattrs < numaliases)
|
||||
elog(ERROR, "Table \"%s\" has %d columns available but %d columns specified",
|
||||
RelationGetRelationName(rel), maxattrs, numaliases);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("table \"%s\" has %d columns available but %d columns specified",
|
||||
RelationGetRelationName(rel), maxattrs, numaliases)));
|
||||
|
||||
/* fill in any unspecified alias columns using actual column names */
|
||||
for (varattno = numaliases; varattno < maxattrs; varattno++)
|
||||
@ -831,8 +853,10 @@ addRangeTableEntryForSubquery(ParseState *pstate,
|
||||
}
|
||||
}
|
||||
if (varattno < numaliases)
|
||||
elog(ERROR, "Table \"%s\" has %d columns available but %d columns specified",
|
||||
refname, varattno, numaliases);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("table \"%s\" has %d columns available but %d columns specified",
|
||||
refname, varattno, numaliases)));
|
||||
|
||||
rte->eref = eref;
|
||||
|
||||
@ -906,7 +930,9 @@ addRangeTableEntryForFunction(ParseState *pstate,
|
||||
* pseudo-type
|
||||
*/
|
||||
if (funcrettype != RECORDOID)
|
||||
elog(ERROR, "A column definition list is only allowed for functions returning RECORD");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("a column definition list is only allowed for functions returning RECORD")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -915,7 +941,9 @@ addRangeTableEntryForFunction(ParseState *pstate,
|
||||
* RECORD pseudo-type
|
||||
*/
|
||||
if (funcrettype == RECORDOID)
|
||||
elog(ERROR, "A column definition list is required for functions returning RECORD");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("a column definition list is required for functions returning RECORD")));
|
||||
}
|
||||
|
||||
functyptype = get_typtype(funcrettype);
|
||||
@ -929,9 +957,8 @@ addRangeTableEntryForFunction(ParseState *pstate,
|
||||
Relation rel;
|
||||
int maxattrs;
|
||||
|
||||
if (!OidIsValid(funcrelid))
|
||||
elog(ERROR, "Invalid typrelid for complex type %u",
|
||||
funcrettype);
|
||||
if (!OidIsValid(funcrelid)) /* shouldn't happen if typtype is 'c' */
|
||||
elog(ERROR, "invalid typrelid for complex type %u", funcrettype);
|
||||
|
||||
/*
|
||||
* Get the rel's relcache entry. This access ensures that we have
|
||||
@ -945,8 +972,11 @@ addRangeTableEntryForFunction(ParseState *pstate,
|
||||
*/
|
||||
maxattrs = RelationGetNumberOfAttributes(rel);
|
||||
if (maxattrs < numaliases)
|
||||
elog(ERROR, "Table \"%s\" has %d columns available but %d columns specified",
|
||||
RelationGetRelationName(rel), maxattrs, numaliases);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("table \"%s\" has %d columns available but %d columns specified",
|
||||
RelationGetRelationName(rel),
|
||||
maxattrs, numaliases)));
|
||||
|
||||
/* fill in alias columns using actual column names */
|
||||
for (varattno = numaliases; varattno < maxattrs; varattno++)
|
||||
@ -971,8 +1001,10 @@ addRangeTableEntryForFunction(ParseState *pstate,
|
||||
* column named for the function.
|
||||
*/
|
||||
if (numaliases > 1)
|
||||
elog(ERROR, "Too many column aliases specified for function %s",
|
||||
funcname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("too many column aliases specified for function %s",
|
||||
funcname)));
|
||||
if (numaliases == 0)
|
||||
eref->colnames = makeList1(makeString(eref->aliasname));
|
||||
}
|
||||
@ -992,8 +1024,10 @@ addRangeTableEntryForFunction(ParseState *pstate,
|
||||
}
|
||||
}
|
||||
else
|
||||
elog(ERROR, "function %s() in FROM has unsupported return type",
|
||||
funcname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("function \"%s\" in FROM has unsupported return type",
|
||||
funcname)));
|
||||
|
||||
/*----------
|
||||
* Flags:
|
||||
@ -1284,8 +1318,8 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
|
||||
int maxattrs;
|
||||
int numaliases;
|
||||
|
||||
if (!OidIsValid(funcrelid))
|
||||
elog(ERROR, "Invalid typrelid for complex type %u",
|
||||
if (!OidIsValid(funcrelid)) /* shouldn't happen */
|
||||
elog(ERROR, "invalid typrelid for complex type %u",
|
||||
funcrettype);
|
||||
|
||||
rel = relation_open(funcrelid, AccessShareLock);
|
||||
@ -1382,7 +1416,9 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
|
||||
}
|
||||
}
|
||||
else
|
||||
elog(ERROR, "function in FROM has unsupported return type");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("function in FROM has unsupported return type")));
|
||||
}
|
||||
break;
|
||||
case RTE_JOIN:
|
||||
@ -1424,8 +1460,7 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "expandRTE: unsupported RTE kind %d",
|
||||
(int) rte->rtekind);
|
||||
elog(ERROR, "unrecognized RTE kind: %d", (int) rte->rtekind);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1502,7 +1537,7 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
|
||||
{
|
||||
attname = get_attname(rte->relid, attnum);
|
||||
if (attname == NULL)
|
||||
elog(ERROR, "cache lookup of attribute %d in relation %u failed",
|
||||
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
|
||||
attnum, rte->relid);
|
||||
return attname;
|
||||
}
|
||||
@ -1514,7 +1549,8 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
|
||||
if (attnum > 0 && attnum <= length(rte->eref->colnames))
|
||||
return strVal(nth(attnum - 1, rte->eref->colnames));
|
||||
|
||||
elog(ERROR, "Invalid attnum %d for rangetable entry %s",
|
||||
/* else caller gave us a bogus attnum */
|
||||
elog(ERROR, "invalid attnum %d for rangetable entry %s",
|
||||
attnum, rte->eref->aliasname);
|
||||
return NULL; /* keep compiler quiet */
|
||||
}
|
||||
@ -1539,10 +1575,9 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
|
||||
ObjectIdGetDatum(rte->relid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
/* this shouldn't happen... */
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "Relation \"%s\" does not have attribute %d",
|
||||
get_rel_name(rte->relid), attnum);
|
||||
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
|
||||
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
|
||||
attnum, rte->relid);
|
||||
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
|
||||
|
||||
/*
|
||||
@ -1550,8 +1585,11 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
|
||||
* in scanRTEForColumn.
|
||||
*/
|
||||
if (att_tup->attisdropped)
|
||||
elog(ERROR, "Relation \"%s\" has no column \"%s\"",
|
||||
get_rel_name(rte->relid), NameStr(att_tup->attname));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("relation \"%s\" has no column \"%s\"",
|
||||
get_rel_name(rte->relid),
|
||||
NameStr(att_tup->attname))));
|
||||
*vartype = att_tup->atttypid;
|
||||
*vartypmod = att_tup->atttypmod;
|
||||
ReleaseSysCache(tp);
|
||||
@ -1573,7 +1611,7 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
|
||||
return;
|
||||
}
|
||||
/* falling off end of list shouldn't happen... */
|
||||
elog(ERROR, "Subquery %s does not have attribute %d",
|
||||
elog(ERROR, "subquery %s does not have attribute %d",
|
||||
rte->eref->aliasname, attnum);
|
||||
}
|
||||
break;
|
||||
@ -1594,18 +1632,17 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
|
||||
HeapTuple tp;
|
||||
Form_pg_attribute att_tup;
|
||||
|
||||
if (!OidIsValid(funcrelid))
|
||||
elog(ERROR, "Invalid typrelid for complex type %u",
|
||||
if (!OidIsValid(funcrelid)) /* shouldn't happen */
|
||||
elog(ERROR, "invalid typrelid for complex type %u",
|
||||
funcrettype);
|
||||
|
||||
tp = SearchSysCache(ATTNUM,
|
||||
ObjectIdGetDatum(funcrelid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
/* this shouldn't happen... */
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "Relation \"%s\" does not have attribute %d",
|
||||
get_rel_name(funcrelid), attnum);
|
||||
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
|
||||
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
|
||||
attnum, funcrelid);
|
||||
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
|
||||
|
||||
/*
|
||||
@ -1613,9 +1650,11 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
|
||||
* notes in scanRTEForColumn.
|
||||
*/
|
||||
if (att_tup->attisdropped)
|
||||
elog(ERROR, "Relation \"%s\" has no column \"%s\"",
|
||||
get_rel_name(funcrelid),
|
||||
NameStr(att_tup->attname));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("relation \"%s\" has no column \"%s\"",
|
||||
get_rel_name(funcrelid),
|
||||
NameStr(att_tup->attname))));
|
||||
*vartype = att_tup->atttypid;
|
||||
*vartypmod = att_tup->atttypmod;
|
||||
ReleaseSysCache(tp);
|
||||
@ -1636,7 +1675,9 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
|
||||
*vartypmod = -1;
|
||||
}
|
||||
else
|
||||
elog(ERROR, "function in FROM has unsupported return type");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("function in FROM has unsupported return type")));
|
||||
}
|
||||
break;
|
||||
case RTE_JOIN:
|
||||
@ -1654,8 +1695,7 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "get_rte_attribute_type: unsupported RTE kind %d",
|
||||
(int) rte->rtekind);
|
||||
elog(ERROR, "unrecognized RTE kind: %d", (int) rte->rtekind);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1680,10 +1720,9 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
|
||||
ObjectIdGetDatum(rte->relid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
/* this shouldn't happen... */
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "Relation \"%s\" does not have attribute %d",
|
||||
get_rel_name(rte->relid), attnum);
|
||||
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
|
||||
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
|
||||
attnum, rte->relid);
|
||||
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
|
||||
result = att_tup->attisdropped;
|
||||
ReleaseSysCache(tp);
|
||||
@ -1713,10 +1752,9 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
|
||||
ObjectIdGetDatum(funcrelid),
|
||||
Int16GetDatum(attnum),
|
||||
0, 0);
|
||||
/* this shouldn't happen... */
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "Relation %s does not have attribute %d",
|
||||
get_rel_name(funcrelid), attnum);
|
||||
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
|
||||
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
|
||||
attnum, funcrelid);
|
||||
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
|
||||
result = att_tup->attisdropped;
|
||||
ReleaseSysCache(tp);
|
||||
@ -1731,8 +1769,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "get_rte_attribute_is_dropped: unsupported RTE kind %d",
|
||||
(int) rte->rtekind);
|
||||
elog(ERROR, "unrecognized RTE kind: %d", (int) rte->rtekind);
|
||||
result = false; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -1769,9 +1806,11 @@ attnameAttNum(Relation rd, const char *attname, bool sysColOK)
|
||||
}
|
||||
|
||||
/* on failure */
|
||||
elog(ERROR, "Relation \"%s\" has no column \"%s\"",
|
||||
RelationGetRelationName(rd), attname);
|
||||
return InvalidAttrNumber; /* lint */
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("relation \"%s\" has no column \"%s\"",
|
||||
RelationGetRelationName(rd), attname)));
|
||||
return InvalidAttrNumber; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
/* specialAttNum()
|
||||
@ -1814,7 +1853,7 @@ attnumAttName(Relation rd, int attid)
|
||||
return &sysatt->attname;
|
||||
}
|
||||
if (attid > rd->rd_att->natts)
|
||||
elog(ERROR, "attnumAttName: invalid attribute number %d", attid);
|
||||
elog(ERROR, "invalid attribute number %d", attid);
|
||||
return &rd->rd_att->attrs[attid - 1]->attname;
|
||||
}
|
||||
|
||||
@ -1836,14 +1875,16 @@ attnumTypeId(Relation rd, int attid)
|
||||
return sysatt->atttypid;
|
||||
}
|
||||
if (attid > rd->rd_att->natts)
|
||||
elog(ERROR, "attnumTypeId: invalid attribute number %d", attid);
|
||||
elog(ERROR, "invalid attribute number %d", attid);
|
||||
return rd->rd_att->attrs[attid - 1]->atttypid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a warning about an implicit RTE, if appropriate.
|
||||
* Generate a warning or error about an implicit RTE, if appropriate.
|
||||
*
|
||||
* Our current theory on this is that we should allow "SELECT foo.*"
|
||||
* If ADD_MISSING_FROM is not enabled, raise an error.
|
||||
*
|
||||
* Our current theory on warnings is that we should allow "SELECT foo.*"
|
||||
* but warn about a mixture of explicit and implicit RTEs.
|
||||
*/
|
||||
static void
|
||||
@ -1852,6 +1893,20 @@ warnAutoRange(ParseState *pstate, RangeVar *relation)
|
||||
bool foundInFromCl = false;
|
||||
List *temp;
|
||||
|
||||
if (!add_missing_from)
|
||||
{
|
||||
if (pstate->parentParseState != NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
errmsg("missing FROM-clause entry in subquery for table \"%s\"",
|
||||
relation->relname)));
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
errmsg("missing FROM-clause entry for table \"%s\"",
|
||||
relation->relname)));
|
||||
}
|
||||
|
||||
foreach(temp, pstate->p_rtable)
|
||||
{
|
||||
RangeTblEntry *rte = lfirst(temp);
|
||||
@ -1864,13 +1919,15 @@ warnAutoRange(ParseState *pstate, RangeVar *relation)
|
||||
}
|
||||
if (foundInFromCl)
|
||||
{
|
||||
if (add_missing_from)
|
||||
elog(NOTICE, "Adding missing FROM-clause entry%s for table \"%s\"",
|
||||
pstate->parentParseState != NULL ? " in subquery" : "",
|
||||
relation->relname);
|
||||
if (pstate->parentParseState != NULL)
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
errmsg("adding missing FROM-clause entry in subquery for table \"%s\"",
|
||||
relation->relname)));
|
||||
else
|
||||
elog(ERROR, "Missing FROM-clause entry%s for table \"%s\"",
|
||||
pstate->parentParseState != NULL ? " in subquery" : "",
|
||||
relation->relname);
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
errmsg("adding missing FROM-clause entry for table \"%s\"",
|
||||
relation->relname)));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.106 2003/07/03 16:34:20 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.107 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -61,7 +61,12 @@ transformTargetEntry(ParseState *pstate,
|
||||
expr = transformExpr(pstate, node);
|
||||
|
||||
if (IsA(expr, RangeVar))
|
||||
elog(ERROR, "You can't use relation names alone in the target list, try relation.*.");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("relation reference \"%s\" cannot be used as a targetlist entry",
|
||||
((RangeVar *) expr)->relname),
|
||||
errhint("Write \"%s\".* to denote all the columns of the relation.",
|
||||
((RangeVar *) expr)->relname)));
|
||||
|
||||
type_id = exprType(expr);
|
||||
type_mod = exprTypmod(expr);
|
||||
@ -146,13 +151,18 @@ transformTargetList(ParseState *pstate, List *targetlist)
|
||||
* it.
|
||||
*/
|
||||
if (strcmp(name1, get_database_name(MyDatabaseId)) != 0)
|
||||
elog(ERROR, "Cross-database references are not implemented");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cross-database references are not implemented")));
|
||||
schemaname = strVal(lsecond(fields));
|
||||
relname = strVal(lthird(fields));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
elog(ERROR, "Invalid qualified name syntax (too many names)");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("improper qualified name (too many dotted names): %s",
|
||||
NameListToString(fields))));
|
||||
schemaname = NULL; /* keep compiler quiet */
|
||||
relname = NULL;
|
||||
break;
|
||||
@ -269,7 +279,7 @@ markTargetListOrigin(ParseState *pstate, Resdom *res, Var *var)
|
||||
}
|
||||
/* falling off end of list shouldn't happen... */
|
||||
if (subtl == NIL)
|
||||
elog(ERROR, "Subquery %s does not have attribute %d",
|
||||
elog(ERROR, "subquery %s does not have attribute %d",
|
||||
rte->eref->aliasname, attnum);
|
||||
}
|
||||
break;
|
||||
@ -320,7 +330,10 @@ updateTargetListEntry(ParseState *pstate,
|
||||
|
||||
Assert(rd != NULL);
|
||||
if (attrno <= 0)
|
||||
elog(ERROR, "Cannot assign to system attribute '%s'", colname);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot assign to system attribute \"%s\"",
|
||||
colname)));
|
||||
attrtype = attnumTypeId(rd, attrno);
|
||||
attrtypmod = rd->rd_att->attrs[attrno - 1]->atttypmod;
|
||||
|
||||
@ -339,7 +352,9 @@ updateTargetListEntry(ParseState *pstate,
|
||||
def->typeId = attrtype;
|
||||
def->typeMod = attrtypmod;
|
||||
if (indirection)
|
||||
elog(ERROR, "cannot set an array element to DEFAULT");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot set an array element to DEFAULT")));
|
||||
}
|
||||
|
||||
/* Now we can use exprType() safely. */
|
||||
@ -404,12 +419,14 @@ updateTargetListEntry(ParseState *pstate,
|
||||
COERCION_ASSIGNMENT,
|
||||
COERCE_IMPLICIT_CAST);
|
||||
if (tle->expr == NULL)
|
||||
elog(ERROR, "column \"%s\" is of type %s"
|
||||
" but expression is of type %s"
|
||||
"\n\tYou will need to rewrite or cast the expression",
|
||||
colname,
|
||||
format_type_be(attrtype),
|
||||
format_type_be(type_id));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||
errmsg("column \"%s\" is of type %s"
|
||||
" but expression is of type %s",
|
||||
colname,
|
||||
format_type_be(attrtype),
|
||||
format_type_be(type_id)),
|
||||
errhint("You will need to rewrite or cast the expression.")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,11 +490,14 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
|
||||
char *name = ((ResTarget *) lfirst(tl))->name;
|
||||
int attrno;
|
||||
|
||||
/* Lookup column name, elog on failure */
|
||||
/* Lookup column name, ereport on failure */
|
||||
attrno = attnameAttNum(pstate->p_target_relation, name, false);
|
||||
/* Check for duplicates */
|
||||
if (intMember(attrno, *attrnos))
|
||||
elog(ERROR, "Attribute '%s' specified more than once", name);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_COLUMN),
|
||||
errmsg("attribute \"%s\" specified more than once in INSERT list",
|
||||
name)));
|
||||
*attrnos = lappendi(*attrnos, attrno);
|
||||
}
|
||||
}
|
||||
@ -512,8 +532,7 @@ ExpandAllTables(ParseState *pstate)
|
||||
pstate->p_rtable);
|
||||
else
|
||||
{
|
||||
elog(ERROR, "ExpandAllTables: unexpected node (internal error)"
|
||||
"\n\t%s", nodeToString(n));
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(n));
|
||||
rte = NULL; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@ -530,7 +549,9 @@ ExpandAllTables(ParseState *pstate)
|
||||
|
||||
/* Check for SELECT *; */
|
||||
if (!found_table)
|
||||
elog(ERROR, "Wildcard with no tables specified not allowed");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("SELECT * with no tables specified is not valid")));
|
||||
|
||||
return target;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.57 2003/04/29 22:13:10 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.58 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -57,8 +57,10 @@ LookupTypeName(const TypeName *typename)
|
||||
switch (length(typename->names))
|
||||
{
|
||||
case 1:
|
||||
elog(ERROR, "Improper %%TYPE reference (too few dotted names): %s",
|
||||
NameListToString(typename->names));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("improper %%TYPE reference (too few dotted names): %s",
|
||||
NameListToString(typename->names))));
|
||||
break;
|
||||
case 2:
|
||||
rel->relname = strVal(lfirst(typename->names));
|
||||
@ -76,8 +78,10 @@ LookupTypeName(const TypeName *typename)
|
||||
field = strVal(lfourth(typename->names));
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "Improper %%TYPE reference (too many dotted names): %s",
|
||||
NameListToString(typename->names));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("improper %%TYPE reference (too many dotted names): %s",
|
||||
NameListToString(typename->names))));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -85,16 +89,20 @@ LookupTypeName(const TypeName *typename)
|
||||
relid = RangeVarGetRelid(rel, false);
|
||||
attnum = get_attnum(relid, field);
|
||||
if (attnum == InvalidAttrNumber)
|
||||
elog(ERROR, "Relation \"%s\" has no column \"%s\"",
|
||||
rel->relname, field);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("relation \"%s\" has no column \"%s\"",
|
||||
rel->relname, field)));
|
||||
restype = get_atttype(relid, attnum);
|
||||
|
||||
/* this construct should never have an array indicator */
|
||||
Assert(typename->arrayBounds == NIL);
|
||||
|
||||
/* emit nuisance warning */
|
||||
elog(NOTICE, "%s converted to %s",
|
||||
TypeNameToString(typename), format_type_be(restype));
|
||||
/* emit nuisance notice */
|
||||
ereport(NOTICE,
|
||||
(errmsg("type reference %s converted to %s",
|
||||
TypeNameToString(typename),
|
||||
format_type_be(restype))));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -188,11 +196,15 @@ typenameTypeId(const TypeName *typename)
|
||||
|
||||
typoid = LookupTypeName(typename);
|
||||
if (!OidIsValid(typoid))
|
||||
elog(ERROR, "Type \"%s\" does not exist",
|
||||
TypeNameToString(typename));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" does not exist",
|
||||
TypeNameToString(typename))));
|
||||
if (!get_typisdefined(typoid))
|
||||
elog(ERROR, "Type \"%s\" is only a shell",
|
||||
TypeNameToString(typename));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" is only a shell",
|
||||
TypeNameToString(typename))));
|
||||
return typoid;
|
||||
}
|
||||
|
||||
@ -210,17 +222,20 @@ typenameType(const TypeName *typename)
|
||||
|
||||
typoid = LookupTypeName(typename);
|
||||
if (!OidIsValid(typoid))
|
||||
elog(ERROR, "Type \"%s\" does not exist",
|
||||
TypeNameToString(typename));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" does not exist",
|
||||
TypeNameToString(typename))));
|
||||
tup = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typoid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "Type \"%s\" does not exist",
|
||||
TypeNameToString(typename));
|
||||
if (!HeapTupleIsValid(tup)) /* should not happen */
|
||||
elog(ERROR, "cache lookup failed for type %u", typoid);
|
||||
if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined)
|
||||
elog(ERROR, "Type \"%s\" is only a shell",
|
||||
TypeNameToString(typename));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" is only a shell",
|
||||
TypeNameToString(typename))));
|
||||
return (Type) tup;
|
||||
}
|
||||
|
||||
@ -244,7 +259,7 @@ typeidType(Oid id)
|
||||
ObjectIdGetDatum(id),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "Unable to locate type oid %u in catalog", id);
|
||||
elog(ERROR, "cache lookup failed for type %u", id);
|
||||
return (Type) tup;
|
||||
}
|
||||
|
||||
@ -252,7 +267,7 @@ typeidType(Oid id)
|
||||
Oid
|
||||
typeTypeId(Type tp)
|
||||
{
|
||||
if (tp == NULL)
|
||||
if (tp == NULL) /* probably useless */
|
||||
elog(ERROR, "typeTypeId() called with NULL type struct");
|
||||
return HeapTupleGetOid(tp);
|
||||
}
|
||||
@ -386,7 +401,7 @@ typeidOutfunc(Oid type_id)
|
||||
ObjectIdGetDatum(type_id),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "typeidOutfunc: Invalid type - oid = %u", type_id);
|
||||
elog(ERROR, "cache lookup failed for type %u", type_id);
|
||||
|
||||
type = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
outfunc = type->typoutput;
|
||||
@ -407,7 +422,7 @@ typeidTypeRelid(Oid type_id)
|
||||
ObjectIdGetDatum(type_id),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "typeidTypeRelid: Invalid type - oid = %u", type_id);
|
||||
elog(ERROR, "cache lookup failed for type %u", type_id);
|
||||
|
||||
type = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
result = type->typrelid;
|
||||
@ -444,7 +459,7 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod)
|
||||
* paranoia is justified since the string might contain anything.
|
||||
*/
|
||||
if (length(raw_parsetree_list) != 1)
|
||||
elog(ERROR, "Invalid type name '%s'", str);
|
||||
goto fail;
|
||||
stmt = (SelectStmt *) lfirst(raw_parsetree_list);
|
||||
if (stmt == NULL ||
|
||||
!IsA(stmt, SelectStmt) ||
|
||||
@ -459,28 +474,35 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod)
|
||||
stmt->limitCount != NULL ||
|
||||
stmt->forUpdate != NIL ||
|
||||
stmt->op != SETOP_NONE)
|
||||
elog(ERROR, "Invalid type name '%s'", str);
|
||||
goto fail;
|
||||
if (length(stmt->targetList) != 1)
|
||||
elog(ERROR, "Invalid type name '%s'", str);
|
||||
goto fail;
|
||||
restarget = (ResTarget *) lfirst(stmt->targetList);
|
||||
if (restarget == NULL ||
|
||||
!IsA(restarget, ResTarget) ||
|
||||
restarget->name != NULL ||
|
||||
restarget->indirection != NIL)
|
||||
elog(ERROR, "Invalid type name '%s'", str);
|
||||
goto fail;
|
||||
typecast = (TypeCast *) restarget->val;
|
||||
if (typecast == NULL ||
|
||||
!IsA(typecast, TypeCast) ||
|
||||
typecast->arg == NULL ||
|
||||
!IsA(typecast->arg, A_Const))
|
||||
elog(ERROR, "Invalid type name '%s'", str);
|
||||
goto fail;
|
||||
typename = typecast->typename;
|
||||
if (typename == NULL ||
|
||||
!IsA(typename, TypeName))
|
||||
elog(ERROR, "Invalid type name '%s'", str);
|
||||
goto fail;
|
||||
|
||||
*type_id = typenameTypeId(typename);
|
||||
*typmod = typename->typmod;
|
||||
|
||||
pfree(buf.data);
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("invalid type name \"%s\"", str)));
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.61 2003/07/18 23:20:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.62 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -114,7 +114,7 @@ load_external_function(char *filename, char *funcname,
|
||||
malloc(sizeof(DynamicFileList) + strlen(fullname));
|
||||
if (file_scanner == NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_RESOURCES),
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory")));
|
||||
|
||||
MemSet((char *) file_scanner, 0, sizeof(DynamicFileList));
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: elog.h,v 1.48 2003/07/18 23:20:32 tgl Exp $
|
||||
* $Id: elog.h,v 1.49 2003/07/19 20:20:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -57,17 +57,68 @@
|
||||
(PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24))
|
||||
|
||||
|
||||
/* SQLSTATE codes defined by SQL99 */
|
||||
#define ERRCODE_AMBIGUOUS_CURSOR_NAME MAKE_SQLSTATE('3','C', '0','0','0')
|
||||
#define ERRCODE_CARDINALITY_VIOLATION MAKE_SQLSTATE('2','1', '0','0','0')
|
||||
#define ERRCODE_CLI_SPECIFIC_CONDITION MAKE_SQLSTATE('H','Y', '0','0','0')
|
||||
/*
|
||||
* SQLSTATE codes for errors.
|
||||
*
|
||||
* The SQL99 code set is rather impoverished, especially in the area of
|
||||
* syntactical and semantic errors. We have borrowed codes from IBM's DB2
|
||||
* and invented our own codes to develop a useful code set.
|
||||
*
|
||||
* When adding a new code, make sure it is placed in the most appropriate
|
||||
* class (the first two characters of the code value identify the class).
|
||||
* The listing is organized by class to make this prominent.
|
||||
*
|
||||
* The generic '000' class code should be used for an error only when there
|
||||
* is not a more-specific code defined.
|
||||
*/
|
||||
|
||||
/* Class 00 - Successful Completion */
|
||||
#define ERRCODE_SUCCESSFUL_COMPLETION MAKE_SQLSTATE('0','0', '0','0','0')
|
||||
|
||||
/* Class 01 - Warning */
|
||||
/* (do not use this class for failure conditions!) */
|
||||
#define ERRCODE_WARNING MAKE_SQLSTATE('0','1', '0','0','0')
|
||||
#define ERRCODE_WARNING_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','1', '0','0','C')
|
||||
#define ERRCODE_WARNING_IMPLICIT_ZERO_BIT_PADDING MAKE_SQLSTATE('0','1', '0','0','8')
|
||||
#define ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION MAKE_SQLSTATE('0','1', '0','0','3')
|
||||
#define ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('0','1', '0','0','4')
|
||||
|
||||
/* Class 02 - No Data */
|
||||
#define ERRCODE_NO_DATA MAKE_SQLSTATE('0','2', '0','0','0')
|
||||
#define ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','2', '0','0','1')
|
||||
|
||||
/* Class 03 - SQL Statement Not Yet Complete */
|
||||
#define ERRCODE_SQL_STATEMENT_NOT_YET_COMPLETE MAKE_SQLSTATE('0','3', '0','0','0')
|
||||
|
||||
/* Class 08 - Connection Exception */
|
||||
#define ERRCODE_CONNECTION_EXCEPTION MAKE_SQLSTATE('0','8', '0','0','0')
|
||||
#define ERRCODE_CONNECTION_DOES_NOT_EXIST MAKE_SQLSTATE('0','8', '0','0','3')
|
||||
#define ERRCODE_CONNECTION_FAILURE MAKE_SQLSTATE('0','8', '0','0','6')
|
||||
#define ERRCODE_CONNECTION_NAME_IN_USE MAKE_SQLSTATE('0','8', '0','0','2')
|
||||
#define ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION MAKE_SQLSTATE('0','8', '0','0','1')
|
||||
#define ERRCODE_SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION MAKE_SQLSTATE('0','8', '0','0','4')
|
||||
#define ERRCODE_TRANSACTION_RESOLUTION_UNKNOWN MAKE_SQLSTATE('0','8', '0','0','7')
|
||||
|
||||
/* Class 0A - Feature Not Supported */
|
||||
#define ERRCODE_FEATURE_NOT_SUPPORTED MAKE_SQLSTATE('0','A', '0','0','0')
|
||||
|
||||
/* Class 0B - Invalid Transaction Initiation */
|
||||
#define ERRCODE_INVALID_TRANSACTION_INITIATION MAKE_SQLSTATE('0','B', '0','0','0')
|
||||
|
||||
/* Class 0F - Locator Exception */
|
||||
#define ERRCODE_LOCATOR_EXCEPTION MAKE_SQLSTATE('0','F', '0','0','0')
|
||||
#define ERRCODE_LOCATOR_EXCEPTION_INVALID_SPECIFICATION MAKE_SQLSTATE('0','F', '0','0','1')
|
||||
|
||||
/* Class 0L - Invalid Grantor */
|
||||
#define ERRCODE_INVALID_GRANTOR MAKE_SQLSTATE('0','L', '0','0','0')
|
||||
|
||||
/* Class 0P - Invalid Role Specification */
|
||||
#define ERRCODE_INVALID_ROLE_SPECIFICATION MAKE_SQLSTATE('0','P', '0','0','0')
|
||||
|
||||
/* Class 21 - Cardinality Violation */
|
||||
/* (this means something returned the wrong number of rows) */
|
||||
#define ERRCODE_CARDINALITY_VIOLATION MAKE_SQLSTATE('2','1', '0','0','0')
|
||||
|
||||
/* Class 22 - Data Exception */
|
||||
#define ERRCODE_DATA_EXCEPTION MAKE_SQLSTATE('2','2', '0','0','0')
|
||||
#define ERRCODE_ARRAY_ELEMENT_ERROR MAKE_SQLSTATE('2','2', '0','2','E')
|
||||
#define ERRCODE_CHARACTER_NOT_IN_REPERTOIRE MAKE_SQLSTATE('2','2', '0','2','1')
|
||||
@ -88,9 +139,9 @@
|
||||
#define ERRCODE_INVALID_REGULAR_EXPRESSION MAKE_SQLSTATE('2','2', '0','1','B')
|
||||
#define ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE MAKE_SQLSTATE('2','2', '0','0','9')
|
||||
#define ERRCODE_INVALID_USE_OF_ESCAPE_CHARACTER MAKE_SQLSTATE('2','2', '0','0','C')
|
||||
#define ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER MAKE_SQLSTATE('2','2', '0','0','G')
|
||||
#define ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH MAKE_SQLSTATE('2','2', '0','0','2')
|
||||
#define ERRCODE_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('2','2', '0','0','4')
|
||||
#define ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER MAKE_SQLSTATE('2','2', '0','0','G')
|
||||
#define ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE MAKE_SQLSTATE('2','2', '0','0','3')
|
||||
#define ERRCODE_STRING_DATA_LENGTH_MISMATCH MAKE_SQLSTATE('2','2', '0','2','6')
|
||||
#define ERRCODE_STRING_DATA_RIGHT_TRUNCATION MAKE_SQLSTATE('2','2', '0','0','1')
|
||||
@ -98,32 +149,15 @@
|
||||
#define ERRCODE_TRIM_ERROR MAKE_SQLSTATE('2','2', '0','2','7')
|
||||
#define ERRCODE_UNTERMINATED_C_STRING MAKE_SQLSTATE('2','2', '0','2','4')
|
||||
#define ERRCODE_ZERO_LENGTH_CHARACTER_STRING MAKE_SQLSTATE('2','2', '0','0','F')
|
||||
#define ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST MAKE_SQLSTATE('2','B', '0','0','0')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION MAKE_SQLSTATE('3','8', '0','0','0')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION_CONTAINING_SQL_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','1')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION_MODIFYING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','2')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION_PROHIBITED_SQL_STATEMENT_ATTEMPTED MAKE_SQLSTATE('3','8', '0','0','3')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION_READING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','4')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION MAKE_SQLSTATE('3','9', '0','0','0')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION_INVALID_SQLSTATE_RETURNED MAKE_SQLSTATE('3','9', '0','0','1')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('3','9', '0','0','4')
|
||||
#define ERRCODE_FEATURE_NOT_SUPPORTED MAKE_SQLSTATE('0','A', '0','0','0')
|
||||
#define ERRCODE_MULTIPLE_ENVIRONMENT_TRANSACTIONS MAKE_SQLSTATE('0','A', '0','0','1')
|
||||
|
||||
/* Class 23 - Integrity Constraint Violation */
|
||||
#define ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('2','3', '0','0','0')
|
||||
#define ERRCODE_RESTRICT_VIOLATION MAKE_SQLSTATE('2','3', '0','0','1')
|
||||
#define ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION MAKE_SQLSTATE('2','8', '0','0','0')
|
||||
#define ERRCODE_INVALID_CATALOG_NAME MAKE_SQLSTATE('3','D', '0','0','0')
|
||||
#define ERRCODE_INVALID_CONDITION_NUMBER MAKE_SQLSTATE('3','5', '0','0','0')
|
||||
#define ERRCODE_INVALID_CONNECTION_NAME MAKE_SQLSTATE('2','E', '0','0','0')
|
||||
#define ERRCODE_INVALID_CURSOR_NAME MAKE_SQLSTATE('3','4', '0','0','0')
|
||||
|
||||
/* Class 24 - Invalid Cursor State */
|
||||
#define ERRCODE_INVALID_CURSOR_STATE MAKE_SQLSTATE('2','4', '0','0','0')
|
||||
#define ERRCODE_INVALID_GRANTOR_STATE MAKE_SQLSTATE('0','L', '0','0','0')
|
||||
#define ERRCODE_INVALID_ROLE_SPECIFICATION MAKE_SQLSTATE('0','P', '0','0','0')
|
||||
#define ERRCODE_INVALID_SCHEMA_NAME MAKE_SQLSTATE('3','F', '0','0','0')
|
||||
#define ERRCODE_INVALID_SQL_DESCRIPTOR_NAME MAKE_SQLSTATE('3','3', '0','0','0')
|
||||
#define ERRCODE_INVALID_SQL_STATEMENT MAKE_SQLSTATE('3','0', '0','0','0')
|
||||
#define ERRCODE_INVALID_SQL_STATEMENT_NAME MAKE_SQLSTATE('2','6', '0','0','0')
|
||||
#define ERRCODE_INVALID_TARGET_SPECIFICATION_VALUE MAKE_SQLSTATE('3','1', '0','0','0')
|
||||
|
||||
/* Class 25 - Invalid Transaction State */
|
||||
#define ERRCODE_INVALID_TRANSACTION_STATE MAKE_SQLSTATE('2','5', '0','0','0')
|
||||
#define ERRCODE_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','1')
|
||||
#define ERRCODE_BRANCH_TRANSACTION_ALREADY_ACTIVE MAKE_SQLSTATE('2','5', '0','0','2')
|
||||
@ -133,66 +167,80 @@
|
||||
#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','5')
|
||||
#define ERRCODE_READ_ONLY_SQL_TRANSACTION MAKE_SQLSTATE('2','5', '0','0','6')
|
||||
#define ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED MAKE_SQLSTATE('2','5', '0','0','7')
|
||||
#define ERRCODE_INVALID_TRANSACTION_INITIATION MAKE_SQLSTATE('0','B', '0','0','0')
|
||||
|
||||
/* Class 26 - Invalid SQL Statement Name */
|
||||
/* (we take this to mean prepared statements) */
|
||||
#define ERRCODE_INVALID_SQL_STATEMENT_NAME MAKE_SQLSTATE('2','6', '0','0','0')
|
||||
|
||||
/* Class 27 - Triggered Data Change Violation */
|
||||
#define ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION MAKE_SQLSTATE('2','7', '0','0','0')
|
||||
|
||||
/* Class 28 - Invalid Authorization Specification */
|
||||
#define ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION MAKE_SQLSTATE('2','8', '0','0','0')
|
||||
|
||||
/* Class 2B - Dependent Privilege Descriptors Still Exist */
|
||||
#define ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST MAKE_SQLSTATE('2','B', '0','0','0')
|
||||
|
||||
/* Class 2D - Invalid Transaction Termination */
|
||||
#define ERRCODE_INVALID_TRANSACTION_TERMINATION MAKE_SQLSTATE('2','D', '0','0','0')
|
||||
#define ERRCODE_LOCATOR_EXCEPTION MAKE_SQLSTATE('0','F', '0','0','0')
|
||||
#define ERRCODE_LOCATOR_EXCEPTION_INVALID_SPECIFICATION MAKE_SQLSTATE('0','F', '0','0','1')
|
||||
#define ERRCODE_NO_DATA MAKE_SQLSTATE('0','2', '0','0','0')
|
||||
#define ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','2', '0','0','1')
|
||||
#define ERRCODE_REMOTE_DATABASE_ACCESS MAKE_SQLSTATE('H','Z', '0','0','0')
|
||||
#define ERRCODE_SAVEPOINT_EXCEPTION MAKE_SQLSTATE('3','B', '0','0','0')
|
||||
#define ERRCODE_SAVEPOINT_EXCEPTION_INVALID_SPECIFICATION MAKE_SQLSTATE('3','B', '0','0','1')
|
||||
#define ERRCODE_SAVEPOINT_EXCEPTION_TOO_MANY MAKE_SQLSTATE('3','B', '0','0','2')
|
||||
|
||||
/* Class 2F - SQL Routine Exception */
|
||||
#define ERRCODE_SQL_ROUTINE_EXCEPTION MAKE_SQLSTATE('2','F', '0','0','0')
|
||||
#define ERRCODE_FUNCTION_EXECUTED_NO_RETURN_STATEMENT MAKE_SQLSTATE('2','F', '0','0','5')
|
||||
#define ERRCODE_MODIFYING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('2','F', '0','0','2')
|
||||
#define ERRCODE_PROHIBITED_SQL_STATEMENT_ATTEMPTED MAKE_SQLSTATE('2','F', '0','0','3')
|
||||
#define ERRCODE_READING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('2','F', '0','0','4')
|
||||
#define ERRCODE_SQL_STATEMENT_NOT_YET_COMPLETE MAKE_SQLSTATE('0','3', '0','0','0')
|
||||
#define ERRCODE_SUCCESSFUL_COMPLETION MAKE_SQLSTATE('0','0', '0','0','0')
|
||||
#define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION MAKE_SQLSTATE('4','2', '0','0','0')
|
||||
#define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION_IN_DIRECT_STATEMENT MAKE_SQLSTATE('2','A', '0','0','0')
|
||||
#define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION_IN_DYNAMIC_STATEMENT MAKE_SQLSTATE('3','7', '0','0','0')
|
||||
|
||||
/* Class 34 - Invalid Cursor Name */
|
||||
#define ERRCODE_INVALID_CURSOR_NAME MAKE_SQLSTATE('3','4', '0','0','0')
|
||||
|
||||
/* Class 38 - External Routine Exception */
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION MAKE_SQLSTATE('3','8', '0','0','0')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION_CONTAINING_SQL_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','1')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION_MODIFYING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','2')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION_PROHIBITED_SQL_STATEMENT_ATTEMPTED MAKE_SQLSTATE('3','8', '0','0','3')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION_READING_SQL_DATA_NOT_PERMITTED MAKE_SQLSTATE('3','8', '0','0','4')
|
||||
|
||||
/* Class 39 - External Routine Invocation Exception */
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION MAKE_SQLSTATE('3','9', '0','0','0')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION_INVALID_SQLSTATE_RETURNED MAKE_SQLSTATE('3','9', '0','0','1')
|
||||
#define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('3','9', '0','0','4')
|
||||
|
||||
/* Class 3D - Invalid Catalog Name */
|
||||
#define ERRCODE_INVALID_CATALOG_NAME MAKE_SQLSTATE('3','D', '0','0','0')
|
||||
|
||||
/* Class 3F - Invalid Schema Name */
|
||||
#define ERRCODE_INVALID_SCHEMA_NAME MAKE_SQLSTATE('3','F', '0','0','0')
|
||||
|
||||
/* Class 40 - Transaction Rollback */
|
||||
#define ERRCODE_TRANSACTION_ROLLBACK MAKE_SQLSTATE('4','0', '0','0','0')
|
||||
#define ERRCODE_TRANSACTION_ROLLBACK_INTEGRITY_CONSTRAINT_VIOLATION MAKE_SQLSTATE('4','0', '0','0','2')
|
||||
#define ERRCODE_TRANSACTION_ROLLBACK_SERIALIZATION_FAILURE MAKE_SQLSTATE('4','0', '0','0','1')
|
||||
#define ERRCODE_TRANSACTION_ROLLBACK_STATEMENT_COMPLETION_UNKNOWN MAKE_SQLSTATE('4','0', '0','0','3')
|
||||
#define ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION MAKE_SQLSTATE('2','7', '0','0','0')
|
||||
#define ERRCODE_WARNING MAKE_SQLSTATE('0','1', '0','0','0')
|
||||
#define ERRCODE_CURSOR_OPERATION_CONFLICT MAKE_SQLSTATE('0','1', '0','0','1')
|
||||
#define ERRCODE_DISCONNECT_ERROR MAKE_SQLSTATE('0','1', '0','0','2')
|
||||
#define ERRCODE_DYNAMIC_RESULT_SETS_RETURNED MAKE_SQLSTATE('0','1', '0','0','C')
|
||||
#define ERRCODE_IMPLICIT_ZERO_BIT_PADDING MAKE_SQLSTATE('0','1', '0','0','8')
|
||||
#define ERRCODE_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION MAKE_SQLSTATE('0','1', '0','0','3')
|
||||
#define ERRCODE_PRIVILEGE_NOT_GRANTED MAKE_SQLSTATE('0','1', '0','0','7')
|
||||
#define ERRCODE_PRIVILEGE_NOT_REVOKED MAKE_SQLSTATE('0','1', '0','0','6')
|
||||
#define ERRCODE_QUERY_EXPRESSION_TOO_LONG_FOR_INFORMATION_SCHEMA MAKE_SQLSTATE('0','1', '0','0','A')
|
||||
#define ERRCODE_SEARCH_CONDITION_TOO_LONG_FOR_INFORMATION_SCHEMA MAKE_SQLSTATE('0','1', '0','0','9')
|
||||
#define ERRCODE_STATEMENT_TOO_LONG_FOR_INFORMATION_SCHEMA MAKE_SQLSTATE('0','1', '0','0','5')
|
||||
#define ERRCODE_STRING_DATA_RIGHT_TRUNCATION_WARNING MAKE_SQLSTATE('0','1', '0','0','4')
|
||||
#define ERRCODE_WITH_CHECK_OPTION_VIOLATION MAKE_SQLSTATE('4','4', '0','0','0')
|
||||
|
||||
/* Implementation-defined error codes for PostgreSQL */
|
||||
/* Where appropriate, we borrow SQLSTATE values from DB2 */
|
||||
#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X', '0','0','0')
|
||||
#define ERRCODE_INSUFFICIENT_PRIVILEGE MAKE_SQLSTATE('4','2', '5','0','1')
|
||||
/* Class 42 - Syntax Error or Access Rule Violation */
|
||||
#define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION MAKE_SQLSTATE('4','2', '0','0','0')
|
||||
/* never use the above; use one of these two if no specific code exists: */
|
||||
#define ERRCODE_SYNTAX_ERROR MAKE_SQLSTATE('4','2', '6','0','1')
|
||||
#define ERRCODE_INSUFFICIENT_PRIVILEGE MAKE_SQLSTATE('4','2', '5','0','1')
|
||||
#define ERRCODE_CANNOT_COERCE MAKE_SQLSTATE('4','2', '8','4','6')
|
||||
#define ERRCODE_GROUPING_ERROR MAKE_SQLSTATE('4','2', '8','0','3')
|
||||
#define ERRCODE_INVALID_FOREIGN_KEY MAKE_SQLSTATE('4','2', '8','3','0')
|
||||
#define ERRCODE_INVALID_NAME MAKE_SQLSTATE('4','2', '6','0','2')
|
||||
#define ERRCODE_NAME_TOO_LONG MAKE_SQLSTATE('4','2', '6','2','2')
|
||||
#define ERRCODE_RESERVED_NAME MAKE_SQLSTATE('4','2', '9','3','9')
|
||||
#define ERRCODE_UNTERMINATED_LITERAL MAKE_SQLSTATE('4','2', '6','0','3')
|
||||
#define ERRCODE_INVALID_LITERAL MAKE_SQLSTATE('4','2', '6','0','6')
|
||||
#define ERRCODE_STATEMENT_TOO_COMPLEX MAKE_SQLSTATE('5','4', '0','0','1')
|
||||
#define ERRCODE_TOO_MANY_ARGUMENTS MAKE_SQLSTATE('4','2', '6','0','5')
|
||||
#define ERRCODE_TOO_MANY_COLUMNS MAKE_SQLSTATE('5','4', '0','1','1')
|
||||
#define ERRCODE_DATATYPE_MISMATCH MAKE_SQLSTATE('4','2', '8','0','4')
|
||||
#define ERRCODE_WRONG_OBJECT_TYPE MAKE_SQLSTATE('4','2', '8','0','9')
|
||||
/*
|
||||
* Note: use the above SQL-standard error codes for undefined catalog, schema,
|
||||
* prepared statement, and cursor names. Curiously, they don't define error
|
||||
* codes for any other kinds of objects. We choose to define separate error
|
||||
* codes for undefined table and column names, as well as one for functions
|
||||
* (also used for operators). All other names (rules, triggers, etc) are
|
||||
* lumped as UNDEFINED_OBJECT.
|
||||
* The same breakdown is used for "ambiguous" and "duplicate" complaints,
|
||||
* Note: for ERRCODE purposes, we divide namable objects into these categories:
|
||||
* databases, schemas, prepared statements, cursors, tables, columns,
|
||||
* functions (including operators), and all else (lumped as "objects").
|
||||
* (The first four categories are mandated by the existence of separate
|
||||
* SQLSTATE classes for them in the spec; in this file, however, we group
|
||||
* the ERRCODE names with all the rest under class 42.) Parameters are
|
||||
* sort-of-named objects and get their own ERRCODE.
|
||||
*
|
||||
* The same breakdown is used for "duplicate" and "ambiguous" complaints,
|
||||
* as well as complaints associated with incorrect declarations.
|
||||
*/
|
||||
#define ERRCODE_UNDEFINED_COLUMN MAKE_SQLSTATE('4','2', '7','0','3')
|
||||
@ -201,39 +249,64 @@
|
||||
#define ERRCODE_UNDEFINED_FUNCTION MAKE_SQLSTATE('4','2', '8','8','3')
|
||||
#define ERRCODE_UNDEFINED_PSTATEMENT ERRCODE_INVALID_SQL_STATEMENT_NAME
|
||||
#define ERRCODE_UNDEFINED_SCHEMA ERRCODE_INVALID_SCHEMA_NAME
|
||||
#define ERRCODE_UNDEFINED_TABLE MAKE_SQLSTATE('4','2', '7','0','4')
|
||||
#define ERRCODE_UNDEFINED_OBJECT MAKE_SQLSTATE('4','2', '7','0','5')
|
||||
#define ERRCODE_UNDEFINED_PARAMETER MAKE_SQLSTATE('4','2', '7','1','5')
|
||||
#define ERRCODE_UNDEFINED_TABLE MAKE_SQLSTATE('4','2', 'P','0','1')
|
||||
#define ERRCODE_UNDEFINED_PARAMETER MAKE_SQLSTATE('4','2', 'P','0','2')
|
||||
#define ERRCODE_UNDEFINED_OBJECT MAKE_SQLSTATE('4','2', '7','0','4')
|
||||
#define ERRCODE_DUPLICATE_COLUMN MAKE_SQLSTATE('4','2', '7','0','1')
|
||||
#define ERRCODE_DUPLICATE_CURSOR MAKE_SQLSTATE('4','2', 'P','0','3')
|
||||
#define ERRCODE_DUPLICATE_DATABASE MAKE_SQLSTATE('4','2', 'P','0','4')
|
||||
#define ERRCODE_DUPLICATE_FUNCTION MAKE_SQLSTATE('4','2', '7','2','3')
|
||||
#define ERRCODE_DUPLICATE_PSTATEMENT MAKE_SQLSTATE('4','2', 'P','0','5')
|
||||
#define ERRCODE_DUPLICATE_SCHEMA MAKE_SQLSTATE('4','2', 'P','0','6')
|
||||
#define ERRCODE_DUPLICATE_TABLE MAKE_SQLSTATE('4','2', 'P','0','7')
|
||||
#define ERRCODE_DUPLICATE_ALIAS MAKE_SQLSTATE('4','2', '7','1','2')
|
||||
#define ERRCODE_DUPLICATE_OBJECT MAKE_SQLSTATE('4','2', '7','1','0')
|
||||
#define ERRCODE_AMBIGUOUS_COLUMN MAKE_SQLSTATE('4','2', '7','0','2')
|
||||
#define ERRCODE_AMBIGUOUS_FUNCTION MAKE_SQLSTATE('4','2', '7','2','5')
|
||||
#define ERRCODE_AMBIGUOUS_PARAMETER MAKE_SQLSTATE('4','2', '7','1','6')
|
||||
#define ERRCODE_DUPLICATE_COLUMN MAKE_SQLSTATE('4','2', '7','1','1')
|
||||
#define ERRCODE_DUPLICATE_CURSOR ERRCODE_DUPLICATE_OBJECT
|
||||
#define ERRCODE_DUPLICATE_DATABASE ERRCODE_DUPLICATE_OBJECT
|
||||
#define ERRCODE_DUPLICATE_FUNCTION MAKE_SQLSTATE('4','2', '7','2','3')
|
||||
#define ERRCODE_DUPLICATE_PSTATEMENT ERRCODE_DUPLICATE_OBJECT
|
||||
#define ERRCODE_DUPLICATE_SCHEMA ERRCODE_DUPLICATE_OBJECT
|
||||
#define ERRCODE_DUPLICATE_TABLE MAKE_SQLSTATE('4','2', '7','2','2')
|
||||
#define ERRCODE_DUPLICATE_OBJECT MAKE_SQLSTATE('4','2', '7','1','0')
|
||||
#define ERRCODE_INVALID_COLUMN_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','1')
|
||||
#define ERRCODE_INVALID_CURSOR_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','2')
|
||||
#define ERRCODE_INVALID_DATABASE_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','3')
|
||||
#define ERRCODE_INVALID_FUNCTION_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','4')
|
||||
#define ERRCODE_INVALID_PSTATEMENT_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','5')
|
||||
#define ERRCODE_INVALID_SCHEMA_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','6')
|
||||
#define ERRCODE_INVALID_TABLE_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','7')
|
||||
#define ERRCODE_INVALID_OBJECT_DEFINITION MAKE_SQLSTATE('4','2', 'A','0','8')
|
||||
#define ERRCODE_WRONG_OBJECT_TYPE MAKE_SQLSTATE('4','2', '8','0','9')
|
||||
#define ERRCODE_AMBIGUOUS_PARAMETER MAKE_SQLSTATE('4','2', 'P','0','8')
|
||||
#define ERRCODE_AMBIGUOUS_ALIAS MAKE_SQLSTATE('4','2', 'P','0','9')
|
||||
#define ERRCODE_INVALID_COLUMN_REFERENCE MAKE_SQLSTATE('4','2', 'P','1','0')
|
||||
#define ERRCODE_INVALID_COLUMN_DEFINITION MAKE_SQLSTATE('4','2', '6','1','1')
|
||||
#define ERRCODE_INVALID_CURSOR_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','1')
|
||||
#define ERRCODE_INVALID_DATABASE_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','2')
|
||||
#define ERRCODE_INVALID_FUNCTION_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','3')
|
||||
#define ERRCODE_INVALID_PSTATEMENT_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','4')
|
||||
#define ERRCODE_INVALID_SCHEMA_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','5')
|
||||
#define ERRCODE_INVALID_TABLE_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','6')
|
||||
#define ERRCODE_INVALID_OBJECT_DEFINITION MAKE_SQLSTATE('4','2', 'P','1','7')
|
||||
|
||||
/* Class 44 - WITH CHECK OPTION Violation */
|
||||
#define ERRCODE_WITH_CHECK_OPTION_VIOLATION MAKE_SQLSTATE('4','4', '0','0','0')
|
||||
|
||||
/* Class 53 - Insufficient Resources (PostgreSQL-specific error class) */
|
||||
#define ERRCODE_INSUFFICIENT_RESOURCES MAKE_SQLSTATE('5','3', '0','0','0')
|
||||
#define ERRCODE_DISK_FULL MAKE_SQLSTATE('5','3', '1','0','0')
|
||||
#define ERRCODE_OUT_OF_MEMORY MAKE_SQLSTATE('5','3', '2','0','0')
|
||||
#define ERRCODE_TOO_MANY_CONNECTIONS MAKE_SQLSTATE('5','3', '3','0','0')
|
||||
|
||||
/* Class 54 - Program Limit Exceeded (class borrowed from DB2) */
|
||||
/* (this is for wired-in limits, not resource exhaustion problems) */
|
||||
#define ERRCODE_PROGRAM_LIMIT_EXCEEDED MAKE_SQLSTATE('5','4', '0','0','0')
|
||||
#define ERRCODE_STATEMENT_TOO_COMPLEX MAKE_SQLSTATE('5','4', '0','0','1')
|
||||
#define ERRCODE_TOO_MANY_COLUMNS MAKE_SQLSTATE('5','4', '0','1','1')
|
||||
#define ERRCODE_TOO_MANY_ARGUMENTS MAKE_SQLSTATE('5','4', '0','2','3')
|
||||
|
||||
/* Class 55 - Object Not In Prerequisite State (class borrowed from DB2) */
|
||||
#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE MAKE_SQLSTATE('5','5', '0','0','0')
|
||||
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5','5', '0','0','6')
|
||||
#define ERRCODE_GROUPING_ERROR MAKE_SQLSTATE('4','2', '8','0','3')
|
||||
#define ERRCODE_TYPE_MISMATCH MAKE_SQLSTATE('4','2', '8','0','4')
|
||||
#define ERRCODE_CANNOT_COERCE MAKE_SQLSTATE('4','2', '8','4','6')
|
||||
#define ERRCODE_INVALID_FOREIGN_KEY MAKE_SQLSTATE('4','2', '8','3','0')
|
||||
#define ERRCODE_TOO_MANY_CONNECTIONS MAKE_SQLSTATE('5','7', '0','3','2')
|
||||
#define ERRCODE_DISK_FULL MAKE_SQLSTATE('5','4', '1','0','0')
|
||||
#define ERRCODE_INSUFFICIENT_RESOURCES MAKE_SQLSTATE('5','4', '2','0','0')
|
||||
|
||||
/* Class 57 - Operator Intervention (class borrowed from DB2) */
|
||||
#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5','7', '0','0','0')
|
||||
#define ERRCODE_QUERY_CANCELED MAKE_SQLSTATE('5','7', '0','1','4')
|
||||
|
||||
/* Class 58 - System Error (class borrowed from DB2) */
|
||||
/* (we define this as errors external to PostgreSQL itself) */
|
||||
#define ERRCODE_IO_ERROR MAKE_SQLSTATE('5','8', '0','3','0')
|
||||
|
||||
/* Class XX - Internal Error (PostgreSQL-specific error class) */
|
||||
/* (this is for "can't-happen" conditions and software bugs) */
|
||||
#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X', '0','0','0')
|
||||
|
||||
|
||||
/* Which __func__ symbol do we have, if any? */
|
||||
#ifdef HAVE_FUNCNAME__FUNC
|
||||
|
@ -156,4 +156,4 @@ select ten, sum(distinct four) from onek a
|
||||
group by ten
|
||||
having exists (select 1 from onek b
|
||||
where sum(distinct a.four + b.four) = b.four);
|
||||
ERROR: Aggregates not allowed in WHERE clause
|
||||
ERROR: aggregates not allowed in WHERE clause
|
||||
|
@ -291,10 +291,10 @@ alter table stud_emp rename to pg_toast_stud_emp;
|
||||
alter table pg_toast_stud_emp rename to stud_emp;
|
||||
-- FOREIGN KEY CONSTRAINT adding TEST
|
||||
CREATE TABLE tmp2 (a int primary key);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'tmp2_pkey' for table 'tmp2'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "tmp2_pkey" for table "tmp2"
|
||||
CREATE TABLE tmp3 (a int, b int);
|
||||
CREATE TABLE tmp4 (a int, b int, unique(a,b));
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'tmp4_a_key' for table 'tmp4'
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "tmp4_a_key" for table "tmp4"
|
||||
CREATE TABLE tmp5 (a int, b int);
|
||||
-- Insert rows into tmp2 (pktable)
|
||||
INSERT INTO tmp2 values (1);
|
||||
@ -335,7 +335,7 @@ DROP TABLE tmp2;
|
||||
-- Note: these tables are TEMP to avoid name conflicts when this test
|
||||
-- is run in parallel with foreign_key.sql.
|
||||
CREATE TEMP TABLE PKTABLE (ptest1 int PRIMARY KEY);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TEMP TABLE FKTABLE (ftest1 inet);
|
||||
-- This next should fail, because inet=int does not exist
|
||||
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
|
||||
@ -363,7 +363,7 @@ NOTICE: Drop cascades to constraint $1 on table fktable
|
||||
DROP TABLE fktable;
|
||||
CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
|
||||
PRIMARY KEY(ptest1, ptest2));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
-- This should fail, because we just chose really odd types
|
||||
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
|
||||
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
|
||||
@ -416,7 +416,7 @@ drop table atacc1;
|
||||
create table atacc1 ( test int );
|
||||
-- add a check constraint (fails)
|
||||
alter table atacc1 add constraint atacc_test1 check (test1>3);
|
||||
ERROR: Attribute "test1" not found
|
||||
ERROR: attribute "test1" not found
|
||||
drop table atacc1;
|
||||
-- something a little more complicated
|
||||
create table atacc1 ( test int, test2 int, test3 int);
|
||||
@ -470,7 +470,7 @@ drop table atacc1;
|
||||
create table atacc1 ( test int );
|
||||
-- add a unique constraint
|
||||
alter table atacc1 add constraint atacc_test1 unique (test);
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for table "atacc1"
|
||||
-- insert first value
|
||||
insert into atacc1 (test) values (2);
|
||||
-- should fail
|
||||
@ -480,7 +480,7 @@ ERROR: Cannot insert a duplicate key into unique index atacc_test1
|
||||
insert into atacc1 (test) values (4);
|
||||
-- try adding a unique oid constraint
|
||||
alter table atacc1 add constraint atacc_oid1 unique(oid);
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index 'atacc_oid1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_oid1" for table "atacc1"
|
||||
drop table atacc1;
|
||||
-- let's do one where the unique constraint fails when added
|
||||
create table atacc1 ( test int );
|
||||
@ -489,7 +489,7 @@ insert into atacc1 (test) values (2);
|
||||
insert into atacc1 (test) values (2);
|
||||
-- add a unique constraint (fails)
|
||||
alter table atacc1 add constraint atacc_test1 unique (test);
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for table "atacc1"
|
||||
ERROR: Cannot create unique index. Table contains non-unique values
|
||||
insert into atacc1 (test) values (3);
|
||||
drop table atacc1;
|
||||
@ -498,13 +498,13 @@ drop table atacc1;
|
||||
create table atacc1 ( test int );
|
||||
-- add a unique constraint (fails)
|
||||
alter table atacc1 add constraint atacc_test1 unique (test1);
|
||||
ERROR: ALTER TABLE: column "test1" named in key does not exist
|
||||
ERROR: column "test1" named in key does not exist
|
||||
drop table atacc1;
|
||||
-- something a little more complicated
|
||||
create table atacc1 ( test int, test2 int);
|
||||
-- add a unique constraint
|
||||
alter table atacc1 add constraint atacc_test1 unique (test, test2);
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc_test1" for table "atacc1"
|
||||
-- insert initial value
|
||||
insert into atacc1 (test,test2) values (4,4);
|
||||
-- should fail
|
||||
@ -517,9 +517,9 @@ insert into atacc1 (test,test2) values (5,5);
|
||||
drop table atacc1;
|
||||
-- lets do some naming tests
|
||||
create table atacc1 (test int, test2 int, unique(test));
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'atacc1_test_key' for table 'atacc1'
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "atacc1_test_key" for table "atacc1"
|
||||
alter table atacc1 add unique (test2);
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index 'atacc1_test2_key' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "atacc1_test2_key" for table "atacc1"
|
||||
-- should fail for @@ second one @@
|
||||
insert into atacc1 (test2, test) values (3, 3);
|
||||
insert into atacc1 (test2, test) values (2, 3);
|
||||
@ -529,7 +529,7 @@ drop table atacc1;
|
||||
create table atacc1 ( test int );
|
||||
-- add a primary key constraint
|
||||
alter table atacc1 add constraint atacc_test1 primary key (test);
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index 'atacc_test1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1" for table "atacc1"
|
||||
-- insert first value
|
||||
insert into atacc1 (test) values (2);
|
||||
-- should fail
|
||||
@ -542,12 +542,12 @@ insert into atacc1 (test) values(NULL);
|
||||
ERROR: ExecInsert: Fail to add null value in not null attribute test
|
||||
-- try adding a second primary key (should fail)
|
||||
alter table atacc1 add constraint atacc_oid1 primary key(oid);
|
||||
ERROR: ALTER TABLE / PRIMARY KEY multiple primary keys for table 'atacc1' are not allowed
|
||||
ERROR: multiple primary keys for table "atacc1" are not allowed
|
||||
-- drop first primary key constraint
|
||||
alter table atacc1 drop constraint atacc_test1 restrict;
|
||||
-- try adding a primary key on oid (should succeed)
|
||||
alter table atacc1 add constraint atacc_oid1 primary key(oid);
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index 'atacc_oid1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_oid1" for table "atacc1"
|
||||
drop table atacc1;
|
||||
-- let's do one where the primary key constraint fails when added
|
||||
create table atacc1 ( test int );
|
||||
@ -556,7 +556,7 @@ insert into atacc1 (test) values (2);
|
||||
insert into atacc1 (test) values (2);
|
||||
-- add a primary key (fails)
|
||||
alter table atacc1 add constraint atacc_test1 primary key (test);
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index 'atacc_test1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1" for table "atacc1"
|
||||
ERROR: Cannot create unique index. Table contains non-unique values
|
||||
insert into atacc1 (test) values (3);
|
||||
drop table atacc1;
|
||||
@ -566,7 +566,7 @@ create table atacc1 ( test int );
|
||||
insert into atacc1 (test) values (NULL);
|
||||
-- add a primary key (fails)
|
||||
alter table atacc1 add constraint atacc_test1 primary key (test);
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index 'atacc_test1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1" for table "atacc1"
|
||||
ERROR: ALTER TABLE: Attribute "test" contains NULL values
|
||||
insert into atacc1 (test) values (3);
|
||||
drop table atacc1;
|
||||
@ -575,16 +575,16 @@ drop table atacc1;
|
||||
create table atacc1 ( test int );
|
||||
-- add a primary key constraint (fails)
|
||||
alter table atacc1 add constraint atacc_test1 primary key (test1);
|
||||
ERROR: ALTER TABLE: column "test1" named in key does not exist
|
||||
ERROR: column "test1" named in key does not exist
|
||||
drop table atacc1;
|
||||
-- something a little more complicated
|
||||
create table atacc1 ( test int, test2 int);
|
||||
-- add a primary key constraint
|
||||
alter table atacc1 add constraint atacc_test1 primary key (test, test2);
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index 'atacc_test1' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc_test1" for table "atacc1"
|
||||
-- try adding a second primary key - should fail
|
||||
alter table atacc1 add constraint atacc_test2 primary key (test);
|
||||
ERROR: ALTER TABLE / PRIMARY KEY multiple primary keys for table 'atacc1' are not allowed
|
||||
ERROR: multiple primary keys for table "atacc1" are not allowed
|
||||
-- insert initial value
|
||||
insert into atacc1 (test,test2) values (4,4);
|
||||
-- should fail
|
||||
@ -603,7 +603,7 @@ insert into atacc1 (test,test2) values (5,5);
|
||||
drop table atacc1;
|
||||
-- lets do some naming tests
|
||||
create table atacc1 (test int, test2 int, primary key(test));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'atacc1_pkey' for table 'atacc1'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "atacc1_pkey" for table "atacc1"
|
||||
-- only first should succeed
|
||||
insert into atacc1 (test2, test) values (3, 3);
|
||||
insert into atacc1 (test2, test) values (2, 3);
|
||||
@ -626,7 +626,7 @@ ERROR: Relation "non_existent" does not exist
|
||||
-- test checking for null values and primary key
|
||||
create table atacc1 (test int not null);
|
||||
alter table atacc1 add constraint "atacc1_pkey" primary key (test);
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index 'atacc1_pkey' for table 'atacc1'
|
||||
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "atacc1_pkey" for table "atacc1"
|
||||
alter table atacc1 alter column test drop not null;
|
||||
ERROR: ALTER TABLE: Attribute "test" is in a primary key
|
||||
alter table atacc1 drop constraint "atacc1_pkey";
|
||||
@ -759,13 +759,13 @@ select * from atacc1;
|
||||
(1 row)
|
||||
|
||||
select * from atacc1 order by a;
|
||||
ERROR: Attribute "a" not found
|
||||
ERROR: attribute "a" not found
|
||||
select * from atacc1 order by "........pg.dropped.1........";
|
||||
ERROR: Attribute "........pg.dropped.1........" not found
|
||||
ERROR: attribute "........pg.dropped.1........" not found
|
||||
select * from atacc1 group by a;
|
||||
ERROR: Attribute "a" not found
|
||||
ERROR: attribute "a" not found
|
||||
select * from atacc1 group by "........pg.dropped.1........";
|
||||
ERROR: Attribute "........pg.dropped.1........" not found
|
||||
ERROR: attribute "........pg.dropped.1........" not found
|
||||
select atacc1.* from atacc1;
|
||||
b | c | d
|
||||
---+---+---
|
||||
@ -773,7 +773,7 @@ select atacc1.* from atacc1;
|
||||
(1 row)
|
||||
|
||||
select a from atacc1;
|
||||
ERROR: Attribute "a" not found
|
||||
ERROR: attribute "a" not found
|
||||
select atacc1.a from atacc1;
|
||||
ERROR: no such attribute atacc1.a
|
||||
select b,c,d from atacc1;
|
||||
@ -783,26 +783,26 @@ select b,c,d from atacc1;
|
||||
(1 row)
|
||||
|
||||
select a,b,c,d from atacc1;
|
||||
ERROR: Attribute "a" not found
|
||||
ERROR: attribute "a" not found
|
||||
select * from atacc1 where a = 1;
|
||||
ERROR: Attribute "a" not found
|
||||
ERROR: attribute "a" not found
|
||||
select "........pg.dropped.1........" from atacc1;
|
||||
ERROR: Attribute "........pg.dropped.1........" not found
|
||||
ERROR: attribute "........pg.dropped.1........" not found
|
||||
select atacc1."........pg.dropped.1........" from atacc1;
|
||||
ERROR: no such attribute atacc1.........pg.dropped.1........
|
||||
select "........pg.dropped.1........",b,c,d from atacc1;
|
||||
ERROR: Attribute "........pg.dropped.1........" not found
|
||||
ERROR: attribute "........pg.dropped.1........" not found
|
||||
select * from atacc1 where "........pg.dropped.1........" = 1;
|
||||
ERROR: Attribute "........pg.dropped.1........" not found
|
||||
ERROR: attribute "........pg.dropped.1........" not found
|
||||
-- UPDATEs
|
||||
update atacc1 set a = 3;
|
||||
ERROR: Relation "atacc1" has no column "a"
|
||||
ERROR: relation "atacc1" has no column "a"
|
||||
update atacc1 set b = 2 where a = 3;
|
||||
ERROR: Attribute "a" not found
|
||||
ERROR: attribute "a" not found
|
||||
update atacc1 set "........pg.dropped.1........" = 3;
|
||||
ERROR: Relation "atacc1" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "atacc1" has no column "........pg.dropped.1........"
|
||||
update atacc1 set b = 2 where "........pg.dropped.1........" = 3;
|
||||
ERROR: Attribute "........pg.dropped.1........" not found
|
||||
ERROR: attribute "........pg.dropped.1........" not found
|
||||
-- INSERTs
|
||||
insert into atacc1 values (10, 11, 12, 13);
|
||||
ERROR: INSERT has more expressions than target columns
|
||||
@ -810,27 +810,27 @@ insert into atacc1 values (default, 11, 12, 13);
|
||||
ERROR: INSERT has more expressions than target columns
|
||||
insert into atacc1 values (11, 12, 13);
|
||||
insert into atacc1 (a) values (10);
|
||||
ERROR: Relation "atacc1" has no column "a"
|
||||
ERROR: relation "atacc1" has no column "a"
|
||||
insert into atacc1 (a) values (default);
|
||||
ERROR: Relation "atacc1" has no column "a"
|
||||
ERROR: relation "atacc1" has no column "a"
|
||||
insert into atacc1 (a,b,c,d) values (10,11,12,13);
|
||||
ERROR: Relation "atacc1" has no column "a"
|
||||
ERROR: relation "atacc1" has no column "a"
|
||||
insert into atacc1 (a,b,c,d) values (default,11,12,13);
|
||||
ERROR: Relation "atacc1" has no column "a"
|
||||
ERROR: relation "atacc1" has no column "a"
|
||||
insert into atacc1 (b,c,d) values (11,12,13);
|
||||
insert into atacc1 ("........pg.dropped.1........") values (10);
|
||||
ERROR: Relation "atacc1" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "atacc1" has no column "........pg.dropped.1........"
|
||||
insert into atacc1 ("........pg.dropped.1........") values (default);
|
||||
ERROR: Relation "atacc1" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "atacc1" has no column "........pg.dropped.1........"
|
||||
insert into atacc1 ("........pg.dropped.1........",b,c,d) values (10,11,12,13);
|
||||
ERROR: Relation "atacc1" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "atacc1" has no column "........pg.dropped.1........"
|
||||
insert into atacc1 ("........pg.dropped.1........",b,c,d) values (default,11,12,13);
|
||||
ERROR: Relation "atacc1" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "atacc1" has no column "........pg.dropped.1........"
|
||||
-- DELETEs
|
||||
delete from atacc1 where a = 3;
|
||||
ERROR: Attribute "a" not found
|
||||
ERROR: attribute "a" not found
|
||||
delete from atacc1 where "........pg.dropped.1........" = 3;
|
||||
ERROR: Attribute "........pg.dropped.1........" not found
|
||||
ERROR: attribute "........pg.dropped.1........" not found
|
||||
delete from atacc1;
|
||||
-- try dropping a non-existent column, should fail
|
||||
alter table atacc1 drop bar;
|
||||
@ -850,13 +850,13 @@ ERROR: ALTER TABLE: relation "myview" is not a table
|
||||
drop view myview;
|
||||
-- test some commands to make sure they fail on the dropped column
|
||||
analyze atacc1(a);
|
||||
ERROR: Relation "atacc1" has no column "a"
|
||||
ERROR: relation "atacc1" has no column "a"
|
||||
analyze atacc1("........pg.dropped.1........");
|
||||
ERROR: Relation "atacc1" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "atacc1" has no column "........pg.dropped.1........"
|
||||
vacuum analyze atacc1(a);
|
||||
ERROR: Relation "atacc1" has no column "a"
|
||||
ERROR: relation "atacc1" has no column "a"
|
||||
vacuum analyze atacc1("........pg.dropped.1........");
|
||||
ERROR: Relation "atacc1" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "atacc1" has no column "........pg.dropped.1........"
|
||||
comment on column atacc1.a is 'testing';
|
||||
ERROR: Relation "atacc1" has no column "a"
|
||||
comment on column atacc1."........pg.dropped.1........" is 'testing';
|
||||
@ -890,19 +890,19 @@ ERROR: renameatt: attribute "a" does not exist
|
||||
alter table atacc1 rename "........pg.dropped.1........" to x;
|
||||
ERROR: renameatt: attribute "........pg.dropped.1........" does not exist
|
||||
alter table atacc1 add primary key(a);
|
||||
ERROR: ALTER TABLE: column "a" named in key does not exist
|
||||
ERROR: column "a" named in key does not exist
|
||||
alter table atacc1 add primary key("........pg.dropped.1........");
|
||||
ERROR: ALTER TABLE: column "........pg.dropped.1........" named in key does not exist
|
||||
ERROR: column "........pg.dropped.1........" named in key does not exist
|
||||
alter table atacc1 add unique(a);
|
||||
ERROR: ALTER TABLE: column "a" named in key does not exist
|
||||
ERROR: column "a" named in key does not exist
|
||||
alter table atacc1 add unique("........pg.dropped.1........");
|
||||
ERROR: ALTER TABLE: column "........pg.dropped.1........" named in key does not exist
|
||||
ERROR: column "........pg.dropped.1........" named in key does not exist
|
||||
alter table atacc1 add check (a > 3);
|
||||
ERROR: Attribute "a" not found
|
||||
ERROR: attribute "a" not found
|
||||
alter table atacc1 add check ("........pg.dropped.1........" > 3);
|
||||
ERROR: Attribute "........pg.dropped.1........" not found
|
||||
ERROR: attribute "........pg.dropped.1........" not found
|
||||
create table atacc2 (id int4 unique);
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'atacc2_id_key' for table 'atacc2'
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "atacc2_id_key" for table "atacc2"
|
||||
alter table atacc1 add foreign key (a) references atacc2(id);
|
||||
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: ALTER TABLE: column "a" referenced in foreign key constraint does not exist
|
||||
@ -990,9 +990,9 @@ alter table test drop a;
|
||||
copy test to stdout;
|
||||
2 3
|
||||
copy test(a) to stdout;
|
||||
ERROR: Relation "test" has no column "a"
|
||||
ERROR: relation "test" has no column "a"
|
||||
copy test("........pg.dropped.1........") to stdout;
|
||||
ERROR: Relation "test" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "test" has no column "........pg.dropped.1........"
|
||||
copy test from stdin;
|
||||
ERROR: Extra data after last expected column
|
||||
CONTEXT: COPY FROM, line 1
|
||||
@ -1011,9 +1011,9 @@ select * from test;
|
||||
(2 rows)
|
||||
|
||||
copy test(a) from stdin;
|
||||
ERROR: Relation "test" has no column "a"
|
||||
ERROR: relation "test" has no column "a"
|
||||
copy test("........pg.dropped.1........") from stdin;
|
||||
ERROR: Relation "test" has no column "........pg.dropped.1........"
|
||||
ERROR: relation "test" has no column "........pg.dropped.1........"
|
||||
copy test(b,c) from stdin;
|
||||
select * from test;
|
||||
b | c
|
||||
@ -1072,7 +1072,7 @@ select f1 from c1;
|
||||
|
||||
alter table c1 drop column f1;
|
||||
select f1 from c1;
|
||||
ERROR: Attribute "f1" not found
|
||||
ERROR: attribute "f1" not found
|
||||
drop table p1 cascade;
|
||||
NOTICE: Drop cascades to table c1
|
||||
create table p1 (f1 int, f2 int);
|
||||
@ -1083,7 +1083,7 @@ ERROR: ALTER TABLE: Cannot drop inherited column "f1"
|
||||
alter table p1 drop column f1;
|
||||
-- c1.f1 is dropped now, since there is no local definition for it
|
||||
select f1 from c1;
|
||||
ERROR: Attribute "f1" not found
|
||||
ERROR: attribute "f1" not found
|
||||
drop table p1 cascade;
|
||||
NOTICE: Drop cascades to table c1
|
||||
create table p1 (f1 int, f2 int);
|
||||
@ -1181,7 +1181,7 @@ select oid > 0, * from altstartwith;
|
||||
|
||||
alter table altstartwith set without oids;
|
||||
select oid > 0, * from altstartwith; -- fails
|
||||
ERROR: Attribute "oid" not found
|
||||
ERROR: attribute "oid" not found
|
||||
select * from altstartwith;
|
||||
col
|
||||
-----
|
||||
@ -1209,9 +1209,9 @@ alter table altwithoid set without oids;
|
||||
alter table altinhoid set without oids; -- fails
|
||||
ERROR: ALTER TABLE: Table is already WITHOUT OIDS
|
||||
select oid > 0, * from altwithoid; -- fails
|
||||
ERROR: Attribute "oid" not found
|
||||
ERROR: attribute "oid" not found
|
||||
select oid > 0, * from altinhoid; -- fails
|
||||
ERROR: Attribute "oid" not found
|
||||
ERROR: attribute "oid" not found
|
||||
select * from altwithoid;
|
||||
col
|
||||
-----
|
||||
|
@ -358,7 +358,7 @@ select 33 * any (44);
|
||||
ERROR: op ANY/ALL (array) requires array on right side
|
||||
-- test indexes on arrays
|
||||
create temp table arr_tbl (f1 int[] unique);
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'arr_tbl_f1_key' for table 'arr_tbl'
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "arr_tbl_f1_key" for table "arr_tbl"
|
||||
insert into arr_tbl values ('{1,2,3}');
|
||||
insert into arr_tbl values ('{1,2}');
|
||||
-- failure expected:
|
||||
|
@ -3,15 +3,15 @@
|
||||
--
|
||||
CREATE TABLE clstr_tst_s (rf_a SERIAL PRIMARY KEY,
|
||||
b INT);
|
||||
NOTICE: CREATE TABLE will create implicit sequence 'clstr_tst_s_rf_a_seq' for SERIAL column 'clstr_tst_s.rf_a'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'clstr_tst_s_pkey' for table 'clstr_tst_s'
|
||||
NOTICE: CREATE TABLE will create implicit sequence "clstr_tst_s_rf_a_seq" for SERIAL column "clstr_tst_s.rf_a"
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_tst_s_pkey" for table "clstr_tst_s"
|
||||
CREATE TABLE clstr_tst (a SERIAL PRIMARY KEY,
|
||||
b INT,
|
||||
c TEXT,
|
||||
d TEXT,
|
||||
CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s);
|
||||
NOTICE: CREATE TABLE will create implicit sequence 'clstr_tst_a_seq' for SERIAL column 'clstr_tst.a'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'clstr_tst_pkey' for table 'clstr_tst'
|
||||
NOTICE: CREATE TABLE will create implicit sequence "clstr_tst_a_seq" for SERIAL column "clstr_tst.a"
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_tst_pkey" for table "clstr_tst"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
CREATE INDEX clstr_tst_b ON clstr_tst (b);
|
||||
CREATE INDEX clstr_tst_c ON clstr_tst (c);
|
||||
@ -300,11 +300,11 @@ WHERE pg_class.oid=indexrelid
|
||||
-- Verify that clustering all tables does in fact cluster the right ones
|
||||
CREATE USER clstr_user;
|
||||
CREATE TABLE clstr_1 (a INT PRIMARY KEY);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'clstr_1_pkey' for table 'clstr_1'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_1_pkey" for table "clstr_1"
|
||||
CREATE TABLE clstr_2 (a INT PRIMARY KEY);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'clstr_2_pkey' for table 'clstr_2'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_2_pkey" for table "clstr_2"
|
||||
CREATE TABLE clstr_3 (a INT PRIMARY KEY);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'clstr_3_pkey' for table 'clstr_3'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_3_pkey" for table "clstr_3"
|
||||
ALTER TABLE clstr_1 OWNER TO clstr_user;
|
||||
ALTER TABLE clstr_3 OWNER TO clstr_user;
|
||||
GRANT SELECT ON clstr_2 TO clstr_user;
|
||||
|
@ -5,7 +5,7 @@ CREATE TABLE x (
|
||||
d text not null,
|
||||
e text
|
||||
);
|
||||
NOTICE: CREATE TABLE will create implicit sequence 'x_a_seq' for SERIAL column 'x.a'
|
||||
NOTICE: CREATE TABLE will create implicit sequence "x_a_seq" for SERIAL column "x.a"
|
||||
CREATE FUNCTION fn_x_before () RETURNS TRIGGER AS '
|
||||
BEGIN
|
||||
NEW.e := ''before trigger fired''::text;
|
||||
@ -28,7 +28,7 @@ COPY x (b, d) from stdin;
|
||||
COPY x (a, b, c, d, e) from stdin;
|
||||
-- non-existent column in column list: should fail
|
||||
COPY x (xyz) from stdin;
|
||||
ERROR: Relation "x" has no column "xyz"
|
||||
ERROR: relation "x" has no column "xyz"
|
||||
-- too many columns in column list: should fail
|
||||
COPY x (a, b, c, d, e, d, c) from stdin;
|
||||
ERROR: Attribute "d" specified more than once
|
||||
|
@ -174,7 +174,7 @@ create table defaulttest
|
||||
, col7 ddef4 DEFAULT 8000
|
||||
, col8 ddef5
|
||||
);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'defaulttest_pkey' for table 'defaulttest'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "defaulttest_pkey" for table "defaulttest"
|
||||
insert into defaulttest default values;
|
||||
insert into defaulttest default values;
|
||||
insert into defaulttest default values;
|
||||
|
@ -31,19 +31,19 @@ select from pg_database;
|
||||
ERROR: syntax error at or near "from" at character 8
|
||||
-- bad name in target list
|
||||
select nonesuch from pg_database;
|
||||
ERROR: Attribute "nonesuch" not found
|
||||
ERROR: attribute "nonesuch" not found
|
||||
-- bad attribute name on lhs of operator
|
||||
select * from pg_database where nonesuch = pg_database.datname;
|
||||
ERROR: Attribute "nonesuch" not found
|
||||
ERROR: attribute "nonesuch" not found
|
||||
-- bad attribute name on rhs of operator
|
||||
select * from pg_database where pg_database.datname = nonesuch;
|
||||
ERROR: Attribute "nonesuch" not found
|
||||
ERROR: attribute "nonesuch" not found
|
||||
-- bad select distinct on syntax, distinct attribute missing
|
||||
select distinct on (foobar) from pg_database;
|
||||
ERROR: syntax error at or near "from" at character 29
|
||||
-- bad select distinct on syntax, distinct attribute not in target list
|
||||
select distinct on (foobar) * from pg_database;
|
||||
ERROR: Attribute "foobar" not found
|
||||
ERROR: attribute "foobar" not found
|
||||
--
|
||||
-- DELETE
|
||||
|
||||
@ -143,7 +143,7 @@ drop aggregate 314159 (int);
|
||||
ERROR: syntax error at or near "314159" at character 16
|
||||
-- bad aggregate type
|
||||
drop aggregate newcnt (nonesuch);
|
||||
ERROR: Type "nonesuch" does not exist
|
||||
ERROR: type "nonesuch" does not exist
|
||||
-- no such aggregate
|
||||
drop aggregate nonesuch (int4);
|
||||
ERROR: aggregate nonesuch(integer) does not exist
|
||||
@ -197,13 +197,13 @@ drop operator === ();
|
||||
ERROR: syntax error at or near ")" at character 20
|
||||
-- no such operator
|
||||
drop operator === (int4);
|
||||
ERROR: parser: argument type missing (use NONE for unary operators)
|
||||
ERROR: argument type missing (use NONE for unary operators)
|
||||
-- no such operator by that name
|
||||
drop operator === (int4, int4);
|
||||
ERROR: operator does not exist: integer === integer
|
||||
-- no such type1
|
||||
drop operator = (nonesuch);
|
||||
ERROR: parser: argument type missing (use NONE for unary operators)
|
||||
ERROR: argument type missing (use NONE for unary operators)
|
||||
-- no such type1
|
||||
drop operator = ( , int4);
|
||||
ERROR: syntax error at or near "," at character 19
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- First test, check and cascade
|
||||
--
|
||||
CREATE TABLE PKTABLE ( ptest1 int PRIMARY KEY, ptest2 text );
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE ( ftest1 int REFERENCES PKTABLE MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE, ftest2 int );
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
-- Insert test data into PKTABLE
|
||||
@ -61,7 +61,7 @@ DROP TABLE PKTABLE;
|
||||
-- check set NULL and table constraint on multiple columns
|
||||
--
|
||||
CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY(ptest1, ptest2) );
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, CONSTRAINT constrname FOREIGN KEY(ftest1, ftest2)
|
||||
REFERENCES PKTABLE MATCH FULL ON DELETE SET NULL ON UPDATE SET NULL);
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
@ -144,7 +144,7 @@ DROP TABLE FKTABLE;
|
||||
-- check set default and table constraint on multiple columns
|
||||
--
|
||||
CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY(ptest1, ptest2) );
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE ( ftest1 int DEFAULT -1, ftest2 int DEFAULT -2, ftest3 int, CONSTRAINT constrname2 FOREIGN KEY(ftest1, ftest2)
|
||||
REFERENCES PKTABLE MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET DEFAULT);
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
@ -234,7 +234,7 @@ DROP TABLE FKTABLE;
|
||||
-- First test, check with no on delete or on update
|
||||
--
|
||||
CREATE TABLE PKTABLE ( ptest1 int PRIMARY KEY, ptest2 text );
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE ( ftest1 int REFERENCES PKTABLE MATCH FULL, ftest2 int );
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
-- Insert test data into PKTABLE
|
||||
@ -307,7 +307,7 @@ DROP TABLE PKTABLE;
|
||||
-- MATCH unspecified
|
||||
-- Base test restricting update/delete
|
||||
CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) );
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3
|
||||
FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE);
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
@ -369,7 +369,7 @@ DROP TABLE FKTABLE;
|
||||
DROP TABLE PKTABLE;
|
||||
-- cascade update/delete
|
||||
CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) );
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3
|
||||
FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE
|
||||
ON DELETE CASCADE ON UPDATE CASCADE);
|
||||
@ -466,7 +466,7 @@ DROP TABLE FKTABLE;
|
||||
DROP TABLE PKTABLE;
|
||||
-- set null update / set default delete
|
||||
CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) );
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE ( ftest1 int DEFAULT 0, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3
|
||||
FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE
|
||||
ON DELETE SET DEFAULT ON UPDATE SET NULL);
|
||||
@ -570,7 +570,7 @@ DROP TABLE FKTABLE;
|
||||
DROP TABLE PKTABLE;
|
||||
-- set default update / set null delete
|
||||
CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) );
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE ( ftest1 int DEFAULT 0, ftest2 int DEFAULT -1, ftest3 int, ftest4 int, CONSTRAINT constrname3
|
||||
FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE
|
||||
ON DELETE SET NULL ON UPDATE SET DEFAULT);
|
||||
@ -686,7 +686,7 @@ SELECT * from FKTABLE;
|
||||
DROP TABLE FKTABLE;
|
||||
DROP TABLE PKTABLE;
|
||||
CREATE TABLE PKTABLE (ptest1 int PRIMARY KEY);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE FKTABLE_FAIL1 ( ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (ftest2) REFERENCES PKTABLE);
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: CREATE TABLE: column "ftest2" referenced in foreign key constraint does not exist
|
||||
@ -700,7 +700,7 @@ ERROR: table "fktable_fail2" does not exist
|
||||
DROP TABLE PKTABLE;
|
||||
-- Test for referencing column number smaller than referenced constraint
|
||||
CREATE TABLE PKTABLE (ptest1 int, ptest2 int, UNIQUE(ptest1, ptest2));
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'pktable_ptest1_key' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "pktable_ptest1_key" for table "pktable"
|
||||
CREATE TABLE FKTABLE_FAIL1 (ftest1 int REFERENCES pktable(ptest1));
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: UNIQUE constraint matching given keys for referenced table "pktable" not found
|
||||
@ -712,7 +712,7 @@ DROP TABLE PKTABLE;
|
||||
--
|
||||
-- Basic one column, two table setup
|
||||
CREATE TABLE PKTABLE (ptest1 int PRIMARY KEY);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
-- This next should fail, because inet=int does not exist
|
||||
CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable);
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
@ -736,7 +736,7 @@ DROP TABLE FKTABLE;
|
||||
DROP TABLE PKTABLE;
|
||||
-- Two columns, two tables
|
||||
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, PRIMARY KEY(ptest1, ptest2));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
-- This should fail, because we just chose really odd types
|
||||
CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
@ -775,33 +775,33 @@ DROP TABLE PKTABLE;
|
||||
-- Make sure this still works...
|
||||
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3,
|
||||
ptest4) REFERENCES pktable(ptest1, ptest2));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
DROP TABLE PKTABLE;
|
||||
-- And this,
|
||||
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3,
|
||||
ptest4) REFERENCES pktable);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
DROP TABLE PKTABLE;
|
||||
-- This shouldn't (mixed up columns)
|
||||
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3,
|
||||
ptest4) REFERENCES pktable(ptest2, ptest1));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: operator does not exist: integer = inet
|
||||
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
|
||||
-- Nor should this... (same reason, we have 4,3 referencing 1,2 which mismatches types
|
||||
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
|
||||
ptest3) REFERENCES pktable(ptest1, ptest2));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: operator does not exist: inet = integer
|
||||
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
|
||||
-- Not this one either... Same as the last one except we didn't defined the columns being referenced.
|
||||
CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
|
||||
ptest3) REFERENCES pktable);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: operator does not exist: inet = integer
|
||||
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
|
||||
@ -810,8 +810,8 @@ HINT: No operator matches the given name and argument type(s). You may need to
|
||||
-- Basic 2 table case: 1 column of matching types.
|
||||
create table pktable_base (base1 int not null);
|
||||
create table pktable (ptest1 int, primary key(base1), unique(base1, ptest1)) inherits (pktable_base);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'pktable_base1_key' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "pktable_base1_key" for table "pktable"
|
||||
create table fktable (ftest1 int references pktable(base1));
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
-- now some ins, upd, del
|
||||
@ -868,7 +868,7 @@ drop table pktable_base;
|
||||
create table pktable_base(base1 int not null, base2 int);
|
||||
create table pktable(ptest1 int, ptest2 int, primary key(base1, ptest1), foreign key(base2, ptest2) references
|
||||
pktable(base1, ptest1)) inherits (pktable_base);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
insert into pktable (base1, ptest1, base2, ptest2) values (1, 1, 1, 1);
|
||||
insert into pktable (base1, ptest1, base2, ptest2) values (2, 1, 1, 1);
|
||||
@ -891,7 +891,7 @@ drop table pktable_base;
|
||||
-- 2 columns (2 tables), mismatched types
|
||||
create table pktable_base(base1 int not null);
|
||||
create table pktable(ptest1 inet, primary key(base1, ptest1)) inherits (pktable_base);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
-- just generally bad types (with and without column references on the referenced table)
|
||||
create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable);
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
@ -920,25 +920,25 @@ drop table pktable_base;
|
||||
create table pktable_base(base1 int not null, base2 int);
|
||||
create table pktable(ptest1 inet, ptest2 inet[], primary key(base1, ptest1), foreign key(base2, ptest2) references
|
||||
pktable(base1, ptest1)) inherits (pktable_base);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: operator does not exist: inet[] = inet
|
||||
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
|
||||
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(base2, ptest2) references
|
||||
pktable(ptest1, base1)) inherits (pktable_base);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: operator does not exist: integer = inet
|
||||
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
|
||||
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
|
||||
pktable(base1, ptest1)) inherits (pktable_base);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: operator does not exist: inet = integer
|
||||
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
|
||||
create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
|
||||
pktable(base1, ptest1)) inherits (pktable_base);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
ERROR: operator does not exist: inet = integer
|
||||
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
|
||||
@ -954,12 +954,12 @@ CREATE TABLE pktable (
|
||||
id INT4 PRIMARY KEY,
|
||||
other INT4
|
||||
);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE fktable (
|
||||
id INT4 PRIMARY KEY,
|
||||
fk INT4 REFERENCES pktable DEFERRABLE
|
||||
);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'fktable_pkey' for table 'fktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "fktable_pkey" for table "fktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
-- default to immediate: should fail
|
||||
INSERT INTO fktable VALUES (5, 10);
|
||||
@ -976,12 +976,12 @@ CREATE TABLE pktable (
|
||||
id INT4 PRIMARY KEY,
|
||||
other INT4
|
||||
);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE fktable (
|
||||
id INT4 PRIMARY KEY,
|
||||
fk INT4 REFERENCES pktable DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'fktable_pkey' for table 'fktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "fktable_pkey" for table "fktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
-- default to deferred, should succeed
|
||||
BEGIN;
|
||||
@ -1004,12 +1004,12 @@ CREATE TABLE pktable (
|
||||
id INT4 PRIMARY KEY,
|
||||
other INT4
|
||||
);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
|
||||
CREATE TABLE fktable (
|
||||
id INT4 PRIMARY KEY,
|
||||
fk INT4 REFERENCES pktable DEFERRABLE
|
||||
);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'fktable_pkey' for table 'fktable'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "fktable_pkey" for table "fktable"
|
||||
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
|
||||
BEGIN;
|
||||
SET CONSTRAINTS ALL DEFERRED;
|
||||
|
@ -806,9 +806,9 @@ SELECT interval '04:30' - time '01:02' AS "20:32:00";
|
||||
(1 row)
|
||||
|
||||
SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01";
|
||||
ERROR: Cannot cast type time with time zone to interval
|
||||
ERROR: cannot cast type time with time zone to interval
|
||||
SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08";
|
||||
ERROR: Cannot cast type interval to time with time zone
|
||||
ERROR: cannot cast type interval to time with time zone
|
||||
SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08";
|
||||
23:29:00-08
|
||||
-------------
|
||||
|
@ -806,9 +806,9 @@ SELECT interval '04:30' - time '01:02' AS "20:32:00";
|
||||
(1 row)
|
||||
|
||||
SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01";
|
||||
ERROR: Cannot cast type time with time zone to interval
|
||||
ERROR: cannot cast type time with time zone to interval
|
||||
SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08";
|
||||
ERROR: Cannot cast type interval to time with time zone
|
||||
ERROR: cannot cast type interval to time with time zone
|
||||
SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08";
|
||||
23:29:00-08
|
||||
-------------
|
||||
|
@ -806,9 +806,9 @@ SELECT interval '04:30' - time '01:02' AS "20:32:00";
|
||||
(1 row)
|
||||
|
||||
SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01";
|
||||
ERROR: Cannot cast type time with time zone to interval
|
||||
ERROR: cannot cast type time with time zone to interval
|
||||
SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08";
|
||||
ERROR: Cannot cast type interval to time with time zone
|
||||
ERROR: cannot cast type interval to time with time zone
|
||||
SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08";
|
||||
23:29:00-08
|
||||
-------------
|
||||
|
@ -536,7 +536,7 @@ SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid;
|
||||
|
||||
-- Confirm PRIMARY KEY adds NOT NULL constraint to child table
|
||||
CREATE TEMP TABLE z (b TEXT, PRIMARY KEY(aa, b)) inherits (a);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'z_pkey' for table 'z'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "z_pkey" for table "z"
|
||||
INSERT INTO z VALUES (NULL, 'text'); -- should fail
|
||||
ERROR: ExecInsert: Fail to add null value in not null attribute aa
|
||||
-- Check UPDATE with inherited target and an inherited source table
|
||||
|
@ -336,7 +336,7 @@ SELECT '' AS "xxx", *
|
||||
-- ambiguous column
|
||||
SELECT '' AS "xxx", i, k, t
|
||||
FROM J1_TBL CROSS JOIN J2_TBL;
|
||||
ERROR: Column reference "i" is ambiguous
|
||||
ERROR: column reference "i" is ambiguous
|
||||
-- resolve previous ambiguity by specifying the table name
|
||||
SELECT '' AS "xxx", t1.i, k, t
|
||||
FROM J1_TBL t1 CROSS JOIN J2_TBL t2;
|
||||
|
@ -69,17 +69,19 @@ EXECUTE q3('AAAAxx', 5::smallint, 10.5::float, false, 500::oid, 4::bigint);
|
||||
|
||||
-- too few params
|
||||
EXECUTE q3('bool');
|
||||
ERROR: Wrong number of parameters, expected 6 but got 1
|
||||
ERROR: wrong number of parameters for prepared statement "q3"
|
||||
DETAIL: Expected 6 parameters but got 1.
|
||||
-- too many params
|
||||
EXECUTE q3('bytea', 5::smallint, 10.5::float, false, 500::oid, 4::bigint, true);
|
||||
ERROR: Wrong number of parameters, expected 6 but got 7
|
||||
ERROR: wrong number of parameters for prepared statement "q3"
|
||||
DETAIL: Expected 6 parameters but got 7.
|
||||
-- wrong param types
|
||||
EXECUTE q3(5::smallint, 10.5::float, false, 500::oid, 4::bigint, 'bytea');
|
||||
ERROR: Parameter $3 of type boolean cannot be coerced into the expected type double precision
|
||||
You will need to rewrite or cast the expression
|
||||
ERROR: parameter $3 of type boolean cannot be coerced to the expected type double precision
|
||||
HINT: You will need to rewrite or cast the expression.
|
||||
-- invalid type
|
||||
PREPARE q4(nonexistenttype) AS SELECT $1;
|
||||
ERROR: Type "nonexistenttype" does not exist
|
||||
ERROR: type "nonexistenttype" does not exist
|
||||
-- create table as execute
|
||||
PREPARE q5(int, text) AS
|
||||
SELECT * FROM tenk1 WHERE unique1 = $1 OR stringu1 = $2;
|
||||
|
@ -18,7 +18,7 @@ INSERT INTO foo2 VALUES(1, 111);
|
||||
CREATE FUNCTION foot(int) returns setof foo2 as 'SELECT * FROM foo2 WHERE fooid = $1;' LANGUAGE SQL;
|
||||
-- supposed to fail with ERROR
|
||||
select * from foo2, foot(foo2.fooid) z where foo2.f2 = z.f2;
|
||||
ERROR: FROM function expression may not refer to other relations of same query level
|
||||
ERROR: function expression in FROM may not refer to other relations of same query level
|
||||
-- function in subselect
|
||||
select * from foo2 where f2 in (select f2 from foot(foo2.fooid) z where z.fooid = foo2.fooid) ORDER BY 1,2;
|
||||
fooid | f2
|
||||
@ -53,7 +53,7 @@ select foot.fooid, foot.f2 from foot(sin(pi()/2)::int) ORDER BY 1,2;
|
||||
(2 rows)
|
||||
|
||||
CREATE TABLE foo (fooid int, foosubid int, fooname text, primary key(fooid,foosubid));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
|
||||
INSERT INTO foo VALUES(1,1,'Joe');
|
||||
INSERT INTO foo VALUES(1,2,'Ed');
|
||||
INSERT INTO foo VALUES(2,1,'Mary');
|
||||
@ -225,7 +225,7 @@ DROP TABLE foo2;
|
||||
DROP TABLE foo;
|
||||
-- Rescan tests --
|
||||
CREATE TABLE foorescan (fooid int, foosubid int, fooname text, primary key(fooid,foosubid));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foorescan_pkey' for table 'foorescan'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foorescan_pkey" for table "foorescan"
|
||||
INSERT INTO foorescan values(5000,1,'abc.5000.1');
|
||||
INSERT INTO foorescan values(5001,1,'abc.5001.1');
|
||||
INSERT INTO foorescan values(5002,1,'abc.5002.1');
|
||||
@ -311,7 +311,7 @@ SELECT * FROM foorescan f WHERE f.fooid IN (SELECT fooid FROM vw_foorescan) ORDE
|
||||
(10 rows)
|
||||
|
||||
CREATE TABLE barrescan (fooid int primary key);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'barrescan_pkey' for table 'barrescan'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "barrescan_pkey" for table "barrescan"
|
||||
INSERT INTO barrescan values(5003);
|
||||
INSERT INTO barrescan values(5004);
|
||||
INSERT INTO barrescan values(5005);
|
||||
|
@ -1180,7 +1180,7 @@ drop rule foorule on foo;
|
||||
-- this should fail because f1 is not exposed for unqualified reference:
|
||||
create rule foorule as on insert to foo where f1 < 100
|
||||
do instead insert into foo2 values (f1);
|
||||
ERROR: Attribute "f1" not found
|
||||
ERROR: attribute "f1" not found
|
||||
-- this is the correct way:
|
||||
create rule foorule as on insert to foo where f1 < 100
|
||||
do instead insert into foo2 values (new.f1);
|
||||
|
@ -44,7 +44,7 @@ SELECT count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY
|
||||
-- w/o existing GROUP BY target and w/o existing a different ORDER BY target
|
||||
-- failure expected
|
||||
SELECT count(*) FROM test_missing_target GROUP BY a ORDER BY b;
|
||||
ERROR: Attribute test_missing_target.b must be GROUPed or used in an aggregate function
|
||||
ERROR: attribute "test_missing_target.b" must be GROUPed or used in an aggregate function
|
||||
-- w/o existing GROUP BY target and w/o existing same ORDER BY target
|
||||
SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b;
|
||||
count
|
||||
@ -120,7 +120,7 @@ ERROR: GROUP BY position 3 is not in target list
|
||||
SELECT count(*) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY b ORDER BY b;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- order w/ target under ambiguous condition
|
||||
-- failure NOT expected
|
||||
SELECT a, a FROM test_missing_target
|
||||
@ -235,7 +235,7 @@ ORDER BY lower(test_missing_target.c);
|
||||
-- w/o existing GROUP BY target and w/o existing a different ORDER BY target
|
||||
-- failure expected
|
||||
SELECT count(a) FROM test_missing_target GROUP BY a ORDER BY b;
|
||||
ERROR: Attribute test_missing_target.b must be GROUPed or used in an aggregate function
|
||||
ERROR: attribute "test_missing_target.b" must be GROUPed or used in an aggregate function
|
||||
-- w/o existing GROUP BY target and w/o existing same ORDER BY target
|
||||
SELECT count(b) FROM test_missing_target GROUP BY b/2 ORDER BY b/2;
|
||||
count
|
||||
@ -286,7 +286,7 @@ SELECT count(b) FROM test_missing_target
|
||||
SELECT count(x.a) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY b/2 ORDER BY b/2;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- group w/ existing GROUP BY target under ambiguous condition
|
||||
SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
@ -303,7 +303,7 @@ SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y
|
||||
SELECT count(b) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY x.b/2;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- group w/o existing GROUP BY target under ambiguous condition
|
||||
-- into a table
|
||||
SELECT count(x.b) INTO TABLE test_missing_target3
|
||||
|
@ -44,7 +44,7 @@ SELECT count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY
|
||||
-- w/o existing GROUP BY target and w/o existing a different ORDER BY target
|
||||
-- failure expected
|
||||
SELECT count(*) FROM test_missing_target GROUP BY a ORDER BY b;
|
||||
ERROR: Attribute test_missing_target.b must be GROUPed or used in an aggregate function
|
||||
ERROR: attribute "test_missing_target.b" must be GROUPed or used in an aggregate function
|
||||
-- w/o existing GROUP BY target and w/o existing same ORDER BY target
|
||||
SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b;
|
||||
count
|
||||
@ -120,7 +120,7 @@ ERROR: GROUP BY position 3 is not in target list
|
||||
SELECT count(*) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY b ORDER BY b;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- order w/ target under ambiguous condition
|
||||
-- failure NOT expected
|
||||
SELECT a, a FROM test_missing_target
|
||||
@ -235,7 +235,7 @@ ORDER BY lower(test_missing_target.c);
|
||||
-- w/o existing GROUP BY target and w/o existing a different ORDER BY target
|
||||
-- failure expected
|
||||
SELECT count(a) FROM test_missing_target GROUP BY a ORDER BY b;
|
||||
ERROR: Attribute test_missing_target.b must be GROUPed or used in an aggregate function
|
||||
ERROR: attribute "test_missing_target.b" must be GROUPed or used in an aggregate function
|
||||
-- w/o existing GROUP BY target and w/o existing same ORDER BY target
|
||||
SELECT count(b) FROM test_missing_target GROUP BY b/2 ORDER BY b/2;
|
||||
count
|
||||
@ -286,7 +286,7 @@ SELECT count(b) FROM test_missing_target
|
||||
SELECT count(x.a) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY b/2 ORDER BY b/2;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- group w/ existing GROUP BY target under ambiguous condition
|
||||
SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
@ -303,7 +303,7 @@ SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y
|
||||
SELECT count(b) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY x.b/2;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- group w/o existing GROUP BY target under ambiguous condition
|
||||
-- into a table
|
||||
SELECT count(x.b) INTO TABLE test_missing_target3
|
||||
|
@ -44,7 +44,7 @@ SELECT count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY
|
||||
-- w/o existing GROUP BY target and w/o existing a different ORDER BY target
|
||||
-- failure expected
|
||||
SELECT count(*) FROM test_missing_target GROUP BY a ORDER BY b;
|
||||
ERROR: Attribute test_missing_target.b must be GROUPed or used in an aggregate function
|
||||
ERROR: attribute "test_missing_target.b" must be GROUPed or used in an aggregate function
|
||||
-- w/o existing GROUP BY target and w/o existing same ORDER BY target
|
||||
SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b;
|
||||
count
|
||||
@ -120,7 +120,7 @@ ERROR: GROUP BY position 3 is not in target list
|
||||
SELECT count(*) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY b ORDER BY b;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- order w/ target under ambiguous condition
|
||||
-- failure NOT expected
|
||||
SELECT a, a FROM test_missing_target
|
||||
@ -235,7 +235,7 @@ ORDER BY lower(test_missing_target.c);
|
||||
-- w/o existing GROUP BY target and w/o existing a different ORDER BY target
|
||||
-- failure expected
|
||||
SELECT count(a) FROM test_missing_target GROUP BY a ORDER BY b;
|
||||
ERROR: Attribute test_missing_target.b must be GROUPed or used in an aggregate function
|
||||
ERROR: attribute "test_missing_target.b" must be GROUPed or used in an aggregate function
|
||||
-- w/o existing GROUP BY target and w/o existing same ORDER BY target
|
||||
SELECT count(b) FROM test_missing_target GROUP BY b/2 ORDER BY b/2;
|
||||
count
|
||||
@ -286,7 +286,7 @@ SELECT count(b) FROM test_missing_target
|
||||
SELECT count(x.a) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY b/2 ORDER BY b/2;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- group w/ existing GROUP BY target under ambiguous condition
|
||||
SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
@ -303,7 +303,7 @@ SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y
|
||||
SELECT count(b) FROM test_missing_target x, test_missing_target y
|
||||
WHERE x.a = y.a
|
||||
GROUP BY x.b/2;
|
||||
ERROR: Column reference "b" is ambiguous
|
||||
ERROR: column reference "b" is ambiguous
|
||||
-- group w/o existing GROUP BY target under ambiguous condition
|
||||
-- into a table
|
||||
SELECT count(x.b) INTO TABLE test_missing_target3
|
||||
|
@ -3,7 +3,7 @@
|
||||
---
|
||||
|
||||
CREATE TABLE serialTest (f1 text, f2 serial);
|
||||
NOTICE: CREATE TABLE will create implicit sequence 'serialtest_f2_seq' for SERIAL column 'serialtest.f2'
|
||||
NOTICE: CREATE TABLE will create implicit sequence "serialtest_f2_seq" for SERIAL column "serialtest.f2"
|
||||
|
||||
INSERT INTO serialTest VALUES ('foo');
|
||||
INSERT INTO serialTest VALUES ('bar');
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- Test basic TRUNCATE functionality.
|
||||
CREATE TABLE truncate_a (col1 integer primary key);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'truncate_a_pkey' for table 'truncate_a'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "truncate_a_pkey" for table "truncate_a"
|
||||
INSERT INTO truncate_a VALUES (1);
|
||||
INSERT INTO truncate_a VALUES (2);
|
||||
SELECT * FROM truncate_a;
|
||||
|
@ -404,7 +404,7 @@ ORDER BY q2,q1;
|
||||
|
||||
-- This should fail, because q2 isn't a name of an EXCEPT output column
|
||||
SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1;
|
||||
ERROR: Attribute "q2" not found
|
||||
ERROR: attribute "q2" not found
|
||||
-- But this should work:
|
||||
SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1)));
|
||||
q1
|
||||
|
@ -286,7 +286,7 @@ SELECT * FROM COPY_TBL;
|
||||
-- Primary keys
|
||||
--
|
||||
CREATE TABLE PRIMARY_TBL (i int PRIMARY KEY, t text);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'primary_tbl_pkey' for table 'primary_tbl'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "primary_tbl_pkey" for table "primary_tbl"
|
||||
INSERT INTO PRIMARY_TBL VALUES (1, 'one');
|
||||
INSERT INTO PRIMARY_TBL VALUES (2, 'two');
|
||||
INSERT INTO PRIMARY_TBL VALUES (1, 'three');
|
||||
@ -307,7 +307,7 @@ SELECT '' AS four, * FROM PRIMARY_TBL;
|
||||
DROP TABLE PRIMARY_TBL;
|
||||
CREATE TABLE PRIMARY_TBL (i int, t text,
|
||||
PRIMARY KEY(i,t));
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'primary_tbl_pkey' for table 'primary_tbl'
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "primary_tbl_pkey" for table "primary_tbl"
|
||||
INSERT INTO PRIMARY_TBL VALUES (1, 'one');
|
||||
INSERT INTO PRIMARY_TBL VALUES (2, 'two');
|
||||
INSERT INTO PRIMARY_TBL VALUES (1, 'three');
|
||||
@ -330,7 +330,7 @@ DROP TABLE PRIMARY_TBL;
|
||||
-- Unique keys
|
||||
--
|
||||
CREATE TABLE UNIQUE_TBL (i int UNIQUE, t text);
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'unique_tbl_i_key' for table 'unique_tbl'
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_key" for table "unique_tbl"
|
||||
INSERT INTO UNIQUE_TBL VALUES (1, 'one');
|
||||
INSERT INTO UNIQUE_TBL VALUES (2, 'two');
|
||||
INSERT INTO UNIQUE_TBL VALUES (1, 'three');
|
||||
@ -353,7 +353,7 @@ SELECT '' AS five, * FROM UNIQUE_TBL;
|
||||
DROP TABLE UNIQUE_TBL;
|
||||
CREATE TABLE UNIQUE_TBL (i int, t text,
|
||||
UNIQUE(i,t));
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'unique_tbl_i_key' for table 'unique_tbl'
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_key" for table "unique_tbl"
|
||||
INSERT INTO UNIQUE_TBL VALUES (1, 'one');
|
||||
INSERT INTO UNIQUE_TBL VALUES (2, 'two');
|
||||
INSERT INTO UNIQUE_TBL VALUES (1, 'three');
|
||||
|
@ -13,8 +13,8 @@ CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE)
|
||||
RETURNS hobbies_r.person%TYPE
|
||||
AS 'select person from hobbies_r where name = $1'
|
||||
LANGUAGE 'sql';
|
||||
NOTICE: hobbies_r.person%TYPE converted to text
|
||||
NOTICE: hobbies_r.name%TYPE converted to text
|
||||
NOTICE: type reference hobbies_r.person%TYPE converted to text
|
||||
NOTICE: type reference hobbies_r.name%TYPE converted to text
|
||||
CREATE FUNCTION equipment(hobbies_r)
|
||||
RETURNS setof equipment_r
|
||||
AS 'select * from equipment_r where hobby = $1.name'
|
||||
|
Loading…
Reference in New Issue
Block a user