Fix ER_OUTOFMEMORY format to use %zu and size_t (MDEV-39138)#4840
Open
Harsh8084 wants to merge 4853 commits intoMariaDB:10.6from
Open
Fix ER_OUTOFMEMORY format to use %zu and size_t (MDEV-39138)#4840Harsh8084 wants to merge 4853 commits intoMariaDB:10.6from
Harsh8084 wants to merge 4853 commits intoMariaDB:10.6from
Conversation
…E TABLE
When executing an atomic sequence of RENAME operations, such as:
RENAME TABLE t1 TO t2, t3 TO t4, ...
any failure in the sequence triggers a rollback of previously completed
renames to preserve atomicity.
However, when an error occurs, `my_error()` is invoked immediately, which
sets the `thd->is_error()` flag. This premature flag setting causes
the rollback logic to misinterpret the thread state, leading to incorrect
reversion behavior and assertion failures.
To address this, the errors are now not emitted immediately but captured
and postponed. A new class `Postponed_error_handler` is introduced for
this purpose. Only after all operations are completed (including
possible DDL reversion), the captured errors are emitted.
Fix log message about unexpected table in system tablespace as the current message can be missleading due to still existing (but already deprecated) system tables SYS_DATAFILES and SYS_TABLESPACES, reported in - MDEV-38412 Also adding the informative message with table name of the unexpected table in system table space.
Item_default_value::do_build_clone() was performing a shallow copy, causing the cloned item to share its 'arg' pointer with the original. During condition pushdown for derived tables: 1. build_pushable_cond() cloned the WHERE clause condition 2. grouping_field_transformer_for_where transformed the cloned DEFAULT(a) to reference the inner select's grouping field, modifying the shared 'arg' via change_item_tree() 3. cleanup_excluding_const_fields_processor cleaned up the transformed items, setting Item_field::field = 0 4. The original WHERE clause still referenced the cleaned-up item 5. Crash in Item_field::used_tables() accessing field->table Fix: Make do_build_clone() create a deep clone of 'arg' member, ensuring the cloned Item_default_value has independent state.
Test was affected by incompletely closed preceding connections. Make test agnostic to concurrent connections by querying performance_schema.status_by_thread only for connections that it uses.
Test output was affected by incompletely closed preceding connections. Make test agnostic to concurrent connections by querying information_schema.processlist only for connections that it uses. Avoid ID-CONNECTION_ID() expression, it is not deterministic.
Test was affected by incompletely closed preceding connections. Make test agnostic to concurrent connections by querying performance_schema.threads only for connections that it uses.
Embedded mode produces different thread identifiers, which makes replace_result replace unwanted occurences. Use temporary table for filtering out unwanted threads such that replace_result is not needed anymore. This is regression after 0eebe3a.
…UND mismatch) Test was affected by incompletely closed preceding connections. Make test agnostic to concurrent connections by querying performance_schema.threads only for connections that it uses.
Revert part of bead24b, which broke this test. The wait is still needed to make variables of preceding connection disappear.
Test was affected by incompletely closed preceding connections. Make test agnostic to concurrent connections by querying performance_schema.user_variables_by_thread only for connections that it uses.
Test was affected by incompletely closed preceding connections. Make test agnostic to concurrent connections by querying performance_schema.events_statements_current only for connections that it uses.
Similar to MDEV-37483, use file name encoding for dbnames to create directories. Adapt mariadb-import to convert the names back.
…ecution Routine name resolution performed on a temporary memory root during execution. So on the second execution LEX::spname members pointed to a cleared memory. Fixing to peform the resolution to parse time, like the CALL statement does. During the execution time LEX::spname members now stay untouched.
Send ok packet earlier for SELECT queries that does not have any updates. This is done in select_send::send_eof() Axel's select benchmarks shows that this has a notable speed improvement: 1 Thread: 28% TPS speedup 8 Threads: 23% 64 Threads 6% This was meassured with t_oltp_point_select With InnoDB running the client over sockets. Other things: - Moved error reporting of LIMIT ROWS EXAMINED from handle_select() to check_limit_rows_examined(). This is to ensure that the error is reported before send_eof() is called. - Removed duplicate "Query execution was interrupted" messages for the same query. killed_for_exceeding_limit_rows_warning_given was introduced for this purpose. We cannot use 'killed' flag in killed_for_exceeding_limit_rows() to detect if we already have produced a warning as the 'killed' in this case is reset for each union. Reviewer: Sergei Golubchik <serg@mariadb.org>
correct the length check. remove assertions that a file read from disk contains a specific substring
…e-level CREATE but not with global CREATE CHECK TABLE was inconsistently requiring SELECT privilege on global/db level or any privilege on the table/column level. Change to require any table-applicable privilege on any level.
don't trust the content of a file read from disk
… queries to fail don't copy field default values and check constraints in CREATE ... SELECT. CREATE ... SELECT means a table is created from a *result set* not from some other table. For backward compatibility, though, let's keep copying constant default values and the "compressed" attribute.
…DEFAULT VALUE() should only use table->insert_values when table->insert_values contains row values. table->insert_values gets row values for the ODKU clause so if VALUE() is used before that it shouldn't use table->insert_values
…sions 10.11.X and beyond my_getcputime() returns "cpu time in 1/10th on a microsecond (1e-7 s)"
otherwise it causes random failures in some later test that lists files in $datadir/test
don't let the parser create ridiculously deep joins that will be rejected later anyway
the "Test that bad value for plugin enum option is rejected correctly" needed multiple fixes: 1. don't set plugin-dir based on $MYSQLTEST_VARDIR, all plugins are in var/plugins, but $MYSQLTEST_VARDIR is var/1/, var/2/, etc if --parallel is used (that is, practically always), thus the ha_example.so cannot be loaded, because cannot be found. Test fails with "unknown option --plugin-example-enum" as the plugin is not loaded 2. force --plugin-maturity=experimental, otherwise even if not parallel the plugin will fail to load because of low maturity, test still fails with "unknown option --plugin-example-enum" 3. don't specify .so extension explicitly otherwise the plugin still doesn't load on windows, even if paths and maturity are fixed 4. set --plugin-example=FORCE otherwise plugin fails to load after reading --plugin-example-enum-var=noexist because of unknown enum value, the server ignores the failure and starts normally. the test hangs. 5. This needs the fix in sql_plugin.cc to detect that the plugin is forced even when some options failed to parse. It used to consider plugin forced only if all options parsed correctly, which was wrong. Now the test passes, testing what it was supposed to test - failure to parse an enum value of a plugin option. Without these fixes the test hanged as in 4 when run on the main branch in non-prarallel (e.g. one test only) mode.
…keys on vault errors * let use_cache_on_timeout apply to other errors * enable use_cache_on_timeout by default and deprecate it * increase cache_timeout to max and deprecate it * change it from long to portable longlong * delete both in 13.3
* put autocommit/commit outside of LOCK/UNLOCK. * use uppercase like all other commands * restore the old value of autocommit
with `ORDER BY number` if the number doesn't refer to a valid result column, use this number in the error message not '???'.
restore OPTIMIZE/ANALYZE replication under @read_only that was disabled in b62101f
…VEPOINT, assertion failure InnoDB was rolling back a transaction internally, while the server thought the transaction stayed open. this was fixed in 10.11 by 387fe5e to rollback the transaction in the server and in 12.3 by d228f23 to not rollback in InnoDB let's keep 12.3 behavior, update test results to match. but combine two nearly indentical test cases into one.
… NULL Fixing the return type of Type_handler::Item_save_in_value() from bool to void. Adding a new method st_value::is_null(). This makes the code less confusing.
Adding support for cursors on prepared statements.
- SQL Standard way:
DECLARE c CURSOR FOR stmt;
PREPARE stmt FROM 'SELECT ?';
OPEN c USING 1;
- Oracle-style way with SYS_REFCURSOR variables:
DECLARE
c SYS_REFCURSOR;
BEGIN
OPEN c FOR 'SELECT ?' USING 1;
…p_lex_instr::get_query, UBSAN member access within null pointer of type 'const sp_assignment_lex'
The patch for "MDEV-38626 Unexpected `Data too long`..." earlier fixed this problem. Adding a test case only.
…::write(THD *, time_t, const char *, size_t, ulonglong, ulonglong, bool, const char *, size_t) The patch for "MDEV-33830 Support for cursors on prepared statements" tried to enable slow log for cursor OPEN statements. However it introduced a crash reported in MDEV-38359. After checking the slog log implementation for sp_instr_stmt, it appeared to be buggy: - MDEV-38611 Procedure statements do not write Explain entries to the slow log - MDEV-38614 Procedure statements write wrong Query_time into slow log It was decided to wait untile these bugs are cloded and enable slow log for OPEN under terms of a separate task: MDEV-38612 Cursor OPEN statements do not write to the slow log This patch reverts the change which enabled slow log for OPEN.
…ool parse_vcol_defs(THD *, MEM_ROOT *, TABLE *, bool *, vcol_init_mode) A new assertion added by MDEV-36290 is correct in trying to identify default_fields that weren't correctly accounted in parse_vcol_defs. It caught a case for INSERT DELAYED on tables using TIMESTAMP and DATETIME types with ON UPDATE default values. That is, the insert delayed logic opens the table in one thread, and then copies the field info to another table in the user thread. This copy loses most flag metadata for these fields though. In this case, the flag ON_UPDATE_NOW_FLAG was dropped, and the parse_col_defs() logic was unable to properly account for that default field, and the assertion fired. This patch fixes this by restoring the ON_UPDATE_NOW_FLAG during the field copy. Also, a comment is added to Field::make_new_field() to explain the state of the returned field. Reviewed-by: Monty <monty@mariadb.com> Signed-off-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
XMLTYPE column added. Type_handler::get_column_attributes() added so parser can check if unexpected attributes were specified for the UDT column.
This is achived by changing the 'is_prefix' parameter to strncoll from a my_bool to my_bool*. This parameter is null if not specified by the caller. If the is_prefix parameter is set to point to a my_bool variable, this variable will be set to 1 if the second argument is a prefix of the first. This is needed by TO_DATE to be able to detect partial uniqiue matches of months etc. find_type() did this for latin1 strings, but we did not do this for utf8mb4 strings. This patch fixes this incompatibility.
Syntax:
TO_DATE(string_expression [DEFAULT string_expression ON CONVERSION ERROR],
format_string [,NLS_FORMAT_STRING])
The format_string has the same format elements as TO_CHAR(), except a
few elements that are not supported/usable for TO_DATE().
TO_DATE() returns a datetime or date value, depending on if the format
element FF is used.
Allowed separators, same as TO_CHAR():
space, tab and any of !#%'()*+,-./:;<=>
'&' can also be used if next character is not a character a-z or A-Z
"text' indicates a text string that is verbatim in the format. One cannot
use " as a separator.
Format elements supported by TO_DATE():
AD Anno Domini ("in the year of the Lord")
AD_DOT Anno Domini ("in the year of the Lord")
AM Meridian indicator (Before midday)
AM_DOT Meridian indicator (Before midday)
DAY Name of day
DD Day (1-31)
DDD Day of year (1-336)
DY Abbreviated name of day
FF[1-6] Fractional seconds
HH Hour (1-12)
HH12 Hour (1-12)
HH24 Hour (0-23)
MI Minutes (0-59)
MM Month (1-12)
MON Abbreviated name of month
MONTH Name of Month
PM Meridian indicator (After midday)
PM_DOT Meridian indicator (After midday)
RR 20th century dates in the 21st century. 2 digits
50-99 is assumed from 2000, 0-49 is assumed from 1900.
RRRR 20th century dates in the 21st century. 4 digits
SS Seconds
SYYYY Signed 4 digit year; MariaDB only supports positive years
Y 1 digit year
YY 2 digits year
YYY 3 digits year
YYYY 4 digits year
Note that if there is a missing part of the date, the current date is used!
For example if 'MM-DD HH-MM-SS' then the current year will be used.
(Oracle behaviour)
Not supported options:
- BC, D, DL, DS, E, EE, FM, FX, RM, SSSSS, TS, TZD, TZH, TZR, X,SY
BC is not supported by MariaDB datetime.
- Most of the other are exotic formats does not make sence in MariaDB as
we return datetime or datetime with fractions, not string.
- D (day-of-week) is not supported as it is not clear exactly how it would
map to MariaDB. This element depends on the NLS territory of the session.
- RR only works with 2 digit years (In Oracle RR can also work with 4
digit years in some context but the rules are not clear).
Extensions / differences compared to Oracle;
- MariaDB supports FF (fractional seconds). If FF[#] is used,
then TO_DATE will return a datetime with # of subseconds.
If FF is not used a datetime will be returned.
There is warning (no error) if string contains more digts than what
is specified with F(#]
- Names can be shortened to it's unique prefix. For example January and Ja
works fine.
- No error if the date string is shorter format_string and the next
not used character is not a number.. This is useful to get a date
from a mixed set of strings in date or datetime format.
Oracle gives an error if date string is too short.
- MariaDB supports short locales as language names
- NLS_DATE_FORMAT can use both " and ' for quoting.
- NLS_DATE_FORMAT must be a constant string.
- This is to ensure that the server knows which locale to use
when executing the function.
New formats handled by TO_CHAR():
FF[1-6] Fractional seconds
DDD Daynumber 1-366
IW Week 1-53 according to ISO 8601
I 1 digit year according to ISO 8601
IY 2 digit year according to ISO 8601
IYY 3 digit year according to ISO 8601
IYYY 4 digit year according to ISO 8601
SYYY 4 digit year according to ISO 8601 (Oracle can do signed)
Supported NLS_FORMAT_STRING options are:
NLS_CALENDAR=GREGORIAN
NLS_DATE_LANGUAGE=language
Support languages are:
- All MariaDB short locales, like en_AU.
- The following Oracle language names:
ALBANIAN, AMERICAN, ARABIC, BASQUE, BELARUSIAN, BRAZILIAN PORTUGUESE
BULGARIAN, CANADIAN FRENCH, CATALAN, CROATIAN, CYRILLIC SERBIAN CZECH,
DANISH, DUTCH, ENGLISH, ESTONIAN, FINNISH, FRENCH, GERMAN,
GREEK, HEBREW, HINDI, HUNGARIAN, ICELANDIC, INDONESIAN ITALIAN,
JAPANESE, KANNADA, KOREAN, LATIN AMERICAN SPANISH, LATVIAN,
LITHUANIAN, MACEDONIAN, MALAY, MEXICAN SPANISH, NORWEGIAN, POLISH,
PORTUGUESE, ROMANIAN, RUSSIAN, SIMPLIFIED CHINESE, SLOVAK, SLOVENIAN,
SPANISH, SWAHILI, SWEDISH, TAMIL, THAI, TRADITIONAL CHINESE, TURKISH,
UKRAINIAN, VIETNAMESE
Development bugs fixed:
MDEV-38403 Server crashes in Item_func_to_date::fix_length_and_dec upon
using an invalid argument
MDEV-38400 compat/oracle.func_to_date fails with PS protocol and cursor
protocol (Fixed by Serg)
MDEV-38404 TO_DATE: MTR coverage omissions, round 1
MDEV-38509 TO_DATE: AD_DOT does not appear to be supported
MDEV-38513 TO_DATE: NULL value for format string causes assertion failure
MDEV-38521 TO_DATE: Date strings with non-ASCII symbols cause warnings
and wrong results
MDEV-38578 TO_DATE: Possibly unexpected results upon wrong input
MDEV-38582 TO_DATE: NLS_DATE_LANGUAGE=JAPANESE does not parse values
which work in Oracle
MDEV-38584 TO_DATE: NLS_DATE_LANGUAGE=VIETNAMESE does not parse values
which work in Oracle
MDEV-38703 TO_DATE: Quotation for multi-word NLS_DATE_LANGUAGE leads
to syntax error in view definition
MDEV-38675 TO_DATE: MSAN/Valgrind/UBSAN errors in
extract_oracle_date_time
MDEV-38635 TO_DATE: UBSAN errors in item_timefunc.h upon comparison with
a view column
MDEV-38719 TO_DATE: Assertion `&my_charset_bin != charset()' failed in
String::append_for_single_quote_using_mb_wc
MDEV-38756 TO_DATE: MSAN/Valgrind errors in
Item_func_to_date::fix_length_and_dec upon PREPARE with
parameters
Known issues:
- Format string character matches inside quotes are done
one-letter-to-one-letter, like in LIKE predicate. That means things
like expansions and contractions do not work.
For example 'ss' does not match 'ß' in collations which treat them
as equal for the comparison operator.
Match is done taking into account case and accent sensitivity
of the subject argument collation, so for example this now works:
MariaDB [test]> SELECT TO_DATE('1920á12','YYYY"a"MM') AS c;
+---------------------+
| c |
+---------------------+
| 1920-12-17 00:00:00 |
+---------------------+
Co-author and reviewer: Alexander Barkov <bar@mariadb.com>
removed: * DES encryption * --secure-auth * --old * spider table options: bfz, btt, cmd, ctp, cwg, isa, ilm, ios, smd, stc, stl extended under old-mode: * YEAR(2), still available when old-mode=2_DIGIT_YEAR un-deprecated: * keep_files_on_create, originally (MDEV-23570) the idea was to make it TRUE and deprecate. It cannot be removed when FALSE, but TRUE breaks mariabackup.aria_backup where a table is altered from Aria to InnoDB during a backup, so both t.MAD/t.MAI and t.ibd gets into a backup.
- Scoped partial optimization for MDEV-21543 improving PAD SPACE collations for multibyte character sets in HA_KEYTYPE_VARTEXT1. - This keeps the old behavior for other cases until MDEV-38712 is resolved. - Benchmark: see zulip topic in the PR description - Results: - ~3.1% lower wall-clock time - ~2.1% fewer CPU cycles - ~0.5% fewer retired instructions - ~0.7% fewer branch mispredictions
…r_sql_thread Pure refactoring for clarity. No functional changes.
Master_Server_Id was not cleared after CHANGE MASTER or RESET SLAVE, showing a stale value until the slave reconnected. Reset master_id and prev_master_id to 0 in both code paths. The reset value (0) will be present in SHOW SLAVE STATUS until it is re-evaluated to the id of a new connected master server. Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
Add support for reversed executable comments using /*!!version */ and /*M!!version */ syntax. These execute the comment body only when the server version is strictly less than the specified version, which is the inverse of the existing /*!version */ syntax. This enables writing portable SQL that uses newer syntax on new servers while falling back to older syntax on older servers, e.g.: CREATE /*!100000 OR REPLACE */ TABLE /*!!100000 IF NOT EXISTS */ t1 ... On MariaDB >= 10.0 this expands to CREATE OR REPLACE TABLE t1, while on older versions it expands to CREATE TABLE IF NOT EXISTS t1. Implementation: in lex_one_token(), after detecting a versioned comment (/*! or /*M!), check for an additional '!' character. If present, invert the version comparison so the comment body is expanded only when MYSQL_VERSION_ID < version. Tests added to main.comments and plugins.server_audit confirming: - Reversed comments with version <= server version do not execute - Reversed comments with version > server version execute - MariaDB-specific /*M!! variant works correctly - Reversed comments without a version number always execute - Audit plugin correctly logs executed reversed comments - Combined forward + reversed comments in a single statement All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
There is a lot of more work needed to make this code compatitble with the rest of the MariaDB server. - All std:: usage should be removed - Most templatest should be removed - Usage of <unordered_map>, <string_view>, <optional>, <unordered_set> should be removed and replaced with my_sys, sql_string functions It would be nice of one could also have default values for all the CHANGE MASTER variables in my.cnf. This would allow one to have much shorter CHANGE MASTER commands
…ns (fix) Correct compilation on clang-20 by using a bitwise & rather than the incorrect &&.
MDL_context_owner was introduced in MySQL for gtest unit testing of MDL, which MariaDB doesn't use. Its virtual methods (enter_cond, exit_cond, is_killed, get_thd, notify_shared_lock) are not MDL-specific - they are part of THD and were only encapsulated in MDL_context_owner as a misleading abstraction. This is a cleanup that: - Removes the MDL_context_owner class entirely - Removes THD's inheritance from MDL_context_owner - Changes MDL to use THD* directly instead of MDL_context_owner* - Removes the redundant MDL_context::get_owner() method - Moves ENTER_COND/EXIT_COND macros to sql_class.h near THD_ENTER_COND
THD::get_thd() is never used after MDEV-34848 cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated the error message format and all related call sites to use %zu (size_t format) and size_t arguments, ensuring proper handling of large memory values without overflow risk.
Changes Made
Error Message Format
Changed ER_OUTOFMEMORY format from %d to %zu across all language variants.
Fixed a malformed Georgian translation line (missing closing quote).
Source Code Updates
Removed (int) casts and ensured size_t arguments in my_error(ER_OUTOFMEMORY, ...) calls.
Files: handler.cc, item_jsonfunc.cc, item_strfunc.cc, session_tracker.cc, set_var.cc.