#include <item_xmlfunc.h>
Inheritance diagram for Item_xml_str_func:


Public Member Functions | |
| Item_xml_str_func (Item *a, Item *b) | |
| Item_xml_str_func (Item *a, Item *b, Item *c) | |
| void | fix_length_and_dec () |
| String * | parse_xml (String *raw_xml, String *parsed_xml_buf) |
Protected Attributes | |
| String | tmp_value |
| String | pxml |
| Item * | nodeset_func |
Definition at line 26 of file item_xmlfunc.h.
| void Item_xml_str_func::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 2392 of file item_xmlfunc.cc.
References Item_func::agg_arg_charsets(), Item_func::arg_count, Item_func::args, my_xpath_lex_st::beg, DTCollation::collation, Item::collation, Item_func::const_item(), my_xpath_st::cs, charset_info_st::csname, current_thd, my_xpath_st::debug, my_xpath_lex_st::end, ER_UNKNOWN_ERROR, Item::fix_fields(), my_xpath_st::item, my_xpath_st::lasttok, String::length(), MAX_BLOB_WIDTH, Item::max_length, charset_info_st::mbminlen, MY_COLL_CMP_CONV, my_printf_error(), my_xpath_init(), my_xpath_parse(), MYF, nodeset_func, String::ptr(), pxml, my_xpath_st::pxml, my_xpath_st::query, String::set_charset(), set_if_bigger, strmake(), and Item::val_str().
02393 { 02394 String *xp, tmp; 02395 MY_XPATH xpath; 02396 int rc; 02397 02398 nodeset_func= 0; 02399 02400 if (agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1)) 02401 return; 02402 02403 if (collation.collation->mbminlen > 1) 02404 { 02405 /* UCS2 is not supported */ 02406 my_printf_error(ER_UNKNOWN_ERROR, 02407 "Character set '%s' is not supported by XPATH", 02408 MYF(0), collation.collation->csname); 02409 return; 02410 } 02411 02412 if (!args[1]->const_item()) 02413 { 02414 my_printf_error(ER_UNKNOWN_ERROR, 02415 "Only constant XPATH queries are supported", MYF(0)); 02416 return; 02417 } 02418 02419 xp= args[1]->val_str(&tmp); 02420 my_xpath_init(&xpath); 02421 xpath.cs= collation.collation; 02422 xpath.debug= 0; 02423 xpath.pxml= &pxml; 02424 pxml.set_charset(collation.collation); 02425 02426 rc= my_xpath_parse(&xpath, xp->ptr(), xp->ptr() + xp->length()); 02427 02428 if (!rc) 02429 { 02430 char context[32]; 02431 uint clen= xpath.query.end - xpath.lasttok.beg; 02432 set_if_bigger(clen, sizeof(context) - 1); 02433 strmake(context, xpath.lasttok.beg, clen); 02434 my_printf_error(ER_UNKNOWN_ERROR, "XPATH syntax error: '%s'", 02435 MYF(0), context); 02436 return; 02437 } 02438 02439 nodeset_func= xpath.item; 02440 if (nodeset_func) 02441 nodeset_func->fix_fields(current_thd, &nodeset_func); 02442 max_length= MAX_BLOB_WIDTH; 02443 }
Here is the call graph for this function:

Definition at line 2582 of file item_xmlfunc.cc.
References buf, current_thd, ER, ER_WRONG_VALUE, String::length(), MY_XML_USER_DATA::level, my_snprintf(), my_xml_error_lineno(), my_xml_error_pos(), my_xml_error_string(), MY_XML_FLAG_RELATIVE_NAMES, MY_XML_FLAG_SKIP_TEXT_NORMALIZATION, MY_XML_NODE_TAG, MY_XML_OK, my_xml_parse(), my_xml_parser_create(), my_xml_parser_free(), my_xml_set_enter_handler(), my_xml_set_leave_handler(), my_xml_set_user_data(), my_xml_set_value_handler(), p, String::ptr(), push_warning_printf(), MY_XML_USER_DATA::pxml, MYSQL_ERROR::WARN_LEVEL_WARN, xml_enter(), xml_leave(), and xml_value().
Referenced by Item_func_xml_update::val_str(), and Item_func_xml_extractvalue::val_str().
02583 { 02584 MY_XML_PARSER p; 02585 MY_XML_USER_DATA user_data; 02586 int rc; 02587 02588 parsed_xml_buf->length(0); 02589 02590 /* Prepare XML parser */ 02591 my_xml_parser_create(&p); 02592 p.flags= MY_XML_FLAG_RELATIVE_NAMES | MY_XML_FLAG_SKIP_TEXT_NORMALIZATION; 02593 user_data.level= 0; 02594 user_data.pxml= parsed_xml_buf; 02595 my_xml_set_enter_handler(&p, xml_enter); 02596 my_xml_set_value_handler(&p, xml_value); 02597 my_xml_set_leave_handler(&p, xml_leave); 02598 my_xml_set_user_data(&p, (void*) &user_data); 02599 02600 /* Add root node */ 02601 p.current_node_type= MY_XML_NODE_TAG; 02602 xml_enter(&p, raw_xml->ptr(), 0); 02603 02604 /* Execute XML parser */ 02605 if ((rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length())) != MY_XML_OK) 02606 { 02607 char buf[128]; 02608 my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %d: %s", 02609 my_xml_error_lineno(&p) + 1, 02610 my_xml_error_pos(&p) + 1, 02611 my_xml_error_string(&p)); 02612 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, 02613 ER_WRONG_VALUE, 02614 ER(ER_WRONG_VALUE), "XML", buf); 02615 } 02616 my_xml_parser_free(&p); 02617 02618 return rc == MY_XML_OK ? parsed_xml_buf : 0; 02619 }
Here is the call graph for this function:

Here is the caller graph for this function:

Item* Item_xml_str_func::nodeset_func [protected] |
Definition at line 30 of file item_xmlfunc.h.
Referenced by fix_length_and_dec(), Item_func_xml_update::val_str(), and Item_func_xml_extractvalue::val_str().
String Item_xml_str_func::pxml [protected] |
Definition at line 29 of file item_xmlfunc.h.
Referenced by fix_length_and_dec(), Item_func_xml_update::val_str(), and Item_func_xml_extractvalue::val_str().
String Item_xml_str_func::tmp_value [protected] |
Definition at line 29 of file item_xmlfunc.h.
Referenced by Item_func_xml_update::val_str(), and Item_func_xml_extractvalue::val_str().
1.4.7

