Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4b583a8

Browse files
committed
Allow sequence nextval actions to be case-sensitive.
1 parent b53ddbe commit 4b583a8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/backend/parser/parse_func.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.39 1999/02/23 07:51:53 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.40 1999/03/15 16:48:34 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -21,6 +21,7 @@
2121
#include "access/relscan.h"
2222
#include "access/sdir.h"
2323
#include "catalog/catname.h"
24+
#include "catalog/heap.h"
2425
#include "catalog/indexing.h"
2526
#include "catalog/pg_inherits.h"
2627
#include "catalog/pg_proc.h"
@@ -440,7 +441,6 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
440441

441442
if (nodeTag(pair) == T_Ident && ((Ident *) pair)->isRel)
442443
{
443-
444444
/*
445445
* a relation
446446
*/
@@ -573,16 +573,21 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
573573
char *seqrel;
574574
text *seqname;
575575
int32 aclcheck_result = -1;
576-
extern text *lower(text *string);
577576

578577
Assert(length(fargs) == ((funcid == F_SETVAL) ? 2 : 1));
579578
seq = (Const *) lfirst(fargs);
580579
if (!IsA((Node *) seq, Const))
581580
elog(ERROR, "Only constant sequence names are acceptable for function '%s'", funcname);
582-
seqname = lower((text *) DatumGetPointer(seq->constvalue));
583-
pfree(DatumGetPointer(seq->constvalue));
584-
seq->constvalue = PointerGetDatum(seqname);
585-
seqrel = textout(seqname);
581+
582+
seqrel = textout((text *) DatumGetPointer(seq->constvalue));
583+
if (RelnameFindRelid(seqrel) == InvalidOid)
584+
{
585+
pfree(seqrel);
586+
seqname = lower((text *) DatumGetPointer(seq->constvalue));
587+
pfree(DatumGetPointer(seq->constvalue));
588+
seq->constvalue = PointerGetDatum(seqname);
589+
seqrel = textout(seqname);
590+
}
586591

587592
if ((aclcheck_result = pg_aclcheck(seqrel, GetPgUserName(),
588593
(((funcid == F_NEXTVAL) || (funcid == F_SETVAL)) ?

0 commit comments

Comments
 (0)