Skip to content

Commit

Permalink
Add supports for JSON #1638
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Nov 23, 2018
1 parent 39d7e35 commit 5034458
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ mariadb-client-library/mariadb_client/include/my_config.h:
cd mariadb-client-library/mariadb_client && patch libmariadb/mysql_async.c < ../mysql_async.c.patch
cd mariadb-client-library/mariadb_client && patch libmariadb/password.c < ../password.c.patch
# cd mariadb-client-library/mariadb_client && patch libmariadb/ma_secure.c < ../ma_secure.c.patch
cd mariadb-client-library/mariadb_client && patch include/mysql_com.h < ../mysql_com.h.patch
cd mariadb-client-library/mariadb_client && patch include/mysql.h < ../mysql.h.patch
cd mariadb-client-library/mariadb_client && patch libmariadb/my_alloc.c < ../my_alloc.c.patch
cd mariadb-client-library/mariadb_client && patch libmariadb/my_charset.c < ../my_charset.c.patch
cd mariadb-client-library/mariadb_client && patch libmariadb/my_stmt.c < ../my_stmt.c.patch
cd mariadb-client-library/mariadb_client && patch libmariadb/my_stmt_codec.c < ../my_stmt_codec.c.patch
cd mariadb-client-library/mariadb_client && CC=${CC} CXX=${CXX} ${MAKE}
# cd mariadb-client-library/mariadb_client/include && make my_config.h

Expand Down
32 changes: 32 additions & 0 deletions deps/mariadb-client-library/my_stmt.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@@ -98,6 +98,7 @@
case MYSQL_TYPE_NULL:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_STRING:
+ case MYSQL_TYPE_JSON:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_TINY:
@@ -523,6 +524,7 @@
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
+ case MYSQL_TYPE_JSON:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
{
@@ -652,6 +654,7 @@
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
+ case MYSQL_TYPE_JSON:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_GEOMETRY:
@@ -839,6 +842,7 @@
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
+ case MYSQL_TYPE_JSON:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
break;
20 changes: 20 additions & 0 deletions deps/mariadb-client-library/my_stmt_codec.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@@ -948,7 +948,7 @@
{
memcpy(r_param->buffer, current_pos, MIN(copylen, r_param->buffer_length));
if (copylen < r_param->buffer_length &&
- r_param->buffer_type == MYSQL_TYPE_STRING)
+ ((r_param->buffer_type == MYSQL_TYPE_STRING) || (r_param->buffer_type == MYSQL_TYPE_JSON)))
((char *)r_param->buffer)[copylen]= 0;
}
}
@@ -1055,6 +1055,10 @@
mysql_ps_fetch_functions[MYSQL_TYPE_STRING].pack_len = MYSQL_PS_SKIP_RESULT_STR;
mysql_ps_fetch_functions[MYSQL_TYPE_STRING].max_len = -1;

+ mysql_ps_fetch_functions[MYSQL_TYPE_JSON].func = ps_fetch_string;
+ mysql_ps_fetch_functions[MYSQL_TYPE_JSON].pack_len = MYSQL_PS_SKIP_RESULT_STR;
+ mysql_ps_fetch_functions[MYSQL_TYPE_JSON].max_len = -1;
+
mysql_ps_fetch_functions[MYSQL_TYPE_DECIMAL].func = ps_fetch_string;
mysql_ps_fetch_functions[MYSQL_TYPE_DECIMAL].pack_len = MYSQL_PS_SKIP_RESULT_STR;
mysql_ps_fetch_functions[MYSQL_TYPE_DECIMAL].max_len = -1;
8 changes: 8 additions & 0 deletions deps/mariadb-client-library/mysql_com.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@@ -278,6 +278,7 @@
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
MYSQL_TYPE_BIT,
+ MYSQL_TYPE_JSON=245,
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,

0 comments on commit 5034458

Please sign in to comment.