Skip to content

Commit 0d916a4

Browse files
committed
> 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
1 parent 7dc40a2 commit 0d916a4

File tree

2 files changed

+81
-3
lines changed

2 files changed

+81
-3
lines changed

src/backend/nodes/outfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.166 2002/08/04 19:48:09 momjian Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.167 2002/08/10 20:44:48 momjian Exp $
99
*
1010
* NOTES
1111
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -193,7 +193,7 @@ _outTypeName(StringInfo str, TypeName *node)
193193
appendStringInfo(str, " TYPENAME :names ");
194194
_outNode(str, node->names);
195195
appendStringInfo(str, " :typeid %u :timezone %s :setof %s"
196-
" :pct_type %s typmod %d :arrayBounds ",
196+
" :pct_type %s :typmod %d :arrayBounds ",
197197
node->typeid,
198198
booltostr(node->timezone),
199199
booltostr(node->setof),

src/backend/nodes/readfuncs.c

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.127 2002/08/04 19:48:09 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.128 2002/08/10 20:44:48 momjian Exp $
1212
*
1313
* NOTES
1414
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -1465,6 +1465,80 @@ _readColumnRef(void)
14651465
return local_node;
14661466
}
14671467

1468+
static ColumnDef *
1469+
_readColumnDef(void)
1470+
{
1471+
ColumnDef *local_node;
1472+
char *token;
1473+
int length;
1474+
1475+
local_node = makeNode(ColumnDef);
1476+
1477+
token = pg_strtok(&length); /* eat :colname */
1478+
token = pg_strtok(&length); /* now read it */
1479+
local_node->colname = nullable_string(token, length);
1480+
1481+
token = pg_strtok(&length); /* eat :typename */
1482+
local_node->typename = nodeRead(true); /* now read it */
1483+
1484+
token = pg_strtok(&length); /* eat :is_not_null */
1485+
token = pg_strtok(&length); /* get :is_not_null */
1486+
local_node->is_not_null = strtobool(token);
1487+
1488+
token = pg_strtok(&length); /* eat :raw_default */
1489+
local_node->raw_default = nodeRead(true); /* now read it */
1490+
1491+
token = pg_strtok(&length); /* eat :cooked_default */
1492+
token = pg_strtok(&length); /* now read it */
1493+
local_node->cooked_default = nullable_string(token, length);
1494+
1495+
token = pg_strtok(&length); /* eat :constraints */
1496+
local_node->constraints = nodeRead(true); /* now read it */
1497+
1498+
token = pg_strtok(&length); /* eat :support */
1499+
local_node->support = nodeRead(true); /* now read it */
1500+
1501+
return local_node;
1502+
}
1503+
1504+
static TypeName *
1505+
_readTypeName(void)
1506+
{
1507+
TypeName *local_node;
1508+
char *token;
1509+
int length;
1510+
1511+
local_node = makeNode(TypeName);
1512+
1513+
token = pg_strtok(&length); /* eat :names */
1514+
local_node->names = nodeRead(true); /* now read it */
1515+
1516+
token = pg_strtok(&length); /* eat :typeid */
1517+
token = pg_strtok(&length); /* get typeid */
1518+
local_node->typeid = atooid(token);
1519+
1520+
token = pg_strtok(&length); /* eat :timezone */
1521+
token = pg_strtok(&length); /* get timezone */
1522+
local_node->timezone = strtobool(token);
1523+
1524+
token = pg_strtok(&length); /* eat :setof */
1525+
token = pg_strtok(&length); /* get setof */
1526+
local_node->setof = strtobool(token);
1527+
1528+
token = pg_strtok(&length); /* eat :pct_type */
1529+
token = pg_strtok(&length); /* get pct_type */
1530+
local_node->pct_type = strtobool(token);
1531+
1532+
token = pg_strtok(&length); /* eat :typmod */
1533+
token = pg_strtok(&length); /* get typmod */
1534+
local_node->typmod = atoi(token);
1535+
1536+
token = pg_strtok(&length); /* eat :arrayBounds */
1537+
local_node->arrayBounds = nodeRead(true); /* now read it */
1538+
1539+
return local_node;
1540+
}
1541+
14681542
static ExprFieldSelect *
14691543
_readExprFieldSelect(void)
14701544
{
@@ -2092,6 +2166,10 @@ parsePlanString(void)
20922166
return_value = _readRangeVar();
20932167
else if (length == 9 && strncmp(token, "COLUMNREF", length) == 0)
20942168
return_value = _readColumnRef();
2169+
else if (length == 9 && strncmp(token, "COLUMNDEF", length) == 0)
2170+
return_value = _readColumnDef();
2171+
else if (length == 8 && strncmp(token, "TYPENAME", length) == 0)
2172+
return_value = _readTypeName();
20952173
else if (length == 15 && strncmp(token, "EXPRFIELDSELECT", length) == 0)
20962174
return_value = _readExprFieldSelect();
20972175
else if (length == 5 && strncmp(token, "ALIAS", length) == 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy