mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-09 08:10:09 +08:00
> create view pg_locks as select l.relation, l.database, l.backendpid,
> l.mode, l.isgranted from pg_lock_info() as l(relation oid, database oid, > backendpid int4, mode text, isgranted bool); > ERROR: badly formatted planstring "COLUMNDEF "... > Reported by Neil Conway -- I never implemented readfuncs.c support for ColumnDef or TypeName, which is needed so that views can be created on functions returning type RECORD. Here's a patch. Joe Conway
This commit is contained in:
parent
7dc40a2be0
commit
0d916a4b60
@ -5,7 +5,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.166 2002/08/04 19:48:09 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.167 2002/08/10 20:44:48 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||
@ -193,7 +193,7 @@ _outTypeName(StringInfo str, TypeName *node)
|
||||
appendStringInfo(str, " TYPENAME :names ");
|
||||
_outNode(str, node->names);
|
||||
appendStringInfo(str, " :typeid %u :timezone %s :setof %s"
|
||||
" :pct_type %s typmod %d :arrayBounds ",
|
||||
" :pct_type %s :typmod %d :arrayBounds ",
|
||||
node->typeid,
|
||||
booltostr(node->timezone),
|
||||
booltostr(node->setof),
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.127 2002/08/04 19:48:09 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.128 2002/08/10 20:44:48 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Most of the read functions for plan nodes are tested. (In fact, they
|
||||
@ -1465,6 +1465,80 @@ _readColumnRef(void)
|
||||
return local_node;
|
||||
}
|
||||
|
||||
static ColumnDef *
|
||||
_readColumnDef(void)
|
||||
{
|
||||
ColumnDef *local_node;
|
||||
char *token;
|
||||
int length;
|
||||
|
||||
local_node = makeNode(ColumnDef);
|
||||
|
||||
token = pg_strtok(&length); /* eat :colname */
|
||||
token = pg_strtok(&length); /* now read it */
|
||||
local_node->colname = nullable_string(token, length);
|
||||
|
||||
token = pg_strtok(&length); /* eat :typename */
|
||||
local_node->typename = nodeRead(true); /* now read it */
|
||||
|
||||
token = pg_strtok(&length); /* eat :is_not_null */
|
||||
token = pg_strtok(&length); /* get :is_not_null */
|
||||
local_node->is_not_null = strtobool(token);
|
||||
|
||||
token = pg_strtok(&length); /* eat :raw_default */
|
||||
local_node->raw_default = nodeRead(true); /* now read it */
|
||||
|
||||
token = pg_strtok(&length); /* eat :cooked_default */
|
||||
token = pg_strtok(&length); /* now read it */
|
||||
local_node->cooked_default = nullable_string(token, length);
|
||||
|
||||
token = pg_strtok(&length); /* eat :constraints */
|
||||
local_node->constraints = nodeRead(true); /* now read it */
|
||||
|
||||
token = pg_strtok(&length); /* eat :support */
|
||||
local_node->support = nodeRead(true); /* now read it */
|
||||
|
||||
return local_node;
|
||||
}
|
||||
|
||||
static TypeName *
|
||||
_readTypeName(void)
|
||||
{
|
||||
TypeName *local_node;
|
||||
char *token;
|
||||
int length;
|
||||
|
||||
local_node = makeNode(TypeName);
|
||||
|
||||
token = pg_strtok(&length); /* eat :names */
|
||||
local_node->names = nodeRead(true); /* now read it */
|
||||
|
||||
token = pg_strtok(&length); /* eat :typeid */
|
||||
token = pg_strtok(&length); /* get typeid */
|
||||
local_node->typeid = atooid(token);
|
||||
|
||||
token = pg_strtok(&length); /* eat :timezone */
|
||||
token = pg_strtok(&length); /* get timezone */
|
||||
local_node->timezone = strtobool(token);
|
||||
|
||||
token = pg_strtok(&length); /* eat :setof */
|
||||
token = pg_strtok(&length); /* get setof */
|
||||
local_node->setof = strtobool(token);
|
||||
|
||||
token = pg_strtok(&length); /* eat :pct_type */
|
||||
token = pg_strtok(&length); /* get pct_type */
|
||||
local_node->pct_type = strtobool(token);
|
||||
|
||||
token = pg_strtok(&length); /* eat :typmod */
|
||||
token = pg_strtok(&length); /* get typmod */
|
||||
local_node->typmod = atoi(token);
|
||||
|
||||
token = pg_strtok(&length); /* eat :arrayBounds */
|
||||
local_node->arrayBounds = nodeRead(true); /* now read it */
|
||||
|
||||
return local_node;
|
||||
}
|
||||
|
||||
static ExprFieldSelect *
|
||||
_readExprFieldSelect(void)
|
||||
{
|
||||
@ -2092,6 +2166,10 @@ parsePlanString(void)
|
||||
return_value = _readRangeVar();
|
||||
else if (length == 9 && strncmp(token, "COLUMNREF", length) == 0)
|
||||
return_value = _readColumnRef();
|
||||
else if (length == 9 && strncmp(token, "COLUMNDEF", length) == 0)
|
||||
return_value = _readColumnDef();
|
||||
else if (length == 8 && strncmp(token, "TYPENAME", length) == 0)
|
||||
return_value = _readTypeName();
|
||||
else if (length == 15 && strncmp(token, "EXPRFIELDSELECT", length) == 0)
|
||||
return_value = _readExprFieldSelect();
|
||||
else if (length == 5 && strncmp(token, "ALIAS", length) == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user