Skip to content

Commit 9e2b31b

Browse files
Fix for server bug experienced in Maria (wrong "Truncated incorrect <var_name>
value" error even though the value was correct): a C function in my_getopt.c was taking bool* in parameter and was called from C++ sql_plugin.cc, but on some Mac OS X sizeof(bool) is 1 in C and 4 in C++, giving funny mismatches. Fixed, all other occurences of bool in C are removed, future ones are blocked by a "C-bool-catcher" in my_global.h (use my_bool).
1 parent ccd5322 commit 9e2b31b

28 files changed

Lines changed: 82 additions & 78 deletions

client/mysqldump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ static int fetch_db_collation(const char *db_name,
10421042
char *db_cl_name,
10431043
int db_cl_size)
10441044
{
1045-
bool err_status= FALSE;
1045+
my_bool err_status= FALSE;
10461046
char query[QUERY_LENGTH];
10471047
MYSQL_RES *db_cl_res;
10481048
MYSQL_ROW db_cl_row;

client/mysqltest.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,7 +4192,7 @@ void do_connect(struct st_command *command)
41924192
{
41934193
int con_port= opt_port;
41944194
char *con_options;
4195-
bool con_ssl= 0, con_compress= 0;
4195+
my_bool con_ssl= 0, con_compress= 0;
41964196
struct st_connection* con_slot;
41974197

41984198
static DYNAMIC_STRING ds_connection_name;
@@ -5484,7 +5484,7 @@ void fix_win_paths(const char *val, int len)
54845484
*/
54855485

54865486
void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
5487-
const char* val, ulonglong len, bool is_null)
5487+
const char* val, ulonglong len, my_bool is_null)
54885488
{
54895489
if (col_idx < max_replace_column && replace_column[col_idx])
54905490
{
@@ -7408,12 +7408,12 @@ void free_replace()
74087408

74097409

74107410
typedef struct st_replace {
7411-
bool found;
7411+
my_bool found;
74127412
struct st_replace *next[256];
74137413
} REPLACE;
74147414

74157415
typedef struct st_replace_found {
7416-
bool found;
7416+
my_bool found;
74177417
char *replace_string;
74187418
uint to_offset;
74197419
int from_offset;

extra/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typedef struct st_replace {
6767
} REPLACE;
6868

6969
typedef struct st_replace_found {
70-
bool found;
70+
my_bool found;
7171
char *replace_string;
7272
uint to_offset;
7373
int from_offset;

include/my_getopt.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint
7575
const struct my_option *));
7676

7777
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
78-
bool *fix);
79-
longlong getopt_ll_limit_value(longlong, const struct my_option *,bool *fix);
78+
my_bool *fix);
79+
longlong getopt_ll_limit_value(longlong, const struct my_option *,
80+
my_bool *fix);
8081
my_bool getopt_compare_strings(const char *s, const char *t, uint length);
8182

8283
C_MODE_END

include/my_global.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,4 +1508,8 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
15081508
#define min(a, b) ((a) < (b) ? (a) : (b))
15091509
#endif
15101510

1511+
#if !defined(__cplusplus) && !defined(bool)
1512+
#define bool In_C_you_should_use_my_bool_instead()
1513+
#endif
1514+
15111515
#endif /* my_global_h */

include/my_sys.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,12 @@ extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
919919
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
920920
uint cs_flags, myf my_flags);
921921

922-
extern bool resolve_charset(const char *cs_name,
923-
CHARSET_INFO *default_cs,
924-
CHARSET_INFO **cs);
925-
extern bool resolve_collation(const char *cl_name,
926-
CHARSET_INFO *default_cl,
927-
CHARSET_INFO **cl);
922+
extern my_bool resolve_charset(const char *cs_name,
923+
CHARSET_INFO *default_cs,
924+
CHARSET_INFO **cs);
925+
extern my_bool resolve_collation(const char *cl_name,
926+
CHARSET_INFO *default_cl,
927+
CHARSET_INFO **cl);
928928

929929
extern void free_charsets(void);
930930
extern char *get_charsets_dir(char *buf);

include/my_time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void init_time(void);
111111
TRUE The MYSQL_TIME value is definitely out of range
112112
*/
113113

114-
static inline bool validate_timestamp_range(const MYSQL_TIME *t)
114+
static inline my_bool validate_timestamp_range(const MYSQL_TIME *t)
115115
{
116116
if ((t->year > TIMESTAMP_MAX_YEAR || t->year < TIMESTAMP_MIN_YEAR) ||
117117
(t->year == TIMESTAMP_MAX_YEAR && (t->month > 1 || t->day > 19)) ||

include/thr_lock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void thr_unlock(THR_LOCK_DATA *data);
148148
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
149149
uint count, THR_LOCK_OWNER *owner);
150150
void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
151-
void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock);
151+
void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock);
152152
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
153153
void thr_print_locks(void); /* For debugging */
154154
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);

libmysql/libmysql.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,7 +3388,7 @@ static void read_binary_time(MYSQL_TIME *tm, uchar **pos)
33883388
if (length)
33893389
{
33903390
uchar *to= *pos;
3391-
tm->neg= (bool) to[0];
3391+
tm->neg= to[0];
33923392

33933393
tm->day= (ulong) sint4korr(to+1);
33943394
tm->hour= (uint) to[5];
@@ -4218,7 +4218,7 @@ static my_bool is_binary_compatible(enum enum_field_types type1,
42184218
for (range= range_list; range != range_list_end; ++range)
42194219
{
42204220
/* check that both type1 and type2 are in the same range */
4221-
bool type1_found= FALSE, type2_found= FALSE;
4221+
my_bool type1_found= FALSE, type2_found= FALSE;
42224222
for (type= *range; *type != MYSQL_TYPE_NULL; type++)
42234223
{
42244224
type1_found|= type1 == *type;

mysys/charset.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,9 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
606606
is no character set with given name.
607607
*/
608608

609-
bool resolve_charset(const char *cs_name,
610-
CHARSET_INFO *default_cs,
611-
CHARSET_INFO **cs)
609+
my_bool resolve_charset(const char *cs_name,
610+
CHARSET_INFO *default_cs,
611+
CHARSET_INFO **cs)
612612
{
613613
*cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0));
614614

@@ -638,9 +638,9 @@ bool resolve_charset(const char *cs_name,
638638
collation with given name.
639639
*/
640640

641-
bool resolve_collation(const char *cl_name,
642-
CHARSET_INFO *default_cl,
643-
CHARSET_INFO **cl)
641+
my_bool resolve_collation(const char *cl_name,
642+
CHARSET_INFO *default_cl,
643+
CHARSET_INFO **cl)
644644
{
645645
*cl= get_charset_by_name(cl_name, MYF(0));
646646

0 commit comments

Comments
 (0)