summaryrefslogtreecommitdiff
path: root/sql/item_xmlfunc.cc
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-23479: Add a THD* argument to Item_func_or_sum::fix_length_and_dec()Rucha Deodhar2022-03-301-5/+5
| | | | | Fix: Added THD *thd argument in Item_func_or_sum::fix_length_and_dec() and in fix_length_and_dec() for all derived classes of Item_func_or_sum.
* Change Item_true and Item_false to pointersMonty2021-07-181-2/+2
| | | | This is a prerequisite for moving them to a readonly segment.
* Change CHARSET_INFO character set and collaction names to LEX_CSTRINGMonty2021-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | This change removed 68 explict strlen() calls from the code. The following renames was done to ensure we don't use the old names when merging code from earlier releases, as using the new variables for print function could result in crashes: - charset->csname renamed to charset->cs_name - charset->name renamed to charset->coll_name Almost everything where mechanical changes except: - Changed to use the new Protocol::store(LEX_CSTRING..) when possible - Changed to use field->store(LEX_CSTRING*, CHARSET_INFO*) when possible - Changed to use String->append(LEX_CSTRING&) when possible Other things: - There where compiler issues with ensuring that all character set names points to the same string: gcc doesn't allow one to use integer constants when defining global structures (constant char * pointers works fine). To get around this, I declared defines for each character set name length.
* Added override to all releveant methods in Item (and a few other classes)Monty2021-05-191-46/+47
| | | | | | Other things: - Remove inline and virtual for methods that are overrides - Added a 'final' to some Item classes
* Reduce usage of strlen()Monty2021-05-191-18/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes: - To detect automatic strlen() I removed the methods in String that uses 'const char *' without a length: - String::append(const char*) - Binary_string(const char *str) - String(const char *str, CHARSET_INFO *cs) - append_for_single_quote(const char *) All usage of append(const char*) is changed to either use String::append(char), String::append(const char*, size_t length) or String::append(LEX_CSTRING) - Added STRING_WITH_LEN() around constant string arguments to String::append() - Added overflow argument to escape_string_for_mysql() and escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow. This was needed as most usage of the above functions never tested the result for -1 and would have given wrong results or crashes in case of overflows. - Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING. Changed all Item_func::func_name()'s to func_name_cstring()'s. The old Item_func_or_sum::func_name() is now an inline function that returns func_name_cstring().str. - Changed Item::mode_name() and Item::func_name_ext() to return LEX_CSTRING. - Changed for some functions the name argument from const char * to to const LEX_CSTRING &: - Item::Item_func_fix_attributes() - Item::check_type_...() - Type_std_attributes::agg_item_collations() - Type_std_attributes::agg_item_set_converter() - Type_std_attributes::agg_arg_charsets...() - Type_handler_hybrid_field_type::aggregate_for_result() - Type_handler_geometry::check_type_geom_or_binary() - Type_handler::Item_func_or_sum_illegal_param() - Predicant_to_list_comparator::add_value_skip_null() - Predicant_to_list_comparator::add_value() - cmp_item_row::prepare_comparators() - cmp_item_row::aggregate_row_elements_for_comparison() - Cursor_ref::print_func() - Removes String_space() as it was only used in one cases and that could be simplified to not use String_space(), thanks to the fixed my_vsnprintf(). - Added some const LEX_CSTRING's for common strings: - NULL_clex_str, DATA_clex_str, INDEX_clex_str. - Changed primary_key_name to a LEX_CSTRING - Renamed String::set_quick() to String::set_buffer_if_not_allocated() to clarify what the function really does. - Rename of protocol function: bool store(const char *from, CHARSET_INFO *cs) to bool store_string_or_null(const char *from, CHARSET_INFO *cs). This was done to both clarify the difference between this 'store' function and also to make it easier to find unoptimal usage of store() calls. - Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*) - Changed some 'const char*' arrays to instead be of type LEX_CSTRING. - class Item_func_units now used LEX_CSTRING for name. Other things: - Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character in the prompt would cause some part of the prompt to be duplicated. - Fixed a lot of instances where the length of the argument to append is known or easily obtain but was not used. - Removed some not needed 'virtual' definition for functions that was inherited from the parent. I added override to these. - Fixed Ordered_key::print() to preallocate needed buffer. Old code could case memory overruns. - Simplified some loops when adding char * to a String with delimiters.
* MDEV-23001 Precreate static Item_bool() to simplify codeMonty2021-05-191-2/+2
| | | | | | | | | | | | | | The following changes where done: - Create global Item: Item_false and Item_true - Replace all creation if 'FALSE' and 'TRUE' top level items used for WHERE/HAVING/ON clauses to use Item_false and Item_true. The benefit are: - Less and faster code - No test needed if we where able to create the new item. - Fixed possible errors if 'new' would have failed for the Item_bool's fixup! 470277728d2e27fe057cf33a437a9e40e1a04b61
* Merge branch '10.4' into 10.5Oleksandr Byelkin2020-08-041-10/+10
|\
| * Merge branch '10.3' into 10.4Oleksandr Byelkin2020-08-031-10/+10
| |\
| | * Merge branch '10.2' into 10.3Oleksandr Byelkin2020-08-031-10/+10
| | |\
| | | * Merge branch '10.1' into 10.2Oleksandr Byelkin2020-08-021-10/+10
| | | |\
| | | | * Code comment spellfixesIan Gilfillan2020-07-221-10/+10
| | | | |
* | | | | Merge 10.4 into 10.5Marko Mäkelä2020-06-031-2/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2020-06-031-2/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.2 into 10.3Marko Mäkelä2020-06-021-2/+1
| | |\ \ \ | | | |/ /
| | | * | Merge 10.1 into 10.2Marko Mäkelä2020-06-011-2/+1
| | | |\ \ | | | | |/
| | | | * MDEV-22744 *SAN: sql/item_xmlfunc.cc:791:43: runtime error: downcast of ↵Alexander Barkov2020-05-291-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | address ... which does not point to an object of type 'Item_func' note: object is of type 'Item_bool' (on optimized builds) In Item_nodeset_func_predicate::val_nodeset, args[1] is not necessarily an Item_func descendant. It can be Item_bool. Removing a wrong cast. It was not really needed anyway.
* | | | | Merge 10.4 into 10.5Marko Mäkelä2020-05-311-11/+23
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2020-05-261-11/+23
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.2 into 10.3Marko Mäkelä2020-05-251-11/+23
| | |\ \ \ | | | |/ /
| | | * | MDEV-22545: my_vsnprintf behaves not as in C standardOleksandr Byelkin2020-05-241-11/+23
| | | | | | | | | | | | | | | | | | | | Added parameter %T for string which should be visibly truncated.
* | | | | MDEV-21581 Helper functions and methods for CHARSET_INFOAlexander Barkov2020-01-281-9/+9
| | | | |
* | | | | MDEV-20674 Reuse val_native() in ExtractValue() and UpdateXML()Alexander Barkov2019-09-261-148/+102
| | | | |
* | | | | Merge remote-tracking branch 'origin/10.4' into 10.5Alexander Barkov2019-08-131-2/+2
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-07-281-2/+2
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.2' into 10.3Oleksandr Byelkin2019-07-261-2/+2
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.1' into 10.2Oleksandr Byelkin2019-07-261-2/+2
| | | |\ \ | | | | |/
| | | | * Merge branch '5.5' into 10.1Oleksandr Byelkin2019-07-251-2/+2
| | | | |\
| | | | | * Bug #27312862: ASAN: HEAP-USE-AFTER-FREE: UPDATEXML RB#21666 RB#21666Georgi Kodinov2019-07-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The xpath parsing function was using a local string buffer that was deallocated when going out of scope. However references to it are preserved in the XPATH parse tree. This was causing read-after-free. Fixed by making the xpath buffer a local variable inside the Item class for the relevant xpath function, thus being preserved for the duration of the query.
| | | | * | imporve clang buildEugene Kosov2019-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug Maintainer mode makes all warnings errors. This patch fix warnings. Mostly about deprecated `register` keyword. Too much warnings came from Mroonga and I gave up on it.
* | | | | | MDEV-20052 Add a MEM_ROOT pointer argument to Type_handler::make_xxx_field()Alexander Barkov2019-07-121-2/+2
|/ / / / /
* | | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |\ \ | | | | |/
| | | | * Update FSF AddressVicențiu Ciorbaru2019-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | * Update wrong zip-code
* | | | | Merge remote-tracking branch 'origin/10.3' into 10.4Alexander Barkov2018-07-031-6/+7
|\ \ \ \ \ | |/ / / /
| * | | | Merge commit '6b8802e8dd5467556a024d807a1df23940b00895' into bb-10.3-fix_len_decbb-10.3-fix_len_decOleksandr Byelkin2018-06-191-6/+7
| |\ \ \ \ | | |/ / /
| | * | | MDEV-11071: Assertion `thd->transaction.stmt.is_empty()' failed in ↵Oleksandr Byelkin2018-06-151-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Locked_tables_list::unlock_locked_table fix_length_and_dec now return result (error/OK)
* | | | | MDEV-16414 Add type_handler_xpath_nodeset and remove XPATH_NODESETAlexander Barkov2018-06-061-51/+58
| | | | |
* | | | | Merge branch '10.3' into 10.4Igor Babaev2018-06-031-0/+4
|\ \ \ \ \ | |/ / / /
| * | | | Addressing Monty's review suggestions for MDEV-11952 Oracle-style packages ↵Alexander Barkov2018-05-211-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (partial) - Using array_elements() instead of a constant to iterate through an array - Adding some comments - Adding new-line function comments - Using STRING_WITH_LEN instead of C_STRING_WITH_LEN
* | | | | MDEV-16351 JSON_OBJECT() treats hybrid functions with boolean arguments as ↵Alexander Barkov2018-05-311-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | numbers Now the boolean data type is preserved in hybrid functions and MIN/MAX, so COALESCE(bool_expr,bool_expr) and MAX(bool_expr) are correctly detected by JSON_OBJECT() as being boolean rather than numeric expressions.
* | | | | MDEV-16309 Split ::create_tmp_field() into virtual methods in ItemAlexander Barkov2018-05-281-1/+12
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Detailed: changes: 1. Moving Field specific code into new methods on Field: - Field *Field::create_tmp_field(...) - virtual void init_for_tmp_table(...) 2. Removing virtual Item::create_tmp_field(). Adding instead a new virtual method Item::create_tmp_field_ex(). Note, a virtual create_tmp_field() still exists, but only for Item_sum. This resembles 10.0 code structure. Perhaps create_tmp_field() should be removed from Item_sum and Item_sum descendants should override create_tmp_field_ex() directly. This can be done in a separate commit. 3. Adding helper classes Tmp_field_src and Tmp_field_param, to make the API for Item::create_tmp_field_ex() smaller and easier to extend in the future. 4. Decomposing the public function create_tmp_field() into virtual implementations for Item and a number of its descendants: - Item_basic_value - Item_sp_variable - Item_name_const - Item_result_field - Item_field - Item_ref - Item_type_holder - Item_row - Item_func_sp - Item_func_user_var - Item_sum - Item_sum_field - Item_proc 5. Adding DBUG_ASSERT-only virtual implementations for Item types that should not appear in create_tmp_table_ex(), for easier debugging: - Item_nodeset_func - Item_nodeset_to_const_comparator - Item_null_result - Item_copy - Item_ident_for_show - Item_user_var_as_out_param 6. Moving public function create_tmp_field_from_field() as a method to Item_field. 7. Removing Item::set_result_field(). It's not needed any more. 8. Cleanup: Removing the enum value "EXPR_CACHE_ITEM", as it's not used for a very long time.
* | | | MDEV-11952 Oracle-style packages: stage#5mariadb-10.3.5bb-10.3-compatibilityAlexander Barkov2018-02-251-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - CREATE PACKAGE [BODY] statements are now entirely written to mysql.proc with type='PACKAGE' and type='PACKAGE BODY'. - CREATE PACKAGE BODY now supports IF NOT EXISTS - DROP PACKAGE BODY now supports IF EXISTS - CREATE OR REPLACE PACKAGE [BODY] is now supported - CREATE PACKAGE [BODY] now support the DEFINER clause: CREATE DEFINER user@host PACKAGE pkg ... END; CREATE DEFINER user@host PACKAGE BODY pkg ... END; - CREATE PACKAGE [BODY] now supports SQL SECURITY and COMMENT clauses, e.g.: CREATE PACKAGE p1 SQL SECURITY INVOKER COMMENT "comment" AS ... END; - Package routines are now created from the package CREATE PACKAGE BODY statement and don't produce individual records in mysql.proc. - CREATE PACKAGE BODY now supports package-wide variables. Package variables can be read and set inside package routines. Package variables are stored in a separate sp_rcontext, which is cached in THD on the first packate routine call. - CREATE PACKAGE BODY now supports the initialization section. - All public routines (i.e. declared in CREATE PACKAGE) must have implementations in CREATE PACKAGE BODY - Only public package routines are available outside of the package - {CREATE|DROP} PACKAGE [BODY] now respects CREATE ROUTINE and ALTER ROUTINE privileges - "GRANT EXECUTE ON PACKAGE BODY pkg" is now supported - SHOW CREATE PACKAGE [BODY] is now supported - SHOW PACKAGE [BODY] STATUS is now supported - CREATE and DROP for PACKAGE [BODY] now works for non-current databases - mysqldump now supports packages - "SHOW {PROCEDURE|FUNCTION) CODE pkg.routine" now works for package routines - "SHOW PACKAGE BODY CODE pkg" now works (the package initialization section) - A new package body level MDL was added - Recursive calls for package procedures are now possible - Routine forward declarations in CREATE PACKATE BODY are now supported. - Package body variables now work as SP OUT parameters - Package body variables now work as SELECT INTO targets - Package body variables now support ROW, %ROWTYPE, %TYPE
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2018-02-151-2/+8
|\ \ \ \
| * \ \ \ Merge remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2018-02-081-2/+8
| |\ \ \ \ | | |/ / /
| | * | | Merge branch 'github/10.1' into 10.2Sergei Golubchik2018-02-061-2/+8
| | |\ \ \ | | | |/ /
| | | * | Merge branch 'github/10.0' into 10.1Sergei Golubchik2018-02-021-2/+8
| | | |\ \
| | | | * | MDEV-15118 ExtractValue(xml,something_complex) does not workAlexander Barkov2018-01-301-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Item_xml_str_func::fix_fields() used a local "String tmp" as a buffer for args[1]->val_str(). "tmp" was freed at the end of fix_fields(), while Items created during my_xpath_parse() still pointed to its fragments. Adding a new member Item_xml_str_func::m_xpath_query and store the result of args[1]->val_str() into it.
* | | | | | Remove not used mem_root argument from build_clone(), get_copy() and ↵Michael Widenius2017-11-231-34/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_item_copy() TODO: - Make get_thd_memroot() inline - To do this, we need to reduce dependence of include files, especially so that sql_class.h is not depending in item.h