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

Commit592a163

Browse files
committed
Avoid failure when selecting a namespace node in XMLTABLE.
It appears that libxml2 doesn't bother to set the "children" field ofan XML_NAMESPACE_DECL node to null; that field just contains garbage.In v10 and v11, this can result in a crash in XMLTABLE(). The rewritedone in commit251cf2e fixed this, somewhat accidentally, in v12.We're not going to back-patch251cf2e, however. The case apparentlydoesn't have wide use, so rather than risk introducing other problems,just add a safety check to throw an error.Even though no bug manifests in v12/HEAD, add the relevant test casethere too, to prevent future regressions.Chapman Flack (per private report)
1 parentcbe63d0 commit592a163

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

‎src/test/regress/expected/xml.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,14 @@ SELECT * FROM XMLTABLE(XMLNAMESPACES(DEFAULT 'http://x.y'),
11701170
PASSING '<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
11711171
COLUMNS a int PATH 'a');
11721172
ERROR: DEFAULT namespace is not supported
1173+
SELECT * FROM XMLTABLE('.'
1174+
PASSING '<foo/>'
1175+
COLUMNS a text PATH 'foo/namespace::node()');
1176+
a
1177+
--------------------------------------
1178+
http://www.w3.org/XML/1998/namespace
1179+
(1 row)
1180+
11731181
-- used in prepare statements
11741182
PREPARE pp AS
11751183
SELECT xmltable.*

‎src/test/regress/expected/xml_1.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,14 @@ LINE 3: PASSING '<rows xmlns="http://x.y"><row...
10481048
^
10491049
DETAIL: This functionality requires the server to be built with libxml support.
10501050
HINT: You need to rebuild PostgreSQL using --with-libxml.
1051+
SELECT * FROM XMLTABLE('.'
1052+
PASSING '<foo/>'
1053+
COLUMNS a text PATH 'foo/namespace::node()');
1054+
ERROR: unsupported XML feature
1055+
LINE 2: PASSING '<foo/>'
1056+
^
1057+
DETAIL: This functionality requires the server to be built with libxml support.
1058+
HINT: You need to rebuild PostgreSQL using --with-libxml.
10511059
-- used in prepare statements
10521060
PREPARE pp AS
10531061
SELECT xmltable.*

‎src/test/regress/expected/xml_2.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,14 @@ SELECT * FROM XMLTABLE(XMLNAMESPACES(DEFAULT 'http://x.y'),
11501150
PASSING '<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
11511151
COLUMNS a int PATH 'a');
11521152
ERROR: DEFAULT namespace is not supported
1153+
SELECT * FROM XMLTABLE('.'
1154+
PASSING '<foo/>'
1155+
COLUMNS a text PATH 'foo/namespace::node()');
1156+
a
1157+
--------------------------------------
1158+
http://www.w3.org/XML/1998/namespace
1159+
(1 row)
1160+
11531161
-- used in prepare statements
11541162
PREPARE pp AS
11551163
SELECT xmltable.*

‎src/test/regress/sql/xml.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ SELECT * FROM XMLTABLE(XMLNAMESPACES(DEFAULT 'http://x.y'),
402402
PASSING'<rows xmlns="http://x.y"><row><a>10</a></row></rows>'
403403
COLUMNS aintPATH'a');
404404

405+
SELECT*FROM XMLTABLE('.'
406+
PASSING'<foo/>'
407+
COLUMNS atextPATH'foo/namespace::node()');
408+
405409
-- used in prepare statements
406410
PREPARE ppAS
407411
SELECT xmltable.*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp