1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

Modify sequence state storage to eliminate dangling-pointer problem

exemplified by bug #671.  Moving the storage to relcache turned out to
be a bad idea because relcache might decide to discard the info.  Instead,
open and close the relcache entry on each sequence operation, and use
a record of the current XID to discover whether we already hold
AccessShareLock on the sequence.
This commit is contained in:
Tom Lane
2002-05-22 21:40:55 +00:00
parent b8ffc99602
commit a2597ef179
5 changed files with 161 additions and 147 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.76 2002/04/15 05:22:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.77 2002/05/22 21:40:55 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@ -37,6 +37,7 @@
#include "commands/defrem.h"
#include "parser/parse_type.h"
#include "utils/int8.h"
/*
@ -114,6 +115,34 @@ defGetNumeric(DefElem *def)
return 0; /* keep compiler quiet */
}
/*
* Extract an int64 value from a DefElem.
*/
int64
defGetInt64(DefElem *def)
{
if (def->arg == NULL)
elog(ERROR, "Define: \"%s\" requires a numeric value",
def->defname);
switch (nodeTag(def->arg))
{
case T_Integer:
return (int64) intVal(def->arg);
case T_Float:
/*
* Values too large for int4 will be represented as Float
* constants by the lexer. Accept these if they are valid int8
* strings.
*/
return DatumGetInt64(DirectFunctionCall1(int8in,
CStringGetDatum(strVal(def->arg))));
default:
elog(ERROR, "Define: \"%s\" requires a numeric value",
def->defname);
}
return 0; /* keep compiler quiet */
}
/*
* Extract a possibly-qualified name (as a List of Strings) from a DefElem.
*/