Skip to content

Commit 884ee22

Browse files
committed
Smaller fixes for LibreOffice integration:
- added type MYSQL_TYPE_JSON (=245) - include error numbers (ma_errmsg.h) via mysql.h - convert MYSQL_TYPE_JSON to string (prepared statements) - added error message number 2034 (invalid buffer)
1 parent 6306c9f commit 884ee22

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

include/ma_errmsg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ extern const char *mariadb_client_errors[]; /* Error messages */
6767
#define CR_NO_PREPARE_STMT 2030
6868
#define CR_PARAMS_NOT_BOUND 2031
6969
#define CR_INVALID_PARAMETER_NO 2034
70+
#define CR_INVALID_BUFFER_USE 2035
7071
#define CR_UNSUPPORTED_PARAM_TYPE 2036
7172

7273
#define CR_SHARED_MEMORY_CONNECTION 2037

include/mariadb_com.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
326326
MYSQL_TYPE_DATETIME2,
327327
MYSQL_TYPE_TIME2,
328328
/* --------------------------------------------- */
329+
MYSQL_TYPE_JSON=245,
329330
MYSQL_TYPE_NEWDECIMAL=246,
330331
MYSQL_TYPE_ENUM=247,
331332
MYSQL_TYPE_SET=248,

include/mysql.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ typedef int my_socket;
6060
#include "mariadb_version.h"
6161
#include "ma_list.h"
6262
#include "mariadb_ctype.h"
63+
#include "ma_errmsg.h"
6364

6465
#ifndef ST_MA_USED_MEM_DEFINED
6566
#define ST_MA_USED_MEM_DEFINED

libmariadb/ma_errmsg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ const char *client_errors[]=
112112
/* 2029 */ "",
113113
/* 2030 */ "Statement is not prepared",
114114
/* 2031 */ "No data supplied for parameters in prepared statement",
115-
/* 2032 */ "",
115+
/* 2032 */ "Data truncated",
116116
/* 2033 */ "",
117-
/* 2034 */ "",
118-
/* 2035 */ "",
117+
/* 2034 */ "Invalid parameter number",
118+
/* 2035 */ "Invalid buffer type: %d (paraneter: %d)",
119119
/* 2036 */ "Buffer type is not supported",
120120
/* 2037 */ "Shared memory: %-.64s",
121121
/* 2038 */ "Shared memory connection failed during %s. (%lu)",

libmariadb/ma_stmt_codec.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ void ps_fetch_bin(MYSQL_BIND *r_param,
939939
memcpy(r_param->buffer, current_pos, MIN(copylen, r_param->buffer_length));
940940
}
941941
if (copylen < r_param->buffer_length &&
942-
r_param->buffer_type == MYSQL_TYPE_STRING)
942+
(r_param->buffer_type == MYSQL_TYPE_STRING ||
943+
r_param->buffer_type == MYSQL_TYPE_JSON))
943944
((char *)r_param->buffer)[copylen]= 0;
944945
*r_param->error= copylen > r_param->buffer_length;
945946
(*row)+= field_length;
@@ -1041,6 +1042,10 @@ void mysql_init_ps_subsystem(void)
10411042
mysql_ps_fetch_functions[MYSQL_TYPE_STRING].pack_len = MYSQL_PS_SKIP_RESULT_STR;
10421043
mysql_ps_fetch_functions[MYSQL_TYPE_STRING].max_len = -1;
10431044

1045+
mysql_ps_fetch_functions[MYSQL_TYPE_JSON].func = ps_fetch_string;
1046+
mysql_ps_fetch_functions[MYSQL_TYPE_JSON].pack_len = MYSQL_PS_SKIP_RESULT_STR;
1047+
mysql_ps_fetch_functions[MYSQL_TYPE_JSON].max_len = -1;
1048+
10441049
mysql_ps_fetch_functions[MYSQL_TYPE_DECIMAL].func = ps_fetch_string;
10451050
mysql_ps_fetch_functions[MYSQL_TYPE_DECIMAL].pack_len = MYSQL_PS_SKIP_RESULT_STR;
10461051
mysql_ps_fetch_functions[MYSQL_TYPE_DECIMAL].max_len = -1;

libmariadb/mariadb_stmt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ my_bool mthd_supported_buffer_type(enum enum_field_types type)
118118
case MYSQL_TYPE_NULL:
119119
case MYSQL_TYPE_SHORT:
120120
case MYSQL_TYPE_STRING:
121+
case MYSQL_TYPE_JSON:
121122
case MYSQL_TYPE_TIME:
122123
case MYSQL_TYPE_TIMESTAMP:
123124
case MYSQL_TYPE_TINY:
@@ -551,6 +552,7 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p, unsigned long r
551552
case MYSQL_TYPE_VARCHAR:
552553
case MYSQL_TYPE_VAR_STRING:
553554
case MYSQL_TYPE_STRING:
555+
case MYSQL_TYPE_JSON:
554556
case MYSQL_TYPE_DECIMAL:
555557
case MYSQL_TYPE_NEWDECIMAL:
556558
{
@@ -738,6 +740,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
738740
case MYSQL_TYPE_VARCHAR:
739741
case MYSQL_TYPE_VAR_STRING:
740742
case MYSQL_TYPE_STRING:
743+
case MYSQL_TYPE_JSON:
741744
case MYSQL_TYPE_DECIMAL:
742745
case MYSQL_TYPE_NEWDECIMAL:
743746
case MYSQL_TYPE_GEOMETRY:
@@ -968,6 +971,7 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind)
968971
stmt->params[i].buffer_length= 5;
969972
break;
970973
case MYSQL_TYPE_STRING:
974+
case MYSQL_TYPE_JSON:
971975
case MYSQL_TYPE_VAR_STRING:
972976
case MYSQL_TYPE_BLOB:
973977
case MYSQL_TYPE_TINY_BLOB:

0 commit comments

Comments
 (0)