MCPcopy Create free account
hub / github.com/MariaDB/server / init_from_sql_statement_string

Method init_from_sql_statement_string

sql/table.cc:3690–3791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3688}
3689
3690int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
3691 const char *sql, size_t sql_length)
3692{
3693 CHARSET_INFO *old_cs= thd->variables.character_set_client;
3694 Parser_state parser_state;
3695 bool error;
3696 char *sql_copy;
3697 handler *file;
3698 LEX *old_lex;
3699 LEX tmp_lex;
3700 KEY *unused1;
3701 uint unused2;
3702 handlerton *hton= plugin_hton(db_plugin);
3703 LEX_CUSTRING frm= {0,0};
3704 LEX_CSTRING db_backup= thd->db;
3705 DBUG_ENTER("TABLE_SHARE::init_from_sql_statement_string");
3706 DBUG_ASSERT(!thd->is_error());
3707
3708 /*
3709 Ouch. Parser may *change* the string it's working on.
3710 Currently (2013-02-26) it is used to permanently disable
3711 conditional comments.
3712 Anyway, let's copy the caller's string...
3713 */
3714 if (!(sql_copy= thd->strmake(sql, sql_length)))
3715 DBUG_RETURN(HA_ERR_OUT_OF_MEM);
3716
3717 if (parser_state.init(thd, sql_copy, sql_length))
3718 DBUG_RETURN(HA_ERR_OUT_OF_MEM);
3719
3720 Sql_mode_instant_set sms(thd, MODE_NO_ENGINE_SUBSTITUTION | MODE_NO_DIR_IN_CREATE);
3721 thd->variables.character_set_client= system_charset_info;
3722 tmp_disable_binlog(thd);
3723 old_lex= thd->lex;
3724 thd->lex= &tmp_lex;
3725
3726
3727 /*
3728 THD::reset_db() does not set THD::db_charset,
3729 so it keeps pointing to the character set and collation
3730 of the current database, rather than the database of the
3731 new initialized table. After reset_db() the result of
3732 get_default_db_collation() can be wrong. The latter is
3733 used inside charset_collation_context_create_table_in_db().
3734 Let's initialize ctx before calling reset_db().
3735 This makes sure the db.opt file to be loaded properly when needed.
3736 */
3737 Charset_collation_context
3738 ctx(thd->charset_collation_context_create_table_in_db(db.str));
3739
3740 thd->reset_db(&db);
3741 lex_start(thd);
3742
3743 if (unlikely((error= parse_sql(thd, & parser_state, NULL) ||
3744 sql_unusable_for_discovery(thd, hton, sql_copy))))
3745 goto ret;
3746
3747 if (thd->lex->create_info.resolve_to_charset_collation_context(thd, ctx))

Callers 9

ha_create_tableFunction · 0.80
hlindex_openMethod · 0.80
discover_tableFunction · 0.80
pfs_discover_tableFunction · 0.80
init_table_shareFunction · 0.80
discover_tableFunction · 0.80
discover_assistedMethod · 0.80

Calls 15

plugin_htonFunction · 0.85
lex_startFunction · 0.85
parse_sqlFunction · 0.85
mysql_create_frm_imageFunction · 0.85
my_freeFunction · 0.85
lex_endFunction · 0.85
my_errorFunction · 0.85
hton_nameFunction · 0.85
strmakeMethod · 0.80

Tested by 1

discover_tableFunction · 0.64