Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
c20fb657
Commit
c20fb657
authored
20 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
On further experimentation, there were still a couple of bugs in
ExpandIndirectionStar() ... and in markTargetListOrigin() too.
parent
dfc5c729
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/parser/parse_target.c
+44
-43
44 additions, 43 deletions
src/backend/parser/parse_target.c
with
44 additions
and
43 deletions
src/backend/parser/parse_target.c
+
44
−
43
View file @
c20fb657
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.13
2
2005/04/25 2
1
:0
3:25
tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.13
3
2005/04/25 2
2
:0
2:30
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -204,8 +204,9 @@ markTargetListOrigin(ParseState *pstate, TargetEntry *tle,
tle
->
resorigcol
=
attnum
;
break
;
case
RTE_SUBQUERY
:
/* Subselect-in-FROM: copy up from the subselect */
if
(
attnum
!=
InvalidAttrNumber
)
{
/* Subselect-in-FROM: copy up from the subselect */
TargetEntry
*
ste
=
get_tle_by_resno
(
rte
->
subquery
->
targetList
,
attnum
);
...
...
@@ -217,8 +218,9 @@ markTargetListOrigin(ParseState *pstate, TargetEntry *tle,
}
break
;
case
RTE_JOIN
:
/* Join RTE --- recursively inspect the alias variable */
if
(
attnum
!=
InvalidAttrNumber
)
{
/* Join RTE --- recursively inspect the alias variable */
Var
*
aliasvar
;
Assert
(
attnum
>
0
&&
attnum
<=
list_length
(
rte
->
joinaliasvars
));
...
...
@@ -920,6 +922,37 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
rte
=
GetRTEByRangeTablePosn
(
pstate
,
var
->
varno
,
netlevelsup
);
attnum
=
var
->
varattno
;
if
(
attnum
==
InvalidAttrNumber
)
{
/* Whole-row reference to an RTE, so expand the known fields */
List
*
names
,
*
vars
;
ListCell
*
lname
,
*
lvar
;
int
i
;
expandRTE
(
GetLevelNRangeTable
(
pstate
,
netlevelsup
),
var
->
varno
,
0
,
false
,
&
names
,
&
vars
);
tupleDesc
=
CreateTemplateTupleDesc
(
list_length
(
vars
),
false
);
i
=
1
;
forboth
(
lname
,
names
,
lvar
,
vars
)
{
char
*
label
=
strVal
(
lfirst
(
lname
));
Node
*
varnode
=
(
Node
*
)
lfirst
(
lvar
);
TupleDescInitEntry
(
tupleDesc
,
i
,
label
,
exprType
(
varnode
),
exprTypmod
(
varnode
),
0
);
i
++
;
}
Assert
(
lname
==
NULL
&&
lvar
==
NULL
);
/* lists same length? */
return
tupleDesc
;
}
expr
=
(
Node
*
)
var
;
/* default if we can't drill down */
switch
(
rte
->
rtekind
)
...
...
@@ -927,10 +960,9 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
case
RTE_RELATION
:
case
RTE_SPECIAL
:
/*
* This case should not occur: a whole-row Var should have the
* table's named rowtype, and a column of a table shouldn't have
* type RECORD either. Fall through and fail (most likely)
* at the bottom.
* This case should not occur: a column of a table shouldn't have
* type RECORD. Fall through and fail (most likely) at the
* bottom.
*/
break
;
case
RTE_SUBQUERY
:
...
...
@@ -963,37 +995,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
}
break
;
case
RTE_JOIN
:
/* Join RTE */
if
(
attnum
==
InvalidAttrNumber
)
{
/* Whole-row reference to join, so expand the fields */
List
*
names
,
*
vars
;
ListCell
*
lname
,
*
lvar
;
int
i
;
expandRTE
(
GetLevelNRangeTable
(
pstate
,
netlevelsup
),
var
->
varno
,
0
,
false
,
&
names
,
&
vars
);
tupleDesc
=
CreateTemplateTupleDesc
(
list_length
(
vars
),
false
);
i
=
1
;
forboth
(
lname
,
names
,
lvar
,
vars
)
{
char
*
label
=
strVal
(
lfirst
(
lname
));
Node
*
varnode
=
(
Node
*
)
lfirst
(
lvar
);
TupleDescInitEntry
(
tupleDesc
,
i
,
label
,
exprType
(
varnode
),
exprTypmod
(
varnode
),
0
);
i
++
;
}
Assert
(
lname
==
NULL
&&
lvar
==
NULL
);
/* lists same len? */
return
tupleDesc
;
}
/* Else recursively inspect the alias variable */
/* Join RTE --- recursively inspect the alias variable */
Assert
(
attnum
>
0
&&
attnum
<=
list_length
(
rte
->
joinaliasvars
));
expr
=
(
Node
*
)
list_nth
(
rte
->
joinaliasvars
,
attnum
-
1
);
if
(
IsA
(
expr
,
Var
))
...
...
@@ -1001,11 +1003,10 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
/* else fall through to inspect the expression */
break
;
case
RTE_FUNCTION
:
expr
=
rte
->
funcexpr
;
/* The func expr probably can't be a Var, but check */
if
(
IsA
(
expr
,
Var
))
return
expandRecordVariable
(
pstate
,
(
Var
*
)
expr
,
netlevelsup
);
/* else fall through to inspect the expression */
/*
* We couldn't get here unless a function is declared with one
* of its result columns as RECORD, which is not allowed.
*/
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment