Commit 719c88e3 authored by monty@mishka.local's avatar monty@mishka.local

true,false -> TRUE, FALSE

Simple fixes/optimization of things discovered during review of new pushed code
parent 05433202
...@@ -726,7 +726,7 @@ extern void my_free_lock(byte *ptr,myf flags); ...@@ -726,7 +726,7 @@ extern void my_free_lock(byte *ptr,myf flags);
#endif #endif
#define alloc_root_inited(A) ((A)->min_malloc != 0) #define alloc_root_inited(A) ((A)->min_malloc != 0)
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; } while(0) #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size, extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size); uint pre_alloc_size);
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
......
...@@ -72,19 +72,48 @@ _hash_init(HASH *hash,CHARSET_INFO *charset, ...@@ -72,19 +72,48 @@ _hash_init(HASH *hash,CHARSET_INFO *charset,
} }
void hash_free(HASH *hash) /*
Call hash->free on all elements in hash.
SYNOPSIS
hash_free_elements()
hash hash table
NOTES:
Sets records to 0
*/
static void inline hash_free_elements(HASH *hash)
{ {
DBUG_ENTER("hash_free");
if (hash->free) if (hash->free)
{ {
uint i,records;
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*); HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
for (i=0,records=hash->records ; i < records ; i++) HASH_LINK *end= data + hash->records;
(*hash->free)(data[i].data); while (data < end)
hash->free=0; (*hash->free)((data++)->data);
} }
delete_dynamic(&hash->array);
hash->records=0; hash->records=0;
}
/*
Free memory used by hash.
SYNOPSIS
hash_free()
hash the hash to delete elements of
NOTES: Hash can't be reused wuthing calling hash_init again.
*/
void hash_free(HASH *hash)
{
DBUG_ENTER("hash_free");
DBUG_PRINT("enter",("hash: 0x%lxd",hash));
hash_free_elements(hash);
hash->free= 0;
delete_dynamic(&hash->array);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -94,21 +123,17 @@ void hash_free(HASH *hash) ...@@ -94,21 +123,17 @@ void hash_free(HASH *hash)
SYNOPSIS SYNOPSIS
hash_reset() hash_reset()
hash the hash to delete elements of hash the hash to delete elements of
*/ */
void hash_reset(HASH *hash) void hash_reset(HASH *hash)
{ {
DBUG_ENTER("hash_reset"); DBUG_ENTER("hash_reset");
if (hash->free) DBUG_PRINT("enter",("hash: 0x%lxd",hash));
{
HASH_LINK *link= dynamic_element(&hash->array, 0, HASH_LINK*); hash_free_elements(hash);
HASH_LINK *end= link + hash->records;
for (; link < end; ++link)
(*hash->free)(link->data);
}
reset_dynamic(&hash->array); reset_dynamic(&hash->array);
hash->records= 0; /* Set row pointers so that the hash can be reused at once */
hash->blength= 1; hash->blength= 1;
hash->current_record= NO_RECORD; hash->current_record= NO_RECORD;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <m_string.h> #include <m_string.h>
inline void bitmap_lock(MY_BITMAP *map) static inline void bitmap_lock(MY_BITMAP *map)
{ {
#ifdef THREAD #ifdef THREAD
if (map->mutex) if (map->mutex)
...@@ -47,7 +47,7 @@ inline void bitmap_lock(MY_BITMAP *map) ...@@ -47,7 +47,7 @@ inline void bitmap_lock(MY_BITMAP *map)
} }
inline void bitmap_unlock(MY_BITMAP *map) static inline void bitmap_unlock(MY_BITMAP *map)
{ {
#ifdef THREAD #ifdef THREAD
if (map->mutex) if (map->mutex)
......
...@@ -103,14 +103,15 @@ ...@@ -103,14 +103,15 @@
rows - This is an unsigned long long which is the number of rows in the data rows - This is an unsigned long long which is the number of rows in the data
file. file.
check point - Reserved for future use check point - Reserved for future use
dirty - Status of the file, whether or not its values are the latest. This flag dirty - Status of the file, whether or not its values are the latest. This
is what causes a repair to occur flag is what causes a repair to occur
The data file: The data file:
check - Just an int of 254 to make sure that the the file we are opening was check - Just an int of 254 to make sure that the the file we are opening was
never corrupted. never corrupted.
version - The current version of the file format. version - The current version of the file format.
data - The data is stored in a "row +blobs" format. data - The data is stored in a "row +blobs" format.
*/
/* Variables for archive share methods */ /* Variables for archive share methods */
pthread_mutex_t archive_mutex; pthread_mutex_t archive_mutex;
......
This diff is collapsed.
...@@ -139,12 +139,12 @@ class ha_ndbcluster: public handler ...@@ -139,12 +139,12 @@ class ha_ndbcluster: public handler
bool low_byte_first() const bool low_byte_first() const
{ {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
return false; return FALSE;
#else #else
return true; return TRUE;
#endif #endif
} }
bool has_transactions() { return true; } bool has_transactions() { return TRUE; }
const char* index_type(uint key_number) { const char* index_type(uint key_number) {
switch (get_index_type(key_number)) { switch (get_index_type(key_number)) {
......
...@@ -1105,6 +1105,11 @@ void handler::print_error(int error, myf errflag) ...@@ -1105,6 +1105,11 @@ void handler::print_error(int error, myf errflag)
break; break;
case HA_ERR_NO_SUCH_TABLE: case HA_ERR_NO_SUCH_TABLE:
{ {
/*
We have to use path to find database name instead of using
table->table_cache_key because if the table didn't exist, then
table_cache_key was not set up
*/
char *db; char *db;
char buff[FN_REFLEN]; char buff[FN_REFLEN];
uint length=dirname_part(buff,table->path); uint length=dirname_part(buff,table->path);
...@@ -1276,23 +1281,26 @@ int ha_create_table_from_engine(THD* thd, ...@@ -1276,23 +1281,26 @@ int ha_create_table_from_engine(THD* thd,
const char *name, const char *name,
bool create_if_found) bool create_if_found)
{ {
int error= 0; int error;
const void* frmblob = NULL; const void *frmblob;
uint frmlen = 0; uint frmlen;
char path[FN_REFLEN]; char path[FN_REFLEN];
HA_CREATE_INFO create_info; HA_CREATE_INFO create_info;
TABLE table; TABLE table;
DBUG_ENTER("ha_create_table_from_engine"); DBUG_ENTER("ha_create_table_from_engine");
DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); DBUG_PRINT("enter", ("name '%s'.'%s' create_if_found: %d",
DBUG_PRINT("enter", ("create_if_found: %d", create_if_found)); db, name, create_if_found));
bzero((char*) &create_info,sizeof(create_info)); bzero((char*) &create_info,sizeof(create_info));
if ((error= ha_discover(thd, db, name, &frmblob, &frmlen))) if ((error= ha_discover(thd, db, name, &frmblob, &frmlen)))
DBUG_RETURN(error); DBUG_RETURN(error);
/*
Table exists in handler
frmblob and frmlen are set
*/
// Table exists in handler if (create_if_found)
if (create_if_found)
{ {
(void)strxnmov(path,FN_REFLEN,mysql_data_home,"/",db,"/",name,NullS); (void)strxnmov(path,FN_REFLEN,mysql_data_home,"/",db,"/",name,NullS);
// Save the frm file // Save the frm file
...@@ -1309,9 +1317,7 @@ int ha_create_table_from_engine(THD* thd, ...@@ -1309,9 +1317,7 @@ int ha_create_table_from_engine(THD* thd,
!(table.file->table_flags() & HA_FILE_BASED)) !(table.file->table_flags() & HA_FILE_BASED))
{ {
/* Ensure that handler gets name in lower case */ /* Ensure that handler gets name in lower case */
strmov(path, name);
my_casedn_str(files_charset_info, path); my_casedn_str(files_charset_info, path);
name= path;
} }
error=table.file->create(path,&table,&create_info); error=table.file->create(path,&table,&create_info);
...@@ -1319,8 +1325,7 @@ int ha_create_table_from_engine(THD* thd, ...@@ -1319,8 +1325,7 @@ int ha_create_table_from_engine(THD* thd,
} }
err_end: err_end:
if (frmblob) my_free((char*) frmblob, MYF(MY_ALLOW_ZERO));
my_free((char*) frmblob,MYF(0));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -1429,10 +1434,14 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache, ...@@ -1429,10 +1434,14 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache,
/* /*
Try to discover one table from handler(s) Try to discover one table from handler(s)
RETURN
0 ok. In this case *frmblob and *frmlen are set
1 error. frmblob and frmlen may not be set
*/ */
int ha_discover(THD* thd, const char* db, const char* name, int ha_discover(THD *thd, const char *db, const char *name,
const void** frmblob, uint* frmlen) const void **frmblob, uint *frmlen)
{ {
int error= 1; // Table does not exist in any handler int error= 1; // Table does not exist in any handler
DBUG_ENTER("ha_discover"); DBUG_ENTER("ha_discover");
...@@ -1470,6 +1479,8 @@ ha_find_files(THD *thd,const char *db,const char *path, ...@@ -1470,6 +1479,8 @@ ha_find_files(THD *thd,const char *db,const char *path,
} }
#ifdef NOT_YET_USED
/* /*
Ask handler if the table exists in engine Ask handler if the table exists in engine
...@@ -1491,6 +1502,7 @@ int ha_table_exists(THD* thd, const char* db, const char* name) ...@@ -1491,6 +1502,7 @@ int ha_table_exists(THD* thd, const char* db, const char* name)
DBUG_RETURN(error); DBUG_RETURN(error);
} }
#endif
/* /*
......
...@@ -855,7 +855,7 @@ class Item_func_like :public Item_bool_func2 ...@@ -855,7 +855,7 @@ class Item_func_like :public Item_bool_func2
char escape; char escape;
Item_func_like(Item *a,Item *b, Item *escape_arg) Item_func_like(Item *a,Item *b, Item *escape_arg)
:Item_bool_func2(a,b), canDoTurboBM(false), pattern(0), pattern_len(0), :Item_bool_func2(a,b), canDoTurboBM(FALSE), pattern(0), pattern_len(0),
bmGs(0), bmBc(0), escape_item(escape_arg) {} bmGs(0), bmBc(0), escape_item(escape_arg) {}
longlong val_int(); longlong val_int();
enum Functype functype() const { return LIKE_FUNC; } enum Functype functype() const { return LIKE_FUNC; }
......
...@@ -2709,41 +2709,40 @@ longlong Item_func_crc32::val_int() ...@@ -2709,41 +2709,40 @@ longlong Item_func_crc32::val_int()
String *Item_func_compress::val_str(String *str) String *Item_func_compress::val_str(String *str)
{ {
int err= Z_OK, code;
ulong new_size;
String *res;
Byte *body;
char *tmp, *last_char;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
String *res= args[0]->val_str(str);
if (!res) if (!(res= args[0]->val_str(str)))
{ {
null_value= 1; null_value= 1;
return 0; return 0;
} }
if (res->is_empty()) return res; if (res->is_empty()) return res;
int err= Z_OK;
int code;
/* /*
citation from zlib.h (comment for compress function): Citation from zlib.h (comment for compress function):
Compresses the source buffer into the destination buffer. sourceLen is Compresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total the byte length of the source buffer. Upon entry, destLen is the total
size of the destination buffer, which must be at least 0.1% larger than size of the destination buffer, which must be at least 0.1% larger than
sourceLen plus 12 bytes. sourceLen plus 12 bytes.
We assume here that the buffer can't grow more than .25 %.
Proportion 120/100 founded by Sinisa with help of procedure
compress(compress(compress(...)))
I.e. zlib give number 'at least'..
*/ */
ulong new_size= res->length() + res->length() / 5 + 12; new_size= res->length() + res->length() / 5 + 12;
// Will check new_size overflow: new_size <= res->length() // Check new_size overflow: new_size <= res->length()
if (((uint32) new_size <= res->length()) || if (((uint32) (new_size+5) <= res->length()) ||
buffer.realloc((uint32) new_size + 4 + 1)) buffer.realloc((uint32) new_size + 4 + 1))
{ {
null_value= 1; null_value= 1;
return 0; return 0;
} }
Byte *body= ((Byte*)buffer.ptr()) + 4; body= ((Byte*)buffer.ptr()) + 4;
// As far as we have checked res->is_empty() we can use ptr() // As far as we have checked res->is_empty() we can use ptr()
if ((err= compress(body, &new_size, if ((err= compress(body, &new_size,
...@@ -2755,11 +2754,11 @@ String *Item_func_compress::val_str(String *str) ...@@ -2755,11 +2754,11 @@ String *Item_func_compress::val_str(String *str)
return 0; return 0;
} }
char *tmp= (char*)buffer.ptr(); // int4store is a macro; avoid side effects tmp= (char*)buffer.ptr(); // int4store is a macro; avoid side effects
int4store(tmp, res->length() & 0x3FFFFFFF); int4store(tmp, res->length() & 0x3FFFFFFF);
/* This is for the stupid char fields which trim ' ': */ /* This is to ensure that things works for CHAR fields, which trim ' ': */
char *last_char= ((char*)body)+new_size-1; last_char= ((char*)body)+new_size-1;
if (*last_char == ' ') if (*last_char == ' ')
{ {
*++last_char= '.'; *++last_char= '.';
......
...@@ -571,7 +571,7 @@ class Load_log_event: public Log_event ...@@ -571,7 +571,7 @@ class Load_log_event: public Log_event
{ {
fname= afname; fname= afname;
fname_len= alen; fname_len= alen;
local_fname= true; local_fname= TRUE;
} }
/* fname doesn't point to memory inside Log_event::temp_buf */ /* fname doesn't point to memory inside Log_event::temp_buf */
int check_fname_outside_temp_buf() int check_fname_outside_temp_buf()
......
...@@ -1368,7 +1368,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, ...@@ -1368,7 +1368,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
*/ */
if (discover_retry_count++ != 0) if (discover_retry_count++ != 0)
goto err; goto err;
if (ha_create_table_from_engine(thd, db, name, true) != 0) if (ha_create_table_from_engine(thd, db, name, TRUE) != 0)
goto err; goto err;
thd->clear_error(); // Clear error message thd->clear_error(); // Clear error message
...@@ -2846,8 +2846,15 @@ void flush_tables() ...@@ -2846,8 +2846,15 @@ void flush_tables()
/* /*
** Mark all entries with the table as deleted to force an reopen of the table Mark all entries with the table as deleted to force an reopen of the table
** Returns true if the table is in use by another thread
The table will be closed (not stored in cache) by the current thread when
close_thread_tables() is called.
RETURN
0 This thread now have exclusive access to this table and no other thread
can access the table until close_thread_tables() is called.
1 Table is in use by another thread
*/ */
bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
......
...@@ -746,7 +746,7 @@ int mysqld_help(THD *thd, const char *mask) ...@@ -746,7 +746,7 @@ int mysqld_help(THD *thd, const char *mask)
select,&subcategories_list); select,&subcategories_list);
delete select; delete select;
String *cat= categories_list.head(); String *cat= categories_list.head();
if (send_header_2(protocol, true) || if (send_header_2(protocol, TRUE) ||
send_variant_2_list(mem_root,protocol,&topics_list, "N",cat) || send_variant_2_list(mem_root,protocol,&topics_list, "N",cat) ||
send_variant_2_list(mem_root,protocol,&subcategories_list,"Y",cat)) send_variant_2_list(mem_root,protocol,&subcategories_list,"Y",cat))
goto end; goto end;
......
...@@ -454,7 +454,6 @@ inline static uint int_token(const char *str,uint length) ...@@ -454,7 +454,6 @@ inline static uint int_token(const char *str,uint length)
int yylex(void *arg, void *yythd) int yylex(void *arg, void *yythd)
{ {
reg1 uchar c; reg1 uchar c;
bool space_ignored;
int tokval, result_state; int tokval, result_state;
uint length; uint length;
enum my_lex_states state; enum my_lex_states state;
...@@ -537,6 +536,7 @@ int yylex(void *arg, void *yythd) ...@@ -537,6 +536,7 @@ int yylex(void *arg, void *yythd)
/* Fall through */ /* Fall through */
case MY_LEX_IDENT_OR_BIN: // TODO: Add binary string handling case MY_LEX_IDENT_OR_BIN: // TODO: Add binary string handling
case MY_LEX_IDENT: case MY_LEX_IDENT:
uchar *start;
#if defined(USE_MB) && defined(USE_MB_IDENT) #if defined(USE_MB) && defined(USE_MB_IDENT)
if (use_mb(cs)) if (use_mb(cs))
{ {
...@@ -573,12 +573,16 @@ int yylex(void *arg, void *yythd) ...@@ -573,12 +573,16 @@ int yylex(void *arg, void *yythd)
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
} }
length= (uint) (lex->ptr - lex->tok_start)-1; length= (uint) (lex->ptr - lex->tok_start)-1;
space_ignored= FALSE; start= lex->ptr;
if (lex->ignore_space) if (lex->ignore_space)
{ {
for (; state_map[c] == MY_LEX_SKIP ; space_ignored= TRUE, c= yyGet()); /*
If we find a space then this can't be an identifier. We notice this
below by checking start != lex->ptr.
*/
for (; state_map[c] == MY_LEX_SKIP ; c= yyGet());
} }
if (! space_ignored && c == '.' && ident_map[yyPeek()]) if (start == lex->ptr && c == '.' && ident_map[yyPeek()])
lex->next_state=MY_LEX_IDENT_SEP; lex->next_state=MY_LEX_IDENT_SEP;
else else
{ // '(' must follow directly if function { // '(' must follow directly if function
......
...@@ -894,7 +894,7 @@ static int check_connection(THD *thd) ...@@ -894,7 +894,7 @@ static int check_connection(THD *thd)
x_free(thd->user); x_free(thd->user);
if (!(thd->user= my_strdup(user, MYF(0)))) if (!(thd->user= my_strdup(user, MYF(0))))
return (ER_OUT_OF_RESOURCES); return (ER_OUT_OF_RESOURCES);
return check_user(thd, COM_CONNECT, passwd, passwd_len, db, true); return check_user(thd, COM_CONNECT, passwd, passwd_len, db, TRUE);
} }
...@@ -4771,7 +4771,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, ...@@ -4771,7 +4771,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
acl_reload(thd); acl_reload(thd);
grant_reload(thd); grant_reload(thd);
if (mqh_used) if (mqh_used)
reset_mqh(thd,(LEX_USER *) NULL,true); reset_mqh(thd,(LEX_USER *) NULL,TRUE);
} }
#endif #endif
if (options & REFRESH_LOG) if (options & REFRESH_LOG)
......
...@@ -1780,7 +1780,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) ...@@ -1780,7 +1780,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
#endif #endif
DBUG_ASSERT(thd->free_list == NULL); DBUG_ASSERT(thd->free_list == NULL);
thd->protocol= &thd->protocol_prep; // Switch to binary protocol thd->protocol= &thd->protocol_prep; // Switch to binary protocol
execute_stmt(thd, stmt, &expanded_query, true); execute_stmt(thd, stmt, &expanded_query, TRUE);
thd->protocol= &thd->protocol_simple; // Use normal protocol thd->protocol= &thd->protocol_simple; // Use normal protocol
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -1832,7 +1832,7 @@ void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name) ...@@ -1832,7 +1832,7 @@ void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name)
my_error(ER_WRONG_ARGUMENTS, MYF(0), "EXECUTE"); my_error(ER_WRONG_ARGUMENTS, MYF(0), "EXECUTE");
send_error(thd); send_error(thd);
} }
execute_stmt(thd, stmt, &expanded_query, false); execute_stmt(thd, stmt, &expanded_query, FALSE);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -223,7 +223,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -223,7 +223,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
(void) unpack_filename(path,path); (void) unpack_filename(path,path);
} }
if (drop_temporary || if (drop_temporary ||
(access(path,F_OK) && ha_create_table_from_engine(thd,db,alias,true))) (access(path,F_OK) && ha_create_table_from_engine(thd,db,alias,TRUE)))
{ {
if (if_exists) if (if_exists)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
......
...@@ -843,14 +843,14 @@ prepare_src: ...@@ -843,14 +843,14 @@ prepare_src:
THD *thd=YYTHD; THD *thd=YYTHD;
LEX *lex= thd->lex; LEX *lex= thd->lex;
lex->prepared_stmt_code= $1; lex->prepared_stmt_code= $1;
lex->prepared_stmt_code_is_varref= false; lex->prepared_stmt_code_is_varref= FALSE;
} }
| '@' ident_or_text | '@' ident_or_text
{ {
THD *thd=YYTHD; THD *thd=YYTHD;
LEX *lex= thd->lex; LEX *lex= thd->lex;
lex->prepared_stmt_code= $2; lex->prepared_stmt_code= $2;
lex->prepared_stmt_code_is_varref= true; lex->prepared_stmt_code_is_varref= TRUE;
}; };
execute: execute:
......
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