From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | bugfix: xpath encoding issue |
Date: | 2017-03-12 19:44:16 |
Message-ID: | CAFj8pRB-FZ1_dYE4rS8iXQDBz6f=pnLq6k+S8XPRLTnHhqWxBQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi
When I tested XMLTABLE function I found a bug of XPATH function -
xpath_internal
There xmltype is not correctly encoded to xmlChar due possible invalid
encoding info in header. It is possible when XML was loaded with recv
function and has not UTF8 encoding.
The functions based on xml_parse function works well.
The fix is simple
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index f81cf489d2..89aae48cb3 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -3874,9 +3874,11 @@ xpath_internal(text *xpath_expr_text, xmltype *data,
ArrayType *namespaces,
ns_count = 0;
}
- datastr = VARDATA(data);
- len = VARSIZE(data) - VARHDRSZ;
+ datastr = xml_out_internal(data, 0);
+ len = strlen(datastr);
+
xpath_len = VARSIZE(xpath_expr_text) - VARHDRSZ;
+
if (xpath_len == 0)
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
Regards
Pavel
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2017-03-12 19:52:30 | Re: [REVIEW] macaddr 64 bit (EUI-64) datatype support |
Previous Message | Stephen Frost | 2017-03-12 19:38:58 | Re: [REVIEW] macaddr 64 bit (EUI-64) datatype support |