mirror of
https://github.com/postgres/postgres.git
synced 2025-06-03 00:02:26 -04:00
Add support for optionally escaping periods when converting SQL identifiers
to XML names, which will be required for supporting XML export.
This commit is contained in:
parent
733abd2987
commit
eb19144894
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.210 2007/02/03 14:06:54 petere Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.211 2007/02/11 22:18:15 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1389,7 +1389,7 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
|
|||||||
|
|
||||||
newx->op = x->op;
|
newx->op = x->op;
|
||||||
if (x->name)
|
if (x->name)
|
||||||
newx->name = map_sql_identifier_to_xml_name(x->name, false);
|
newx->name = map_sql_identifier_to_xml_name(x->name, false, false);
|
||||||
else
|
else
|
||||||
newx->name = NULL;
|
newx->name = NULL;
|
||||||
|
|
||||||
@ -1411,10 +1411,10 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
|
|||||||
expr = transformExpr(pstate, r->val);
|
expr = transformExpr(pstate, r->val);
|
||||||
|
|
||||||
if (r->name)
|
if (r->name)
|
||||||
argname = map_sql_identifier_to_xml_name(r->name, false);
|
argname = map_sql_identifier_to_xml_name(r->name, false, false);
|
||||||
else if (IsA(r->val, ColumnRef))
|
else if (IsA(r->val, ColumnRef))
|
||||||
argname = map_sql_identifier_to_xml_name(FigureColname(r->val),
|
argname = map_sql_identifier_to_xml_name(FigureColname(r->val),
|
||||||
true);
|
true, false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.26 2007/02/10 18:47:41 petere Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.27 2007/02/11 22:18:15 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1318,8 +1318,14 @@ is_valid_xml_namechar(pg_wchar c)
|
|||||||
* Map SQL identifier to XML name; see SQL/XML:2003 section 9.1.
|
* Map SQL identifier to XML name; see SQL/XML:2003 section 9.1.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
map_sql_identifier_to_xml_name(char *ident, bool fully_escaped)
|
map_sql_identifier_to_xml_name(char *ident, bool fully_escaped, bool escape_period)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* SQL/XML doesn't make use of this case anywhere, so it's
|
||||||
|
* probably a mistake.
|
||||||
|
*/
|
||||||
|
Assert(fully_escaped || !escape_period);
|
||||||
|
|
||||||
#ifdef USE_LIBXML
|
#ifdef USE_LIBXML
|
||||||
StringInfoData buf;
|
StringInfoData buf;
|
||||||
char *p;
|
char *p;
|
||||||
@ -1340,6 +1346,8 @@ map_sql_identifier_to_xml_name(char *ident, bool fully_escaped)
|
|||||||
else
|
else
|
||||||
appendStringInfo(&buf, "_x0058_");
|
appendStringInfo(&buf, "_x0058_");
|
||||||
}
|
}
|
||||||
|
else if (escape_period && *p == '.')
|
||||||
|
appendStringInfo(&buf, "_x002E_");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pg_wchar u = sqlchar_to_unicode(p);
|
pg_wchar u = sqlchar_to_unicode(p);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.14 2007/02/03 14:06:56 petere Exp $
|
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.15 2007/02/11 22:18:16 petere Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -53,7 +53,7 @@ extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
|
|||||||
extern bool xml_is_document(xmltype *arg);
|
extern bool xml_is_document(xmltype *arg);
|
||||||
extern text *xmltotext_with_xmloption(xmltype *data, XmlOptionType xmloption_arg);
|
extern text *xmltotext_with_xmloption(xmltype *data, XmlOptionType xmloption_arg);
|
||||||
|
|
||||||
extern char *map_sql_identifier_to_xml_name(char *ident, bool fully_escaped);
|
extern char *map_sql_identifier_to_xml_name(char *ident, bool fully_escaped, bool escape_period);
|
||||||
extern char *map_xml_name_to_sql_identifier(char *name);
|
extern char *map_xml_name_to_sql_identifier(char *name);
|
||||||
extern char *map_sql_value_to_xml_value(Datum value, Oid type);
|
extern char *map_sql_value_to_xml_value(Datum value, Oid type);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user