aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_func.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-06-11 20:08:01 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-06-11 20:08:01 +0000
commit3477957b44baf2b53f95207ff8824a0361301a2e (patch)
treed3b15fe37f59cc4423a59a734d65dd48615fb265 /src/backend/parser/parse_func.c
parente9acba1aded0caf2f7e02e8f1bbb813207d8cc8d (diff)
downloadpostgresql-3477957b44baf2b53f95207ff8824a0361301a2e.tar.gz
postgresql-3477957b44baf2b53f95207ff8824a0361301a2e.zip
Update sequence-related functions to new fmgr style. Remove downcasing,
quote-stripping, and acl-checking tasks for these functions from the parser, and do them at function execution time instead. This fixes the failure of pg_dump to produce correct output for nextval(Foo) used in a rule, and also eliminates the restriction that the argument of these functions must be a parse-time constant.
Diffstat (limited to 'src/backend/parser/parse_func.c')
-rw-r--r--src/backend/parser/parse_func.c58
1 files changed, 8 insertions, 50 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index 878c5530054..541211af64d 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.82 2000/06/03 04:41:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.83 2000/06/11 20:08:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -709,56 +709,14 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
}
/*
- * Sequence handling.
+ * Special checks to disallow sequence functions with side-effects
+ * in WHERE clauses. This is pretty much of a hack; why disallow these
+ * when we have no way to check for side-effects of user-defined fns?
*/
- if (funcid == F_NEXTVAL ||
- funcid == F_CURRVAL ||
- funcid == F_SETVAL)
- {
- Const *seq;
- char *seqrel;
- text *seqname;
- int32 aclcheck_result = -1;
-
- Assert(nargs == ((funcid == F_SETVAL) ? 2 : 1));
- seq = (Const *) lfirst(fargs);
- if (!IsA((Node *) seq, Const))
- elog(ERROR, "Only constant sequence names are acceptable for function '%s'", funcname);
-
- seqrel = textout((text *) DatumGetPointer(seq->constvalue));
- /* Do we have nextval('"Aa"')? */
- if (strlen(seqrel) >= 2 &&
- seqrel[0] == '\"' && seqrel[strlen(seqrel) - 1] == '\"')
- {
- /* strip off quotes, keep case */
- seqrel = pstrdup(seqrel + 1);
- seqrel[strlen(seqrel) - 1] = '\0';
- pfree(DatumGetPointer(seq->constvalue));
- seq->constvalue = (Datum) textin(seqrel);
- }
- else
- {
- pfree(seqrel);
- seqname = lower((text *) DatumGetPointer(seq->constvalue));
- pfree(DatumGetPointer(seq->constvalue));
- seq->constvalue = PointerGetDatum(seqname);
- seqrel = textout(seqname);
- }
-
- if ((aclcheck_result = pg_aclcheck(seqrel, GetPgUserName(),
- (((funcid == F_NEXTVAL) || (funcid == F_SETVAL)) ?
- ACL_WR : ACL_RD)))
- != ACLCHECK_OK)
- elog(ERROR, "%s.%s: %s",
- seqrel, funcname, aclcheck_error_strings[aclcheck_result]);
-
- pfree(seqrel);
-
- if (funcid == F_NEXTVAL && pstate->p_in_where_clause)
- elog(ERROR, "Sequence function nextval is not allowed in WHERE clauses");
- if (funcid == F_SETVAL && pstate->p_in_where_clause)
- elog(ERROR, "Sequence function setval is not allowed in WHERE clauses");
- }
+ if (funcid == F_NEXTVAL && pstate->p_in_where_clause)
+ elog(ERROR, "Sequence function nextval is not allowed in WHERE clauses");
+ if (funcid == F_SETVAL && pstate->p_in_where_clause)
+ elog(ERROR, "Sequence function setval is not allowed in WHERE clauses");
expr = makeNode(Expr);
expr->typeOid = rettype;