summaryrefslogtreecommitdiff
path: root/sql/sql_string.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.4 into 10.5Marko Mäkelä2020-10-301-1/+2
|\
| * MDEV-22387: Static_binary_string::q_append() invokes memcpy on NULLMarko Mäkelä2020-10-301-1/+2
| | | | | | | | | | | | | | | | | | | | Invoking memcpy() on a NULL pointer is undefined behaviour (even if the length is 0) and gives the compiler permission to assume that the pointer is nonnull. Recent versions of GCC (starting with version 8) are more aggressively optimizing away checks for NULL pointers. This undefined behaviour would cause a SIGSEGV in the test main.func_encrypt on an optimized debug build on GCC 10.2.0.
* | cleanup: Static_binary_string need not take non-const double parameterVicențiu Ciorbaru2020-10-281-1/+1
| | | | | | | | | | Convert the parameter to const as the function won't modify the pointer value.
* | Merge 10.4 into 10.5Marko Mäkelä2020-08-101-0/+6
|\ \ | |/
| * Merge mariadb-10.4.14Marko Mäkelä2020-08-101-0/+4
| |\
| | * Merge branch '10.3' into 10.4Oleksandr Byelkin2020-08-031-0/+4
| | |\
| | | * MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ↵Alexander Barkov2020-08-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... SELECT in ORACLE mode - Adding optional qualifiers to data types: CREATE TABLE t1 (a schema.DATE); Qualifiers now work only for three pre-defined schemas: mariadb_schema oracle_schema maxdb_schema These schemas are virtual (hard-coded) for now, but may turn into real databases on disk in the future. - mariadb_schema.TYPE now always resolves to a true MariaDB data type TYPE without sql_mode specific translations. - oracle_schema.DATE translates to MariaDB DATETIME. - maxdb_schema.TIMESTAMP translates to MariaDB DATETIME. - Fixing SHOW CREATE TABLE to use a qualifier for a data type TYPE if the current sql_mode translates TYPE to something else. The above changes fix the reported problem, so this script: SET sql_mode=ORACLE; CREATE TABLE t2 AS SELECT mariadb_date_column FROM t1; is now replicated as: SET sql_mode=ORACLE; CREATE TABLE t2 (mariadb_date_column mariadb_schema.DATE); and the slave can unambiguously treat DATE as the true MariaDB DATE without ORACLE specific translation to DATETIME. Similar, SET sql_mode=MAXDB; CREATE TABLE t2 AS SELECT mariadb_timestamp_column FROM t1; is now replicated as: SET sql_mode=MAXDB; CREATE TABLE t2 (mariadb_timestamp_column mariadb_schema.TIMESTAMP); so the slave treats TIMESTAMP as the true MariaDB TIMESTAMP without MAXDB specific translation to DATETIME.
| * | | MDEV-23415 Server crash or Assertion `dec_length <= str_length' failed in ↵Alexander Barkov2020-08-081-0/+6
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Item_func_format::val_str_ascii Problem: The crash happened in FORMAT(double, dec>=31, 'de_DE'). The patch for MDEV-23118 (commit 0041dacc1b8e85e1958355d1cfdc36055b05a884) did not take into account that String::set_real() has a limit of 31 (FLOATING_POINT_DECIMALS) fractional digits. So for the range of 31..38 digits, set_real() switches to use: - my_fcvt() - decimal point notation, e.g. 1.9999999999 - my_gcvt() - scientific notation, e.g. 1e22 my_gcvt() returned a shorter string than Item_func_format::val_str_ascii() expected to get after the my_fcvt() call, so it crashed on assert. Solution: We cannot extend set_real() to use the my_fcvt() mode for the range of 31..38 fractional digits, because set_real() is used in a lot of places and such a change will break everything. Introducing String::set_fcvt() which always prints using my_fcvt() for the whole range of decimals 0..38, supported by the FORMAT() function.
* | | MDEV-23330 Server crash or ASAN negative-size-param in my_strnncollsp_binary ↵Sergei Golubchik2020-08-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | / SORT_FIELD_ATTR::compare_packed_varstrings and MDEV-23414 Assertion `res->charset() == item->collation.collation' failed in Type_handler_string_result::make_packed_sort_key_part pack_sort_string() *must* take a collation from the Item, not from the String value. Because when casting a string to _binary the original String is not copied for performance reasons, it's reused but its collation does not match Item's collation anymore. Note, that String's collation cannot be simply changed to _binary, because for an Item_string literal the original String must stay unchanged for the duration of the query. this partially reverts 61c15ebe323
* | | Remove String::lex_string() and String::lex_cstring()Monty2020-07-231-15/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Better to use 'String *' directly. - Added String::get_value(LEX_STRING*) for the few cases where we want to convert a String to LEX_CSTRING. Other things: - Use StringBuffer for some functions to avoid mallocs
* | | Merge 10.4 into 10.5Marko Mäkelä2020-04-251-1/+1
|\ \ \ | |/ / | | | | | | | | | The functional changes of commit 5836191c8f0658d5d75484766fdcc3d838b0a5c1 (MDEV-21168) are omitted due to MDEV-742 having addressed the issue.
| * | Merge 10.3 into 10.4Marko Mäkelä2020-04-161-1/+1
| |\ \ | | |/ | | | | | | | | | | | | | | | In main.index_merge_myisam we remove the test that was added in commit a2d24def8cc42d27c72d833abfb39ef24a2b96ba because it duplicates the test case that was added in commit 5af12e463549e4bbc2ce6ab720d78937d5e5db4e.
| | * fix tests related to SQL comment lengthEugene Kosov2020-04-151-1/+1
| | | | | | | | | | | | | | | | | | | | | tests are: engines/funcs.jp_comment_column engines/funcs.jp_comment_index engines/funcs.jp_comment_table
* | | Merge 10.4 into 10.5Marko Mäkelä2020-03-301-0/+4
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-03-301-1/+5
| |\ \ | | |/
| | * Merge 10.2 into 10.3Marko Mäkelä2020-03-301-1/+5
| | |\
| | | * MDEV-22005 UBSAN: applying non-zero offset 2 to null pointer in my_charpos_mb()Eugene Kosov2020-03-261-1/+5
| | | | | | | | | | | | | | | | Empty comment has a correct length.
* | | | perfschema memory related instrumentation changesSergei Golubchik2020-03-101-22/+9
| | | |
* | | | MDEV-21581 Helper functions and methods for CHARSET_INFOAlexander Barkov2020-01-281-6/+7
| | | |
* | | | A cleanup for MDEV-8844: Fixing compilation failure on WindowsAlexander Barkov2019-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Fixing lossy type conversions: - from int64 to int - from size_t to uint
* | | | MDEV-8844 Unreadable control characters printed as is in warningsAlexander Barkov2019-12-061-0/+9
| | | |
* | | | Merge 10.4 into 10.5Aleksey Midenkov2019-11-251-1/+5
|\ \ \ \ | |/ / /
| * | | MDEV-20190 Instant operation fails when add column and collation change on ↵Marko Mäkelä2019-11-251-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | non-indexed column We must relax too strict debug assertions. For latin1_swedish_ci, mtype=DATA_CHAR or mtype=DATA_VARCHAR will be used instead of mtype=DATA_MYSQL or mtype=DATA_VARMYSQL. Likewise, some changes of dtype_get_charset_coll() do not affect the data type encoding, but only any indexes that are defined on the column. Charset::same_encoding(): Check whether two charset-collations have the same character set encoding. dict_col_t::same_encoding(): Check whether two character columns have the same character set encoding. dict_col_t::same_type(): Check whether two columns have a compatible data type encoding. dict_col_t::same_format(), dict_table_t::instant_column(): Do not compare mtype or the charset-collation of prtype directly. Rely on dict_col_t::same_type() instead. dtype_get_charset_coll(): Narrow the return type to uint16_t. This is a refined version of a fix that was developed by Thirunarayanan Balathandayuthapani.
* | | | MDEV-20856 Bad values in metadata views for partitions on VARBINARYAlexander Barkov2019-10-181-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code to print partition values was too complicated: - it created new Items for character set conversion purposes. - it mixed string conversion and partition error reporting in the same code blocks. Simplifying the code as follows: - Adding helper methods String::can_be_safely_convert_to() and String::append_introducer_and_hex(). - Adding DBUG_EXECUTE_IF("generate_partition_syntax_for_frm", push_warning...) into generate_partition_syntax_for_frm(), to test the PARTITON clause written to FRM. Adding test partition_utf8-debug.test for this. - Removing functions get_cs_converted_part_value_from_string() and get_cs_converted_string_value. Changing get_partition_column_description() to use Type_handler::partition_field_append_value() instead. This makes SHOW CREATE TABLE and SELECT FROM I_S.PARTITIONS use the same code path. - Changing Type_handler::partition_field_append_value() not to call convert_charset_partition_constant(), to avoid creating a new Item for string conversion pursposes. Rewritting the code to use only String methods. - Removing error reporting code (ER_PARTITION_FUNCTION_IS_NOT_ALLOWED) from Type_handler::partition_field_append_value(). The error is correctly detected and reported on the caller level. So error reporting was redundant here. Also: - Moving methods Type_handler::partition_field_*() from sql_partition.cc to sql_type.cc. This fixes compilation problem with -DPLUGIN_PARTITION=NO, earlier introduced by the patch for MDEV-20831.
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-09-061-0/+8
|\ \ \ \ | |/ / /
| * | | Merge branch '10.3' into 10.4Sergei Golubchik2019-09-061-0/+8
| |\ \ \ | | |/ /
| | * | Merge 10.2 (up to commit ef00ac4c86daf3294c46a45358da636763fb0049) into 10.3Alexander Barkov2019-09-041-0/+5
| | |\ \ | | | |/
| | | * MDEV-18156 Assertion `0' failed or `btr_validate_index(index, 0, false)' in ↵Alexander Barkov2019-09-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with PAD_CHAR_TO_FULL_LENGTH This change takes into account a column's GENERATED ALWAYS AS expression dependcy on sql_mode's PAD_CHAR_TO_FULL_LENGTH and NO_UNSIGNED_SUBTRACTION flags. Indexed virtual columns as well as persistent generated columns are now not allowed to have such dependencies to avoid inconsistent data or index files on sql_mode changes. So an error is now returned in cases like this: CREATE OR REPLACE TABLE t1 ( a CHAR(5), v VARCHAR(5) AS (a) PERSISTENT -- CHAR->VARCHAR or CHAR->TEXT = ERROR ); Functions RPAD() and RTRIM() can now remove dependency on PAD_CHAR_TO_FULL_LENGTH. So this can be used instead: CREATE OR REPLACE TABLE t1 ( a CHAR(5), v VARCHAR(5) AS (RTRIM(a)) PERSISTENT ); Note, unlike CHAR->VARCHAR and CHAR->TEXT this still works, not RPAD(a) is needed: CREATE OR REPLACE TABLE t1 ( a CHAR(5), v CHAR(5) AS (a) PERSISTENT -- CHAR->CHAR is OK ); More sql_mode flags may affect values of generated columns. They will be addressed separately. See comments in sql_mode.h for implementation details.
* | | | MDEV-20042 Implement EXTRA2_FIELD_DATA_TYPE_INFO in FRMAlexander Barkov2019-07-111-0/+13
| | | |
* | | | Merge remote-tracking branch 'origin/10.4' into 10.5Monty2019-06-271-1/+2
|\ \ \ \ | |/ / /
| * | | MDEV-17301 Change of COLLATE unnecessarily requires ALGORITHM=COPYEugene Kosov2019-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch is about two cases: 1) On some collate changes it's possible to rebuild only secondary indexes 2) For non-indexed columns collate can be changed INSTANTly Implemented mostly in Field_{string,varstring,blob}::is_equal(). Make this method return how exactly collationa differs. This information is later used by fill_alter_inplace_info() to pass correct info to engine.
| * | | MDEV-19776: Assertion `to_len >= 8' failed in convert_to_printable with ↵Varun Gupta2019-06-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | optimizer trace enabled Introduced the convert_to_printable_required_length to return the correct length(taking into consideration of dots in the case of error messages).
* | | | MDEV-19843 Modify ST_FIELD_INFO to use Type_handler and LEX_CSTRINGAlexander Barkov2019-06-241-0/+4
| | | |
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-06-131-0/+3
|\ \ \ \ | |/ / /
| * | | MDEV-18880: Optimizer trace prints date in hexadecimalVarun2019-06-111-0/+3
| | | | | | | | | | | | | | | | | | | | Introduced a print_key_value function to makes sure that the trace prints data in readable format for readable characters and the rest of the characters are printed as hexadecimal.
* | | | MDEV-19727 Add Type_handler::Key_part_spec_init_ftAlexander Barkov2019-06-111-0/+5
|/ / /
* | | 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
* | | | | A joint patch for MDEV-19284 and MDEV-19285 (INSTANT ALTER)Alexander Barkov2019-05-161-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes: - MDEV-19284 INSTANT ALTER with ucs2-to-utf16 conversion produces bad data - MDEV-19285 INSTANT ALTER from ascii_general_ci to latin1_general_ci produces corrupt data These regressions were introduced in 10.4.3 by: - MDEV-15564 Avoid table rebuild in ALTER TABLE on collation or charset changes Changes: 1. Cleanup: Adding a helper method Field_longstr::csinfo_change_allows_instant_alter(), to remove some duplicate code in field.cc. 2. Cleanup: removing Type_handler::Charsets_are_compatible() and static function charsets_are_compatible() and introducing new methods in the recently added class Charset instead: - encoding_allows_reinterpret_as() - encoding_and_order_allow_reinterpret_as() 3. Bug fix: Removing the code that allowed instant conversion for ascii-to->8bit and ucs2-to->utf16. This actually fixes MDEV-19284 and MDEV-19285. 4. Bug fix: Adding a helper method Charset::collation_specific_name(). The old corresponding code in Type_handler::Charsets_are_compatible() was not safe against (badly named) user-defined collations whose character set name can be longer than collation name.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-04-251-5/+0
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | In is_eits_usable(), we disable an assertion that fails due to MDEV-19334.
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-04-251-5/+0
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-04-251-5/+0
| | |\ \ \ | | | |/ /
| | | * | MDEV-9465 The constructor StringBuffer(const char *str, size_t length, const ↵Alexander Barkov2019-04-231-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CHARSET_INFO *cs) looks suspicious Removing the suspicious constructor, it's not used in the code anyway.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-03-201-19/+2
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MDEV-17262 commit 26432e49d37a37d09b862bb49a021e44bdf4789c was skipped. In Galera 4, the implementation would seem to require changes to the streaming replication. In the tests archive.rnd_pos main.profiling, disable_ps_protocol for SHOW STATUS and SHOW PROFILE commands until MDEV-18974 has been fixed.
| * | | | Merge branch '10.2' into 10.3Sergei Golubchik2019-03-171-18/+2
| |\ \ \ \ | | |/ / /
| | * | | post-merge: gcc 8 warningsSergei Golubchik2019-03-151-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | note: Inherit String from Sql_alloc, to get operators new and new[] in sync in rocksdb gcc was complaining that non-lvalue was cast to const.
* | | | | MDEV-17906 Class Binary_stringbb-10.4-mdev7063Alexander Barkov2018-12-051-205/+364
| | | | |