1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

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.
This commit is contained in:
Tom Lane
2000-06-11 20:08:01 +00:00
parent e9acba1ade
commit 3477957b44
6 changed files with 113 additions and 91 deletions

View File

@ -1,9 +1,9 @@
#include "executor/spi.h" /* this is what you need to work with SPI */
#include "commands/trigger.h" /* -"- and triggers */
#include "commands/sequence.h" /* for nextval() */
extern Datum autoinc(PG_FUNCTION_ARGS);
extern int4 nextval(struct varlena * seqin);
Datum
autoinc(PG_FUNCTION_ARGS)
@ -53,7 +53,7 @@ autoinc(PG_FUNCTION_ARGS)
for (i = 0; i < nargs;)
{
struct varlena *seqname;
text *seqname;
int attnum = SPI_fnumber(tupdesc, args[i]);
int32 val;
@ -74,9 +74,11 @@ autoinc(PG_FUNCTION_ARGS)
i++;
chattrs[chnattrs] = attnum;
seqname = textin(args[i]);
newvals[chnattrs] = Int32GetDatum(nextval(seqname));
newvals[chnattrs] = DirectFunctionCall1(nextval,
PointerGetDatum(seqname));
if (DatumGetInt32(newvals[chnattrs]) == 0)
newvals[chnattrs] = Int32GetDatum(nextval(seqname));
newvals[chnattrs] = DirectFunctionCall1(nextval,
PointerGetDatum(seqname));
pfree(seqname);
chnattrs++;
i++;