Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
052c2eaa
Commit
052c2eaa
authored
Sep 17, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify and clean up FigureColname; make it work without coredumping
for TypeCast case.
parent
ec7ddc15
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
26 deletions
+16
-26
src/backend/parser/parse_target.c
src/backend/parser/parse_target.c
+16
-26
No files found.
src/backend/parser/parse_target.c
View file @
052c2eaa
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.7
1 2001/09/10 14:53:10 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.7
2 2001/09/17 01:06:36 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -26,7 +26,7 @@
static
List
*
ExpandAllTables
(
ParseState
*
pstate
);
static
char
*
FigureColname
(
Node
*
expr
,
Node
*
resval
);
static
char
*
FigureColname
(
Node
*
node
);
/*
...
...
@@ -64,12 +64,11 @@ transformTargetEntry(ParseState *pstate,
if
(
colname
==
NULL
)
{
/*
* Generate a suitable column name for a column without any
* explicit 'AS ColumnName' clause.
*/
colname
=
FigureColname
(
expr
,
node
);
colname
=
FigureColname
(
node
);
}
resnode
=
makeResdom
((
AttrNumber
)
pstate
->
p_last_resno
++
,
...
...
@@ -455,21 +454,21 @@ ExpandAllTables(ParseState *pstate)
* list, we have to guess a suitable name. The SQL spec provides some
* guidance, but not much...
*
* Note that the argument is the *untransformed* parse tree for the target
* item. This is a shade easier to work with than the transformed tree.
*/
static
char
*
FigureColname
(
Node
*
expr
,
Node
*
resval
)
FigureColname
(
Node
*
node
)
{
/* Some of these are easiest to do with the untransformed node */
switch
(
nodeTag
(
resval
))
if
(
node
==
NULL
)
return
"?column?"
;
switch
(
nodeTag
(
node
))
{
case
T_TypeCast
:
return
(
(
((
Ident
*
)
((
TypeCast
*
)
resval
)
->
arg
)
->
name
));
case
T_Ident
:
return
((
Ident
*
)
resval
)
->
name
;
return
((
Ident
*
)
node
)
->
name
;
case
T_Attr
:
{
List
*
attrs
=
((
Attr
*
)
resval
)
->
attrs
;
List
*
attrs
=
((
Attr
*
)
node
)
->
attrs
;
if
(
attrs
)
{
...
...
@@ -479,23 +478,15 @@ FigureColname(Node *expr, Node *resval)
}
}
break
;
default:
break
;
}
/* Otherwise, work with the transformed node */
switch
(
nodeTag
(
expr
))
{
case
T_Expr
:
if
(((
Expr
*
)
expr
)
->
opType
==
FUNC_EXPR
&&
IsA
(
resval
,
FuncCall
))
return
((
FuncCall
*
)
resval
)
->
funcname
;
break
;
case
T_Aggref
:
return
((
Aggref
*
)
expr
)
->
aggname
;
case
T_FuncCall
:
return
((
FuncCall
*
)
node
)
->
funcname
;
case
T_TypeCast
:
return
FigureColname
(((
TypeCast
*
)
node
)
->
arg
);
case
T_CaseExpr
:
{
char
*
name
;
name
=
FigureColname
(((
CaseExpr
*
)
expr
)
->
defresult
,
resval
);
name
=
FigureColname
(((
CaseExpr
*
)
node
)
->
defresult
);
if
(
strcmp
(
name
,
"?column?"
)
==
0
)
name
=
"case"
;
return
name
;
...
...
@@ -504,6 +495,5 @@ FigureColname(Node *expr, Node *resval)
default:
break
;
}
return
"?column?"
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment