Changeset: 395c48fd33fe for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=395c48fd33fe
Added Files:
sql/test/BugTracker-2013/Tests/avg_needs_abort_on_error.Bug-3329.sql
sql/test/BugTracker-2013/Tests/avg_needs_abort_on_error.Bug-3329.stable.err
sql/test/BugTracker-2013/Tests/avg_needs_abort_on_error.Bug-3329.stable.out
sql/test/BugTracker-2013/Tests/mitosis-floor.Bug-3330.sql
sql/test/BugTracker-2013/Tests/mitosis-floor.Bug-3330.stable.err
sql/test/BugTracker-2013/Tests/mitosis-floor.Bug-3330.stable.out
sql/test/BugTracker-2013/Tests/unique_constraint_on_declared_table.Bug-3319.sql
sql/test/BugTracker-2013/Tests/unique_constraint_on_declared_table.Bug-3319.stable.err
sql/test/BugTracker-2013/Tests/unique_constraint_on_declared_table.Bug-3319.stable.out
sql/test/BugTracker-2013/Tests/update_on_declared_table.Bug-3318.sql
sql/test/BugTracker-2013/Tests/update_on_declared_table.Bug-3318.stable.err
sql/test/BugTracker-2013/Tests/update_on_declared_table.Bug-3318.stable.out
Modified Files:
monetdb5/modules/atoms/batxml.c
monetdb5/modules/atoms/batxml.mal
monetdb5/modules/atoms/xml.c
monetdb5/optimizer/opt_mergetable.c
monetdb5/optimizer/opt_prelude.c
monetdb5/optimizer/opt_prelude.h
monetdb5/optimizer/opt_support.c
sql/backends/monet5/sql.mx
sql/backends/monet5/sql_gencode.c
sql/server/rel_schema.c
sql/server/rel_updates.c
sql/test/BugTracker-2011/Tests/func_iter_vs_bulk.Bug-2826.stable.out
sql/test/BugTracker-2013/Tests/All
sql/test/sql_xml/Tests/xml.stable.out
sql/test/sql_xml/Tests/xmlelement_segfault.SF-2812767.stable.out
tools/merovingian/ChangeLog.Feb2013
tools/merovingian/client/monetdb.c
Branch: SciQL-2
Log Message:
Merge with Feb2013 branch.
diffs (truncated from 1164 to 300 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/monetdb5/optimizer/opt_mergetable.c
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -22,8 +22,8 @@
typedef enum mat_type_t {
mat_none = 0, /* Simple mat aligned operations (ie batcalc etc) */
mat_grp = 1, /* result of phase one of a mat - group.new/derive */
- mat_ext = 2, /* after mat_grp the extend gets a mat.mirror */
- mat_cnt = 3, /* after mat_grp the extend gets a mat.mirror */
+ mat_ext = 2, /* mat_grp extend */
+ mat_cnt = 3, /* mat_grp count */
mat_tpn = 4, /* Phase one of topn on a mat */
mat_slc = 5, /* Last phase of topn (or just slice) on a mat */
mat_rdr = 6 /* Phase one of sorting, ie sorted the parts sofar */
@@ -258,7 +258,9 @@ static InstrPtr
mat_apply1(MalBlkPtr mb, InstrPtr p, mat_t *mat, int m, int var)
{
int tpe, k, is_select = isSubSelect(p), is_mirror = (getFunctionId(p)
== mirrorRef);
- InstrPtr r = NULL;
+ int is_identity = (getFunctionId(p) == identityRef && getModuleId(p) ==
batcalcRef);
+ int ident_var = 0;
+ InstrPtr r = NULL, q;
//printf("# %s.%s(%d)", getModuleId(p), getFunctionId(p), m);
@@ -268,13 +270,35 @@ mat_apply1(MalBlkPtr mb, InstrPtr p, mat
getArg(r, 0) = getArg(p,0);
tpe = getArgType(mb,p,0);
+ if (is_identity) {
+ q = newInstruction(mb, ASSIGNsymbol);
+ getArg(q, 0) = newTmpVariable(mb, TYPE_oid);
+ q->retc = 1;
+ q->argc = 1;
+ q = pushOid(mb, q, 0);
+ ident_var = getArg(q, 0);
+ pushInstruction(mb, q);
+ }
for(k=1; k < mat[m].mi->argc; k++) {
- InstrPtr q = copyInstruction(p);
+ q = copyInstruction(p);
getArg(q, 0) = newTmpVariable(mb, tpe);
- getArg(q, var) = getArg(mat[m].mi, k);
+ if (is_identity)
+ getArg(q, 1) = newTmpVariable(mb, TYPE_oid);
+ getArg(q, var+is_identity) = getArg(mat[m].mi, k);
+ if (is_identity) {
+ getArg(q, 3) = ident_var;
+ q->retc = 2;
+ q->argc = 4;
+ /* make sure to resolve again */
+ q->token = ASSIGNsymbol;
+ q->typechk = TYPE_UNKNOWN;
+ q->fcn = NULL;
+ q->blk = NULL;
+ }
+ ident_var = getArg(q, 1);
pushInstruction(mb, q);
- if (is_mirror) {
+ if (is_mirror || is_identity) {
propagateMirror(mb, getArg(mat[m].mi, k), getArg(q,0));
} else if (is_select)
propagatePartnr(mb, getArg(mat[m].mi, k), getArg(q,0),
k);
@@ -670,6 +694,44 @@ group_by_ext(mat_t *mat, int mtop, int g
return 0;
}
+/* In some cases we have non groupby attribute columns, these require
+ * gext.leftfetchjoin(mat.pack(per partition ext.leftfetchjoins(x)))
+ */
+
+static int
+mat_group_project(MalBlkPtr mb, InstrPtr p, mat_t *mat, int mtop, int e, int a)
+{
+ int tp = getArgType(mb,p,0), k;
+ int tail = getTailType(tp);
+ InstrPtr ai1 = newInstruction(mb, ASSIGNsymbol), r;
+
+ setModuleId(ai1,matRef);
+ setFunctionId(ai1,packRef);
+ getArg(ai1,0) = newTmpVariable(mb, tp);
+
+ assert(mat[e].mi->argc == mat[a].mi->argc);
+ for(k=1; k<mat[a].mi->argc; k++) {
+ InstrPtr q = copyInstruction(p);
+
+ getArg(q,0) = newTmpVariable(mb, tp);
+ getArg(q,1) = getArg(mat[e].mi,k);
+ getArg(q,2) = getArg(mat[a].mi,k);
+ pushInstruction(mb,q);
+
+ /* pack the result into a mat */
+ ai1 = pushArgument(mb,ai1,getArg(q,0));
+ }
+ pushInstruction(mb, ai1);
+
+ r = copyInstruction(p);
+ getArg(r,1) = mat[e].mv;
+ getArg(r,2) = getArg(ai1,0);
+ pushInstruction(mb,r);
+ if (tail == TYPE_oid)
+ mtop = mat_add_var(mat, mtop, ai1, r, getArg(r, 0), mat_ext,
-1, -1);
+ return mtop;
+}
+
static void
mat_group_aggr(MalBlkPtr mb, InstrPtr p, mat_t *mat, int b, int g, int e)
{
@@ -1272,7 +1334,11 @@ OPTmergetableImplementation(Client cntxt
(m=is_a_mat(getArg(p,1), mat, mtop)) >= 0 &&
(n=is_a_mat(getArg(p,2), mat, mtop)) >= 0 &&
(mat[m].type == mat_ext || mat[n].type == mat_grp)) {
- pushInstruction(mb, copyInstruction(p));
+ assert(mat[m].pushed);
+ if (!mat[n].pushed)
+ mtop = mat_group_project(mb, p, mat, mtop, m,
n);
+ else
+ pushInstruction(mb, copyInstruction(p));
continue;
}
diff --git a/monetdb5/optimizer/opt_prelude.c b/monetdb5/optimizer/opt_prelude.c
--- a/monetdb5/optimizer/opt_prelude.c
+++ b/monetdb5/optimizer/opt_prelude.c
@@ -43,6 +43,7 @@ str boxRef;
str batstrRef;
str batmtimeRef;
str batmmathRef;
+str batxmlRef;
str bbpRef;
str tidRef;
str deltaRef;
@@ -303,6 +304,7 @@ void optimizerInit(void){
batstrRef = putName("batstr",6);
batmtimeRef = putName("batmtime",8);
batmmathRef = putName("batmmath",8);
+ batxmlRef = putName("batxml",6);
bbpRef = putName("bbp",3);
tidRef = putName("tid",3);
deltaRef = putName("delta",5);
diff --git a/monetdb5/optimizer/opt_prelude.h b/monetdb5/optimizer/opt_prelude.h
--- a/monetdb5/optimizer/opt_prelude.h
+++ b/monetdb5/optimizer/opt_prelude.h
@@ -42,6 +42,7 @@ opt_export str boxRef;
opt_export str batstrRef;
opt_export str batmtimeRef;
opt_export str batmmathRef;
+opt_export str batxmlRef;
opt_export str bbpRef;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list