Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf374fe

Browse files
committed
>Turning nextval and currval into keywords is not an acceptable way to
>go about this. That will risk breaking existing applications that use>those names as column names.>>It should actually almost work to write sq.nextval as things stand,>because Postgres has for a long time considered table.function and>function(table) to be interchangeable notations for certain kinds of>functions. nextval doesn't seem to be one of that kind of function,>at the moment. I'd suggest leaving the grammar as it was, and taking a>look at ParseFuncOrColumn in parse_func.c to see if you can't persuade>it to accept the sequence functions in that style.OK, good point. I tried to implement it somewhere else and ended upextending transformAttr. Attached you'll find the patch.Jeroen van Vianen
1 parent99b8f84 commitcf374fe

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎src/backend/parser/parse_expr.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.60 1999/12/1007:37:35 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.61 1999/12/16 20:07:41 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -531,6 +531,30 @@ static Node *
531531
transformAttr(ParseState*pstate,Attr*att,intprecedence)
532532
{
533533
Node*basenode;
534+
char*attribute;
535+
536+
/* Get the name of the first attribute */
537+
if ((att!=NULL)&& (lfirst(att->attrs)!=NULL))
538+
{
539+
/*
540+
* Special case for name.nextval and name.currval, assume it's a
541+
* sequence and transform to function call to nextval('name') and
542+
* currval('name')
543+
*/
544+
attribute=pstrdup(((Value*)lfirst(att->attrs))->val.str);
545+
if ((strcasecmp(attribute,"nextval")==0)||
546+
(strcasecmp(attribute,"currval")==0))
547+
{
548+
Value*s=makeNode(Value);
549+
550+
s->type=T_String;
551+
s->val.str=att->relname;
552+
553+
returnParseFuncOrColumn(pstate,attribute,
554+
lcons(make_const(s),NIL), false, false,
555+
&pstate->p_last_resno,precedence);
556+
}
557+
}
534558

535559
basenode=ParseNestedFuncOrColumn(pstate,att,&pstate->p_last_resno,
536560
precedence);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp