Skip to content

Commit 0aacab3

Browse files
committed
write normal case before with more readable condition
brianmario#764 (comment)
1 parent cdc0dbc commit 0aacab3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/mysql2/statement.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,14 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
290290
#endif
291291
break;
292292
case T_BIGNUM:
293-
bind_buffers[i].buffer_type = MYSQL_TYPE_LONGLONG;
294293
{
295294
LONG_LONG num;
296-
if (my_big2ll(argv[i], &num)) {
295+
if (my_big2ll(argv[i], &num) == 0) {
296+
bind_buffers[i].buffer_type = MYSQL_TYPE_LONGLONG;
297+
bind_buffers[i].buffer = xmalloc(sizeof(long long int));
298+
*(LONG_LONG*)(bind_buffers[i].buffer) = num;
299+
} else {
300+
/* The bignum was larger than we can fit in LONG_LONG, send it as a string */
297301
VALUE rb_val_as_string = rb_big2str(argv[i], 10);
298302
bind_buffers[i].buffer_type = MYSQL_TYPE_NEWDECIMAL;
299303
params_enc[i] = rb_val_as_string;
@@ -302,10 +306,6 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
302306
#endif
303307
set_buffer_for_string(&bind_buffers[i], &length_buffers[i], params_enc[i]);
304308
}
305-
else {
306-
bind_buffers[i].buffer = xmalloc(sizeof(long long int));
307-
*(LONG_LONG*)(bind_buffers[i].buffer) = num;
308-
}
309309
}
310310
break;
311311
case T_FLOAT:

0 commit comments

Comments
 (0)