Commit dc73a153 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  mishka.local:/home/my/mysql-5.0


mysql-test/r/information_schema.result:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
parents e583b08a 0776999d
......@@ -933,10 +933,10 @@ typedef char bool; /* Ordinary boolean values 0 1 */
(ABSTIME).ts_nsec=0; \
}
#define set_timespec_nsec(ABSTIME,NSEC) \
{\
ulonglong now= my_getsystime(); \
(ABSTIME).ts_sec= (now / ULL(10000000)) + (NSEC / ULL(1000000000)); \
(ABSTIME).ts_nsec= (now % ULL(10000000)) * 100 + (NSEC % ULL(1000000000)); \
{ \
ulonglong now= my_getsystime() + (NSEC/100); \
(ABSTIME).ts_sec= (now / ULL(10000000)); \
(ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
}
#else
#define set_timespec(ABSTIME,SEC) \
......@@ -948,9 +948,9 @@ typedef char bool; /* Ordinary boolean values 0 1 */
}
#define set_timespec_nsec(ABSTIME,NSEC) \
{\
ulonglong now= my_getsystime(); \
(ABSTIME).tv_sec= (now / ULL(10000000)) + (NSEC / ULL(1000000000)); \
(ABSTIME).tv_nsec= (now % ULL(10000000)) * 100 + (NSEC % ULL(1000000000)); \
ulonglong now= my_getsystime() + (NSEC/100); \
(ABSTIME).tv_sec= (now / ULL(10000000)); \
(ABSTIME).tv_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
}
#endif /* HAVE_TIMESPEC_TS_SEC */
#endif /* set_timespec */
......
......@@ -966,4 +966,8 @@ column_name column_default
a NULL
b NULL
use test;
show columns from t1;
Field Type Null Key Default Extra
a int(11) NO
b int(11) YES NULL
drop table t1;
......@@ -245,6 +245,8 @@ end//
grant usage on *.* to mysqltest_1@localhost;
call 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 database mysqltest_1;
revoke usage on *.* from mysqltest_1@localhost;
......
......@@ -649,4 +649,5 @@ use information_schema;
select column_name, column_default from columns
where table_schema='test' and table_name='t1';
use test;
show columns from t1;
drop table t1;
......@@ -397,6 +397,12 @@ connection n1;
--error 1370
call mysqltest_1.p1();
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;
......
......@@ -630,7 +630,7 @@ int Arg_comparator::compare_row()
owner->null_value= 0;
res= 0; // continue comparison (maybe we will meet explicit difference)
}
if (res)
else if (res)
return res;
}
if (was_null)
......@@ -645,6 +645,7 @@ int Arg_comparator::compare_row()
return 0;
}
int Arg_comparator::compare_e_row()
{
(*a)->bring_value();
......
......@@ -730,7 +730,8 @@ static void close_connections(void)
DBUG_PRINT("quit",("Informing thread %ld that it's time to die",
tmp->thread_id));
/* We skip slave threads on this first loop through. */
if (tmp->slave_thread) continue;
if (tmp->slave_thread)
continue;
tmp->killed= THD::KILL_CONNECTION;
if (tmp->mysys_var)
......
......@@ -127,15 +127,16 @@ sp_prepare_func_item(THD* thd, Item **it_addr)
/* Macro to switch arena in sp_eval_func_item */
#define CREATE_ON_CALLERS_ARENA(new_command, condition, backup_arena) do\
{\
#define CREATE_ON_CALLERS_ARENA(new_command, condition, backup_arena) \
do \
{ \
if (condition) \
thd->set_n_backup_item_arena(thd->spcont->callers_arena,\
backup_arena);\
new_command;\
if (condition)\
thd->restore_backup_item_arena(thd->spcont->callers_arena,\
&backup_current_arena);\
thd->set_n_backup_item_arena(thd->spcont->callers_arena, \
backup_arena); \
new_command; \
if (condition) \
thd->restore_backup_item_arena(thd->spcont->callers_arena, \
&backup_current_arena); \
} while(0)
/*
......@@ -174,10 +175,6 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
DBUG_RETURN(NULL);
}
/* QQ How do we do this? Is there some better way? */
if (type == MYSQL_TYPE_NULL)
goto return_null_item;
switch (sp_map_result_type(type)) {
case INT_RESULT:
{
......@@ -188,35 +185,34 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
DBUG_PRINT("info", ("INT_RESULT: null"));
goto return_null_item;
}
else
{
DBUG_PRINT("info", ("INT_RESULT: %d", i));
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize) Item_int(i),
use_callers_arena, &backup_current_arena);
}
break;
}
case REAL_RESULT:
{
double d= it->val_real();
uint8 decimals;
uint32 max_length;
if (it->null_value)
{
DBUG_PRINT("info", ("REAL_RESULT: null"));
goto return_null_item;
}
else
{
/* There's some difference between Item::new_item() and the
* constructor; the former crashes, the latter works... weird. */
uint8 decimals= it->decimals;
uint32 max_length= it->max_length;
/*
There's some difference between Item::new_item() and the
constructor; the former crashes, the latter works... weird.
*/
decimals= it->decimals;
max_length= it->max_length;
DBUG_PRINT("info", ("REAL_RESULT: %g", d));
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize) Item_float(d),
use_callers_arena, &backup_current_arena);
it->decimals= decimals;
it->max_length= max_length;
}
break;
}
case DECIMAL_RESULT:
......@@ -224,13 +220,15 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
my_decimal value, *val= it->val_decimal(&value);
if (it->null_value)
goto return_null_item;
else
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize) Item_decimal(val),
use_callers_arena, &backup_current_arena);
#ifndef DBUG_OFF
{
char dbug_buff[DECIMAL_MAX_STR_LENGTH+1];
DBUG_PRINT("info", ("DECIMAL_RESULT: %s", dbug_decimal_as_string(dbug_buff, val)));
DBUG_PRINT("info", ("DECIMAL_RESULT: %s",
dbug_decimal_as_string(dbug_buff, val)));
#endif
}
break;
}
case STRING_RESULT:
......@@ -239,21 +237,18 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
String tmp(buffer, sizeof(buffer), it->collation.collation);
String *s= it->val_str(&tmp);
if (it->null_value)
if (type == MYSQL_TYPE_NULL || it->null_value)
{
DBUG_PRINT("info", ("default result: null"));
DBUG_PRINT("info", ("STRING_RESULT: null"));
goto return_null_item;
}
else
{
DBUG_PRINT("info",("default result: %*s",
DBUG_PRINT("info",("STRING_RESULT: %*s",
s->length(), s->c_ptr_quick()));
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize)
Item_string(thd->strmake(s->ptr(),
s->length()), s->length(),
it->collation.collation),
use_callers_arena, &backup_current_arena);
}
break;
}
case ROW_RESULT:
......@@ -574,13 +569,10 @@ sp_head::destroy()
/*
* This is only used for result fields from functions (both during
* fix_length_and_dec() and evaluation).
*
* Since the current mem_root during a will be freed and the result
* field will be used by the caller, we have to put it in the caller's
* or main mem_root.
*/
This is only used for result fields from functions (both during
fix_length_and_dec() and evaluation).
*/
Field *
sp_head::make_field(uint max_length, const char *name, TABLE *dummy)
{
......@@ -817,47 +809,49 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
sp_rcontext *octx = thd->spcont;
sp_rcontext *nctx = NULL;
uint i;
int ret;
Item_null *nit;
int ret= -1; // Assume error
if (argcount != params)
{
/*
Need to use my_printf_error here, or it will not terminate the
Need to use my_error here, or it will not terminate the
invoking query properly.
*/
my_error(ER_SP_WRONG_NO_OF_ARGS, MYF(0),
"FUNCTION", m_qname.str, params, argcount);
DBUG_RETURN(-1);
goto end;
}
// QQ Should have some error checking here? (types, etc...)
nctx= new sp_rcontext(csize, hmax, cmax);
if (!(nctx= new sp_rcontext(csize, hmax, cmax)))
goto end;
for (i= 0 ; i < argcount ; i++)
{
sp_pvar_t *pvar = m_pcont->find_pvar(i);
Item *it= sp_eval_func_item(thd, argp++, pvar->type, NULL, FALSE);
if (it)
if (!it)
goto end; // EOM error
nctx->push_item(it);
else
{
DBUG_RETURN(-1);
}
}
/*
The rest of the frame are local variables which are all IN.
Default all variables to null (those with default clauses will
be set by an set instruction).
*/
{
Item_null *nit= NULL; // Re-use this, and only create if needed
nit= NULL; // Re-use this, and only create if needed
for (; i < csize ; i++)
{
if (! nit)
nit= new Item_null();
nctx->push_item(nit);
{
if (!(nit= new Item_null()))
DBUG_RETURN(-1);
}
nctx->push_item(nit);
}
thd->spcont= nctx;
......@@ -878,14 +872,15 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
}
nctx->pop_all_cursors(); // To avoid memory leaks after an error
delete nctx;
delete nctx; // Doesn't do anything
thd->spcont= octx;
end:
DBUG_RETURN(ret);
}
static Item_func_get_user_var *
item_is_user_var(Item *it)
static Item_func_get_user_var *item_is_user_var(Item *it)
{
if (it->type() == Item::FUNC_ITEM)
{
......@@ -897,19 +892,18 @@ item_is_user_var(Item *it)
return NULL;
}
int
sp_head::execute_procedure(THD *thd, List<Item> *args)
int sp_head::execute_procedure(THD *thd, List<Item> *args)
{
DBUG_ENTER("sp_head::execute_procedure");
DBUG_PRINT("info", ("procedure %s", m_name.str));
int ret= 0;
uint csize = m_pcont->max_pvars();
uint params = m_pcont->current_pvars();
uint hmax = m_pcont->max_handlers();
uint cmax = m_pcont->max_cursors();
sp_rcontext *octx = thd->spcont;
sp_rcontext *save_spcont, *octx;
sp_rcontext *nctx = NULL;
my_bool is_tmp_octx = FALSE; // True if we have allocated a temporary octx
DBUG_ENTER("sp_head::execute_procedure");
DBUG_PRINT("info", ("procedure %s", m_name.str));
if (args->elements != params)
{
......@@ -918,17 +912,22 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
DBUG_RETURN(-1);
}
save_spcont= octx= thd->spcont;
if (! octx)
{ // Create a temporary old context
octx= new sp_rcontext(csize, hmax, cmax);
is_tmp_octx= TRUE;
if (!(octx= new sp_rcontext(csize, hmax, cmax)))
DBUG_RETURN(-1);
thd->spcont= octx;
/* set callers_arena to thd, for upper-level function to work */
thd->spcont->callers_arena= thd;
}
nctx= new sp_rcontext(csize, hmax, cmax);
if (!(nctx= new sp_rcontext(csize, hmax, cmax)))
{
thd->spcont= save_spcont;
DBUG_RETURN(-1);
}
if (csize > 0 || hmax > 0 || cmax > 0)
{
......@@ -937,7 +936,6 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
List_iterator<Item> li(*args);
Item *it;
/* Evaluate SP arguments (i.e. get the values passed as parameters) */
// QQ: Should do type checking?
DBUG_PRINT("info",(" %.*s: eval args", m_name.length, m_name.str));
......@@ -959,20 +957,25 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
if (pvar->mode == sp_param_out)
{
if (! nit)
nit= new Item_null();
{
if (!(nit= new Item_null()))
{
ret= -1;
break;
}
}
nctx->push_item(nit); // OUT
}
else
{
Item *it2= sp_eval_func_item(thd, li.ref(), pvar->type, NULL, FALSE);
if (it2)
nctx->push_item(it2); // IN or INOUT
else
if (!it2)
{
ret= -1; // Eval failed
break;
}
nctx->push_item(it2); // IN or INOUT
}
}
}
......@@ -994,7 +997,13 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
for (; i < csize ; i++)
{
if (! nit)
nit= new Item_null();
{
if (!(nit= new Item_null()))
{
ret= -1;
break;
}
}
nctx->push_item(nit);
}
}
......@@ -1090,15 +1099,12 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
}
}
if (is_tmp_octx)
{
delete octx; /* call destructor */
octx= NULL;
}
if (!save_spcont)
delete octx; // Does nothing
nctx->pop_all_cursors(); // To avoid memory leaks after an error
delete nctx;
thd->spcont= octx;
delete nctx; // Does nothing
thd->spcont= save_spcont;
DBUG_RETURN(ret);
}
......
......@@ -150,14 +150,10 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
DBUG_ASSERT(share->table_name != 0);
if ((!share->table_name)) // To be removed
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)
{
if (wild_compare(share->table_name,wild,0))
if (wild && wild_compare(share->table_name,wild,0))
continue;
}
/* Check if user has SELECT privilege for any column in the table */
table_list.db= (char*) share->db;
......@@ -3367,7 +3363,7 @@ static bool
set_new_item_local_context(THD *thd, Item_ident *item, TABLE_LIST *table_ref)
{
Name_resolution_context *context;
if (!(context= new Name_resolution_context))
if (!(context= new (thd->mem_root) Name_resolution_context))
return TRUE;
context->init();
context->first_name_resolution_table=
......@@ -3801,7 +3797,6 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
if (cur_left_neighbor &&
cur_table_ref->outer_join & JOIN_TYPE_RIGHT)
{
DBUG_ASSERT(cur_table_ref);
/* This can happen only for JOIN ... ON. */
DBUG_ASSERT(table_ref->nested_join->join_list.elements == 2);
swap_variables(TABLE_LIST*, cur_left_neighbor, cur_table_ref);
......
......@@ -998,7 +998,7 @@ static long mysql_rm_arc_files(THD *thd, MY_DIR *dirp,
mysql_change_db()
thd Thread handler
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
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 path[FN_REFLEN];
HA_CREATE_INFO create;
bool schema_db= 0;
bool system_db= 0;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
ulong db_access;
#endif
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 (no_access_check && dbname)
{
/* Called from SP when orignal database was not set */
system_db= 1;
goto end;
}
x_free(dbname); /* purecov: inspected */
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR),
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));
if (!my_strcasecmp(system_charset_info, dbname, information_schema_name.str))
{
schema_db= 1;
system_db= 1;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
db_access= SELECT_ACL;
#endif
......@@ -1055,13 +1063,15 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!no_access_check) {
if (!no_access_check)
{
if (test_all_bits(thd->master_access,DB_ACLS))
db_access=DB_ACLS;
else
db_access= (acl_get(thd->host,thd->ip, thd->priv_user,dbname,0) |
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),
thd->priv_user,
......@@ -1094,7 +1104,7 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
if (!no_access_check)
thd->db_access=db_access;
#endif
if (schema_db)
if (system_db)
{
thd->db_charset= system_charset_info;
thd->variables.collation_database= system_charset_info;
......
......@@ -1520,7 +1520,7 @@ void st_select_lex_unit::print(String *str)
if (union_all)
str->append("all ", 4);
else if (union_distinct == sl)
union_all= true;
union_all= TRUE;
}
if (sl->braces)
str->append('(');
......
......@@ -239,6 +239,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
/*
Check if user exist and password supplied is correct.
SYNOPSIS
check_user()
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 */
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_length= 0;
if (mysql_change_db(thd, db, FALSE))
......@@ -6415,7 +6420,7 @@ Name_resolution_context *
make_join_on_context(THD *thd, TABLE_LIST *left_op, TABLE_LIST *right_op)
{
Name_resolution_context *on_context;
if (!(on_context= new Name_resolution_context))
if (!(on_context= new (thd->mem_root) Name_resolution_context))
return NULL;
on_context->init();
on_context->first_name_resolution_table=
......
......@@ -626,7 +626,7 @@ static const char *require_quotes(const char *name, uint name_length)
uint length;
const char *end= name + name_length;
for ( ; name < end ; name++)
for (; name < end ; name++)
{
uchar chr= (uchar) *name;
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)
{
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)
continue;
......@@ -2373,7 +2373,13 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
LEX *lex= thd->lex;
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
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");
if (res)
{
if (lex->orig_sql_command != SQLCOM_SHOW_FIELDS)
......@@ -2390,16 +2396,15 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
DBUG_RETURN(res);
}
TABLE *show_table= tables->table;
handler *file= show_table->file;
show_table= tables->table;
file= show_table->file;
count= 0;
file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
restore_record(show_table, s->default_values);
Field **ptr,*field;
int count= 0;
base_name_length= strlen(base_name);
file_name_length= strlen(file_name);
for (ptr=show_table->field; (field= *ptr) ; ptr++)
{
if (!wild || !wild[0] ||
!wild_case_compare(system_charset_info, field->field_name,wild))
{
const char *tmp_buff;
byte *pos;
......@@ -2408,8 +2413,16 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
char tmp[MAX_FIELD_WIDTH];
char tmp1[MAX_FIELD_WIDTH];
String type(tmp,sizeof(tmp), system_charset_info);
char *end= tmp;
char *end;
int decimals, field_length;
if (wild && wild[0] &&
wild_case_compare(system_charset_info, field->field_name,wild))
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
......@@ -2422,6 +2435,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
if (lex->orig_sql_command != SQLCOM_SHOW_FIELDS &&
!tables->schema_table && !col_access)
continue;
end= tmp;
for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
{
if (col_access & 1)
......@@ -2437,11 +2451,9 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
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[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);
......@@ -2494,59 +2506,52 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
table->field[9]->set_notnull();
}
{
uint dec =field->decimals();
/*
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:
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();
field_length= ((Field_new_decimal*) field)->precision;
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();
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:
{
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();
field_length= field->max_length() - 1;
break;
}
case FIELD_TYPE_BIT:
{
table->field[10]->store((longlong) field->max_length());
table->field[10]->set_notnull();
field_length= field->max_length();
decimals= -1; // return NULL
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();
}
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;
......@@ -2563,17 +2568,16 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
(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);
}
}
DBUG_RETURN(0);
}
......@@ -2585,7 +2589,8 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond)
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
TABLE *table= tables->table;
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];
if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) &&
......@@ -2593,12 +2598,12 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond)
!(wild && wild[0] &&
wild_case_compare(scs, tmp_cs->csname,wild)))
{
const char *comment;
restore_record(table, s->default_values);
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[2]->store(tmp_cs->comment ? tmp_cs->comment : "",
strlen(tmp_cs->comment ? tmp_cs->comment : ""),
scs);
comment= tmp_cs->comment ? tmp_cs->comment : "";
table->field[2]->store(comment, strlen(comment), scs);
table->field[3]->store((longlong) tmp_cs->mbmaxlen);
if (schema_table_store_record(thd, table))
return 1;
......@@ -2614,14 +2619,14 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond)
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
TABLE *table= tables->table;
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 *tmp_cs= cs[0];
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
!(tmp_cs->state & MY_CS_PRIMARY))
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];
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
......@@ -2654,14 +2659,14 @@ int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond)
CHARSET_INFO **cs;
TABLE *table= tables->table;
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 *tmp_cs= cs[0];
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
!(tmp_cs->state & MY_CS_PRIMARY))
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];
if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
......@@ -3266,7 +3271,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 *schema_table= schema_tables;
for ( ; schema_table->table_name; schema_table++)
for (; schema_table->table_name; schema_table++)
{
if (!my_strcasecmp(system_charset_info,
schema_table->table_name,
......@@ -3307,7 +3312,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("create_schema_table");
for ( ; fields_info->field_name; fields_info++)
for (; fields_info->field_name; fields_info++)
{
switch (fields_info->field_type) {
case MYSQL_TYPE_LONG:
......@@ -3376,7 +3381,7 @@ int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
ST_FIELD_INFO *field_info= schema_table->fields_info;
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)
{
......
......@@ -310,7 +310,7 @@ bool mysql_create_view(THD *thd,
open_and_lock_tables can change the value of tables,
e.g. it may happen if before the function call tables was equal to 0.
*/
for (tbl= tables= lex->query_tables; tbl; tbl= tbl->next_global)
for (tbl= lex->query_tables; tbl; tbl= tbl->next_global)
{
/* is this table temporary and is not view? */
if (tbl->table->s->tmp_table != NO_TMP_TABLE && !tbl->view &&
......
......@@ -2518,12 +2518,9 @@ void Field_iterator_natural_join::set(TABLE_LIST *table_ref)
void Field_iterator_natural_join::next()
{
cur_column_ref= (*column_ref_it)++;
DBUG_ASSERT(cur_column_ref ?
(cur_column_ref->table_field ?
DBUG_ASSERT(!cur_column_ref || ! cur_column_ref->table_field ||
cur_column_ref->table_ref->table ==
cur_column_ref->table_field->table :
TRUE) :
TRUE);
cur_column_ref->table_field->table);
}
......@@ -2695,9 +2692,8 @@ Field_iterator_table_ref::get_or_create_column_ref(THD *thd, bool *is_created)
nj_col= natural_join_it.column_ref();
DBUG_ASSERT(nj_col);
}
DBUG_ASSERT(nj_col->table_field ?
nj_col->table_ref->table == nj_col->table_field->table :
TRUE);
DBUG_ASSERT(!nj_col->table_field ||
nj_col->table_ref->table == nj_col->table_field->table);
return nj_col;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment