Changeset: ccdbdfbabe50 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ccdbdfbabe50
Modified Files:
monetdb5/modules/atoms/batxml.c
monetdb5/modules/atoms/batxml.mal
monetdb5/modules/atoms/xml.c
sql/test/sql_xml/Tests/xml.stable.out
sql/test/sql_xml/Tests/xmlelement_segfault.SF-2812767.stable.out
Branch: Feb2013
Log Message:
reenabled the batxml code
diffs (233 lines):
diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c
--- a/monetdb5/modules/atoms/batxml.c
+++ b/monetdb5/modules/atoms/batxml.c
@@ -875,7 +875,7 @@ BATXMLelement(int *ret, str *name, xml *
goto bunins_failed;
}
}
- if (strNil(t)) {
+ if (strNil(t) && (!attr || strNil(*attr))) {
strcpy(buf, str_nil);
bn->T->nonil = 0;
} else {
diff --git a/monetdb5/modules/atoms/batxml.mal
b/monetdb5/modules/atoms/batxml.mal
--- a/monetdb5/modules/atoms/batxml.mal
+++ b/monetdb5/modules/atoms/batxml.mal
@@ -1,69 +1,71 @@
-command xml.xml(src:bat[:oid,:str]):bat[:oid,:xml]
+module batxml;
+
+command batxml.xml(src:bat[:oid,:str]):bat[:oid,:xml]
address BATXMLstr2xml
comment "Cast the string to an xml compliant string.";
-command xml.str(src:bat[:oid,:xml]):bat[:oid,:str]
+command batxml.str(src:bat[:oid,:xml]):bat[:oid,:str]
address BATXMLxml2str
comment "Cast the xml to a string.";
-command xml.document(src:bat[:oid,:str]):bat[:oid,:xml]
+command batxml.document(src:bat[:oid,:str]):bat[:oid,:xml]
address BATXMLdocument
comment "Parse the string as an XML document.";
-command xml.content(src:bat[:oid,:str]):bat[:oid,:xml]
+command batxml.content(src:bat[:oid,:str]):bat[:oid,:xml]
address BATXMLcontent
comment "Parse the string as XML element content.";
-command xml.comment(val:bat[:oid,:str]):bat[:oid,:xml]
+command batxml.comment(val:bat[:oid,:str]):bat[:oid,:xml]
address BATXMLcomment
comment "Create an XML comment element.";
-command xml.parse(doccont:str,val:bat[:oid,:str],option:str):bat[:oid,:xml]
+command batxml.parse(doccont:str,val:bat[:oid,:str],option:str):bat[:oid,:xml]
address BATXMLparse
comment "Parse the XML document or element string values.";
-command xml.serialize(val:bat[:oid,:xml]):bat[:oid,:str]
+command batxml.serialize(val:bat[:oid,:xml]):bat[:oid,:str]
address BATXMLxml2str
comment "Serialize the XML object to a string.";
-command xml.text(val:bat[:oid,:xml]):bat[:oid,:str]
+command batxml.text(val:bat[:oid,:xml]):bat[:oid,:str]
address BATXMLxmltext
comment "Serialize the XML object to a string.";
-command xml.xquery(val:bat[:oid,:str],expr:str):bat[:oid,:xml]
+command batxml.xquery(val:bat[:oid,:str],expr:str):bat[:oid,:xml]
address BATXMLxquery
comment "Execute the XQuery against the elements.";
# todo
-# command xml.table(val:bat[:oid,:str],expr:str):bat[:oid,:xml]
+# command batxml.table(val:bat[:oid,:str],expr:str):bat[:oid,:xml]
# address BATXMLquery
# comment "Execute the XQuery against the elements";
-command xml.pi(target:str, val:bat[:oid,:xml]):bat[:oid,:xml]
+command batxml.pi(target:str, val:bat[:oid,:xml]):bat[:oid,:xml]
address BATXMLpi
comment "Construct a processing instruction.";
-command xml.attribute(name:str, val:bat[:oid,:str]):bat[:oid,:xml]
+command batxml.attribute(name:str, val:bat[:oid,:str]):bat[:oid,:xml]
address BATXMLattribute
comment "Construct an attribute value pair.";
-command xml.element(name:str, s:bat[:oid,:xml]) :bat[:oid,:xml]
+command batxml.element(name:str, s:bat[:oid,:xml]) :bat[:oid,:xml]
address BATXMLelementSmall
comment "The basic building block for XML elements are namespaces, attributes
and a sequence of XML elements. The name space and the attributes may be left
unspecified.";
-command xml.options(tag:str, option:str,left:bat[:oid,:xml]):bat[:oid,:xml]
+command batxml.options(tag:str, option:str,left:bat[:oid,:xml]):bat[:oid,:xml]
address BATXMLoptions
comment "Create the components including NULL conversions.";
-command xml.element(name:str, ns:xml, attr:xml,
s:bat[:oid,:xml]):bat[:oid,:xml]
+command batxml.element(name:str, ns:xml, attr:xml,
s:bat[:oid,:xml]):bat[:oid,:xml]
address BATXMLelement
comment "The basic building block for XML elements are namespaces, attributes
and a sequence of XML elements. The name space and the attributes may be left
unspecified(=nil).";
-command xml.concat(left:bat[:oid,:xml],right:bat[:oid,:xml] ):bat[:oid,:xml]
+command batxml.concat(left:bat[:oid,:xml],right:bat[:oid,:xml] ):bat[:oid,:xml]
address BATXMLconcat
comment "Concatenate the XML values.";
-pattern xml.forest(val:bat[:oid,:xml]...):bat[:oid,:xml]
+pattern batxml.forest(val:bat[:oid,:xml]...):bat[:oid,:xml]
address BATXMLforest
comment "Construct an element list.";
@@ -79,11 +81,11 @@ command xml.agg(val:bat[:oid,:xml]):xml
address BATXMLgroup
comment "Aggregate the XML values over groups specified.";
-command xml.root(val:bat[:oid,:xml], version:str,
standalone:str):bat[:oid,:xml]
+command batxml.root(val:bat[:oid,:xml], version:str,
standalone:str):bat[:oid,:xml]
address BATXMLroot
comment "Contruct the root nodes.";
-command xml.isdocument(val:bat[:oid,:str]):bat[:oid,:bit]
+command batxml.isdocument(val:bat[:oid,:str]):bat[:oid,:bit]
address BATXMLisdocument
comment "Validate the string as a XML document.";
diff --git a/monetdb5/modules/atoms/xml.c b/monetdb5/modules/atoms/xml.c
--- a/monetdb5/modules/atoms/xml.c
+++ b/monetdb5/modules/atoms/xml.c
@@ -490,15 +490,19 @@ XMLelement(xml *ret, str *name, xml *nsp
len += strlen(*val + 1) + namelen + 2; /* extra "<", ">", and
name ("/" already counted) */
}
buf = GDKmalloc(len);
- i = snprintf(buf, len, "C<%s", *name);
- if (nspace && !strNil(*nspace))
- i += snprintf(buf + i, len - i, " %s", *nspace + 1);
- if (attr && !strNil(*attr))
- i += snprintf(buf + i, len - i, " %s", *attr + 1);
- if (!strNil(*val))
- i += snprintf(buf + i, len - i, ">%s</%s>", *val + 1, *name);
- else
- i += snprintf(buf + i, len - i, "/>");
+ if (strNil(*val) && (!attr || strNil(*attr))) {
+ strcpy(buf, str_nil);
+ } else {
+ i = snprintf(buf, len, "C<%s", *name);
+ if (nspace && !strNil(*nspace))
+ i += snprintf(buf + i, len - i, " %s", *nspace + 1);
+ if (attr && !strNil(*attr))
+ i += snprintf(buf + i, len - i, " %s", *attr + 1);
+ if (!strNil(*val))
+ i += snprintf(buf + i, len - i, ">%s</%s>", *val + 1,
*name);
+ else
+ i += snprintf(buf + i, len - i, "/>");
+ }
*ret = buf;
return MAL_SUCCEED;
}
diff --git a/sql/test/sql_xml/Tests/xml.stable.out
b/sql/test/sql_xml/Tests/xml.stable.out
--- a/sql/test/sql_xml/Tests/xml.stable.out
+++ b/sql/test/sql_xml/Tests/xml.stable.out
@@ -94,11 +94,11 @@ Ready.
% .L # table_name
% element_project # name
% xml # type
-% 125 # length
-[ <project
id="1"><custid>1</custid><custname>WoodWorks</custname><projid>1</projid><projname>Medusa</projname></project>
]
-[ <project id="2"><custid>4</custid><custname>Hardware
Shop</custname><projid>2</projid><projname>Pegasus</projname></project> ]
-[ <project id="8"><custid>4</custid><custname>Hardware
Shop</custname><projid>8</projid><projname>Typhon</projname></project> ]
-[ <project id="10"><custid>5</custid><custname>Books
Inc</custname><projid>10</projid><projname>Sphinx</projname></project> ]
+% 127 # length
+[ <project id =
"1"><custid>1</custid><custname>WoodWorks</custname><projid>1</projid><projname>Medusa</projname></project>
]
+[ <project id = "2"><custid>4</custid><custname>Hardware
Shop</custname><projid>2</projid><projname>Pegasus</projname></project> ]
+[ <project id = "8"><custid>4</custid><custname>Hardware
Shop</custname><projid>8</projid><projname>Typhon</projname></project> ]
+[ <project id = "10"><custid>5</custid><custname>Books
Inc</custname><projid>10</projid><projname>Sphinx</projname></project> ]
#select
# xmlelement(name "Customer",
# xmlattributes(c.CustId as "id"),
@@ -114,12 +114,12 @@ Ready.
% .L2 # table_name
% customer_projects # name
% xml # type
-% 190 # length
-[ <Customer
id="1"><name>WoodWorks</name><city>Baltimore</city><projects><project
id="1"><name>Medusa</name></project></projects></Customer> ]
-[ <Customer id="2"><name>Software
Solutions</name><city>Boston</city><projects/></Customer> ]
-[ <Customer id="3"><name>Food Supplies</name><city>New
York</city><projects/></Customer> ]
-[ <Customer id="4"><name>Hardware
Shop</name><city>Washington</city><projects><project
id="2"><name>Pegasus</name></project><project
id="8"><name>Typhon</name></project></projects></Customer> ]
-[ <Customer id="5"><name>Books Inc</name><city>New
Orleans</city><projects><project
id="10"><name>Sphinx</name></project></projects></Customer> ]
+% 196 # length
+[ <Customer id =
"1"><name>WoodWorks</name><city>Baltimore</city><projects><project id =
"1"><name>Medusa</name></project></projects></Customer> ]
+[ <Customer id = "2"><name>Software
Solutions</name><city>Boston</city></Customer> ]
+[ <Customer id = "3"><name>Food Supplies</name><city>New
York</city></Customer> ]
+[ <Customer id = "4"><name>Hardware
Shop</name><city>Washington</city><projects><project id =
"2"><name>Pegasus</name></project><project id =
"8"><name>Typhon</name></project></projects></Customer> ]
+[ <Customer id = "5"><name>Books Inc</name><city>New
Orleans</city><projects><project id =
"10"><name>Sphinx</name></project></projects></Customer> ]
#select
# xmlelement(name "Customer",
# xmlattributes(c.CustId as "id"),
@@ -128,14 +128,14 @@ Ready.
% .L # table_name
% element_Customer # name
% xml # type
-% 55 # length
-[ <Customer id="1"><!--simple comment test--></Customer> ]
-[ <Customer id="2"><!--simple comment test--></Customer> ]
-[ <Customer id="3"><!--simple comment test--></Customer> ]
-[ <Customer id="4"><!--simple comment test--></Customer> ]
-[ <Customer id="5"><!--simple comment test--></Customer> ]
+% 57 # length
+[ <Customer id = "1"><!--simple comment test--></Customer> ]
+[ <Customer id = "2"><!--simple comment test--></Customer> ]
+[ <Customer id = "3"><!--simple comment test--></Customer> ]
+[ <Customer id = "4"><!--simple comment test--></Customer> ]
+[ <Customer id = "5"><!--simple comment test--></Customer> ]
-# 16:53:32 >
-# 16:53:32 > Done.
-# 16:53:32 >
+# 23:08:33 >
+# 23:08:33 > "Done."
+# 23:08:33 >
diff --git a/sql/test/sql_xml/Tests/xmlelement_segfault.SF-2812767.stable.out
b/sql/test/sql_xml/Tests/xmlelement_segfault.SF-2812767.stable.out
--- a/sql/test/sql_xml/Tests/xmlelement_segfault.SF-2812767.stable.out
+++ b/sql/test/sql_xml/Tests/xmlelement_segfault.SF-2812767.stable.out
@@ -36,10 +36,11 @@ Ready.
% .L1 # table_name
% element_a # name
% xml # type
-% 5 # length
-[ <a/> ]
+% 0 # length
+[ NULL ]
+#rollback;
-# 17:59:18 >
-# 17:59:18 > Done.
-# 17:59:18 >
+# 23:08:34 >
+# 23:08:34 > "Done."
+# 23:08:34 >
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list