718
725
thd->convert_string(&tmp, system_charset_info,
719
726
packet, packet_length-1, thd->charset());
720
if (!mysql_change_db(thd, tmp.str, FALSE))
727
if (!mysql_change_db(thd, &tmp, FALSE))
722
729
general_log_print(thd, command, "%s",thd->db);
783
790
uint passwd_len= (thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
784
791
*passwd++ : strlen(passwd));
785
uint dummy_errors, save_db_length, db_length, res;
792
uint dummy_errors, save_db_length, db_length;
786
794
Security_context save_security_ctx= *thd->security_ctx;
787
795
USER_CONN *save_user_connect;
829
837
/* authentication failure, we shall restore old user */
831
839
my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
841
thd->clear_error(); // Error already sent to client
832
842
x_free(thd->security_ctx->user);
833
843
*thd->security_ctx= save_security_ctx;
834
844
thd->user_connect= save_user_connect;
981
991
/* init structures for VIEW processing */
982
992
table_list.select_lex= &(thd->lex->select_lex);
983
mysql_init_query(thd, (uchar*)"", 0);
993
mysql_init_query(thd, "", 0);
985
995
select_lex.table_list.link_in_list((byte*) &table_list,
986
996
(byte**) &table_list.next_local);
1150
1161
statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_STATUS],
1152
1163
calc_sum_of_all_status(¤t_global_status_var);
1153
uptime= (ulong) (thd->start_time - server_start_time);
1164
if (!(uptime= (ulong) (thd->start_time - server_start_time)))
1165
queries_per_second1000= 0;
1167
queries_per_second1000= thd->query_id * LL(1000) / uptime;
1154
1169
length= my_snprintf((char*) buff, buff_len - 1,
1155
1170
"Uptime: %lu Threads: %d Questions: %lu "
1156
1171
"Slow queries: %lu Opens: %lu Flush tables: %lu "
1157
"Open tables: %u Queries per second avg: %.3f",
1172
"Open tables: %u Queries per second avg: %u.%u",
1159
1174
(int) thread_count, (ulong) thd->query_id,
1160
1175
current_global_status_var.long_query_count,
1161
1176
current_global_status_var.opened_tables,
1162
1177
refresh_version,
1163
1178
cached_open_tables(),
1164
(uptime ? (ulonglong2double(thd->query_id) /
1165
(double) uptime) : (double) 0));
1179
(uint) (queries_per_second1000 / 1000),
1180
(uint) (queries_per_second1000 % 1000));
1166
1181
#ifdef SAFEMALLOC
1167
1182
if (sf_malloc_cur_memory) // Using SAFEMALLOC
1348
1363
int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
1349
1364
enum enum_schema_tables schema_table_idx)
1366
SELECT_LEX *schema_select_lex= NULL;
1351
1367
DBUG_ENTER("prepare_schema_table");
1353
1369
switch (schema_table_idx) {
1354
1370
case SCH_SCHEMATA:
1355
1371
#if defined(DONT_ALLOW_SHOW_COMMANDS)
1381
1395
DBUG_RETURN(1);
1383
db.str= lex->select_lex.db;
1397
schema_select_lex= new SELECT_LEX();
1398
db.str= schema_select_lex->db= lex->select_lex.db;
1399
schema_select_lex->table_list.first= NULL;
1384
1400
db.length= strlen(db.str);
1385
1402
if (check_db_name(&db))
1387
1404
my_error(ER_WRONG_DB_NAME, MYF(0), db.str);
1388
1405
DBUG_RETURN(1);
1390
if (check_access(thd, SELECT_ACL, db.str, &thd->col_access, 0, 0,
1391
is_schema_db(db.str)))
1392
DBUG_RETURN(1); /* purecov: inspected */
1393
if (!thd->col_access && check_grant_db(thd, db.str))
1395
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
1396
thd->security_ctx->priv_user, thd->security_ctx->priv_host,
1403
1410
case SCH_COLUMNS:
1404
1411
case SCH_STATISTICS:
1405
1413
#ifdef DONT_ALLOW_SHOW_COMMANDS
1406
1414
my_message(ER_NOT_ALLOWED_COMMAND,
1407
1415
ER(ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */
1408
1416
DBUG_RETURN(1);
1412
TABLE_LIST **query_tables_last= lex->query_tables_last;
1413
sel= new SELECT_LEX();
1414
/* 'parent_lex' is used in init_query() so it must be before it. */
1415
sel->parent_lex= lex;
1417
if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ,
1418
(List<String> *) 0, (List<String> *) 0))
1420
lex->query_tables_last= query_tables_last;
1421
TABLE_LIST *table_list= (TABLE_LIST*) sel->table_list.first;
1422
char *db= table_list->db;
1423
if (check_access(thd,SELECT_ACL | EXTRA_ACL,db,
1424
&table_list->grant.privilege, 0, 0,
1425
test(table_list->schema_table)))
1426
DBUG_RETURN(1); /* purecov: inspected */
1427
if (grant_option && check_grant(thd, SELECT_ACL, table_list, 2,
1418
DBUG_ASSERT(table_ident);
1419
TABLE_LIST **query_tables_last= lex->query_tables_last;
1420
schema_select_lex= new SELECT_LEX();
1421
/* 'parent_lex' is used in init_query() so it must be before it. */
1422
schema_select_lex->parent_lex= lex;
1423
schema_select_lex->init_query();
1424
if (!schema_select_lex->add_table_to_list(thd, table_ident, 0, 0, TL_READ))
1426
lex->query_tables_last= query_tables_last;
1433
1430
case SCH_OPEN_TABLES:
1434
1431
case SCH_VARIABLES:
2171
2167
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE))
2173
2169
TABLE_LIST *duplicate;
2174
if ((duplicate= unique_table(thd, create_table, select_tables)))
2170
if ((duplicate= unique_table(thd, create_table, select_tables, 0)))
2176
2172
update_non_unique_table_error(create_table, "CREATE", duplicate);
2596
2592
case SQLCOM_REPLACE:
2594
if (mysql_bin_log.is_open())
2597
Generate an incident log event before writing the real event
2598
to the binary log. We put this event is before the statement
2599
since that makes it simpler to check that the statement was
2600
not executed on the slave (since incidents usually stop the
2603
Observe that any row events that are generated will be
2606
This is only for testing purposes and will not be present in a
2610
Incident incident= INCIDENT_NONE;
2611
DBUG_PRINT("debug", ("Just before generate_incident()"));
2612
DBUG_EXECUTE_IF("incident_database_resync_on_replace",
2613
incident= INCIDENT_LOST_EVENTS;);
2616
Incident_log_event ev(thd, incident);
2617
mysql_bin_log.write(&ev);
2618
mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
2620
DBUG_PRINT("debug", ("Just after generate_incident()"));
2597
2623
case SQLCOM_INSERT:
2599
2625
DBUG_ASSERT(first_table == all_tables && first_table != 0);
3151
3182
switch (lex->sql_command) {
3152
3183
case SQLCOM_CREATE_EVENT:
3153
res= Events::get_instance()->
3154
create_event(thd, lex->event_parse_data,
3155
lex->create_info.options & HA_LEX_CREATE_IF_NOT_EXISTS);
3185
bool if_not_exists= (lex->create_info.options &
3186
HA_LEX_CREATE_IF_NOT_EXISTS);
3187
res= Events::create_event(thd, lex->event_parse_data, if_not_exists);
3157
3190
case SQLCOM_ALTER_EVENT:
3158
res= Events::get_instance()->update_event(thd, lex->event_parse_data,
3191
res= Events::update_event(thd, lex->event_parse_data,
3192
lex->spname ? &lex->spname->m_db : NULL,
3193
lex->spname ? &lex->spname->m_name : NULL);
3162
3196
DBUG_ASSERT(0);
3175
3209
/* lex->unit.cleanup() is called outside, no need to call it here */
3211
case SQLCOM_SHOW_CREATE_EVENT:
3212
res= Events::show_create_event(thd, lex->spname->m_db,
3213
lex->spname->m_name);
3177
3215
case SQLCOM_DROP_EVENT:
3178
case SQLCOM_SHOW_CREATE_EVENT:
3180
DBUG_ASSERT(lex->spname);
3181
if (! lex->spname->m_db.str)
3183
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
3186
if (check_access(thd, EVENT_ACL, lex->spname->m_db.str, 0, 0, 0,
3187
is_schema_db(lex->spname->m_db.str)))
3190
if (lex->spname->m_name.length > NAME_LEN)
3192
my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str);
3193
/* this jumps to the end of the function and skips own messaging */
3197
if (lex->sql_command == SQLCOM_SHOW_CREATE_EVENT)
3198
res= Events::get_instance()->show_create_event(thd, lex->spname->m_db,
3199
lex->spname->m_name);
3202
if (!(res= Events::get_instance()->drop_event(thd,
3204
lex->spname->m_name,
3205
lex->drop_if_exists)))
3216
if (!(res= Events::drop_event(thd,
3217
lex->spname->m_db, lex->spname->m_name,
3218
lex->drop_if_exists)))
3210
3221
case SQLCOM_CREATE_FUNCTION: // UDF function
3212
3223
if (check_access(thd,INSERT_ACL,"mysql",0,1,0,0))
3967
3976
case SQLCOM_SHOW_CREATE_PROC:
3969
if (lex->spname->m_name.length > NAME_LEN)
3971
my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str);
3974
3978
if (sp_show_create_procedure(thd, lex->spname) != SP_OK)
3975
3979
{ /* We don't distinguish between errors for now */
3976
3980
my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
3982
3986
case SQLCOM_SHOW_CREATE_FUNC:
3984
if (lex->spname->m_name.length > NAME_LEN)
3986
my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str);
3989
3988
if (sp_show_create_function(thd, lex->spname) != SP_OK)
3990
3989
{ /* We don't distinguish between errors for now */
3991
3990
my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
4017
if (lex->spname->m_name.length > NAME_LEN)
4019
my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str);
4022
4016
if (lex->sql_command == SQLCOM_SHOW_PROC_CODE)
4023
4017
sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname,
4024
4018
&thd->sp_proc_cache, FALSE);
4109
4103
thd->transaction.xid_state.xa_state=XA_ACTIVE;
4110
4104
thd->transaction.xid_state.xid.set(thd->lex->xid);
4111
4105
xid_cache_insert(&thd->transaction.xid_state);
4112
thd->options= ((thd->options & ~(OPTION_STATUS_NO_TRANS_UPDATE |
4106
thd->options= ((thd->options & ~(OPTION_KEEP_LOG)) | OPTION_BEGIN);
4107
thd->no_trans_update.all= FALSE;
4115
4108
thd->server_status|= SERVER_STATUS_IN_TRANS;
4204
4197
xa_state_names[thd->transaction.xid_state.xa_state]);
4207
thd->options&= ~(OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE |
4200
thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
4201
thd->no_trans_update.all= FALSE;
4209
4202
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
4210
4203
xid_cache_delete(&thd->transaction.xid_state);
4211
4204
thd->transaction.xid_state.xa_state=XA_NOTR;
4235
4228
my_error(ER_XAER_RMERR, MYF(0));
4238
thd->options&= ~(OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE |
4231
thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
4232
thd->no_trans_update.all= FALSE;
4240
4233
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
4241
4234
xid_cache_delete(&thd->transaction.xid_state);
4242
4235
thd->transaction.xid_state.xa_state=XA_NOTR;
4304
4305
LEX *lex= thd->lex;
4305
4306
DBUG_PRINT("info", ("case SQLCOM_DROP_SERVER"));
4308
if (check_global_access(thd, SUPER_ACL))
4306
4311
if ((err_code= drop_server(thd, &lex->server_options)))
4308
if (! lex->drop_if_exists && err_code == ER_FOREIGN_SERVER_EXISTS)
4313
if (! lex->drop_if_exists && err_code == ER_FOREIGN_SERVER_DOESNT_EXIST)
4310
4315
DBUG_PRINT("info", ("problem dropping server %s",
4311
4316
lex->server_options.server_name));
4454
4461
db_name= all_tables->db;
4456
4463
if (check_access(thd, privilege, db_name,
4457
&all_tables->grant.privilege, 0, 0,
4464
&all_tables->grant.privilege, 0, no_errors,
4458
4465
test(all_tables->schema_table)))
4461
4468
/* Show only 1 table for check_grant */
4462
if (grant_option && check_grant(thd, privilege, all_tables, 0, 1, 0))
4470
!(all_tables->belong_to_view &&
4471
(thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) &&
4472
check_grant(thd, privilege, all_tables, 0, 1, no_errors))
4465
4475
thd->security_ctx= backup_ctx;
4488
4498
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *all_tables)
4490
if (check_single_table_access (thd,privilege,all_tables))
4500
if (check_single_table_access (thd,privilege,all_tables, FALSE))
4493
4503
/* Check rights on tables of subselects and implictly opened tables */
4689
static bool check_show_access(THD *thd, TABLE_LIST *table)
4691
switch (get_schema_table_idx(table->schema_table)) {
4693
return (specialflag & SPECIAL_SKIP_SHOW_DB) &&
4694
check_global_access(thd, SHOW_DB_ACL);
4696
case SCH_TABLE_NAMES:
4702
const char *dst_db_name= table->schema_select_lex->db;
4704
DBUG_ASSERT(dst_db_name);
4706
if (check_access(thd, SELECT_ACL, dst_db_name,
4707
&thd->col_access, FALSE, FALSE,
4708
is_schema_db(dst_db_name)))
4711
if (!thd->col_access && check_grant_db(thd, dst_db_name))
4713
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
4714
thd->security_ctx->priv_user,
4715
thd->security_ctx->priv_host,
4724
case SCH_STATISTICS:
4726
TABLE_LIST *dst_table;
4727
dst_table= (TABLE_LIST *) table->schema_select_lex->table_list.first;
4729
DBUG_ASSERT(dst_table);
4731
if (check_access(thd, SELECT_ACL | EXTRA_ACL,
4733
&dst_table->grant.privilege,
4735
test(dst_table->schema_table)))
4738
return (grant_option &&
4739
check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE));
4680
4750
Check the privilege for all used tables.
4736
4806
Remove SHOW_VIEW_ACL, because it will be checked during making view
4738
4808
tables->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL);
4739
if (tables->derived || tables->schema_table ||
4740
(tables->table && (int)tables->table->s->tmp_table) ||
4741
my_tz_check_n_skip_implicit_tables(&tables,
4742
thd->lex->time_zone_tables_used))
4810
if (tables->schema_table_reformed)
4812
if (check_show_access(thd, tables))
4818
if (tables->derived ||
4819
(tables->table && (int)tables->table->s->tmp_table))
4744
4821
thd->security_ctx= sctx;
4745
4822
if ((sctx->master_access & want_access) ==
4971
5048
****************************************************************************/
4974
mysql_init_query(THD *thd, uchar *buf, uint length)
5051
mysql_init_query(THD *thd, const char *buf, uint length)
4976
5053
DBUG_ENTER("mysql_init_query");
4977
5054
lex_start(thd, buf, length);
5195
5275
DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on(););
5197
mysql_init_query(thd, (uchar*) inBuf, length);
5277
mysql_init_query(thd, inBuf, length);
5198
5279
if (query_cache_send_result_to_client(thd, inBuf, length) <= 0)
5200
5281
LEX *lex= thd->lex;
5274
5355
DBUG_ENTER("mysql_test_parse_for_slave");
5276
mysql_init_query(thd, (uchar*) inBuf, length);
5357
mysql_init_query(thd, inBuf, length);
5277
5358
if (!MYSQLparse((void*) thd) && ! thd->is_fatal_error &&
5278
5359
all_tables_not_ok(thd,(TABLE_LIST*) lex->select_lex.table_list.first))
5279
5360
error= 1; /* Ignore question */
5290
5371
** Return 0 if ok
5291
5372
******************************************************************************/
5293
bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
5374
bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
5294
5375
char *length, char *decimals,
5295
5376
uint type_modifier,
5296
5377
Item *default_value, Item *on_update_value,
5303
5384
LEX *lex= thd->lex;
5304
5385
DBUG_ENTER("add_field_to_list");
5306
if (strlen(field_name) > NAME_LEN)
5387
if (check_string_char_length(field_name, "", NAME_CHAR_LEN,
5388
system_charset_info, 1))
5308
my_error(ER_TOO_LONG_IDENT, MYF(0), field_name); /* purecov: inspected */
5390
my_error(ER_TOO_LONG_IDENT, MYF(0), field_name->str); /* purecov: inspected */
5309
5391
DBUG_RETURN(1); /* purecov: inspected */
5311
5393
if (type_modifier & PRI_KEY_FLAG)
5313
lex->col_list.push_back(new key_part_spec(field_name,0));
5395
lex->col_list.push_back(new key_part_spec(field_name->str, 0));
5314
5396
lex->key_list.push_back(new Key(Key::PRIMARY, NullS,
5315
5397
&default_key_create_info,
5316
5398
0, lex->col_list));
5319
5401
if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG))
5321
lex->col_list.push_back(new key_part_spec(field_name,0));
5403
lex->col_list.push_back(new key_part_spec(field_name->str, 0));
5322
5404
lex->key_list.push_back(new Key(Key::UNIQUE, NullS,
5323
5405
&default_key_create_info, 0,
5324
5406
lex->col_list));
5338
5420
!(((Item_func*)default_value)->functype() == Item_func::NOW_FUNC &&
5339
5421
type == MYSQL_TYPE_TIMESTAMP))
5341
my_error(ER_INVALID_DEFAULT, MYF(0), field_name);
5423
my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
5342
5424
DBUG_RETURN(1);
5344
5426
else if (default_value->type() == Item::NULL_ITEM)
5347
5429
if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) ==
5350
my_error(ER_INVALID_DEFAULT, MYF(0), field_name);
5432
my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
5351
5433
DBUG_RETURN(1);
5354
5436
else if (type_modifier & AUTO_INCREMENT_FLAG)
5356
my_error(ER_INVALID_DEFAULT, MYF(0), field_name);
5438
my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
5357
5439
DBUG_RETURN(1);
5361
5443
if (on_update_value && type != MYSQL_TYPE_TIMESTAMP)
5363
my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name);
5445
my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name->str);
5364
5446
DBUG_RETURN(1);
5378
5460
if (!(new_field= new create_field()) ||
5379
new_field->init(thd, field_name, type, length, decimals, type_modifier,
5461
new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
5380
5462
default_value, on_update_value, comment, change,
5381
5463
interval_list, cs, uint_geom_type))
5382
5464
DBUG_RETURN(1);
5518
5599
ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);
5519
5600
ptr->derived= table->sel;
5520
5601
if (!ptr->derived && !my_strcasecmp(system_charset_info, ptr->db,
5521
information_schema_name.str))
5602
INFORMATION_SCHEMA_NAME.str))
5523
5604
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name);
5524
5605
if (!schema_table ||
5526
5607
(sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0))
5528
5609
my_error(ER_UNKNOWN_TABLE, MYF(0),
5529
ptr->table_name, information_schema_name.str);
5610
ptr->table_name, INFORMATION_SCHEMA_NAME.str);
5530
5611
DBUG_RETURN(0);
5532
5613
ptr->schema_table_name= ptr->table_name;
5535
5616
ptr->select_lex= lex->current_select;
5536
5617
ptr->cacheable_table= 1;
5538
ptr->use_index=(List<String> *) thd->memdup((gptr) use_index_arg,
5539
sizeof(*use_index_arg));
5540
if (ignore_index_arg)
5541
ptr->ignore_index=(List<String> *) thd->memdup((gptr) ignore_index_arg,
5542
sizeof(*ignore_index_arg));
5618
ptr->index_hints= index_hints_arg;
5543
5619
ptr->option= option ? option->str : 0;
5544
5620
/* check that used name is unique */
5545
5621
if (lock_type != TL_IGNORE)
6508
6584
Is there tables of subqueries?
6510
if (&lex->select_lex != lex->all_selects_list || lex->time_zone_tables_used)
6586
if (&lex->select_lex != lex->all_selects_list)
6512
6588
DBUG_PRINT("info",("Checking sub query list"));
6513
6589
for (table= tables; table; table= table->next_global)
6515
if (!my_tz_check_n_skip_implicit_tables(&table,
6516
lex->time_zone_tables_used) &&
6517
!table->table_in_first_from_clause)
6591
if (!table->table_in_first_from_clause)
6519
6593
if (check_access(thd, SELECT_ACL, table->db,
6520
6594
&table->grant.privilege, 0, 0,
6939
Check that length of a string does not exceed some limit.
7013
Check that byte length of a string does not exceed some limit.
6942
check_string_length()
6943
str string to be checked
6944
err_msg error message to be displayed if the string is too long
6945
max_length max length
7016
check_string_byte_length()
7017
str string to be checked
7018
err_msg error message to be displayed if the string is too long
7019
max_byte_length max length in bytes
6948
7022
FALSE the passed string is not longer than max_length
6949
7023
TRUE the passed string is longer than max_length
6952
bool check_string_length(LEX_STRING *str, const char *err_msg,
6955
if (str->length <= max_length)
6958
my_error(ER_WRONG_STRING_LENGTH, MYF(0), str->str, err_msg, max_length);
7026
The function is not used in existing code but can be useful later?
7029
bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
7030
uint max_byte_length)
7032
if (str->length <= max_byte_length)
7035
my_error(ER_WRONG_STRING_LENGTH, MYF(0), str->str, err_msg, max_byte_length);
7042
Check that char length of a string does not exceed some limit.
7045
check_string_char_length()
7046
str string to be checked
7047
err_msg error message to be displayed if the string is too long
7048
max_char_length max length in symbols
7052
FALSE the passed string is not longer than max_char_length
7053
TRUE the passed string is longer than max_char_length
7057
bool check_string_char_length(LEX_STRING *str, const char *err_msg,
7058
uint max_char_length, CHARSET_INFO *cs,
7061
int well_formed_error;
7062
uint res= cs->cset->well_formed_len(cs, str->str, str->str + str->length,
7063
max_char_length, &well_formed_error);
7065
if (!well_formed_error && str->length == res)
7069
my_error(ER_WRONG_STRING_LENGTH, MYF(0), str->str, err_msg, max_char_length);