Commit 9ef2a83f authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Portability fixes for windows

After merge fixes
parent e71b53a8
...@@ -49,20 +49,24 @@ ...@@ -49,20 +49,24 @@
/* The following is parameter to ha_rkey() how to use key */ /* The following is parameter to ha_rkey() how to use key */
/* We define a complete-field prefix of a key value as a prefix where the /*
last included field in the prefix contains the full field, not just some bytes We define a complete-field prefix of a key value as a prefix where
from the start of the field. A partial-field prefix is allowed to the last included field in the prefix contains the full field, not
contain only a few first bytes from the last included field. just some bytes from the start of the field. A partial-field prefix
is allowed to contain only a few first bytes from the last included
Below HA_READ_KEY_EXACT, ..., HA_READ_BEFORE_KEY can take a field.
complete-field prefix of a key value as the search key. HA_READ_PREFIX
and HA_READ_PREFIX_LAST could also take a partial-field prefix, but Below HA_READ_KEY_EXACT, ..., HA_READ_BEFORE_KEY can take a
currently (4.0.10) they are only used with complete-field prefixes. MySQL uses complete-field prefix of a key value as the search
a padding trick to implement LIKE 'abc%' queries. key. HA_READ_PREFIX and HA_READ_PREFIX_LAST could also take a
partial-field prefix, but currently (4.0.10) they are only used with
NOTE that in InnoDB HA_READ_PREFIX_LAST will NOT work with a partial-field complete-field prefixes. MySQL uses a padding trick to implement
prefix because InnoDB currently strips spaces from the end of varchar LIKE 'abc%' queries.
fields! */
NOTE that in InnoDB HA_READ_PREFIX_LAST will NOT work with a
partial-field prefix because InnoDB currently strips spaces from the
end of varchar fields!
*/
enum ha_rkey_function { enum ha_rkey_function {
HA_READ_KEY_EXACT, /* Find first record else error */ HA_READ_KEY_EXACT, /* Find first record else error */
......
...@@ -52,9 +52,9 @@ void STDCALL cli_mysql_close(MYSQL *mysql); ...@@ -52,9 +52,9 @@ void STDCALL cli_mysql_close(MYSQL *mysql);
MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql); MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql);
my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt); my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt);
MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
uint fields); uint fields);
int STDCALL cli_stmt_execute(MYSQL_STMT *stmt); int STDCALL cli_stmt_execute(MYSQL_STMT *stmt);
MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt); MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt);
int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row); int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row);
const char * STDCALL cli_read_statistic(MYSQL *mysql); const char * STDCALL cli_read_statistic(MYSQL *mysql);
...@@ -3098,7 +3098,7 @@ int STDCALL mysql_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, ...@@ -3098,7 +3098,7 @@ int STDCALL mysql_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
Read all rows of data from server (binary format) Read all rows of data from server (binary format)
*/ */
MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt) MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt)
{ {
ulong pkt_len; ulong pkt_len;
uchar *cp; uchar *cp;
......
...@@ -81,7 +81,7 @@ EXPORTS ...@@ -81,7 +81,7 @@ EXPORTS
mysql_param_result mysql_param_result
mysql_ping mysql_ping
mysql_prepare mysql_prepare
mysql_prepare_result mysql_get_metadata
mysql_query mysql_query
mysql_read_query_result mysql_read_query_result
mysql_real_connect mysql_real_connect
......
...@@ -235,7 +235,7 @@ ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and shoul ...@@ -235,7 +235,7 @@ ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and shoul
set myisam_max_extra_sort_file_size=100; set myisam_max_extra_sort_file_size=100;
ERROR HY000: Variable 'myisam_max_extra_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL ERROR HY000: Variable 'myisam_max_extra_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
set @@SQL_WARNINGS=NULL; set @@SQL_WARNINGS=NULL;
ERROR HY000: Variable 'sql_warnings' can't be set to the value of 'NULL' ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'NULL'
set autocommit=1; set autocommit=1;
set big_tables=1; set big_tables=1;
select @@autocommit, @@big_tables; select @@autocommit, @@big_tables;
......
...@@ -1137,8 +1137,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, ...@@ -1137,8 +1137,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
/* Read all rows (fields or data) from server */ /* Read all rows (fields or data) from server */
MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
unsigned int fields) unsigned int fields)
{ {
uint field; uint field;
ulong pkt_len; ulong pkt_len;
......
...@@ -238,7 +238,8 @@ int berkeley_show_logs(Protocol *protocol) ...@@ -238,7 +238,8 @@ int berkeley_show_logs(Protocol *protocol)
MEM_ROOT *old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); MEM_ROOT *old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC);
DBUG_ENTER("berkeley_show_logs"); DBUG_ENTER("berkeley_show_logs");
init_sql_alloc(&show_logs_root, 1024, 1024); init_sql_alloc(&show_logs_root, BDB_LOG_ALLOC_BLOCK_SIZE,
BDB_LOG_ALLOC_BLOCK_SIZE);
my_pthread_setspecific_ptr(THR_MALLOC,&show_logs_root); my_pthread_setspecific_ptr(THR_MALLOC,&show_logs_root);
if ((error= db_env->log_archive(db_env, &all_logs, if ((error= db_env->log_archive(db_env, &all_logs,
......
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
#include "md5.h" #include "md5.h"
#include "sha1.h" #include "sha1.h"
#include "my_aes.h" #include "my_aes.h"
C_MODE_START
#include "../mysys/my_static.h" // For soundex_map #include "../mysys/my_static.h" // For soundex_map
C_MODE_END
String my_empty_string("",default_charset_info); String my_empty_string("",default_charset_info);
......
...@@ -94,6 +94,9 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; ...@@ -94,6 +94,9 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
#define ACL_ALLOC_BLOCK_SIZE 1024 #define ACL_ALLOC_BLOCK_SIZE 1024
#define UDF_ALLOC_BLOCK_SIZE 1024 #define UDF_ALLOC_BLOCK_SIZE 1024
#define TABLE_ALLOC_BLOCK_SIZE 1024 #define TABLE_ALLOC_BLOCK_SIZE 1024
#define BDB_LOG_ALLOC_BLOCK_SIZE 1024
#define WARN_ALLOC_BLOCK_SIZE 2048
#define WARN_ALLOC_PREALLOC_SIZE 1024
/* /*
The following parameters is to decide when to use an extra cache to The following parameters is to decide when to use an extra cache to
......
...@@ -3575,7 +3575,6 @@ enum options ...@@ -3575,7 +3575,6 @@ enum options
OPT_SHARED_MEMORY_BASE_NAME, OPT_SHARED_MEMORY_BASE_NAME,
OPT_OLD_PASSWORDS, OPT_OLD_PASSWORDS,
OPT_EXPIRE_LOGS_DAYS, OPT_EXPIRE_LOGS_DAYS,
OPT_DEFAULT_WEEK_FORMAT,
OPT_GROUP_CONCAT_MAX_LEN, OPT_GROUP_CONCAT_MAX_LEN,
OPT_DEFAULT_COLLATION, OPT_DEFAULT_COLLATION,
OPT_SECURE_AUTH, OPT_SECURE_AUTH,
......
...@@ -127,8 +127,7 @@ class SQL_SELECT :public Sql_alloc { ...@@ -127,8 +127,7 @@ class SQL_SELECT :public Sql_alloc {
SQL_SELECT(); SQL_SELECT();
~SQL_SELECT(); ~SQL_SELECT();
bool check_quick(THD *thd, bool force_quick_range= 0, bool check_quick(THD *thd, bool force_quick_range, ha_rows limit)
ha_rows limit= HA_POS_ERROR)
{ return test_quick_select(thd, ~0L,0,limit, force_quick_range) < 0; } { return test_quick_select(thd, ~0L,0,limit, force_quick_range) < 0; }
inline bool skipp_record() { return cond ? cond->val_int() == 0 : 0; } inline bool skipp_record() { return cond ? cond->val_int() == 0 : 0; }
int test_quick_select(THD *thd, key_map keys, table_map prev_tables, int test_quick_select(THD *thd, key_map keys, table_map prev_tables,
......
...@@ -693,7 +693,7 @@ class NAMED_LIST :public ilink ...@@ -693,7 +693,7 @@ class NAMED_LIST :public ilink
uint name_length_arg, gptr data_arg) uint name_length_arg, gptr data_arg)
:name_length(name_length_arg), data(data_arg) :name_length(name_length_arg), data(data_arg)
{ {
name= my_memdup(name_arg, name_length, MYF(MY_WME)); name= my_memdup((byte*) name_arg, name_length, MYF(MY_WME));
links->push_back(this); links->push_back(this);
} }
inline bool cmp(const char *name_cmp, uint length) inline bool cmp(const char *name_cmp, uint length)
......
...@@ -148,7 +148,7 @@ THD::THD():user_time(0), is_fatal_error(0), ...@@ -148,7 +148,7 @@ THD::THD():user_time(0), is_fatal_error(0),
bzero((char*) &transaction.mem_root,sizeof(transaction.mem_root)); bzero((char*) &transaction.mem_root,sizeof(transaction.mem_root));
bzero((char*) &con_root,sizeof(con_root)); bzero((char*) &con_root,sizeof(con_root));
bzero((char*) &warn_root,sizeof(warn_root)); bzero((char*) &warn_root,sizeof(warn_root));
init_alloc_root(&warn_root, 1024, 0); init_alloc_root(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
user_connect=(USER_CONN *)0; user_connect=(USER_CONN *)0;
hash_init(&user_vars, &my_charset_bin, USER_VARS_HASH_SIZE, 0, 0, hash_init(&user_vars, &my_charset_bin, USER_VARS_HASH_SIZE, 0, 0,
(hash_get_key) get_var_key, (hash_get_key) get_var_key,
...@@ -230,9 +230,11 @@ void THD::init(void) ...@@ -230,9 +230,11 @@ void THD::init(void)
void THD::init_for_queries() void THD::init_for_queries()
{ {
init_sql_alloc(&mem_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC); init_sql_alloc(&mem_root, variables.query_alloc_block_size,
variables.query_prealloc_size);
init_sql_alloc(&transaction.mem_root, init_sql_alloc(&transaction.mem_root,
TRANS_MEM_ROOT_BLOCK_SIZE, TRANS_MEM_ROOT_PREALLOC); variables.trans_alloc_block_size,
variables.trans_prealloc_size);
} }
......
...@@ -599,7 +599,7 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE_LIST *tables, ...@@ -599,7 +599,7 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE_LIST *tables,
{ {
cond->fix_fields(thd, tables, &cond); // can never fail cond->fix_fields(thd, tables, &cond); // can never fail
SQL_SELECT *res= make_select(table,0,0,cond,error); SQL_SELECT *res= make_select(table,0,0,cond,error);
return (*error || (res && res->check_quick(0, HA_POS_ERROR))) ? 0 : res; return (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR))) ? 0 : res;
} }
/* /*
...@@ -627,6 +627,8 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen, ...@@ -627,6 +627,8 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen,
Item *cond= new Item_func_like(new Item_field(pfname), Item *cond= new Item_func_like(new Item_field(pfname),
new Item_string(mask,mlen,pfname->charset()), new Item_string(mask,mlen,pfname->charset()),
(char*) "\\"); (char*) "\\");
if (thd->is_fatal_error)
return 0; // OOM
return prepare_simple_select(thd,cond,tables,table,error); return prepare_simple_select(thd,cond,tables,table,error);
} }
......
...@@ -888,12 +888,15 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length) ...@@ -888,12 +888,15 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
{ {
MEM_ROOT thd_root= thd->mem_root; MEM_ROOT thd_root= thd->mem_root;
PREP_STMT stmt; PREP_STMT stmt;
SELECT_LEX *sl;
DBUG_ENTER("mysql_stmt_prepare"); DBUG_ENTER("mysql_stmt_prepare");
bzero((char*) &stmt, sizeof(stmt)); bzero((char*) &stmt, sizeof(stmt));
stmt.stmt_id= ++thd->current_stmt_id; stmt.stmt_id= ++thd->current_stmt_id;
init_sql_alloc(&stmt.mem_root, 8192, 8192); init_sql_alloc(&stmt.mem_root,
thd->variables.query_alloc_block_size,
thd->variables.query_prealloc_size);
stmt.thd= thd; stmt.thd= thd;
stmt.thd->mem_root= stmt.mem_root; stmt.thd->mem_root= stmt.mem_root;
...@@ -908,7 +911,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length) ...@@ -908,7 +911,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
my_pthread_setprio(pthread_self(),WAIT_PRIOR); my_pthread_setprio(pthread_self(),WAIT_PRIOR);
// save WHERE clause pointers to avoid damaging they by optimisation // save WHERE clause pointers to avoid damaging they by optimisation
for (SELECT_LEX *sl= thd->lex.all_selects_list; for (sl= thd->lex.all_selects_list;
sl; sl;
sl= sl->next_select_in_list()) sl= sl->next_select_in_list())
{ {
...@@ -943,8 +946,9 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length) ...@@ -943,8 +946,9 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
void mysql_stmt_execute(THD *thd, char *packet) void mysql_stmt_execute(THD *thd, char *packet)
{ {
ulong stmt_id= uint4korr(packet); ulong stmt_id= uint4korr(packet);
PREP_STMT *stmt; PREP_STMT *stmt;
SELECT_LEX *sl;
DBUG_ENTER("mysql_stmt_execute"); DBUG_ENTER("mysql_stmt_execute");
if (!(stmt=find_prepared_statement(thd, stmt_id, "execute"))) if (!(stmt=find_prepared_statement(thd, stmt_id, "execute")))
...@@ -963,11 +967,13 @@ void mysql_stmt_execute(THD *thd, char *packet) ...@@ -963,11 +967,13 @@ void mysql_stmt_execute(THD *thd, char *packet)
LEX thd_lex= thd->lex; LEX thd_lex= thd->lex;
thd->lex= stmt->lex; thd->lex= stmt->lex;
for (SELECT_LEX *sl= stmt->lex.all_selects_list; for (sl= stmt->lex.all_selects_list;
sl; sl;
sl= sl->next_select_in_list()) sl= sl->next_select_in_list())
{ {
// copy WHERE clause pointers to avoid damaging they by optimisation /*
Copy WHERE clause pointers to avoid damaging they by optimisation
*/
if (sl->prep_where) if (sl->prep_where)
sl->where= sl->prep_where->copy_andor_structure(thd); sl->where= sl->prep_where->copy_andor_structure(thd);
DBUG_ASSERT(sl->join == 0); DBUG_ASSERT(sl->join == 0);
......
...@@ -2656,9 +2656,9 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) ...@@ -2656,9 +2656,9 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
while (!t->file->rnd_next(t->record[0])) while (!t->file->rnd_next(t->record[0]))
{ {
ha_checksum row_crc= 0; ha_checksum row_crc= 0;
if (t->record[0] != t->field[0]->ptr) if (t->record[0] != (byte*) t->field[0]->ptr)
row_crc= my_checksum(row_crc, t->record[0], row_crc= my_checksum(row_crc, t->record[0],
t->field[0]->ptr - t->record[0]); ((byte*) t->field[0]->ptr) - t->record[0]);
for (uint i= 0; i < t->fields; i++ ) for (uint i= 0; i < t->fields; i++ )
{ {
...@@ -2667,10 +2667,11 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) ...@@ -2667,10 +2667,11 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
{ {
String tmp; String tmp;
f->val_str(&tmp,&tmp); f->val_str(&tmp,&tmp);
row_crc= my_checksum(row_crc, tmp.ptr(), tmp.length()); row_crc= my_checksum(row_crc, (byte*) tmp.ptr(), tmp.length());
} }
else else
row_crc= my_checksum(row_crc, f->ptr, f->pack_length()); row_crc= my_checksum(row_crc, (byte*) f->ptr,
f->pack_length());
} }
crc+= row_crc; crc+= row_crc;
......
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