Skip to content

Commit

Permalink
Smaller fixes for LibreOffice integration:
Browse files Browse the repository at this point in the history
  - 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)
  • Loading branch information
9EOR9 committed Oct 23, 2016
1 parent 6306c9f commit 884ee22
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/ma_errmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ extern const char *mariadb_client_errors[]; /* Error messages */
#define CR_NO_PREPARE_STMT 2030
#define CR_PARAMS_NOT_BOUND 2031
#define CR_INVALID_PARAMETER_NO 2034
#define CR_INVALID_BUFFER_USE 2035
#define CR_UNSUPPORTED_PARAM_TYPE 2036

#define CR_SHARED_MEMORY_CONNECTION 2037
Expand Down
1 change: 1 addition & 0 deletions include/mariadb_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
MYSQL_TYPE_DATETIME2,
MYSQL_TYPE_TIME2,
/* --------------------------------------------- */
MYSQL_TYPE_JSON=245,
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,
Expand Down
1 change: 1 addition & 0 deletions include/mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ typedef int my_socket;
#include "mariadb_version.h"
#include "ma_list.h"
#include "mariadb_ctype.h"
#include "ma_errmsg.h"

#ifndef ST_MA_USED_MEM_DEFINED
#define ST_MA_USED_MEM_DEFINED
Expand Down
6 changes: 3 additions & 3 deletions libmariadb/ma_errmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ const char *client_errors[]=
/* 2029 */ "",
/* 2030 */ "Statement is not prepared",
/* 2031 */ "No data supplied for parameters in prepared statement",
/* 2032 */ "",
/* 2032 */ "Data truncated",
/* 2033 */ "",
/* 2034 */ "",
/* 2035 */ "",
/* 2034 */ "Invalid parameter number",
/* 2035 */ "Invalid buffer type: %d (paraneter: %d)",
/* 2036 */ "Buffer type is not supported",
/* 2037 */ "Shared memory: %-.64s",
/* 2038 */ "Shared memory connection failed during %s. (%lu)",
Expand Down
7 changes: 6 additions & 1 deletion libmariadb/ma_stmt_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ void ps_fetch_bin(MYSQL_BIND *r_param,
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;
*r_param->error= copylen > r_param->buffer_length;
(*row)+= field_length;
Expand Down Expand Up @@ -1041,6 +1042,10 @@ void mysql_init_ps_subsystem(void)
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;
Expand Down
4 changes: 4 additions & 0 deletions libmariadb/mariadb_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ my_bool mthd_supported_buffer_type(enum enum_field_types type)
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:
Expand Down Expand Up @@ -551,6 +552,7 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p, unsigned long r
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:
{
Expand Down Expand Up @@ -738,6 +740,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
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:
Expand Down Expand Up @@ -968,6 +971,7 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind)
stmt->params[i].buffer_length= 5;
break;
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_JSON:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_TINY_BLOB:
Expand Down

0 comments on commit 884ee22

Please sign in to comment.