Commit graph

86 commits

Author SHA1 Message Date
Marko Mäkelä
3d23adb766 Merge 10.6 into 10.11 2024-11-29 13:43:17 +02:00
Marko Mäkelä
7d4077cc11 Merge 10.5 into 10.6 2024-11-29 12:37:46 +02:00
Alexander Barkov
74184074a0 MDEV-28652 SUBSTRING(str,pos,len) returns incorrect result in view (returns an empty string)
Item_func_substr::fix_length_and_dec() incorrecltly calculated its max_length
to 0 when a huge number was passed as the third argument:
  substring('hello', 1, 4294967295)
Fixing this.
2024-11-19 12:35:00 +04:00
Alexander Barkov
c4843c10a3 MDEV-35416 CONV(1<<63, 10, -2) fails with --view-protocol
Item_func_conv::fix_length_and_dec() incorrectly set maximum
length as 64 character. But for negative numbers it can
return up to 65 charcters (including the sign).
2024-11-14 17:05:31 +04:00
Alexander Barkov
25be7da202 MDEV-32755 Stack-Buffer-Overflow at /mariadb-11.3.0/strings/int2str.c:122
The buffer ans[65] in Item_func_conv::val_str() was too small.
Fixing it to ans[66].
Thanks to Kristian Nielsen for the analysis.
2024-11-13 14:32:03 +04:00
Alexander Barkov
b9f9d804f2 MDEV-28686 Assertion `0' in Type_handler_string_result::make_sort_key or unexpected result
The code in the can_eval_in_optimize() branch in
Item_func_pad::fix_length_and_dec() did not take into account
that the constant can be negative. So the function will return NULL.

This later crashed on DBUG_ASSERT() because a NOT NULL function returned NULL.

Adding set_maybe_null() into this branch if the constant is negative.
2024-11-06 15:45:59 +04:00
Alexander Barkov
eb41c1171e MDEV-33942 View cuts off the end of string with the utf8 character set in INSERT function
Item_func_insert::fix_length_and_dec() incorrectly calculated max_length
when its collation.collation evaluated to my_charset_bin.

Fixing the code to calculate max_length in terms of octets rather
than in terms of characters when collation.collation is my_charset_bin.
2024-11-05 11:16:10 +04:00
Alexander Barkov
c2bf1d4781 MDEV-29552 LEFT and RIGHT with big value for parameter 'len' >0 return empty value in view
The code in max_length_for_string() erroneously returned 0
for huge numbers like 4294967295.

Rewriting the code in a more straightforward way.
2024-11-05 09:19:05 +04:00
Marko Mäkelä
63913ce5af Merge 10.6 into 10.11 2024-10-03 10:55:08 +03:00
Marko Mäkelä
7e0afb1c73 Merge 10.5 into 10.6 2024-10-03 09:31:39 +03:00
Alexander Barkov
841dc07ee1 MDEV-28386 UBSAN: runtime error: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoull_8bit on SELECT ... OCT
The code in my_strntoull_8bit() and my_strntoull_mb2_or_mb4()
could hit undefinite behavior by negating of LONGLONG_MIN.
Fixing the code to avoid this.
2024-09-20 11:01:31 +04:00
Oleksandr Byelkin
034a175982 Merge branch '10.6' into 10.11 2024-07-04 11:52:07 +02:00
Oleksandr Byelkin
dcd8a64892 Merge branch '10.5' into 10.6 2024-07-03 13:27:23 +02:00
Alexander Barkov
d046b13e7b MDEV-20548 Unexpected error on CREATE..SELECT HEX(num)
Item_func_hex::fix_length_and_dec() evaluated a too short data type
for signed numeric arguments, which resulted in a 'Data too long for column'
error on CREATE..SELECT.

Fixing the code to take into account that a short negative
numer can produce a long HEX value: -1  -> 'FFFFFFFFFFFFFFFF'

Also fixing Item_func_hex::val_str_ascii_from_val_real().
Without this change, MTR test with HEX with negative float point arguments
failed on some platforms (aarch64, ppc64le, s390-x).
2024-07-01 18:50:32 +04:00
Lena Startseva
9e74a7f4f3 Removing MDEV-27871 from tastcases because it is not a bug 2024-06-28 16:45:50 +07:00
Marko Mäkelä
22ba7e4ff8 Merge 10.6 into 10.11 2024-05-30 16:04:00 +03:00
Marko Mäkelä
5ba542e9ee Merge 10.5 into 10.6 2024-05-30 14:27:07 +03:00
Alexander Barkov
7c4c082349 MDEV-28387 UBSAN: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strtoll10 on SELECT
Fixing the condition to raise an overflow in the ulonglong
representation of the number is greater or equal to 0x8000000000000000ULL.
Before this change the condition did not catch -9223372036854775808
(the smallest possible signed negative longlong number).
2024-05-23 14:18:34 +04:00
Marko Mäkelä
788953463d Merge 10.6 into 10.11
Some fixes related to commit f838b2d799 and
Rows_log_event::do_apply_event() and Update_rows_log_event::do_exec_row()
for system-versioned tables were provided by Nikita Malyavin.
This was required by test versioning.rpl,trx_id,row.
2024-03-28 09:16:57 +02:00
Marko Mäkelä
ccb7a1e9a1 Merge 10.5 into 10.6 2024-03-27 15:00:56 +02:00
Dave Gosselin
58df20974b MDEV-33460 select '123' 'x'; unexpected result
Queries that select concatenated constant strings now have
colname and value that match.  For example,
  SELECT '123' 'x';
will return a result where the column name and value both
are '123x'.

Review: Daniel Black
2024-03-27 15:51:26 +11:00
Oleksandr Byelkin
f30244d13c Merge branch '10.11' into mariadb-10.11.7 2024-02-07 08:18:05 +01:00
Alexander Barkov
c4c167778e MDEV-33392 Server crashes when using RANDOM_BYTES function and GROUP BY clause on a column with a negative value
Item_func_random_bytes did not set its NULL-ability flag.
2024-02-07 09:05:28 +04:00
Sergei Golubchik
87e13722a9 Merge branch '10.6' into 10.11 2024-02-01 18:36:14 +01:00
Sergei Golubchik
3f6038bc51 Merge branch '10.5' into 10.6 2024-01-31 18:04:03 +01:00
Alexander Barkov
81d01855fe MDEV-28651 quote(NULL) returns incorrect result in view ('NU' instead of 'NULL')
Item_func_quote did not calculate its max_length correctly for nullable
arguments.

Fix:

In case if the argument is nullable, reserve at least 4 characters
so the string "NULL" fits.
2024-01-23 13:22:58 +04:00
Oleksandr Byelkin
04d9a46c41 Merge branch '10.6' into 10.10 2023-11-08 16:23:30 +01:00
Oleksandr Byelkin
b83c379420 Merge branch '10.5' into 10.6 2023-11-08 15:57:05 +01:00
Oleksandr Byelkin
6cfd2ba397 Merge branch '10.4' into 10.5 2023-11-08 12:59:00 +01:00
Alexander Barkov
09e237088c MDEV-31184 Remove parser tokens DECODE_MARIADB_SYM and DECODE_ORACLE_SYM
Changing the code handling sql_mode-dependent function DECODE():

- removing parser tokens DECODE_MARIADB_SYM and DECODE_ORACLE_SYM
- removing the DECODE() related code from sql_yacc.yy/sql_yacc_ora.yy
- adding handling of DECODE() with help of a new Create_func_func_decode
2023-10-24 01:45:47 +04:00
Marko Mäkelä
a009280e60 Merge 10.9 into 10.10 2023-04-14 12:24:14 +03:00
Marko Mäkelä
5bada1246d Merge 10.5 into 10.6 2023-04-11 16:15:19 +03:00
Oleksandr Byelkin
ac5a534a4c Merge remote-tracking branch '10.4' into 10.5 2023-03-31 21:32:41 +02:00
Weijun Huang
f70de1451b MDEV-30351 crash in Item_func_left::val_str
When using LEFT() function with a string that is without a charset,
the function crashes. This is because the function assumes that
the string has a charset, and tries to use it to calculate the
length of the string.

Two functions, UNHEX and WEIGHT_STRING, returned a string without
the charset being set to a not null value.

The fix is to set charset when calling val_str on these two functions.

Reviewed-by: Alexander Barkov <bar@mariadb.com>
Reviewed-by: Daniel Black <daniel@mariadb.org>
2023-03-31 14:53:50 +11:00
Marko Mäkelä
5e996fbad9 Merge 10.9 into 10.10 2022-09-21 10:59:56 +03:00
Marko Mäkelä
44fd2c4b24 Merge 10.5 into 10.6 2022-09-20 16:53:20 +03:00
Alexander Barkov
fe844c16b6 Merge remote-tracking branch 'origin/10.4' into 10.5 2022-09-14 16:24:51 +04:00
Marko Mäkelä
18795f5512 Merge 10.3 into 10.4 2022-09-13 16:36:38 +03:00
Alexander Barkov
f1544424de MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
Sergei Golubchik
b74dbcb157 MDEV-23149 Server crashes in my_convert / ErrConvString::ptr / Item_char_typecast::check_truncation_with_warn
10.10 part
2022-08-10 15:05:12 +02:00
Daniel Black
0caa6bf14e MDEV-25704 more tests 2022-07-31 14:54:37 +02:00
Sergei Golubchik
3607da3c4e MDEV-25704 RANDOM_BYTES - post-review fixes
don't error out on values out of range, return NULL
(as in, e.g. sqrt(-1))
2022-07-31 14:54:37 +02:00
Daniel Black
d7e3265dd3 MDEV-29154 Excessive warnings upon a call to RANDOM_BYTES
Bring the 5 warnings of select random_bytes(cast('x' as unsigned)+1);
back to two. 1 for Item_func_random_bytes::fix_length_and_dec and
one from Item_func_random_bytes::val_str.

The warnings are from args[0]->val_int().
2022-07-31 14:54:37 +02:00
Daniel Black
7f06f68108 MDEV-29108 RANDOM_BYTES - assertion in Create_tmp_table::finalize
Setting max_length to a negative value in Item_func_random_bytes::fix_length_and_dec
underflowed resulting in debug optimizer assertion.

Also set the maximium to 1024 rather than MAX_BLOB_WIDTH because
we aren't going to return more than that.
2022-07-31 14:54:37 +02:00
Vanislavsky
3c2b0cac52 MDEV-25704 Add RANDOM_BYTES function
MySQL 5.6 added the RANDOM_BYTES function.
https://dev.mysql.com/doc/refman/5.6/en/encryption-functions.html#function_random-bytes

This is needed for compatibility purposes.
2022-07-31 14:54:37 +02:00
Marko Mäkelä
30914389fe Merge 10.5 into 10.6 2022-07-27 17:52:37 +03:00
Marko Mäkelä
098c0f2634 Merge 10.4 into 10.5 2022-07-27 17:17:24 +03:00
Oleksandr Byelkin
3bb36e9495 Merge branch '10.3' into 10.4 2022-07-27 11:02:57 +02:00
Alexander Barkov
57f5c319af MDEV-21445 Strange/inconsistent behavior of IN condition when mixing numbers and strings 2022-07-06 15:42:21 +04:00
Oleksandr Byelkin
f5c5f8e41e Merge branch '10.5' into 10.6 2022-02-03 17:01:31 +01:00