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
dfb8e3f1
Commit
dfb8e3f1
authored
Aug 11, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CREATE VIEW with optional column name list wasn't quite right for the
case where there are resjunk columns in the query.
parent
548512ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
src/backend/parser/analyze.c
src/backend/parser/analyze.c
+19
-14
No files found.
src/backend/parser/analyze.c
View file @
dfb8e3f1
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.19
3 2001/07/16 05:06:58
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.19
4 2001/08/11 00:02:13
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -161,31 +161,36 @@ transformStmt(ParseState *pstate, Node *parseTree)
...
@@ -161,31 +161,36 @@ transformStmt(ParseState *pstate, Node *parseTree)
* If a list of column names was given, run through and
* If a list of column names was given, run through and
* insert these into the actual query tree. - thomas
* insert these into the actual query tree. - thomas
* 2000-03-08
* 2000-03-08
*
* Outer loop is over targetlist to make it easier to
* skip junk targetlist entries.
*/
*/
if
(
n
->
aliases
!=
NIL
)
if
(
n
->
aliases
!=
NIL
)
{
{
int
i
;
List
*
aliaslist
=
n
->
aliases
;
List
*
targetList
=
n
->
query
->
targetList
;
List
*
targetList
;
if
(
length
(
targetList
)
<
length
(
n
->
aliases
))
elog
(
ERROR
,
"CREATE VIEW specifies %d columns"
" but only %d columns are present"
,
length
(
targetList
),
length
(
n
->
aliases
));
for
(
i
=
0
;
i
<
length
(
n
->
aliases
);
i
++
)
for
each
(
targetList
,
n
->
query
->
targetList
)
{
{
Ident
*
id
;
TargetEntry
*
te
=
(
TargetEntry
*
)
lfirst
(
targetList
);
TargetEntry
*
te
;
Resdom
*
rd
;
Resdom
*
rd
;
Ident
*
id
;
id
=
nth
(
i
,
n
->
aliases
);
Assert
(
IsA
(
id
,
Ident
));
te
=
nth
(
i
,
targetList
);
Assert
(
IsA
(
te
,
TargetEntry
));
Assert
(
IsA
(
te
,
TargetEntry
));
rd
=
te
->
resdom
;
rd
=
te
->
resdom
;
Assert
(
IsA
(
rd
,
Resdom
));
Assert
(
IsA
(
rd
,
Resdom
));
if
(
rd
->
resjunk
)
/* junk columns don't get aliases */
continue
;
id
=
(
Ident
*
)
lfirst
(
aliaslist
);
Assert
(
IsA
(
id
,
Ident
));
rd
->
resname
=
pstrdup
(
id
->
name
);
rd
->
resname
=
pstrdup
(
id
->
name
);
aliaslist
=
lnext
(
aliaslist
);
if
(
aliaslist
==
NIL
)
break
;
/* done assigning aliases */
}
}
if
(
aliaslist
!=
NIL
)
elog
(
ERROR
,
"CREATE VIEW specifies more column names than columns"
);
}
}
result
=
makeNode
(
Query
);
result
=
makeNode
(
Query
);
result
->
commandType
=
CMD_UTILITY
;
result
->
commandType
=
CMD_UTILITY
;
...
...
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