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:
@ -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++;
|
||||
|
Reference in New Issue
Block a user