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
40136f44
Commit
40136f44
authored
Apr 18, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make rule lister do the right thing with Vars representing whole tuples.
parent
4a590518
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
src/backend/parser/parse_relation.c
src/backend/parser/parse_relation.c
+7
-1
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/ruleutils.c
+22
-9
No files found.
src/backend/parser/parse_relation.c
View file @
40136f44
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.5
3 2001/03/22 03:59:41 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.5
4 2001/04/18 17:04:24 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -909,6 +909,9 @@ expandNamesVars(ParseState *pstate, List *names, List *vars)
* In particular, it will work on an RTE for a subselect, whereas
* get_attname() only works on real relations.
*
* "*" is returned if the given attnum is InvalidAttrNumber --- this case
* occurs when a Var represents a whole tuple of a relation.
*
* XXX Actually, this is completely bogus, because refnames of RTEs are
* not guaranteed unique, and may not even have scope across the whole
* query. Cleanest fix would be to add refname/attname to Var nodes and
...
...
@@ -920,6 +923,9 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
{
char
*
attname
;
if
(
attnum
==
InvalidAttrNumber
)
return
"*"
;
/*
* If there is an alias, use it
*/
...
...
src/backend/utils/adt/ruleutils.c
View file @
40136f44
...
...
@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.7
6 2001/04/15 03:14:18
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.7
7 2001/04/18 17:04:24
tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
...
...
@@ -1051,7 +1051,8 @@ get_basic_select_query(Query *query, deparse_context *context)
char
*
attname
;
get_names_for_var
(
var
,
context
,
&
refname
,
&
attname
);
tell_as
=
(
strcmp
(
attname
,
tle
->
resdom
->
resname
)
!=
0
);
tell_as
=
(
attname
==
NULL
||
strcmp
(
attname
,
tle
->
resdom
->
resname
)
!=
0
);
}
/* and do if so */
...
...
@@ -1380,6 +1381,9 @@ get_utility_query_def(Query *query, deparse_context *context)
/*
* Get the relation refname and attname for a (possibly nonlocal) Var.
*
* attname will be returned as NULL if the Var represents a whole tuple
* of the relation.
*
* This is trickier than it ought to be because of the possibility of aliases
* and limited scope of refnames. We have to try to return the correct alias
* with respect to the current namespace given by the context.
...
...
@@ -1414,7 +1418,10 @@ get_names_for_var(Var *var, deparse_context *context,
*/
rte
=
rt_fetch
(
var
->
varno
,
dpns
->
rtable
);
*
refname
=
rte
->
eref
->
relname
;
*
attname
=
get_rte_attribute_name
(
rte
,
var
->
varattno
);
if
(
var
->
varattno
==
InvalidAttrNumber
)
*
attname
=
NULL
;
else
*
attname
=
get_rte_attribute_name
(
rte
,
var
->
varattno
);
}
/*
...
...
@@ -1474,7 +1481,10 @@ find_alias_in_namespace(Node *nsnode, Node *expr,
RangeTblEntry
*
rte
=
rt_fetch
(
rtindex
,
rangetable
);
*
refname
=
rte
->
eref
->
relname
;
*
attname
=
get_rte_attribute_name
(
rte
,
var
->
varattno
);
if
(
var
->
varattno
==
InvalidAttrNumber
)
*
attname
=
NULL
;
else
*
attname
=
get_rte_attribute_name
(
rte
,
var
->
varattno
);
return
true
;
}
}
...
...
@@ -1684,17 +1694,20 @@ get_rule_expr(Node *node, deparse_context *context)
char
*
attname
;
get_names_for_var
(
var
,
context
,
&
refname
,
&
attname
);
if
(
context
->
varprefix
)
if
(
context
->
varprefix
||
attname
==
NULL
)
{
if
(
strcmp
(
refname
,
"*NEW*"
)
==
0
)
appendStringInfo
(
buf
,
"new
.
"
);
appendStringInfo
(
buf
,
"new"
);
else
if
(
strcmp
(
refname
,
"*OLD*"
)
==
0
)
appendStringInfo
(
buf
,
"old
.
"
);
appendStringInfo
(
buf
,
"old"
);
else
appendStringInfo
(
buf
,
"%s
.
"
,
appendStringInfo
(
buf
,
"%s"
,
quote_identifier
(
refname
));
if
(
attname
)
appendStringInfoChar
(
buf
,
'.'
);
}
appendStringInfo
(
buf
,
"%s"
,
quote_identifier
(
attname
));
if
(
attname
)
appendStringInfo
(
buf
,
"%s"
,
quote_identifier
(
attname
));
}
break
;
...
...
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