mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Implement parser hooks for processing ColumnRef and ParamRef nodes, as per my
recent proposal. As proof of concept, remove knowledge of Params from the core parser, arranging for them to be handled entirely by parser hook functions. It turns out we need an additional hook for that --- I had forgotten about the code that handles inferring a parameter's type from context. This is a preliminary step towards letting plpgsql handle its variables through parser hooks. Additional work remains to be done to expose the facility through SPI, but I think this is all the changes needed in the core parser.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.146 2009/10/27 17:11:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.147 2009/10/31 01:41:31 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -86,7 +86,17 @@ refnameRangeTblEntry(ParseState *pstate,
|
||||
{
|
||||
Oid namespaceId;
|
||||
|
||||
namespaceId = LookupExplicitNamespace(schemaname);
|
||||
/*
|
||||
* We can use LookupNamespaceNoError() here because we are only
|
||||
* interested in finding existing RTEs. Checking USAGE permission
|
||||
* on the schema is unnecessary since it would have already been
|
||||
* checked when the RTE was made. Furthermore, we want to report
|
||||
* "RTE not found", not "no permissions for schema", if the name
|
||||
* happens to match a schema name the user hasn't got access to.
|
||||
*/
|
||||
namespaceId = LookupNamespaceNoError(schemaname);
|
||||
if (!OidIsValid(relId))
|
||||
return NULL;
|
||||
relId = get_relname_relid(refname, namespaceId);
|
||||
if (!OidIsValid(relId))
|
||||
return NULL;
|
||||
@ -555,32 +565,6 @@ colNameToVar(ParseState *pstate, char *colname, bool localonly,
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* qualifiedNameToVar
|
||||
* Search for a qualified column name: either refname.colname or
|
||||
* schemaname.relname.colname.
|
||||
*
|
||||
* If found, return the appropriate Var node.
|
||||
* If not found, return NULL. If the name proves ambiguous, raise error.
|
||||
*/
|
||||
Node *
|
||||
qualifiedNameToVar(ParseState *pstate,
|
||||
char *schemaname,
|
||||
char *refname,
|
||||
char *colname,
|
||||
int location)
|
||||
{
|
||||
RangeTblEntry *rte;
|
||||
int sublevels_up;
|
||||
|
||||
rte = refnameRangeTblEntry(pstate, schemaname, refname, location,
|
||||
&sublevels_up);
|
||||
if (rte == NULL)
|
||||
return NULL;
|
||||
|
||||
return scanRTEForColumn(pstate, rte, colname, location);
|
||||
}
|
||||
|
||||
/*
|
||||
* markRTEForSelectPriv
|
||||
* Mark the specified column of an RTE as requiring SELECT privilege
|
||||
@ -2389,7 +2373,8 @@ errorMissingRTE(ParseState *pstate, RangeVar *relation)
|
||||
|
||||
/*
|
||||
* Check to see if there are any potential matches in the query's
|
||||
* rangetable.
|
||||
* rangetable. (Note: cases involving a bad schema name in the
|
||||
* RangeVar will throw error immediately here. That seems OK.)
|
||||
*/
|
||||
rte = searchRangeTable(pstate, relation);
|
||||
|
||||
|
Reference in New Issue
Block a user