diff options
author | unknown <bar@mysql.com> | 2006-03-09 11:53:56 +0400 |
---|---|---|
committer | unknown <bar@mysql.com> | 2006-03-09 11:53:56 +0400 |
commit | 41a863830aa7d7d0a4c0eae87ecb268a60c70149 (patch) | |
tree | d112af938f97483403d7e55fadd1bb01f3c65407 /sql/item_xmlfunc.cc | |
parent | a4920a66ff987867ee1d28abf0fc0a12f26a8059 (diff) | |
parent | a5694ba4cf36bbb4434d319665831fb25b1c995e (diff) | |
download | mariadb-git-41a863830aa7d7d0a4c0eae87ecb268a60c70149.tar.gz |
Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.1-new/
into mysql.com:/usr/home/bar/mysql-5.1-new.b16318
sql/item_xmlfunc.cc:
Auto merged
mysql-test/r/xml.result:
After merge fix
mysql-test/t/xml.test:
After merge fix
Diffstat (limited to 'sql/item_xmlfunc.cc')
-rw-r--r-- | sql/item_xmlfunc.cc | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 8ad7e2f9661..7378be0ac4c 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -30,7 +30,6 @@ 2. add nodeset_to_nodeset_comparator 3. add lacking functions: - name() - - last() - lang() - string() - id() @@ -75,6 +74,7 @@ typedef struct my_xpath_flt_st { uint num; /* absolute position in MY_XML_NODE array */ uint pos; /* relative position in context */ + uint size; /* context size */ } MY_XPATH_FLT; @@ -123,6 +123,15 @@ public: MY_XPATH_FLT add; add.num= num; add.pos= pos; + add.size= 0; + return append_element(&add); + } + inline bool append_element(uint32 num, uint32 pos, uint32 size) + { + MY_XPATH_FLT add; + add.num= num; + add.pos= pos; + add.size= size; return append_element(&add); } inline MY_XPATH_FLT *element(uint i) @@ -455,7 +464,11 @@ public: void fix_length_and_dec() { max_length=10; } longlong val_int() { + uint predicate_supplied_context_size; String *res= args[0]->val_nodeset(&tmp_value); + if (res->length() == sizeof(MY_XPATH_FLT) && + (predicate_supplied_context_size= ((MY_XPATH_FLT*)res->ptr())->size)) + return predicate_supplied_context_size; return res->length() / sizeof(MY_XPATH_FLT); } }; @@ -735,13 +748,15 @@ String *Item_nodeset_func_predicate::val_nodeset(String *str) { Item_nodeset_func *nodeset_func= (Item_nodeset_func*) args[0]; Item_func *comp_func= (Item_func*)args[1]; - uint pos= 0; + uint pos= 0, size; prepare(str); + size= fltend - fltbeg; for (MY_XPATH_FLT *flt= fltbeg; flt < fltend; flt++) { nodeset_func->context_cache.length(0); ((XPathFilter*)(&nodeset_func->context_cache))->append_element(flt->num, - flt->pos); + flt->pos, + size); if (comp_func->val_int()) ((XPathFilter*)str)->append_element(flt->num, pos++); } @@ -751,17 +766,19 @@ String *Item_nodeset_func_predicate::val_nodeset(String *str) String *Item_nodeset_func_elementbyindex::val_nodeset(String *nodeset) { + Item_nodeset_func *nodeset_func= (Item_nodeset_func*) args[0]; prepare(nodeset); - int index= args[1]->val_int() - 1; - if (index >= 0) + MY_XPATH_FLT *flt; + uint pos, size= fltend - fltbeg; + for (pos= 0, flt= fltbeg; flt < fltend; flt++) { - MY_XPATH_FLT *flt; - uint pos; - for (pos= 0, flt= fltbeg; flt < fltend; flt++) - { - if (flt->pos == (uint) index || args[1]->is_bool_func()) - ((XPathFilter*)nodeset)->append_element(flt->num, pos++); - } + nodeset_func->context_cache.length(0); + ((XPathFilter*)(&nodeset_func->context_cache))->append_element(flt->num, + flt->pos, + size); + int index= args[1]->val_int() - 1; + if (index >= 0 && (flt->pos == (uint) index || args[1]->is_bool_func())) + ((XPathFilter*)nodeset)->append_element(flt->num, pos++); } return nodeset; } |