1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-25 12:03:53 +03:00

Implement XMLSERIALIZE for real. Analogously, make the xml to text cast

observe the xmloption.

Reorganize the representation of the XML option in the parse tree and the
API to make it easier to manage and understand.

Add regression tests for parsing back XML expressions.
This commit is contained in:
Peter Eisentraut
2007-02-03 14:06:56 +00:00
parent 25dc46334b
commit ec020e1ceb
23 changed files with 344 additions and 99 deletions

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.364 2007/01/23 05:07:17 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.365 2007/02/03 14:06:54 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1116,6 +1116,9 @@ _copyXmlExpr(XmlExpr *from)
COPY_NODE_FIELD(named_args);
COPY_NODE_FIELD(arg_names);
COPY_NODE_FIELD(args);
COPY_SCALAR_FIELD(xmloption);
COPY_SCALAR_FIELD(type);
COPY_SCALAR_FIELD(typmod);
return newnode;
}
@@ -1723,6 +1726,18 @@ _copyLockingClause(LockingClause *from)
return newnode;
}
static XmlSerialize *
_copyXmlSerialize(XmlSerialize *from)
{
XmlSerialize *newnode = makeNode(XmlSerialize);
COPY_SCALAR_FIELD(xmloption);
COPY_NODE_FIELD(expr);
COPY_NODE_FIELD(typename);
return newnode;
}
static Query *
_copyQuery(Query *from)
{
@@ -3430,6 +3445,9 @@ copyObject(void *from)
case T_FuncWithArgs:
retval = _copyFuncWithArgs(from);
break;
case T_XmlSerialize:
retval = _copyXmlSerialize(from);
break;
default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));

View File

@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.297 2007/01/23 05:07:17 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.298 2007/02/03 14:06:54 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -462,6 +462,9 @@ _equalXmlExpr(XmlExpr *a, XmlExpr *b)
COMPARE_NODE_FIELD(named_args);
COMPARE_NODE_FIELD(arg_names);
COMPARE_NODE_FIELD(args);
COMPARE_SCALAR_FIELD(xmloption);
COMPARE_SCALAR_FIELD(type);
COMPARE_SCALAR_FIELD(typmod);
return true;
}
@@ -1830,6 +1833,15 @@ _equalFkConstraint(FkConstraint *a, FkConstraint *b)
return true;
}
static bool
_equalXmlSerialize(XmlSerialize *a, XmlSerialize *b)
{
COMPARE_SCALAR_FIELD(xmloption);
COMPARE_NODE_FIELD(expr);
COMPARE_NODE_FIELD(typename);
return true;
}
/*
* Stuff from pg_list.h
@@ -2411,6 +2423,9 @@ equal(void *a, void *b)
case T_FuncWithArgs:
retval = _equalFuncWithArgs(a, b);
break;
case T_XmlSerialize:
retval = _equalXmlSerialize(a, b);
break;
default:
elog(ERROR, "unrecognized node type: %d",

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.295 2007/01/22 20:00:39 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.296 2007/02/03 14:06:54 petere Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
@@ -933,6 +933,9 @@ _outXmlExpr(StringInfo str, XmlExpr *node)
WRITE_NODE_FIELD(named_args);
WRITE_NODE_FIELD(arg_names);
WRITE_NODE_FIELD(args);
WRITE_ENUM_FIELD(xmloption, XmlOptionType);
WRITE_OID_FIELD(type);
WRITE_INT_FIELD(typmod);
}
static void
@@ -1521,6 +1524,16 @@ _outLockingClause(StringInfo str, LockingClause *node)
WRITE_BOOL_FIELD(noWait);
}
static void
_outXmlSerialize(StringInfo str, XmlSerialize *node)
{
WRITE_NODE_TYPE("XMLSERIALIZE");
WRITE_ENUM_FIELD(xmloption, XmlOptionType);
WRITE_NODE_FIELD(expr);
WRITE_NODE_FIELD(typename);
}
static void
_outColumnDef(StringInfo str, ColumnDef *node)
{
@@ -2290,6 +2303,9 @@ _outNode(StringInfo str, void *obj)
case T_LockingClause:
_outLockingClause(str, obj);
break;
case T_XmlSerialize:
_outXmlSerialize(str, obj);
break;
default:

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.201 2007/01/09 02:14:12 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.202 2007/02/03 14:06:54 petere Exp $
*
* NOTES
* Path and Plan nodes do not have any readfuncs support, because we
@@ -723,6 +723,9 @@ _readXmlExpr(void)
READ_NODE_FIELD(named_args);
READ_NODE_FIELD(arg_names);
READ_NODE_FIELD(args);
READ_ENUM_FIELD(xmloption, XmlOptionType);
READ_OID_FIELD(type);
READ_INT_FIELD(typmod);
READ_DONE();
}