Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb19144

Browse files
committed
Add support for optionally escaping periods when converting SQL identifiers
to XML names, which will be required for supporting XML export.
1 parent733abd2 commiteb19144

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

‎src/backend/parser/parse_expr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.210 2007/02/03 14:06:54 petere Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.211 2007/02/11 22:18:15 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1389,7 +1389,7 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
13891389

13901390
newx->op=x->op;
13911391
if (x->name)
1392-
newx->name=map_sql_identifier_to_xml_name(x->name, false);
1392+
newx->name=map_sql_identifier_to_xml_name(x->name, false, false);
13931393
else
13941394
newx->name=NULL;
13951395

@@ -1411,10 +1411,10 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
14111411
expr=transformExpr(pstate,r->val);
14121412

14131413
if (r->name)
1414-
argname=map_sql_identifier_to_xml_name(r->name, false);
1414+
argname=map_sql_identifier_to_xml_name(r->name, false, false);
14151415
elseif (IsA(r->val,ColumnRef))
14161416
argname=map_sql_identifier_to_xml_name(FigureColname(r->val),
1417-
true);
1417+
true, false);
14181418
else
14191419
{
14201420
ereport(ERROR,

‎src/backend/utils/adt/xml.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.26 2007/02/1018:47:41 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.27 2007/02/11 22:18:15 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1318,8 +1318,14 @@ is_valid_xml_namechar(pg_wchar c)
13181318
* Map SQL identifier to XML name; see SQL/XML:2003 section 9.1.
13191319
*/
13201320
char*
1321-
map_sql_identifier_to_xml_name(char*ident,boolfully_escaped)
1321+
map_sql_identifier_to_xml_name(char*ident,boolfully_escaped,boolescape_period)
13221322
{
1323+
/*
1324+
* SQL/XML doesn't make use of this case anywhere, so it's
1325+
* probably a mistake.
1326+
*/
1327+
Assert(fully_escaped|| !escape_period);
1328+
13231329
#ifdefUSE_LIBXML
13241330
StringInfoDatabuf;
13251331
char*p;
@@ -1340,6 +1346,8 @@ map_sql_identifier_to_xml_name(char *ident, bool fully_escaped)
13401346
else
13411347
appendStringInfo(&buf,"_x0058_");
13421348
}
1349+
elseif (escape_period&&*p=='.')
1350+
appendStringInfo(&buf,"_x002E_");
13431351
else
13441352
{
13451353
pg_wcharu=sqlchar_to_unicode(p);

‎src/include/utils/xml.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.14 2007/02/03 14:06:56 petere Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.15 2007/02/11 22:18:16 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -53,7 +53,7 @@ extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
5353
externboolxml_is_document(xmltype*arg);
5454
externtext*xmltotext_with_xmloption(xmltype*data,XmlOptionTypexmloption_arg);
5555

56-
externchar*map_sql_identifier_to_xml_name(char*ident,boolfully_escaped);
56+
externchar*map_sql_identifier_to_xml_name(char*ident,boolfully_escaped,boolescape_period);
5757
externchar*map_xml_name_to_sql_identifier(char*name);
5858
externchar*map_sql_value_to_xml_value(Datumvalue,Oidtype);
5959

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp