Reproducible on 10.2-10.4, with MyIsam/Innodb
set names utf8;
|
set use_stat_tables=complementary;
|
|
create table t1 ( a varchar(255) character set utf8);
|
insert into t1 values ('ӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥӥ');
|
|
analyze table t1;
|
select 1 from t1;
|
|
10.2 bf71d263621c90cbddc7bde
|
#0 0x5577ef4348a6 in Field::set_warning_truncated_wrong_value(char const*, char const*) /home/alice/git/10.2/sql/field.cc:10949
|
#1 0x5577ef413a76 in Field_longstr::check_string_copy_error(String_copier const*, char const*, charset_info_st const*) /home/alice/git/10.2/sql/field.cc:7031
|
#2 0x5577ef43746a in Field_longstr::check_conversion_status(String_copier const*, char const*, charset_info_st const*, bool) /home/alice/git/10.2/sql/field.h:1770
|
#3 0x5577ef4192d4 in Field_varstring::store(char const*, unsigned int, charset_info_st const*) /home/alice/git/10.2/sql/field.cc:7635
|
#4 0x5577ef05a995 in Column_stat::get_stat_values() (/home/alice/git/10.2/sql/mysqld+0xf7b995)
|
#5 0x5577ef04fd7d in read_statistics_for_table /home/alice/git/10.2/sql/sql_statistics.cc:2998
|
#6 0x5577ef051b09 in read_statistics_for_tables_if_needed(THD*, TABLE_LIST*) /home/alice/git/10.2/sql/sql_statistics.cc:3289
|
#7 0x5577eed987dc in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /home/alice/git/10.2/sql/sql_base.cc:4779
|
#8 0x5577eed7aa77 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /home/alice/git/10.2/sql/sql_base.h:506
|
#9 0x5577eeeab591 in execute_sqlcom_select /home/alice/git/10.2/sql/sql_parse.cc:6446
|
#10 0x5577eee98fac in mysql_execute_command(THD*) /home/alice/git/10.2/sql/sql_parse.cc:3537
|
#11 0x5577eeeb466c in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/alice/git/10.2/sql/sql_parse.cc:8059
|
#12 0x5577eee8f8d4 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/alice/git/10.2/sql/sql_parse.cc:1829
|
#13 0x5577eee8ca53 in do_command(THD*) /home/alice/git/10.2/sql/sql_parse.cc:1379
|
#14 0x5577ef1b52f2 in do_handle_one_connection(CONNECT*) /home/alice/git/10.2/sql/sql_connect.cc:1336
|
#15 0x5577ef1b4cfa in handle_one_connection /home/alice/git/10.2/sql/sql_connect.cc:1242
|
#16 0x5577f0365327 in pfs_spawn_thread /home/alice/git/10.2/storage/perfschema/pfs.cc:1862
|
#17 0x7fb000b9d6b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
|
#18 0x7fb00003241c in clone (/lib/x86_64-linux-gnu/libc.so.6+0x10741c)
|
|
Reproducible on non-debug build
10.3.13
|
190312 11:40:40 [ERROR] mysqld got signal 11 ;
|
|
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fc2c4b2a390]
|
sql/field.cc:11253(Field::set_warning_truncated_wrong_value(char const*, char const*))[0x557c68f3767b]
|
sql/field.cc:6963(Field_longstr::check_string_copy_error(String_copier const*, char const*, charset_info_st const*))[0x557c68f37777]
|
sql/field.h:1790(Field_longstr::check_conversion_status(String_copier const*, char const*, charset_info_st const*, bool))[0x557c68f3e6f1]
|
sql/field.h:3357(Field_varstring::store_length(unsigned int))[0x557c68f38056]
|
sql/sql_statistics.cc:1157(Column_stat::get_stat_values())[0x557c68dfaeef]
|
sql/sql_statistics.cc:4088(read_statistics_for_table)[0x557c68df96a4]
|
sql/sql_base.cc:5019(open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*))[0x557c68d33d72]
|
sql/sql_base.h:503(open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int))[0x557c68d06977]
|
sql/sql_parse.cc:6472(execute_sqlcom_select(THD*, TABLE_LIST*))[0x557c68ca10cd]
|
sql/sql_parse.cc:3772(mysql_execute_command(THD*))[0x557c68d8a78c]
|
sql/sql_class.h:1810(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x557c68d8cdf9]
|
sql/sql_parse.cc:1854(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x557c68d8ef95]
|
sql/sql_parse.cc:1398(do_command(THD*))[0x557c68d8f73e]
|
sql/sql_connect.cc:1403(do_handle_one_connection(CONNECT*))[0x557c68e573ff]
|
sql/sql_connect.cc:1311(handle_one_connection)[0x557c68e57524]
|
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7fc2c4b206ba]
|
x86_64/clone.S:111(clone)[0x7fc2c398541d]
|
|
Query (0x7fc2500115d0): select 1 from t1
|
{"report":{"fcp":751,"ttfb":183.79999995231628,"pageVisibility":"visible","entityId":73210,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"37c115ec-e4d7-4538-a186-7b3cc47f307d","navigationType":0,"readyForUser":837.5,"redirectCount":0,"resourceLoadedEnd":689.6000001430511,"resourceLoadedStart":189.40000009536743,"resourceTiming":[{"duration":52.39999985694885,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":189.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":189.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":241.79999995231628,"responseStart":0,"secureConnectionStart":0},{"duration":53,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":189.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":189.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":242.60000014305115,"responseStart":0,"secureConnectionStart":0},{"duration":106.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":189.70000004768372,"connectEnd":189.70000004768372,"connectStart":189.70000004768372,"domainLookupEnd":189.70000004768372,"domainLookupStart":189.70000004768372,"fetchStart":189.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":189.70000004768372,"responseEnd":296.40000009536743,"responseStart":296.40000009536743,"secureConnectionStart":189.70000004768372},{"duration":198.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":189.79999995231628,"connectEnd":189.79999995231628,"connectStart":189.79999995231628,"domainLookupEnd":189.79999995231628,"domainLookupStart":189.79999995231628,"fetchStart":189.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":189.79999995231628,"responseEnd":388.7000000476837,"responseStart":388.7000000476837,"secureConnectionStart":189.79999995231628},{"duration":202.39999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":189.90000009536743,"connectEnd":189.90000009536743,"connectStart":189.90000009536743,"domainLookupEnd":189.90000009536743,"domainLookupStart":189.90000009536743,"fetchStart":189.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":189.90000009536743,"responseEnd":392.2999999523163,"responseStart":392.2999999523163,"secureConnectionStart":189.90000009536743},{"duration":203.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":190,"connectEnd":190,"connectStart":190,"domainLookupEnd":190,"domainLookupStart":190,"fetchStart":190,"redirectEnd":0,"redirectStart":0,"requestStart":190,"responseEnd":393.10000014305115,"responseStart":393.10000014305115,"secureConnectionStart":190},{"duration":203.39999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":190.10000014305115,"connectEnd":190.10000014305115,"connectStart":190.10000014305115,"domainLookupEnd":190.10000014305115,"domainLookupStart":190.10000014305115,"fetchStart":190.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":190.10000014305115,"responseEnd":393.5,"responseStart":393.5,"secureConnectionStart":190.10000014305115},{"duration":203.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":190.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":190.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":394.10000014305115,"responseStart":0,"secureConnectionStart":0},{"duration":203.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":190.40000009536743,"connectEnd":190.40000009536743,"connectStart":190.40000009536743,"domainLookupEnd":190.40000009536743,"domainLookupStart":190.40000009536743,"fetchStart":190.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":190.40000009536743,"responseEnd":394.10000014305115,"responseStart":394.10000014305115,"secureConnectionStart":190.40000009536743},{"duration":204.20000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":190.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":190.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":394.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":204.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":190.79999995231628,"connectEnd":190.79999995231628,"connectStart":190.79999995231628,"domainLookupEnd":190.79999995231628,"domainLookupStart":190.79999995231628,"fetchStart":190.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":190.79999995231628,"responseEnd":394.90000009536743,"responseStart":394.90000009536743,"secureConnectionStart":190.79999995231628},{"duration":343.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":196.60000014305115,"connectEnd":196.60000014305115,"connectStart":196.60000014305115,"domainLookupEnd":196.60000014305115,"domainLookupStart":196.60000014305115,"fetchStart":196.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":196.60000014305115,"responseEnd":540.1000001430511,"responseStart":540.1000001430511,"secureConnectionStart":196.60000014305115},{"duration":473.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":197.20000004768372,"connectEnd":197.20000004768372,"connectStart":197.20000004768372,"domainLookupEnd":197.20000004768372,"domainLookupStart":197.20000004768372,"fetchStart":197.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":197.20000004768372,"responseEnd":671.1000001430511,"responseStart":671.1000001430511,"secureConnectionStart":197.20000004768372},{"duration":90.70000004768372,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":449.7999999523163,"connectEnd":449.7999999523163,"connectStart":449.7999999523163,"domainLookupEnd":449.7999999523163,"domainLookupStart":449.7999999523163,"fetchStart":449.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":449.7999999523163,"responseEnd":540.5,"responseStart":540.5,"secureConnectionStart":449.7999999523163},{"duration":33.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":656.1000001430511,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":656.1000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":689.6000001430511,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":36,"responseStart":184,"responseEnd":196,"domLoading":187,"domInteractive":909,"domContentLoadedEventStart":909,"domContentLoadedEventEnd":968,"domComplete":1073,"loadEventStart":1073,"loadEventEnd":1074,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":878.4000000953674},{"name":"bigPipe.sidebar-id.end","time":879.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.start","time":879.2999999523163},{"name":"bigPipe.activity-panel-pipe-id.end","time":882.5},{"name":"activityTabFullyLoaded","time":983.6000001430511}],"measures":[],"correlationId":"a0e38a743f3da0","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":87,"dbReadsTimeInMs":14,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The crash happens in Field_varstring::store() which is called from here:
table_field->read_stats->min_value->set_notnull();
stat_field->val_str(&val);
table_field->read_stats->min_value->store(val.ptr(), val.length(),
&my_charset_bin);
Field_varstring::store() tries to generate a warning, because the value in the column column_statistics.min_value is not well-formed: it has a hard limit of 255 bytes, so in this bug report on the position 255 it contains the first byte (of a two-byte character) without the second byte.
The warning is generated here:
{
THD *thd= get_thd();
...
}
Notice, it tries to get the db and the table from from "table", however "table" is a NULL pointer here.
table_field->read_stats->min_value is created here:
static
TABLE_SHARE *table_share)
{
...
{
Field *fld;
Field *table_field= *field_ptr;
my_ptrdiff_t diff= record - table_share->default_values;
table_field->read_stats->min_value= fld;
table_field->read_stats->max_value= fld;
}
...
}
The above code clones a Field instance but does not set the "table" pointer for the cloned Field.
Note, the original instance, table_field, does have a non-NULL pointer.
So a solution to fix the crash would probably to copy table_field->table to min_value and max_value.
However, it will fix only a part of the problem.
Well-formedness problem
It is generally wrong that any warnings are generated while copying from column_statistics.min_value.
1. either column_statistics.min_value should store well-formed values (e.g. don't break characters in the middle)
2. or the copying code should suppress warnings
Note, column_statistics.min_value can be modified manually. So probably both #1 and #2 are needed.
Contraction problem
Also, the underlying code should be checked for contraction compatibility. The code copying to column_statistics.min_value should make sure not to break contractions in the middle, otherwise max_value can be very far from the actual maximum value.
For example, consider this data in combination with Czech collation:
'ch' is a separate letter which is sorted between 'h' and 'i':
http://collation-charts.org/mysql60/mysql604.utf8_czech_ci.html
'ch' should not be broken into parts when copying to column_statistics.min_value:
'c' cannot be the last 255-th byte in column_statistics.min_value, because it was followed by 'h' in the original full-length data. The copying code should store only the REPEAT('x',254) part.
For column_statistics.max_value, the copying code will be even harder: it should replace 'ch' to the character which immediately follows 'ch' in the collation, which is 'i'.