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

Function prepare_schema_table

sql/sql_parse.cc:2651–2737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2649*/
2650
2651int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
2652 enum enum_schema_tables schema_table_idx)
2653{
2654 SELECT_LEX *schema_select_lex= NULL;
2655 DBUG_ENTER("prepare_schema_table");
2656
2657 switch (schema_table_idx) {
2658 case SCH_SCHEMATA:
2659#if defined(DONT_ALLOW_SHOW_COMMANDS)
2660 my_message(ER_NOT_ALLOWED_COMMAND,
2661 ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0));
2662 DBUG_RETURN(1);
2663#else
2664 break;
2665#endif
2666
2667 case SCH_TABLE_NAMES:
2668 case SCH_TABLES:
2669 case SCH_CHECK_CONSTRAINTS:
2670 case SCH_VIEWS:
2671 case SCH_TRIGGERS:
2672 case SCH_EVENTS:
2673#ifdef DONT_ALLOW_SHOW_COMMANDS
2674 my_message(ER_NOT_ALLOWED_COMMAND,
2675 ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0));
2676 DBUG_RETURN(1);
2677#else
2678 {
2679 if (lex->first_select_lex()->db.str == NULL &&
2680 lex->copy_db_to(&lex->first_select_lex()->db))
2681 {
2682 DBUG_RETURN(1);
2683 }
2684 schema_select_lex= new (thd->mem_root) SELECT_LEX();
2685 schema_select_lex->table_list.first= NULL;
2686 if (lower_case_table_names == 1)
2687 lex->first_select_lex()->db=
2688 thd->make_ident_casedn(lex->first_select_lex()->db);
2689 schema_select_lex->db= lex->first_select_lex()->db;
2690 if (Lex_ident_db::check_name_with_error(lex->first_select_lex()->db))
2691 DBUG_RETURN(1);
2692 break;
2693 }
2694#endif
2695 case SCH_COLUMNS:
2696 case SCH_STATISTICS:
2697#ifdef DONT_ALLOW_SHOW_COMMANDS
2698 my_message(ER_NOT_ALLOWED_COMMAND,
2699 ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0));
2700 DBUG_RETURN(1);
2701#else
2702 {
2703 DBUG_ASSERT(table_ident);
2704 TABLE_LIST **query_tables_last= lex->query_tables_last;
2705 schema_select_lex= new (thd->mem_root) SELECT_LEX();
2706 /* 'parent_lex' is used in init_query() so it must be before it. */
2707 schema_select_lex->parent_lex= lex;
2708 schema_select_lex->init_query();

Callers

nothing calls this directly

Calls 10

my_messageFunction · 0.85
make_schema_selectFunction · 0.85
get_schema_tableFunction · 0.85
first_select_lexMethod · 0.80
make_ident_casednMethod · 0.80
init_queryMethod · 0.80
add_table_to_listMethod · 0.80
discard_current_queryMethod · 0.80
set_master_unitMethod · 0.80
copy_db_toMethod · 0.45

Tested by

no test coverage detected