Skip to content

Commit 1246d79

Browse files
committed
Rename xml_valid() to xml_is_well_formed(), but provide a temporary
alias with the old name for backwards compatibility. Per discussion, the old name is actively wrong because validity and well-formedness have different meanings in XML.
1 parent 801cbe3 commit 1246d79

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

contrib/xml2/README.xml2

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,24 @@ you can place it in a different directory in a PostgreSQL tree).
2121
Before you begin, just check the Makefile, and then just 'make' and
2222
'make install'.
2323

24-
This code requires libxml to be previously installed.
24+
By default, this module requires both libxml2 and libxslt to be installed
25+
on your system. If you do not have libxslt or do not want to use XSLT
26+
functions, you must edit the Makefile to not build the XSLT functions,
27+
as directed in its comments; and edit pgxml.sql.in to remove the XSLT
28+
function declarations, as directed in its comments.
2529

2630
Description of functions
2731
------------------------
2832

2933
The first set of functions are straightforward XML parsing and XPath queries:
3034

31-
xml_valid(document) RETURNS bool
35+
xml_is_well_formed(document) RETURNS bool
3236

3337
This parses the document text in its parameter and returns true if the
34-
document is well-formed XML.
38+
document is well-formed XML. (Note: before PostgreSQL 8.2, this function
39+
was called xml_valid(). That is the wrong name since validity and
40+
well-formedness have different meanings in XML. The old name is still
41+
available, but is deprecated and will be removed in 8.3.)
3542

3643
xpath_string(document,query) RETURNS text
3744
xpath_number(document,query) RETURNS float4

contrib/xml2/pgxml.sql.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
--SQL for XML parser
22

3-
CREATE OR REPLACE FUNCTION xml_valid(text) RETURNS bool
3+
CREATE OR REPLACE FUNCTION xml_is_well_formed(text) RETURNS bool
44
AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE;
55

6+
-- deprecated old name for xml_is_well_formed
7+
CREATE OR REPLACE FUNCTION xml_valid(text) RETURNS bool
8+
AS 'MODULE_PATHNAME', 'xml_is_well_formed' LANGUAGE C STRICT IMMUTABLE;
9+
610
CREATE OR REPLACE FUNCTION xml_encode_special_chars(text) RETURNS text
711
AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE;
812

contrib/xml2/uninstall_pgxml.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ DROP FUNCTION xpath_string(text,text);
2424

2525
DROP FUNCTION xml_encode_special_chars(text);
2626

27+
-- deprecated old name for xml_is_well_formed
2728
DROP FUNCTION xml_valid(text);
29+
30+
DROP FUNCTION xml_is_well_formed(text);

contrib/xml2/xpath.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ xmlChar *pgxml_texttoxmlchar(text *textstring);
4242
static xmlXPathObjectPtr pgxml_xpath(text *document, xmlChar * xpath);
4343

4444

45-
Datum xml_valid(PG_FUNCTION_ARGS);
45+
Datum xml_is_well_formed(PG_FUNCTION_ARGS);
4646
Datum xml_encode_special_chars(PG_FUNCTION_ARGS);
4747
Datum xpath_nodeset(PG_FUNCTION_ARGS);
4848
Datum xpath_string(PG_FUNCTION_ARGS);
@@ -166,12 +166,12 @@ pgxml_parser_init()
166166

167167
/* Returns true if document is well-formed */
168168

169-
PG_FUNCTION_INFO_V1(xml_valid);
169+
PG_FUNCTION_INFO_V1(xml_is_well_formed);
170170

171171
Datum
172-
xml_valid(PG_FUNCTION_ARGS)
172+
xml_is_well_formed(PG_FUNCTION_ARGS)
173173
{
174-
/* called as xml_valid(document) */
174+
/* called as xml_is_well_formed(document) */
175175
xmlDocPtr doctree;
176176
text *t = PG_GETARG_TEXT_P(0); /* document buffer */
177177
int32 docsize = VARSIZE(t) - VARHDRSZ;

doc/src/sgml/datatype.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.174 2006/09/16 00:30:12 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.175 2006/09/16 16:18:11 tgl Exp $ -->
22

33
<chapter id="datatype">
44
<title id="datatype-title">Data Types</title>
@@ -3345,8 +3345,8 @@ SELECT * FROM pg_attribute
33453345

33463346
<para>
33473347
<filename>/contrib/xml2</> has a function called
3348-
<function>xml_valid()</> that can be used in a <literal>CHECK</>
3349-
constraint to enforce that a field contains valid <acronym>XML</>.
3348+
<function>xml_is_well_formed()</> that can be used in a <literal>CHECK</>
3349+
constraint to enforce that a field contains well-formed <acronym>XML</>.
33503350
It does not support validation against a specific <acronym>XML</>
33513351
schema. A server-side language with <acronym>XML</> capabilities
33523352
could be used to do schema-specific <acronym>XML</> checks.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy