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

Commit2337780

Browse files
committed
Change display of FieldSelect nodes from arg.field to field(arg),
per bug report from Stefan Hadjistoytchev. There are some caseswhere the dot notation works, but there are more where it doesn't.Eventually ought to consider fixing the parser to allow cases likefunc().field, but for now this is the simplest patch.
1 parent2631b79 commit2337780

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*back to source text
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.88 2001/11/2600:29:15 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.89 2001/11/2621:15:14 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -1866,28 +1866,36 @@ get_rule_expr(Node *node, deparse_context *context)
18661866
caseT_FieldSelect:
18671867
{
18681868
FieldSelect*fselect= (FieldSelect*)node;
1869+
OidargType=exprType(fselect->arg);
18691870
HeapTupletypetup;
18701871
Form_pg_typetypeStruct;
18711872
Oidtyprelid;
18721873
char*fieldname;
18731874

1874-
/* we do NOT parenthesize the arg expression, for now */
1875-
get_rule_expr(fselect->arg,context);
1875+
/* lookup arg type and get the field name */
18761876
typetup=SearchSysCache(TYPEOID,
1877-
ObjectIdGetDatum(exprType(fselect->arg)),
1877+
ObjectIdGetDatum(argType),
18781878
0,0,0);
18791879
if (!HeapTupleIsValid(typetup))
18801880
elog(ERROR,"cache lookup of type %u failed",
1881-
exprType(fselect->arg));
1881+
argType);
18821882
typeStruct= (Form_pg_type)GETSTRUCT(typetup);
18831883
typrelid=typeStruct->typrelid;
18841884
if (!OidIsValid(typrelid))
18851885
elog(ERROR,"Argument type %s of FieldSelect is not a tuple type",
1886-
NameStr(typeStruct->typname));
1886+
format_type_be(argType));
1887+
ReleaseSysCache(typetup);
18871888
fieldname=get_relid_attribute_name(typrelid,
18881889
fselect->fieldnum);
1889-
appendStringInfo(buf,".%s",quote_identifier(fieldname));
1890-
ReleaseSysCache(typetup);
1890+
/*
1891+
* If the argument is simple enough, we could emit
1892+
* arg.fieldname, but most cases where FieldSelect is used
1893+
* are *not* simple. For now, always use the projection-
1894+
* function syntax.
1895+
*/
1896+
appendStringInfo(buf,"%s(",quote_identifier(fieldname));
1897+
get_rule_expr(fselect->arg,context);
1898+
appendStringInfoChar(buf,')');
18911899
}
18921900
break;
18931901

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp