mirror of
https://github.com/postgres/postgres.git
synced 2025-07-17 06:41:09 +03:00
Various fixes in the logic of XML functions:
- Add new SQL command SET XML OPTION (also available via regular GUC) to control the DOCUMENT vs. CONTENT option in implicit parsing and serialization operations. - Subtle corrections in the handling of the standalone property in xmlroot(). - Allow xmlroot() to work on content fragments. - Subtle corrections in the handling of the version property in xmlconcat(). - Code refactoring for producing XML declarations.
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.576 2007/01/23 05:07:17 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.577 2007/01/25 11:53:51 petere Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -60,6 +60,7 @@
|
||||
#include "utils/date.h"
|
||||
#include "utils/datetime.h"
|
||||
#include "utils/numeric.h"
|
||||
#include "utils/xml.h"
|
||||
|
||||
|
||||
/* Location tracking support --- simpler than bison's default */
|
||||
@ -439,7 +440,7 @@ static Node *makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args)
|
||||
|
||||
WHEN WHERE WHITESPACE_P WITH WITHOUT WORK WRITE
|
||||
|
||||
XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLFOREST XMLPARSE
|
||||
XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLFOREST XMLPARSE
|
||||
XMLPI XMLROOT XMLSERIALIZE
|
||||
|
||||
YEAR_P YES_P
|
||||
@ -1112,6 +1113,13 @@ set_rest: var_name TO var_list_or_default
|
||||
n->args = NIL;
|
||||
$$ = n;
|
||||
}
|
||||
| XML_P OPTION document_or_content
|
||||
{
|
||||
VariableSetStmt *n = makeNode(VariableSetStmt);
|
||||
n->name = "xmloption";
|
||||
n->args = list_make1(makeStringConst($3 ? "DOCUMENT" : "CONTENT", NULL));
|
||||
$$ = n;
|
||||
}
|
||||
;
|
||||
|
||||
var_name:
|
||||
@ -7938,21 +7946,13 @@ xml_root_version: VERSION_P a_expr
|
||||
;
|
||||
|
||||
opt_xml_root_standalone: ',' STANDALONE_P YES_P
|
||||
{ $$ = (Node *) makeBoolAConst(true); }
|
||||
{ $$ = (Node *) makeIntConst(XML_STANDALONE_YES); }
|
||||
| ',' STANDALONE_P NO
|
||||
{ $$ = (Node *) makeBoolAConst(false); }
|
||||
{ $$ = (Node *) makeIntConst(XML_STANDALONE_NO); }
|
||||
| ',' STANDALONE_P NO VALUE_P
|
||||
{
|
||||
A_Const *val = makeNode(A_Const);
|
||||
val->val.type = T_Null;
|
||||
$$ = (Node *) val;
|
||||
}
|
||||
{ $$ = (Node *) makeIntConst(XML_STANDALONE_NO_VALUE); }
|
||||
| /*EMPTY*/
|
||||
{
|
||||
A_Const *val = makeNode(A_Const);
|
||||
val->val.type = T_Null;
|
||||
$$ = (Node *) val;
|
||||
}
|
||||
{ $$ = (Node *) makeIntConst(XML_STANDALONE_OMITTED); }
|
||||
;
|
||||
|
||||
xml_attributes: XMLATTRIBUTES '(' xml_attribute_list ')' { $$ = $3; }
|
||||
@ -8864,6 +8864,7 @@ unreserved_keyword:
|
||||
| WITHOUT
|
||||
| WORK
|
||||
| WRITE
|
||||
| XML_P
|
||||
| YEAR_P
|
||||
| YES_P
|
||||
| ZONE
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.183 2007/01/23 05:07:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.184 2007/01/25 11:53:51 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -380,6 +380,7 @@ static const ScanKeyword ScanKeywords[] = {
|
||||
{"without", WITHOUT},
|
||||
{"work", WORK},
|
||||
{"write", WRITE},
|
||||
{"xml", XML_P},
|
||||
{"xmlattributes", XMLATTRIBUTES},
|
||||
{"xmlconcat", XMLCONCAT},
|
||||
{"xmlelement", XMLELEMENT},
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.208 2007/01/14 13:11:53 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.209 2007/01/25 11:53:51 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1481,7 +1481,8 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
|
||||
newe = coerce_to_specific_type(pstate, newe, TEXTOID,
|
||||
"XMLROOT");
|
||||
else
|
||||
newe = coerce_to_boolean(pstate, newe, "XMLROOT");
|
||||
newe = coerce_to_specific_type(pstate, newe, INT4OID,
|
||||
"XMLROOT");
|
||||
break;
|
||||
case IS_DOCUMENT:
|
||||
newe = coerce_to_specific_type(pstate, newe, XMLOID,
|
||||
|
Reference in New Issue
Block a user