diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2017-03-31 01:14:00 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2017-03-31 01:14:00 +0300 |
commit | 5210c69e71ddcf39ca14194504e45baa4d325610 (patch) | |
tree | 846e5597b87730f756d2883af273ff90dc7fdb5d /sql/sql_show.cc | |
parent | c29336f2b0c99d39979609374b8673573475696f (diff) | |
parent | a0c79bcf0062adc2489f0b0bed98b05d4db8f476 (diff) | |
download | mariadb-git-5210c69e71ddcf39ca14194504e45baa4d325610.tar.gz |
Merge 10.2 into bb-10.2-mariarocks
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 79 |
1 files changed, 70 insertions, 9 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e176f7e6301..32e7d6f140b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4133,6 +4133,22 @@ make_table_name_list(THD *thd, Dynamic_array<LEX_STRING*> *table_names, } +static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl, + LEX_STRING *db, LEX_STRING *table) +{ + LEX_STRING engine_name= { buf, 0 }; + + if (thd->get_stmt_da()->sql_errno() == ER_UNKNOWN_STORAGE_ENGINE) + { + char path[FN_REFLEN]; + build_table_filename(path, sizeof(path) - 1, + db->str, table->str, reg_ext, 0); + if (dd_frm_type(thd, path, &engine_name) == FRMTYPE_TABLE) + tl->option= engine_name.str; + } +} + + /** Fill I_S table with data obtained by performing full-blown table open. @@ -4203,9 +4219,9 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys, /* Since make_table_list() might change database and table name passed - to it we create copies of orig_db_name and orig_table_name here. - These copies are used for make_table_list() while unaltered values - are passed to process_table() functions. + to it (if lower_case_table_names) we create copies of orig_db_name and + orig_table_name here. These copies are used for make_table_list() + while unaltered values are passed to process_table() functions. */ if (!thd->make_lex_string(&db_name, orig_db_name->str, orig_db_name->length) || @@ -4292,6 +4308,10 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys, } else { + char buf[NAME_CHAR_LEN + 1]; + if (thd->is_error()) + get_table_engine_for_i_s(thd, buf, table_list, &db_name, &table_name); + result= schema_table->process_table(thd, table_list, table, result, orig_db_name, @@ -4508,15 +4528,13 @@ try_acquire_high_prio_shared_mdl_lock(THD *thd, TABLE_LIST *table, open_tables function for this table */ -static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables, +static int fill_schema_table_from_frm(THD *thd, TABLE *table, ST_SCHEMA_TABLE *schema_table, LEX_STRING *db_name, LEX_STRING *table_name, - enum enum_schema_tables schema_table_idx, Open_tables_backup *open_tables_state_backup, bool can_deadlock) { - TABLE *table= tables->table; TABLE_SHARE *share; TABLE tbl; TABLE_LIST table_list; @@ -4598,7 +4616,19 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables, share= tdc_acquire_share(thd, &table_list, GTS_TABLE | GTS_VIEW); if (!share) { - res= 0; + if (thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE || + thd->get_stmt_da()->sql_errno() == ER_WRONG_OBJECT) + { + res= 0; + } + else + { + char buf[NAME_CHAR_LEN + 1]; + get_table_engine_for_i_s(thd, buf, &table_list, db_name, table_name); + + res= schema_table->process_table(thd, &table_list, table, + true, db_name, table_name); + } goto end; } @@ -4874,9 +4904,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) if (!(table_open_method & ~OPEN_FRM_ONLY) && db_name != &INFORMATION_SCHEMA_NAME) { - if (!fill_schema_table_from_frm(thd, tables, schema_table, + if (!fill_schema_table_from_frm(thd, table, schema_table, db_name, table_name, - schema_table_idx, &open_tables_state_backup, can_deadlock)) continue; @@ -5010,6 +5039,11 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, else table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs); + if (tables->option) + { + table->field[4]->store(tables->option, strlen(tables->option), cs); + table->field[4]->set_notnull(); + } goto err; } @@ -5505,13 +5539,24 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[17]->store(STRING_WITH_LEN("auto_increment"), cs); if (print_on_update_clause(field, &type, true)) table->field[17]->store(type.ptr(), type.length(), cs); + if (field->vcol_info) { + String gen_s(tmp,sizeof(tmp), system_charset_info); + gen_s.length(0); + field->vcol_info->print(&gen_s); + table->field[21]->store(gen_s.ptr(), gen_s.length(), cs); + table->field[21]->set_notnull(); + table->field[20]->store(STRING_WITH_LEN("ALWAYS"), cs); + if (field->vcol_info->stored_in_db) table->field[17]->store(STRING_WITH_LEN("STORED GENERATED"), cs); else table->field[17]->store(STRING_WITH_LEN("VIRTUAL GENERATED"), cs); } + else + table->field[20]->store(STRING_WITH_LEN("NEVER"), cs); + table->field[19]->store(field->comment.str, field->comment.length, cs); if (schema_table_store_record(thd, table)) DBUG_RETURN(1); @@ -6375,6 +6420,19 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, } } + // Table check constraints + for ( uint i = 0; i < show_table->s->table_check_constraints; i++ ) + { + Virtual_column_info *check = show_table->check_constraints[ i ]; + + if ( store_constraints( thd, table, db_name, table_name, check->name.str, + check->name.length, + STRING_WITH_LEN( "CHECK" ) ) ) + { + DBUG_RETURN( 1 ); + } + } + show_table->file->get_foreign_key_list(thd, &f_key_list); FOREIGN_KEY_INFO *f_key_info; List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list); @@ -8444,6 +8502,9 @@ ST_FIELD_INFO columns_fields_info[]= {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges", OPEN_FRM_ONLY}, {"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY}, + {"IS_GENERATED", 6, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY}, + {"GENERATION_EXPRESSION", MAX_FIELD_VARCHARLENGTH, MYSQL_TYPE_STRING, 0, 1, + 0, OPEN_FRM_ONLY}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; |