Re: [GENERAL] Bug with sequences in 6.4.2 - Mailing list pgsql-general
From | Bruce Momjian |
---|---|
Subject | Re: [GENERAL] Bug with sequences in 6.4.2 |
Date | |
Msg-id | 199903151650.LAA16254@candle.pha.pa.us Whole thread Raw |
In response to | Bug with sequences in 6.4.2 (wehner@digital-security.com (Stefan Wehner)) |
List | pgsql-general |
> Greetings, > there seems to be a slight bug in the parsing of the > nextval function, tested under 6.4.2. > It affects also the SERIAL type. > > Symptom : > > CREATE SEQUENCE "AA"; > -- Correct, quoted identifier is allowed; > SELECT NEXTVAL('AA'); > --Produces Error > --aa.nextval: sequence does not exist > > > Probable source of problem, the Argument to nextval is > not handled correctly as an Table Identifier. > > E.g. nextval('"AA"') is generates > "aa".nextval: sequence does not exist > > Note the lowercase between the quotes. > > I quickly browsed the sources, but have not found the > place where the conversion to lowercase occurs. OK, I have made the following change to allow case-sensitive handling of nextval. It tries the exact case first, then tries lowercase. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 Index: parse_func.c =================================================================== RCS file: /usr/local/cvsroot/pgsql/src/backend/parser/parse_func.c,v retrieving revision 1.39 retrieving revision 1.40 diff -c -r1.39 -r1.40 *** parse_func.c 1999/02/23 07:51:53 1.39 --- parse_func.c 1999/03/15 16:48:34 1.40 *************** *** 7,13 **** * * * IDENTIFICATION ! * $Header: /usr/local/cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.39 1999/02/23 07:51:53 thomas Exp $ * *------------------------------------------------------------------------- */ --- 7,13 ---- * * * IDENTIFICATION ! * $Header: /usr/local/cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.40 1999/03/15 16:48:34 momjian Exp $ * *------------------------------------------------------------------------- */ *************** *** 21,26 **** --- 21,27 ---- #include "access/relscan.h" #include "access/sdir.h" #include "catalog/catname.h" + #include "catalog/heap.h" #include "catalog/indexing.h" #include "catalog/pg_inherits.h" #include "catalog/pg_proc.h" *************** *** 440,446 **** if (nodeTag(pair) == T_Ident && ((Ident *) pair)->isRel) { - /* * a relation */ --- 441,446 ---- *************** *** 573,588 **** char *seqrel; text *seqname; int32 aclcheck_result = -1; - extern text *lower(text *string); Assert(length(fargs) == ((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); ! 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)) ? --- 573,593 ---- char *seqrel; text *seqname; int32 aclcheck_result = -1; Assert(length(fargs) == ((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)); ! if (RelnameFindRelid(seqrel) == InvalidOid) ! { ! 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)) ?
pgsql-general by date: