mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge mishka.local:/tmp/skr99/mysql-5.0
into mishka.local:/home/my/mysql-5.0 sql/item_strfunc.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_show.cc: Auto merged
This commit is contained in:
@ -966,4 +966,8 @@ column_name column_default
|
|||||||
a NULL
|
a NULL
|
||||||
b NULL
|
b NULL
|
||||||
use test;
|
use test;
|
||||||
|
show columns from t1;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
a int(11) NO
|
||||||
|
b int(11) YES NULL
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
@ -245,6 +245,8 @@ end//
|
|||||||
grant usage on *.* to mysqltest_1@localhost;
|
grant usage on *.* to mysqltest_1@localhost;
|
||||||
call mysqltest_1.p1();
|
call mysqltest_1.p1();
|
||||||
ERROR 42000: execute command denied to user 'mysqltest_1'@'localhost' for routine 'mysqltest_1.p1'
|
ERROR 42000: execute command denied to user 'mysqltest_1'@'localhost' for routine 'mysqltest_1.p1'
|
||||||
|
call mysqltest_1.p1();
|
||||||
|
ERROR 42000: execute command denied to user 'mysqltest_1'@'localhost' for routine 'mysqltest_1.p1'
|
||||||
drop procedure mysqltest_1.p1;
|
drop procedure mysqltest_1.p1;
|
||||||
drop database mysqltest_1;
|
drop database mysqltest_1;
|
||||||
revoke usage on *.* from mysqltest_1@localhost;
|
revoke usage on *.* from mysqltest_1@localhost;
|
||||||
|
@ -649,4 +649,5 @@ use information_schema;
|
|||||||
select column_name, column_default from columns
|
select column_name, column_default from columns
|
||||||
where table_schema='test' and table_name='t1';
|
where table_schema='test' and table_name='t1';
|
||||||
use test;
|
use test;
|
||||||
|
show columns from t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
@ -397,6 +397,12 @@ connection n1;
|
|||||||
--error 1370
|
--error 1370
|
||||||
call mysqltest_1.p1();
|
call mysqltest_1.p1();
|
||||||
disconnect n1;
|
disconnect n1;
|
||||||
|
# Test also without a current database
|
||||||
|
connect (n2,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK);
|
||||||
|
connection n2;
|
||||||
|
--error 1370
|
||||||
|
call mysqltest_1.p1();
|
||||||
|
disconnect n2;
|
||||||
|
|
||||||
connection default;
|
connection default;
|
||||||
|
|
||||||
|
@ -730,7 +730,8 @@ static void close_connections(void)
|
|||||||
DBUG_PRINT("quit",("Informing thread %ld that it's time to die",
|
DBUG_PRINT("quit",("Informing thread %ld that it's time to die",
|
||||||
tmp->thread_id));
|
tmp->thread_id));
|
||||||
/* We skip slave threads on this first loop through. */
|
/* We skip slave threads on this first loop through. */
|
||||||
if (tmp->slave_thread) continue;
|
if (tmp->slave_thread)
|
||||||
|
continue;
|
||||||
|
|
||||||
tmp->killed= THD::KILL_CONNECTION;
|
tmp->killed= THD::KILL_CONNECTION;
|
||||||
if (tmp->mysys_var)
|
if (tmp->mysys_var)
|
||||||
|
@ -150,14 +150,10 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
|
|||||||
DBUG_ASSERT(share->table_name != 0);
|
DBUG_ASSERT(share->table_name != 0);
|
||||||
if ((!share->table_name)) // To be removed
|
if ((!share->table_name)) // To be removed
|
||||||
continue; // Shouldn't happen
|
continue; // Shouldn't happen
|
||||||
if (db && my_strcasecmp(system_charset_info, db, share->table_cache_key))
|
if (db && my_strcasecmp(system_charset_info, db, share->db))
|
||||||
|
continue;
|
||||||
|
if (wild && wild_compare(share->table_name,wild,0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (wild)
|
|
||||||
{
|
|
||||||
if (wild_compare(share->table_name,wild,0))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if user has SELECT privilege for any column in the table */
|
/* Check if user has SELECT privilege for any column in the table */
|
||||||
table_list.db= (char*) share->db;
|
table_list.db= (char*) share->db;
|
||||||
@ -3801,7 +3797,6 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
|
|||||||
if (cur_left_neighbor &&
|
if (cur_left_neighbor &&
|
||||||
cur_table_ref->outer_join & JOIN_TYPE_RIGHT)
|
cur_table_ref->outer_join & JOIN_TYPE_RIGHT)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(cur_table_ref);
|
|
||||||
/* This can happen only for JOIN ... ON. */
|
/* This can happen only for JOIN ... ON. */
|
||||||
DBUG_ASSERT(table_ref->nested_join->join_list.elements == 2);
|
DBUG_ASSERT(table_ref->nested_join->join_list.elements == 2);
|
||||||
swap_variables(TABLE_LIST*, cur_left_neighbor, cur_table_ref);
|
swap_variables(TABLE_LIST*, cur_left_neighbor, cur_table_ref);
|
||||||
@ -3811,7 +3806,7 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
|
|||||||
store_top_level_join_columns(thd, cur_table_ref,
|
store_top_level_join_columns(thd, cur_table_ref,
|
||||||
cur_left_neighbor, cur_right_neighbor))
|
cur_left_neighbor, cur_right_neighbor))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
cur_right_neighbor= cur_table_ref;
|
cur_right_neighbor= cur_table_ref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,7 +998,7 @@ err:
|
|||||||
mysql_change_db()
|
mysql_change_db()
|
||||||
thd Thread handler
|
thd Thread handler
|
||||||
name Databasename
|
name Databasename
|
||||||
no_access_check True= don't do access check
|
no_access_check True don't do access check. In this case name may be ""
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
Becasue the database name may have been given directly from the
|
Becasue the database name may have been given directly from the
|
||||||
@ -1025,14 +1025,22 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
|
|||||||
char *dbname=my_strdup((char*) name,MYF(MY_WME));
|
char *dbname=my_strdup((char*) name,MYF(MY_WME));
|
||||||
char path[FN_REFLEN];
|
char path[FN_REFLEN];
|
||||||
HA_CREATE_INFO create;
|
HA_CREATE_INFO create;
|
||||||
bool schema_db= 0;
|
bool system_db= 0;
|
||||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
ulong db_access;
|
ulong db_access;
|
||||||
#endif
|
#endif
|
||||||
DBUG_ENTER("mysql_change_db");
|
DBUG_ENTER("mysql_change_db");
|
||||||
|
DBUG_PRINT("enter",("name: '%s'",name));
|
||||||
|
|
||||||
|
/* dbname can only be NULL if malloc failed */
|
||||||
if (!dbname || !(db_length= strlen(dbname)))
|
if (!dbname || !(db_length= strlen(dbname)))
|
||||||
{
|
{
|
||||||
|
if (no_access_check && dbname)
|
||||||
|
{
|
||||||
|
/* Called from SP when orignal database was not set */
|
||||||
|
system_db= 1;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
x_free(dbname); /* purecov: inspected */
|
x_free(dbname); /* purecov: inspected */
|
||||||
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR),
|
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR),
|
||||||
MYF(0)); /* purecov: inspected */
|
MYF(0)); /* purecov: inspected */
|
||||||
@ -1047,7 +1055,7 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
|
|||||||
DBUG_PRINT("info",("Use database: %s", dbname));
|
DBUG_PRINT("info",("Use database: %s", dbname));
|
||||||
if (!my_strcasecmp(system_charset_info, dbname, information_schema_name.str))
|
if (!my_strcasecmp(system_charset_info, dbname, information_schema_name.str))
|
||||||
{
|
{
|
||||||
schema_db= 1;
|
system_db= 1;
|
||||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
db_access= SELECT_ACL;
|
db_access= SELECT_ACL;
|
||||||
#endif
|
#endif
|
||||||
@ -1055,13 +1063,15 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
if (!no_access_check) {
|
if (!no_access_check)
|
||||||
|
{
|
||||||
if (test_all_bits(thd->master_access,DB_ACLS))
|
if (test_all_bits(thd->master_access,DB_ACLS))
|
||||||
db_access=DB_ACLS;
|
db_access=DB_ACLS;
|
||||||
else
|
else
|
||||||
db_access= (acl_get(thd->host,thd->ip, thd->priv_user,dbname,0) |
|
db_access= (acl_get(thd->host,thd->ip, thd->priv_user,dbname,0) |
|
||||||
thd->master_access);
|
thd->master_access);
|
||||||
if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
|
if (!(db_access & DB_ACLS) && (!grant_option ||
|
||||||
|
check_grant_db(thd,dbname)))
|
||||||
{
|
{
|
||||||
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
|
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
|
||||||
thd->priv_user,
|
thd->priv_user,
|
||||||
@ -1094,7 +1104,7 @@ end:
|
|||||||
if (!no_access_check)
|
if (!no_access_check)
|
||||||
thd->db_access=db_access;
|
thd->db_access=db_access;
|
||||||
#endif
|
#endif
|
||||||
if (schema_db)
|
if (system_db)
|
||||||
{
|
{
|
||||||
thd->db_charset= system_charset_info;
|
thd->db_charset= system_charset_info;
|
||||||
thd->variables.collation_database= system_charset_info;
|
thd->variables.collation_database= system_charset_info;
|
||||||
|
@ -238,7 +238,8 @@ end:
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check if user exist and password supplied is correct.
|
Check if user exist and password supplied is correct.
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
check_user()
|
check_user()
|
||||||
thd thread handle, thd->{host,user,ip} are used
|
thd thread handle, thd->{host,user,ip} are used
|
||||||
@ -273,6 +274,10 @@ int check_user(THD *thd, enum enum_server_command command,
|
|||||||
/* Change database if necessary */
|
/* Change database if necessary */
|
||||||
if (db && db[0])
|
if (db && db[0])
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
thd->db is saved in caller and needs to be freed by caller if this
|
||||||
|
function returns 0
|
||||||
|
*/
|
||||||
thd->db= 0;
|
thd->db= 0;
|
||||||
thd->db_length= 0;
|
thd->db_length= 0;
|
||||||
if (mysql_change_db(thd, db, FALSE))
|
if (mysql_change_db(thd, db, FALSE))
|
||||||
|
379
sql/sql_show.cc
379
sql/sql_show.cc
@ -626,7 +626,7 @@ static const char *require_quotes(const char *name, uint name_length)
|
|||||||
uint length;
|
uint length;
|
||||||
const char *end= name + name_length;
|
const char *end= name + name_length;
|
||||||
|
|
||||||
for ( ; name < end ; name++)
|
for (; name < end ; name++)
|
||||||
{
|
{
|
||||||
uchar chr= (uchar) *name;
|
uchar chr= (uchar) *name;
|
||||||
length= my_mbcharlen(system_charset_info, chr);
|
length= my_mbcharlen(system_charset_info, chr);
|
||||||
@ -1914,7 +1914,7 @@ int make_db_list(THD *thd, List<char> *files,
|
|||||||
int schema_tables_add(THD *thd, List<char> *files, const char *wild)
|
int schema_tables_add(THD *thd, List<char> *files, const char *wild)
|
||||||
{
|
{
|
||||||
ST_SCHEMA_TABLE *tmp_schema_table= schema_tables;
|
ST_SCHEMA_TABLE *tmp_schema_table= schema_tables;
|
||||||
for ( ; tmp_schema_table->table_name; tmp_schema_table++)
|
for (; tmp_schema_table->table_name; tmp_schema_table++)
|
||||||
{
|
{
|
||||||
if (tmp_schema_table->hidden)
|
if (tmp_schema_table->hidden)
|
||||||
continue;
|
continue;
|
||||||
@ -2371,7 +2371,13 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
|
|||||||
LEX *lex= thd->lex;
|
LEX *lex= thd->lex;
|
||||||
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
|
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
|
||||||
CHARSET_INFO *cs= system_charset_info;
|
CHARSET_INFO *cs= system_charset_info;
|
||||||
|
TABLE *show_table;
|
||||||
|
handler *file;
|
||||||
|
Field **ptr,*field;
|
||||||
|
int count;
|
||||||
|
uint base_name_length, file_name_length;
|
||||||
DBUG_ENTER("get_schema_column_record");
|
DBUG_ENTER("get_schema_column_record");
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
if (lex->orig_sql_command != SQLCOM_SHOW_FIELDS)
|
if (lex->orig_sql_command != SQLCOM_SHOW_FIELDS)
|
||||||
@ -2388,189 +2394,187 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
|
|||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TABLE *show_table= tables->table;
|
show_table= tables->table;
|
||||||
handler *file= show_table->file;
|
file= show_table->file;
|
||||||
|
count= 0;
|
||||||
file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
|
file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
|
||||||
restore_record(show_table, s->default_values);
|
restore_record(show_table, s->default_values);
|
||||||
Field **ptr,*field;
|
base_name_length= strlen(base_name);
|
||||||
int count= 0;
|
file_name_length= strlen(file_name);
|
||||||
|
|
||||||
for (ptr=show_table->field; (field= *ptr) ; ptr++)
|
for (ptr=show_table->field; (field= *ptr) ; ptr++)
|
||||||
{
|
{
|
||||||
if (!wild || !wild[0] ||
|
const char *tmp_buff;
|
||||||
!wild_case_compare(system_charset_info, field->field_name,wild))
|
byte *pos;
|
||||||
{
|
bool is_blob;
|
||||||
const char *tmp_buff;
|
uint flags=field->flags;
|
||||||
byte *pos;
|
char tmp[MAX_FIELD_WIDTH];
|
||||||
bool is_blob;
|
char tmp1[MAX_FIELD_WIDTH];
|
||||||
uint flags=field->flags;
|
String type(tmp,sizeof(tmp), system_charset_info);
|
||||||
char tmp[MAX_FIELD_WIDTH];
|
char *end;
|
||||||
char tmp1[MAX_FIELD_WIDTH];
|
int decimals, field_length;
|
||||||
String type(tmp,sizeof(tmp), system_charset_info);
|
|
||||||
char *end= tmp;
|
if (wild && wild[0] &&
|
||||||
count++;
|
wild_case_compare(system_charset_info, field->field_name,wild))
|
||||||
restore_record(table, s->default_values);
|
continue;
|
||||||
|
|
||||||
|
flags= field->flags;
|
||||||
|
count++;
|
||||||
|
/* Get default row, with all NULL fields set to NULL */
|
||||||
|
restore_record(table, s->default_values);
|
||||||
|
|
||||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
uint col_access;
|
uint col_access;
|
||||||
check_access(thd,SELECT_ACL | EXTRA_ACL, base_name,
|
check_access(thd,SELECT_ACL | EXTRA_ACL, base_name,
|
||||||
&tables->grant.privilege, 0, 0);
|
&tables->grant.privilege, 0, 0);
|
||||||
col_access= get_column_grant(thd, &tables->grant,
|
col_access= get_column_grant(thd, &tables->grant,
|
||||||
base_name, file_name,
|
base_name, file_name,
|
||||||
field->field_name) & COL_ACLS;
|
field->field_name) & COL_ACLS;
|
||||||
if (lex->orig_sql_command != SQLCOM_SHOW_FIELDS &&
|
if (lex->orig_sql_command != SQLCOM_SHOW_FIELDS &&
|
||||||
!tables->schema_table && !col_access)
|
!tables->schema_table && !col_access)
|
||||||
continue;
|
continue;
|
||||||
for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
|
end= tmp;
|
||||||
|
for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
|
||||||
|
{
|
||||||
|
if (col_access & 1)
|
||||||
{
|
{
|
||||||
if (col_access & 1)
|
*end++=',';
|
||||||
{
|
end=strmov(end,grant_types.type_names[bitnr]);
|
||||||
*end++=',';
|
|
||||||
end=strmov(end,grant_types.type_names[bitnr]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (tables->schema_table) // any user has 'select' privilege on all
|
|
||||||
// I_S table columns
|
|
||||||
table->field[17]->store(grant_types.type_names[0],
|
|
||||||
strlen(grant_types.type_names[0]), cs);
|
|
||||||
else
|
|
||||||
table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs);
|
|
||||||
|
|
||||||
#else
|
|
||||||
*end= 0;
|
|
||||||
#endif
|
|
||||||
table->field[1]->store(base_name, strlen(base_name), cs);
|
|
||||||
table->field[2]->store(file_name, strlen(file_name), cs);
|
|
||||||
table->field[3]->store(field->field_name, strlen(field->field_name),
|
|
||||||
cs);
|
|
||||||
table->field[4]->store((longlong) count);
|
|
||||||
field->sql_type(type);
|
|
||||||
table->field[14]->store(type.ptr(), type.length(), cs);
|
|
||||||
tmp_buff= strchr(type.ptr(), '(');
|
|
||||||
table->field[7]->store(type.ptr(),
|
|
||||||
(tmp_buff ? tmp_buff - type.ptr() :
|
|
||||||
type.length()), cs);
|
|
||||||
if (show_table->timestamp_field == field &&
|
|
||||||
field->unireg_check != Field::TIMESTAMP_UN_FIELD)
|
|
||||||
{
|
|
||||||
table->field[5]->store("CURRENT_TIMESTAMP", 17, cs);
|
|
||||||
table->field[5]->set_notnull();
|
|
||||||
}
|
|
||||||
else if (field->unireg_check != Field::NEXT_NUMBER &&
|
|
||||||
!field->is_null() &&
|
|
||||||
!(field->flags & NO_DEFAULT_VALUE_FLAG))
|
|
||||||
{
|
|
||||||
String def(tmp1,sizeof(tmp1), cs);
|
|
||||||
type.set(tmp, sizeof(tmp), field->charset());
|
|
||||||
field->val_str(&type);
|
|
||||||
uint dummy_errors;
|
|
||||||
def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors);
|
|
||||||
table->field[5]->store(def.ptr(), def.length(), def.charset());
|
|
||||||
table->field[5]->set_notnull();
|
|
||||||
}
|
|
||||||
else if (field->unireg_check == Field::NEXT_NUMBER ||
|
|
||||||
lex->orig_sql_command != SQLCOM_SHOW_FIELDS ||
|
|
||||||
field->maybe_null())
|
|
||||||
table->field[5]->set_null(); // Null as default
|
|
||||||
else
|
|
||||||
{
|
|
||||||
table->field[5]->store("",0, cs);
|
|
||||||
table->field[5]->set_notnull();
|
|
||||||
}
|
|
||||||
pos=(byte*) ((flags & NOT_NULL_FLAG) &&
|
|
||||||
field->type() != FIELD_TYPE_TIMESTAMP ?
|
|
||||||
"NO" : "YES");
|
|
||||||
table->field[6]->store((const char*) pos,
|
|
||||||
strlen((const char*) pos), cs);
|
|
||||||
is_blob= (field->type() == FIELD_TYPE_BLOB);
|
|
||||||
if (field->has_charset() || is_blob)
|
|
||||||
{
|
|
||||||
longlong c_octet_len= is_blob ? (longlong) field->max_length() :
|
|
||||||
(longlong) field->max_length()/field->charset()->mbmaxlen;
|
|
||||||
table->field[8]->store(c_octet_len);
|
|
||||||
table->field[8]->set_notnull();
|
|
||||||
table->field[9]->store((longlong) field->max_length());
|
|
||||||
table->field[9]->set_notnull();
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
uint dec =field->decimals();
|
|
||||||
switch (field->type()) {
|
|
||||||
case FIELD_TYPE_NEWDECIMAL:
|
|
||||||
table->field[10]->store((longlong)
|
|
||||||
((Field_new_decimal*)field)->precision);
|
|
||||||
table->field[10]->set_notnull();
|
|
||||||
table->field[11]->store((longlong) field->decimals());
|
|
||||||
table->field[11]->set_notnull();
|
|
||||||
break;
|
|
||||||
case FIELD_TYPE_DECIMAL:
|
|
||||||
{
|
|
||||||
uint int_part=field->field_length - (dec ? dec + 1 : 0);
|
|
||||||
table->field[10]->store((longlong) (int_part + dec - 1));
|
|
||||||
table->field[10]->set_notnull();
|
|
||||||
table->field[11]->store((longlong) field->decimals());
|
|
||||||
table->field[11]->set_notnull();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FIELD_TYPE_TINY:
|
|
||||||
case FIELD_TYPE_SHORT:
|
|
||||||
case FIELD_TYPE_LONG:
|
|
||||||
case FIELD_TYPE_LONGLONG:
|
|
||||||
case FIELD_TYPE_INT24:
|
|
||||||
{
|
|
||||||
table->field[10]->store((longlong) field->max_length() - 1);
|
|
||||||
table->field[10]->set_notnull();
|
|
||||||
table->field[11]->store((longlong) 0);
|
|
||||||
table->field[11]->set_notnull();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FIELD_TYPE_BIT:
|
|
||||||
{
|
|
||||||
table->field[10]->store((longlong) field->max_length());
|
|
||||||
table->field[10]->set_notnull();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FIELD_TYPE_FLOAT:
|
|
||||||
case FIELD_TYPE_DOUBLE:
|
|
||||||
{
|
|
||||||
table->field[10]->store((longlong) field->field_length);
|
|
||||||
table->field[10]->set_notnull();
|
|
||||||
if (dec != NOT_FIXED_DEC)
|
|
||||||
{
|
|
||||||
table->field[11]->store((longlong) dec);
|
|
||||||
table->field[11]->set_notnull();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (field->has_charset())
|
|
||||||
{
|
|
||||||
pos=(byte*) field->charset()->csname;
|
|
||||||
table->field[12]->store((const char*) pos,
|
|
||||||
strlen((const char*) pos), cs);
|
|
||||||
table->field[12]->set_notnull();
|
|
||||||
pos=(byte*) field->charset()->name;
|
|
||||||
table->field[13]->store((const char*) pos,
|
|
||||||
strlen((const char*) pos), cs);
|
|
||||||
table->field[13]->set_notnull();
|
|
||||||
}
|
|
||||||
pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
|
|
||||||
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
|
|
||||||
(field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
|
|
||||||
table->field[15]->store((const char*) pos,
|
|
||||||
strlen((const char*) pos), cs);
|
|
||||||
end= tmp;
|
|
||||||
if (field->unireg_check == Field::NEXT_NUMBER)
|
|
||||||
end=strmov(tmp,"auto_increment");
|
|
||||||
table->field[16]->store(tmp, (uint) (end-tmp), cs);
|
|
||||||
|
|
||||||
end=tmp;
|
|
||||||
table->field[18]->store(field->comment.str, field->comment.length, cs);
|
|
||||||
if (schema_table_store_record(thd, table))
|
|
||||||
DBUG_RETURN(1);
|
|
||||||
}
|
}
|
||||||
|
if (tables->schema_table) // any user has 'select' privilege on all
|
||||||
|
// I_S table columns
|
||||||
|
table->field[17]->store(grant_types.type_names[0],
|
||||||
|
strlen(grant_types.type_names[0]), cs);
|
||||||
|
else
|
||||||
|
table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
table->field[1]->store(base_name, base_name_length, cs);
|
||||||
|
table->field[2]->store(file_name, file_name_length, cs);
|
||||||
|
table->field[3]->store(field->field_name, strlen(field->field_name),
|
||||||
|
cs);
|
||||||
|
table->field[4]->store((longlong) count);
|
||||||
|
field->sql_type(type);
|
||||||
|
table->field[14]->store(type.ptr(), type.length(), cs);
|
||||||
|
tmp_buff= strchr(type.ptr(), '(');
|
||||||
|
table->field[7]->store(type.ptr(),
|
||||||
|
(tmp_buff ? tmp_buff - type.ptr() :
|
||||||
|
type.length()), cs);
|
||||||
|
if (show_table->timestamp_field == field &&
|
||||||
|
field->unireg_check != Field::TIMESTAMP_UN_FIELD)
|
||||||
|
{
|
||||||
|
table->field[5]->store("CURRENT_TIMESTAMP", 17, cs);
|
||||||
|
table->field[5]->set_notnull();
|
||||||
|
}
|
||||||
|
else if (field->unireg_check != Field::NEXT_NUMBER &&
|
||||||
|
!field->is_null() &&
|
||||||
|
!(field->flags & NO_DEFAULT_VALUE_FLAG))
|
||||||
|
{
|
||||||
|
String def(tmp1,sizeof(tmp1), cs);
|
||||||
|
type.set(tmp, sizeof(tmp), field->charset());
|
||||||
|
field->val_str(&type);
|
||||||
|
uint dummy_errors;
|
||||||
|
def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors);
|
||||||
|
table->field[5]->store(def.ptr(), def.length(), def.charset());
|
||||||
|
table->field[5]->set_notnull();
|
||||||
|
}
|
||||||
|
else if (field->unireg_check == Field::NEXT_NUMBER ||
|
||||||
|
lex->orig_sql_command != SQLCOM_SHOW_FIELDS ||
|
||||||
|
field->maybe_null())
|
||||||
|
table->field[5]->set_null(); // Null as default
|
||||||
|
else
|
||||||
|
{
|
||||||
|
table->field[5]->store("",0, cs);
|
||||||
|
table->field[5]->set_notnull();
|
||||||
|
}
|
||||||
|
pos=(byte*) ((flags & NOT_NULL_FLAG) &&
|
||||||
|
field->type() != FIELD_TYPE_TIMESTAMP ?
|
||||||
|
"NO" : "YES");
|
||||||
|
table->field[6]->store((const char*) pos,
|
||||||
|
strlen((const char*) pos), cs);
|
||||||
|
is_blob= (field->type() == FIELD_TYPE_BLOB);
|
||||||
|
if (field->has_charset() || is_blob)
|
||||||
|
{
|
||||||
|
longlong c_octet_len= is_blob ? (longlong) field->max_length() :
|
||||||
|
(longlong) field->max_length()/field->charset()->mbmaxlen;
|
||||||
|
table->field[8]->store(c_octet_len);
|
||||||
|
table->field[8]->set_notnull();
|
||||||
|
table->field[9]->store((longlong) field->max_length());
|
||||||
|
table->field[9]->set_notnull();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Calculate field_length and decimals.
|
||||||
|
They are set to -1 if they should not be set (we should return NULL)
|
||||||
|
*/
|
||||||
|
|
||||||
|
decimals= field->decimals();
|
||||||
|
switch (field->type()) {
|
||||||
|
case FIELD_TYPE_NEWDECIMAL:
|
||||||
|
field_length= ((Field_new_decimal*) field)->precision;
|
||||||
|
break;
|
||||||
|
case FIELD_TYPE_DECIMAL:
|
||||||
|
field_length= field->field_length - (decimals ? 2 : 1);
|
||||||
|
break;
|
||||||
|
case FIELD_TYPE_TINY:
|
||||||
|
case FIELD_TYPE_SHORT:
|
||||||
|
case FIELD_TYPE_LONG:
|
||||||
|
case FIELD_TYPE_LONGLONG:
|
||||||
|
case FIELD_TYPE_INT24:
|
||||||
|
field_length= field->max_length() - 1;
|
||||||
|
break;
|
||||||
|
case FIELD_TYPE_BIT:
|
||||||
|
field_length= field->max_length();
|
||||||
|
decimals= -1; // return NULL
|
||||||
|
break;
|
||||||
|
case FIELD_TYPE_FLOAT:
|
||||||
|
case FIELD_TYPE_DOUBLE:
|
||||||
|
field_length= field->field_length;
|
||||||
|
if (decimals == NOT_FIXED_DEC)
|
||||||
|
decimals= -1; // return NULL
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
field_length= decimals= -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field_length >= 0)
|
||||||
|
{
|
||||||
|
table->field[10]->store((longlong) field_length);
|
||||||
|
table->field[10]->set_notnull();
|
||||||
|
}
|
||||||
|
if (decimals >= 0)
|
||||||
|
{
|
||||||
|
table->field[11]->store((longlong) decimals);
|
||||||
|
table->field[11]->set_notnull();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field->has_charset())
|
||||||
|
{
|
||||||
|
pos=(byte*) field->charset()->csname;
|
||||||
|
table->field[12]->store((const char*) pos,
|
||||||
|
strlen((const char*) pos), cs);
|
||||||
|
table->field[12]->set_notnull();
|
||||||
|
pos=(byte*) field->charset()->name;
|
||||||
|
table->field[13]->store((const char*) pos,
|
||||||
|
strlen((const char*) pos), cs);
|
||||||
|
table->field[13]->set_notnull();
|
||||||
|
}
|
||||||
|
pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
|
||||||
|
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
|
||||||
|
(field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
|
||||||
|
table->field[15]->store((const char*) pos,
|
||||||
|
strlen((const char*) pos), cs);
|
||||||
|
|
||||||
|
end= tmp;
|
||||||
|
if (field->unireg_check == Field::NEXT_NUMBER)
|
||||||
|
end=strmov(tmp,"auto_increment");
|
||||||
|
table->field[16]->store(tmp, (uint) (end-tmp), cs);
|
||||||
|
|
||||||
|
table->field[18]->store(field->comment.str, field->comment.length, cs);
|
||||||
|
if (schema_table_store_record(thd, table))
|
||||||
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
@ -2583,7 +2587,8 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
|
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
|
||||||
TABLE *table= tables->table;
|
TABLE *table= tables->table;
|
||||||
CHARSET_INFO *scs= system_charset_info;
|
CHARSET_INFO *scs= system_charset_info;
|
||||||
for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ )
|
|
||||||
|
for (cs= all_charsets ; cs < all_charsets+255 ; cs++)
|
||||||
{
|
{
|
||||||
CHARSET_INFO *tmp_cs= cs[0];
|
CHARSET_INFO *tmp_cs= cs[0];
|
||||||
if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) &&
|
if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) &&
|
||||||
@ -2591,12 +2596,12 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
!(wild && wild[0] &&
|
!(wild && wild[0] &&
|
||||||
wild_case_compare(scs, tmp_cs->csname,wild)))
|
wild_case_compare(scs, tmp_cs->csname,wild)))
|
||||||
{
|
{
|
||||||
|
const char *comment;
|
||||||
restore_record(table, s->default_values);
|
restore_record(table, s->default_values);
|
||||||
table->field[0]->store(tmp_cs->csname, strlen(tmp_cs->csname), scs);
|
table->field[0]->store(tmp_cs->csname, strlen(tmp_cs->csname), scs);
|
||||||
table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs);
|
table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs);
|
||||||
table->field[2]->store(tmp_cs->comment ? tmp_cs->comment : "",
|
comment= tmp_cs->comment ? tmp_cs->comment : "";
|
||||||
strlen(tmp_cs->comment ? tmp_cs->comment : ""),
|
table->field[2]->store(comment, strlen(comment), scs);
|
||||||
scs);
|
|
||||||
table->field[3]->store((longlong) tmp_cs->mbmaxlen);
|
table->field[3]->store((longlong) tmp_cs->mbmaxlen);
|
||||||
if (schema_table_store_record(thd, table))
|
if (schema_table_store_record(thd, table))
|
||||||
return 1;
|
return 1;
|
||||||
@ -2612,14 +2617,14 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
|
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
|
||||||
TABLE *table= tables->table;
|
TABLE *table= tables->table;
|
||||||
CHARSET_INFO *scs= system_charset_info;
|
CHARSET_INFO *scs= system_charset_info;
|
||||||
for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ )
|
for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
|
||||||
{
|
{
|
||||||
CHARSET_INFO **cl;
|
CHARSET_INFO **cl;
|
||||||
CHARSET_INFO *tmp_cs= cs[0];
|
CHARSET_INFO *tmp_cs= cs[0];
|
||||||
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
|
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
|
||||||
!(tmp_cs->state & MY_CS_PRIMARY))
|
!(tmp_cs->state & MY_CS_PRIMARY))
|
||||||
continue;
|
continue;
|
||||||
for ( cl= all_charsets; cl < all_charsets+255 ;cl ++)
|
for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
|
||||||
{
|
{
|
||||||
CHARSET_INFO *tmp_cl= cl[0];
|
CHARSET_INFO *tmp_cl= cl[0];
|
||||||
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
|
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
|
||||||
@ -2652,14 +2657,14 @@ int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
CHARSET_INFO **cs;
|
CHARSET_INFO **cs;
|
||||||
TABLE *table= tables->table;
|
TABLE *table= tables->table;
|
||||||
CHARSET_INFO *scs= system_charset_info;
|
CHARSET_INFO *scs= system_charset_info;
|
||||||
for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ )
|
for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
|
||||||
{
|
{
|
||||||
CHARSET_INFO **cl;
|
CHARSET_INFO **cl;
|
||||||
CHARSET_INFO *tmp_cs= cs[0];
|
CHARSET_INFO *tmp_cs= cs[0];
|
||||||
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
|
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
|
||||||
!(tmp_cs->state & MY_CS_PRIMARY))
|
!(tmp_cs->state & MY_CS_PRIMARY))
|
||||||
continue;
|
continue;
|
||||||
for ( cl= all_charsets; cl < all_charsets+255 ;cl ++)
|
for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
|
||||||
{
|
{
|
||||||
CHARSET_INFO *tmp_cl= cl[0];
|
CHARSET_INFO *tmp_cl= cl[0];
|
||||||
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
|
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
|
||||||
@ -3264,7 +3269,7 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name)
|
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name)
|
||||||
{
|
{
|
||||||
ST_SCHEMA_TABLE *schema_table= schema_tables;
|
ST_SCHEMA_TABLE *schema_table= schema_tables;
|
||||||
for ( ; schema_table->table_name; schema_table++)
|
for (; schema_table->table_name; schema_table++)
|
||||||
{
|
{
|
||||||
if (!my_strcasecmp(system_charset_info,
|
if (!my_strcasecmp(system_charset_info,
|
||||||
schema_table->table_name,
|
schema_table->table_name,
|
||||||
@ -3305,7 +3310,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
|
|||||||
CHARSET_INFO *cs= system_charset_info;
|
CHARSET_INFO *cs= system_charset_info;
|
||||||
DBUG_ENTER("create_schema_table");
|
DBUG_ENTER("create_schema_table");
|
||||||
|
|
||||||
for ( ; fields_info->field_name; fields_info++)
|
for (; fields_info->field_name; fields_info++)
|
||||||
{
|
{
|
||||||
switch (fields_info->field_type) {
|
switch (fields_info->field_type) {
|
||||||
case MYSQL_TYPE_LONG:
|
case MYSQL_TYPE_LONG:
|
||||||
@ -3374,7 +3379,7 @@ int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
|||||||
{
|
{
|
||||||
ST_FIELD_INFO *field_info= schema_table->fields_info;
|
ST_FIELD_INFO *field_info= schema_table->fields_info;
|
||||||
Name_resolution_context *context= &thd->lex->select_lex.context;
|
Name_resolution_context *context= &thd->lex->select_lex.context;
|
||||||
for ( ; field_info->field_name; field_info++)
|
for (; field_info->field_name; field_info++)
|
||||||
{
|
{
|
||||||
if (field_info->old_name)
|
if (field_info->old_name)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user