diff --git a/deps/Makefile b/deps/Makefile index 2e8a8333b5..7fa0cec5b7 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -193,53 +193,47 @@ jemalloc: jemalloc/jemalloc/lib/libjemalloc.a mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a: libssl/openssl/libssl.a cd mariadb-client-library && rm -rf mariadb-connector-c-*/ || true - cd mariadb-client-library && tar -zxf mariadb-connector-c-3.1.9-src.tar.gz - cd mariadb-client-library/mariadb_client && patch ./plugins/auth/CMakeLists.txt < ../plugin_auth_CMakeLists.txt.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../ConnectorName.patch + cd mariadb-client-library && tar -zxf mariadb-connector-c-3.3.8-src.tar.gz + cd mariadb-client-library/mariadb_client && patch -p0 < ../plugin_auth_CMakeLists.txt.patch cd mariadb-client-library/mariadb_client && cmake . -Wno-dev -DOPENSSL_ROOT_DIR=$(shell pwd)/libssl/openssl/ -DOPENSSL_LIBRARIES=$(shell pwd)/libssl/openssl/ -DICONV_LIBRARIES=$(brew --prefix libiconv)/lib -DICONV_INCLUDE=$(brew --prefix libiconv)/include . ifeq ($(PROXYDEBUG),1) - cd mariadb-client-library/mariadb_client && patch include/ma_context.h < ../ma_context.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_context.h.patch else ifeq ($(USEVALGRIND),1) - cd mariadb-client-library/mariadb_client && patch include/ma_context.h < ../ma_context.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_context.h.patch endif - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_stmt.c < ../mariadb_stmt.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.collation.patch # make sure this path is applied after mariadb_lib.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.ipv6_fix.patch # make sure this patch is applied after mariadb_lib.c.collation.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_stmt.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_lib.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_lib.c.collation.patch # make sure this path is applied after mariadb_lib.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_lib.c.ipv6_fix.patch # make sure this patch is applied after mariadb_lib.c.collation.patch # cd mariadb-client-library/mariadb_client && patch libmariadb/net.c < ../net.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_async.c < ../mariadb_async.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/ma_password.c < ../ma_password.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_async.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_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.h < ../mysql.h.patch - cd mariadb-client-library/mariadb_client && patch include/mariadb_com.h < ../mariadb_com.h.patch - cd mariadb-client-library/mariadb_client && patch include/ma_priv.h < ../ma_priv.h.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/ma_alloc.c < ../ma_alloc.c.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/ma_charset.c < ../ma_charset.c.patch -# cd mariadb-client-library/mariadb_client && patch libmariadb/ma_pvio.c < ../ma_pvio.c.patch - cd mariadb-client-library/mariadb_client && patch unittest/libmariadb/basic-t.c < ../unittest_basic-t.c.patch - cd mariadb-client-library/mariadb_client && patch unittest/libmariadb/charset.c < ../unittest_charset.c.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../client_deprecate_eof.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../cr_new_stmt_metadata_removal.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../ps_buffer_stmt_read_all_rows.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../empty_split_compress_packet.patch - cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_stmt_store_result_err.patch - + cd mariadb-client-library/mariadb_client && patch -p0 < ../mysql.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_priv.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_alloc.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_charset.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../unittest_basic-t.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../unittest_charset.c.patch ifeq ($(WITHASAN),1) cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_asan.patch endif - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_dyncol.c < ../mariadb_dyncol.c-multiplication-overflow.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/ma_array.c < ../ma_array.c-multiplication-overflow.patch - cd mariadb-client-library/mariadb_client && patch zlib/zutil.c < ../zutil.c-multiplication-overflow.patch - # patches for replication testing - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_rpl.c < ../mariadb_rpl.c.patch - cd mariadb-client-library/mariadb_client && patch include/mariadb_rpl.h < ../mariadb_rpl.h.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_dyncol.c-multiplication-overflow.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ma_array.c-multiplication-overflow.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../zutil.c-multiplication-overflow.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../cr_new_stmt_metadata_removal.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../ps_buffer_stmt_read_all_rows.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_stmt_store_result_err.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../empty_split_compress_packet.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../sslkeylogfile.patch + #cd mariadb-client-library/mariadb_client && patch libmariadb/ma_pvio.c < ../ma_pvio.c.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../client_deprecate_eof.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_com.h.patch # patches for x509 cache . See https://github.com/sysown/proxysql/issues/4117 (Slow connection time with SSL and large CA file , relevant on Aurora) - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.x509cache.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/secure/openssl.c < ../openssl.c.x509cache.patch - cd mariadb-client-library/mariadb_client && patch include/mysql.h < ../mysql.h.sslkeylogfile.patch - cd mariadb-client-library/mariadb_client && patch include/ma_common.h < ../ma_common.h.sslkeylogfile.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/mariadb_lib.c < ../mariadb_lib.c.sslkeylogfile.patch - cd mariadb-client-library/mariadb_client && patch libmariadb/secure/openssl.c < ../openssl.c.sslkeylogfile.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../x509cache.patch + # patches for replication testing + cd mariadb-client-library/mariadb_client && patch -p0 < ../mariadb_rpl.patch + cd mariadb-client-library/mariadb_client && patch -p0 < ../cmakelists.txt.patch cd mariadb-client-library/mariadb_client && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient # cd mariadb-client-library/mariadb_client/include && make my_config.h diff --git a/deps/mariadb-client-library/ConnectorName.patch b/deps/mariadb-client-library/ConnectorName.patch deleted file mode 100644 index 3227bd1d7c..0000000000 --- a/deps/mariadb-client-library/ConnectorName.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git cmake/ConnectorName.cmake cmake/ConnectorName.cmake -index b7bbbad..357b8ac 100644 ---- cmake/ConnectorName.cmake -+++ cmake/ConnectorName.cmake -@@ -22,7 +22,7 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Windows") - SET(MACHINE_NAME "x64") - ELSE() - SET(MACHINE_NAME "32") -- END() -+ ENDIF() - ENDIF() - - SET(product_name "mysql-connector-c-${CPACK_PACKAGE_VERSION}-${PLATFORM_NAME}${CONCAT_SIGN}${MACHINE_NAME}") diff --git a/deps/mariadb-client-library/client_deprecate_eof.patch b/deps/mariadb-client-library/client_deprecate_eof.patch index bca69d290d..bf8a89822e 100644 --- a/deps/mariadb-client-library/client_deprecate_eof.patch +++ b/deps/mariadb-client-library/client_deprecate_eof.patch @@ -1,10 +1,10 @@ diff --git include/ma_common.h include/ma_common.h -index 62cf71c..c05e9a3 100644 +index 0d3f39b3..112cd3b5 100644 --- include/ma_common.h +++ include/ma_common.h -@@ -23,6 +23,8 @@ - #include - #include +@@ -24,6 +24,8 @@ + #include + #include +#define MAX_PACKET_LENGTH (256L*256L*256L-1) + @@ -12,37 +12,36 @@ index 62cf71c..c05e9a3 100644 COM_MULTI_OFF= 0, COM_MULTI_CANCEL, diff --git include/mariadb_com.h include/mariadb_com.h -index 948d96e..225b2f5 100644 +index 67461b4f..96e6e04f 100644 --- include/mariadb_com.h +++ include/mariadb_com.h -@@ -160,6 +160,7 @@ enum enum_server_command - #define CLIENT_CONNECT_ATTRS (1UL << 20) +@@ -161,6 +161,7 @@ enum enum_server_command + #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) #define CLIENT_SESSION_TRACKING (1UL << 23) +#define CLIENT_DEPRECATE_EOF (1UL << 24) + #define CLIENT_ZSTD_COMPRESSION (1UL << 26) #define CLIENT_PROGRESS (1UL << 29) /* client supports progress indicator */ #define CLIENT_PROGRESS_OBSOLETE CLIENT_PROGRESS - #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) -@@ -204,8 +205,14 @@ enum enum_server_command +@@ -209,7 +210,13 @@ enum enum_server_command CLIENT_REMEMBER_OPTIONS |\ CLIENT_PLUGIN_AUTH |\ CLIENT_SESSION_TRACKING |\ + CLIENT_DEPRECATE_EOF |\ CLIENT_CONNECT_ATTRS) - +/* Client capabilities *does no* longer holds 'CLIENT_DEPRECATE_EOF' flag + * by default. This is part of ProxySQL feature for conditionally disabling + * 'deprecate_eof' support in both client and backend connections. For more + * context see #3280. -+ */ - #define CLIENT_CAPABILITIES (CLIENT_MYSQL | \ ++ */ + #define CLIENT_CAPABILITIES (CLIENT_MYSQL | \ CLIENT_LONG_FLAG |\ CLIENT_TRANSACTIONS |\ diff --git include/mariadb_stmt.h include/mariadb_stmt.h -index d07540e..4930573 100644 +index 531c2181..1ae9cf99 100644 --- include/mariadb_stmt.h +++ include/mariadb_stmt.h -@@ -257,7 +257,7 @@ typedef struct st_mysql_perm_bind { +@@ -209,7 +209,7 @@ typedef struct st_mysql_perm_bind { } MYSQL_PS_CONVERSION; extern MYSQL_PS_CONVERSION mysql_ps_fetch_functions[MYSQL_TYPE_GEOMETRY + 1]; @@ -52,7 +51,7 @@ index d07540e..4930573 100644 unsigned long net_field_length(unsigned char **packet); int ma_simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, diff --git libmariadb/ma_net.c libmariadb/ma_net.c -index 15be4fc..a69e637 100644 +index 0b1d0cce..83bf729a 100644 --- libmariadb/ma_net.c +++ libmariadb/ma_net.c @@ -39,8 +39,6 @@ @@ -65,10 +64,10 @@ index 15be4fc..a69e637 100644 See bug conc-57 */ diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c -index e475e25..1a04b2f 100644 +index 75e3c9a4..916024a8 100644 --- libmariadb/mariadb_lib.c +++ libmariadb/mariadb_lib.c -@@ -144,6 +144,7 @@ struct st_mariadb_methods MARIADB_DEFAULT_METHODS; +@@ -150,6 +150,7 @@ struct st_mariadb_methods MARIADB_DEFAULT_METHODS; #define IS_CONNHDLR_ACTIVE(mysql)\ ((mysql)->extension && (mysql)->extension->conn_hdlr) @@ -76,7 +75,7 @@ index e475e25..1a04b2f 100644 static void end_server(MYSQL *mysql); static void mysql_close_memory(MYSQL *mysql); void read_user_name(char *name); -@@ -190,11 +191,15 @@ void net_get_error(char *buf, size_t buf_len, +@@ -196,11 +197,15 @@ void net_get_error(char *buf, size_t buf_len, *****************************************************************************/ ulong @@ -93,45 +92,44 @@ index e475e25..1a04b2f 100644 restart: if (net->pvio != 0) len=ma_net_read(net); -@@ -251,6 +256,28 @@ restart: +@@ -263,6 +268,27 @@ restart: return(packet_error); } + else + { + if (is_data_packet) { -+ unsigned long deprecate_eof = -+ mysql->server_capabilities & CLIENT_DEPRECATE_EOF; -+ *is_data_packet = TRUE; -+ -+ // NOTE: -+ // The only possible alternative to an okay packet where the first byte is -+ // 0xfe, is a packet of int which is bigger than 0xffffff. This is -+ // the reason why a check 'len <= MAX_PACKET_LENGTH' guarantees that -+ // *by_exclusion* the current packet is an 'ok_packet'. -+ if (deprecate_eof && (net->read_pos[0] == 254 && len <= MAX_PACKET_LENGTH)) { -+ *is_data_packet = FALSE; -+ } -+ // A '< 9' check guarantees that it's an EOF packet. -+ else if (!deprecate_eof && (net->read_pos[0] == 254 && len < 9)) -+ { -+ *is_data_packet = FALSE; -+ } ++ unsigned long deprecate_eof = mysql->server_capabilities & CLIENT_DEPRECATE_EOF; ++ *is_data_packet = TRUE; ++ ++ // NOTE: ++ // The only possible alternative to an okay packet where the first byte is ++ // 0xfe, is a packet of int which is bigger than 0xffffff. This is ++ // the reason why a check 'len <= MAX_PACKET_LENGTH' guarantees that ++ // *by_exclusion* the current packet is an 'ok_packet'. ++ if (deprecate_eof && (net->read_pos[0] == 254 && len <= MAX_PACKET_LENGTH)) { ++ *is_data_packet = FALSE; ++ } ++ // A '< 9' check guarantees that it's an EOF packet. ++ else if (!deprecate_eof && (net->read_pos[0] == 254 && len < 9)) ++ { ++ *is_data_packet = FALSE; ++ } + } + } return len; } -@@ -424,7 +451,7 @@ mthd_my_send_cmd(MYSQL *mysql,enum enum_server_command command, const char *arg, +@@ -448,7 +474,7 @@ mthd_my_send_cmd(MYSQL *mysql,enum enum_server_command command, const char *arg, - if (!skipp_check) + if (!skip_check) { - result= ((mysql->packet_length=ma_net_safe_read(mysql)) == packet_error ? + result= ((mysql->packet_length=ma_net_safe_read(mysql, NULL)) == packet_error ? 1 : 0); } end: -@@ -565,12 +592,14 @@ end_server(MYSQL *mysql) +@@ -581,12 +607,14 @@ end_server(MYSQL *mysql) void mthd_my_skip_result(MYSQL *mysql) { ulong pkt_len; @@ -148,29 +146,29 @@ index e475e25..1a04b2f 100644 return; } -@@ -851,6 +880,95 @@ static size_t rset_field_offsets[]= { +@@ -1021,6 +1049,95 @@ static size_t rset_field_offsets[]= { OFFSET(MYSQL_FIELD, org_name_length) }; +/** -+ * @brief Helper function to unpack a particular field. -+ * -+ * NOTE: This function have been introduced due to the requirement -+ * of 'field unpacking' in mthd_my_read_metadata_ex. Extracting the -+ * logic from 'unpack_fields' function. -+ * -+ * @param mysql The mysql connection handler. -+ * @param alloc The mem_root allocator. -+ * @param default_value The default value to use for the field in case -+ * of not containing one. -+ * @param row The row containing the field description. -+ * @param field Output parameter holding the unpacked MYSQL_FIELD. -+ * -+ * @returns 0 on success. -+ */ ++ * @brief Helper function to unpack a particular field. ++ * ++ * NOTE: This function have been introduced due to the requirement ++ * of 'field unpacking' in mthd_my_read_metadata_ex. Extracting the ++ * logic from 'unpack_fields' function. ++ * ++ * @param mysql The mysql connection handler. ++ * @param alloc The mem_root allocator. ++ * @param default_value The default value to use for the field in case ++ * of not containing one. ++ * @param row The row containing the field description. ++ * @param field Output parameter holding the unpacked MYSQL_FIELD. ++ * ++ * @returns 0 on success. ++ */ +int +unpack_field(const MYSQL *mysql, MA_MEM_ROOT *alloc, my_bool default_value, -+ MYSQL_ROWS *row, MYSQL_FIELD *field, ulong* field_length) ++ MYSQL_ROWS *row, MYSQL_FIELD *field, ulong* field_length) +{ + unsigned int i, field_count = sizeof(rset_field_offsets) / sizeof(size_t) / 2; + char *p = NULL; @@ -181,15 +179,15 @@ index e475e25..1a04b2f 100644 + { + // Initialize in case of empty field + if (row->data[i][0] == 0) { -+ *(char **)(((char *)field) + rset_field_offsets[i*2]) = ma_strdup_root(alloc, ""); -+ *(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1]) = 0; ++ *(char **)(((char *)field) + rset_field_offsets[i*2]) = ma_strdup_root(alloc, ""); ++ *(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1]) = 0; + } + // Copy data in case of not empty + else + { -+ uint length = (uint)((field_length != NULL) ? field_length[i] : (row->data[i+1] - row->data[i] - 1)); ++ uint length = ((field_length != NULL) ? (uint)field_length[i] : (uint)(row->data[i+1] - row->data[i] - 1)); + *(char **)(((char *)field) + rset_field_offsets[i*2]) = -+ ma_strdup_root(alloc, (char *)row->data[i]); ++ ma_strdup_root(alloc, (char *)row->data[i]); + *(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1]) = + length; + } @@ -228,9 +226,9 @@ index e475e25..1a04b2f 100644 + field->flags|= NUM_FLAG; + + i++; -+ /* This is used by deprecated function mysql_list_fields only, -+ however the reported length is not correct, so we always zero it */ -+ if (default_value && row->data[i]) ++ /*This is used by deprecated function mysql_list_fields only, ++ however the reported length is not correct, so we always zero it */ ++ if (default_value && row->data[i]) + field->def = ma_strdup_root(alloc,(char*) row->data[i]); + else + field->def = 0; @@ -244,7 +242,7 @@ index e475e25..1a04b2f 100644 MYSQL_FIELD * unpack_fields(const MYSQL *mysql, MYSQL_DATA *data, MA_MEM_ROOT *alloc, uint fields, -@@ -858,71 +976,19 @@ unpack_fields(const MYSQL *mysql, +@@ -1028,71 +1145,19 @@ unpack_fields(const MYSQL *mysql, { MYSQL_ROWS *row; MYSQL_FIELD *field,*result; @@ -264,7 +262,7 @@ index e475e25..1a04b2f 100644 - for (i=0; i < field_count; i++) - { - uint length= (uint)(row->data[i+1] - row->data[i] - 1); -- if (!row->data[i] && row->data[i][length]) +- if (!row->data[i] || row->data[i][length]) - goto error; - - *(char **)(((char *)field) + rset_field_offsets[i*2])= @@ -319,7 +317,7 @@ index e475e25..1a04b2f 100644 } if (field < result + fields) goto error; -@@ -948,8 +1014,9 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +@@ -1118,8 +1183,9 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, MYSQL_DATA *result; MYSQL_ROWS **prev_ptr,*cur; NET *net = &mysql->net; @@ -330,7 +328,7 @@ index e475e25..1a04b2f 100644 return(0); if (!(result=(MYSQL_DATA*) calloc(1, sizeof(MYSQL_DATA)))) { -@@ -962,7 +1029,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +@@ -1132,7 +1198,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, result->rows=0; result->fields=fields; @@ -339,7 +337,7 @@ index e475e25..1a04b2f 100644 { result->rows++; if (!(cur= (MYSQL_ROWS*) ma_alloc_root(&result->alloc, -@@ -1005,7 +1072,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +@@ -1175,7 +1241,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, } } cur->data[field]=to; /* End of last field */ @@ -348,10 +346,10 @@ index e475e25..1a04b2f 100644 { free_rows(result); return(0); -@@ -1015,10 +1082,14 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - /* save status */ +@@ -1186,10 +1252,14 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, if (pkt_len > 1) { + unsigned int last_status= mysql->server_status; - cp++; - mysql->warning_count= uint2korr(cp); - cp+= 2; @@ -359,15 +357,15 @@ index e475e25..1a04b2f 100644 + // read the final EOF or OK packet + if (mysql->server_capabilities & CLIENT_DEPRECATE_EOF) + { -+ ma_read_ok_packet(mysql, cp + 1, pkt_len); ++ ma_read_ok_packet(mysql, cp + 1, pkt_len); + } else { -+ mysql->warning_count = uint2korr(cp + 1); -+ mysql->server_status = uint2korr(cp + 3); ++ mysql->warning_count = uint2korr(cp + 1); ++ mysql->server_status = uint2korr(cp + 3); + } + ma_status_callback(mysql, last_status) } return(result); - } -@@ -1035,15 +1106,21 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) +@@ -1207,15 +1277,21 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) uint field; ulong pkt_len,len; uchar *pos,*prev_pos, *end_pos; @@ -381,20 +379,19 @@ index e475e25..1a04b2f 100644 + // we are reading either final 'OK' or 'EOF' packet + if (mysql->net.read_pos[0] != 0 && !is_data_packet) { + unsigned int last_status= mysql->server_status; - mysql->warning_count= uint2korr(mysql->net.read_pos + 1); - mysql->server_status= uint2korr(mysql->net.read_pos + 3); -- return 1; /* End of data */ + if (mysql->server_capabilities & CLIENT_DEPRECATE_EOF) { + ma_read_ok_packet(mysql, mysql->net.read_pos + 1, pkt_len); + } else { + mysql->warning_count= uint2korr(mysql->net.read_pos + 1); + mysql->server_status= uint2korr(mysql->net.read_pos + 3); + } -+ return 1; + ma_status_callback(mysql, last_status); + return 1; /* End of data */ } - prev_pos= 0; /* allowed to write at packet[-1] */ - pos=mysql->net.read_pos; -@@ -1077,6 +1154,85 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) +@@ -1251,6 +1327,85 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) return 0; } @@ -438,27 +435,27 @@ index e475e25..1a04b2f 100644 + // read the columns info + for (f_i = 0; f_i < field_count; f_i++) + { -+ if (mthd_my_read_one_row(mysql, m_field_count, m_rows.data, m_len) == -1) -+ return NULL; -+ if (unpack_field(mysql, mem_root, 0, &m_rows, m_fields++, m_len)) -+ return NULL; ++ if (mthd_my_read_one_row(mysql, m_field_count, m_rows.data, m_len) == -1) ++ return NULL; ++ if (unpack_field(mysql, mem_root, 0, &m_rows, m_fields++, m_len)) ++ return NULL; + } + // read EOF packet in case of client not supporting 'CLIENT_DEPRECATE_EOF' + if (!(mysql->server_capabilities & CLIENT_DEPRECATE_EOF)) + { + // read the EOF packet + if (packet_error == ma_net_safe_read(mysql, NULL)) -+ return 0; ++ return 0; + -+ // verify it's actually an EOF packet -+ if (*(mysql->net.read_pos) == 254) -+ { -+ mysql->warning_count = uint2korr(mysql->net.read_pos + 1); -+ mysql->server_status = uint2korr(mysql->net.read_pos + 3); -+ } ++ // verify it's actually an EOF packet ++ if (*(mysql->net.read_pos) == 254) ++ { ++ mysql->warning_count = uint2korr(mysql->net.read_pos + 1); ++ mysql->server_status = uint2korr(mysql->net.read_pos + 3); + } ++ } + -+ return result; ++ return result; +} + +/** @@ -474,13 +471,13 @@ index e475e25..1a04b2f 100644 + */ +MYSQL_FIELD* mthd_my_read_metadata(MYSQL* mysql, ulong field_count, uint m_field_count) +{ -+ return mthd_my_read_metadata_ex(mysql, &mysql->field_alloc, field_count, m_field_count); ++ return mthd_my_read_metadata_ex(mysql, &mysql->field_alloc, field_count, m_field_count); +} + /**************************************************************************** ** Init MySQL structure or allocate one ****************************************************************************/ -@@ -1494,7 +1650,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, +@@ -1793,7 +1948,7 @@ restart: goto error; } */ @@ -489,7 +486,7 @@ index e475e25..1a04b2f 100644 { if (mysql->net.last_errno == CR_SERVER_LOST) my_set_error(mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN, -@@ -1596,6 +1752,16 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, +@@ -1894,6 +2049,16 @@ restart: } } @@ -506,14 +503,15 @@ index e475e25..1a04b2f 100644 /* pad 2 */ end+= 18; -@@ -2361,14 +2527,13 @@ int mthd_my_read_query_result(MYSQL *mysql) +@@ -2856,7 +3021,6 @@ int mthd_my_read_query_result(MYSQL *mysql) { uchar *pos; ulong field_count; - MYSQL_DATA *fields; ulong length; - my_bool can_local_infile= (mysql->options.extension) && (mysql->extension->auto_local_infile != WAIT_FOR_QUERY); - + const uchar *end; + uchar has_metadata; +@@ -2866,7 +3030,7 @@ int mthd_my_read_query_result(MYSQL *mysql) if (mysql->options.extension && mysql->extension->auto_local_infile == ACCEPT_FILE_REQUEST) mysql->extension->auto_local_infile= WAIT_FOR_QUERY; @@ -522,7 +520,7 @@ index e475e25..1a04b2f 100644 { return(1); } -@@ -2381,7 +2546,7 @@ get_info: +@@ -2880,7 +3044,7 @@ get_info: { int error=mysql_handle_local_infile(mysql, (char *)pos, can_local_infile); @@ -531,27 +529,34 @@ index e475e25..1a04b2f 100644 return(-1); goto get_info; /* Get info packet */ } -@@ -2389,12 +2554,13 @@ get_info: - mysql->server_status|= SERVER_STATUS_IN_TRANS; - - mysql->extra_info= net_field_length_ll(&pos); /* Maybe number of rec */ -- if (!(fields=mysql->methods->db_read_rows(mysql,(MYSQL_FIELD*) 0, -- ma_result_set_rows(mysql)))) -- return(-1); -- if (!(mysql->fields=unpack_fields(mysql, fields, &mysql->field_alloc, -- (uint) field_count, 1))) -- return(-1); -+ // read packet metadata -+ mysql->fields = -+ mthd_my_read_metadata(mysql, field_count, 7 + ma_extended_type_info_rows(mysql)); -+ if (!mysql->fields) { -+ ma_free_root(&mysql->field_alloc, MYF(0)); -+ return(1); -+ } - mysql->status=MYSQL_STATUS_GET_RESULT; - mysql->field_count=field_count; - return(0); -@@ -2775,21 +2941,17 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild) +@@ -2901,18 +3065,19 @@ get_info: + + if (has_metadata) + { +- if (!(fields= mysql->methods->db_read_rows(mysql, (MYSQL_FIELD *) 0, +- ma_result_set_rows(mysql)))) +- return (-1); +- if (!(mysql->fields= unpack_fields(mysql, fields, &mysql->field_alloc, +- (uint) field_count, 1))) +- return (-1); ++ // read packet metadata ++ mysql->fields = ++ mthd_my_read_metadata(mysql, field_count, 7 + ma_extended_type_info_rows(mysql)); ++ if (!mysql->fields) { ++ ma_free_root(&mysql->field_alloc, MYF(0)); ++ return(1); ++ } + } + else + { + unsigned int last_status= mysql->server_status; + /* Read EOF, to get the status and warning count. */ +- if ((length= ma_net_safe_read(mysql)) == packet_error) ++ if ((length= ma_net_safe_read(mysql, NULL)) == packet_error) + { + return -1; + } +@@ -3309,20 +3474,16 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild) MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql) { @@ -569,14 +574,12 @@ index e475e25..1a04b2f 100644 - return(NULL); - if (!(mysql->fields= unpack_fields(mysql, fields, &mysql->field_alloc, - field_count, 0))) -- return(NULL); + mysql->fields= mthd_my_read_metadata(mysql, field_count, 7); + if (!mysql->fields) -+ return(NULL); + return(NULL); mysql->status=MYSQL_STATUS_GET_RESULT; mysql->field_count=field_count; - return(mysql_store_result(mysql)); -@@ -4251,7 +4413,7 @@ mysql_debug(const char *debug __attribute__((unused))) +@@ -4830,7 +4991,7 @@ mysql_debug(const char *debug __attribute__((unused))) *********************************************************************/ ulong STDCALL mysql_net_read_packet(MYSQL *mysql) { @@ -586,23 +589,23 @@ index e475e25..1a04b2f 100644 ulong STDCALL mysql_net_field_length(uchar **packet) diff --git libmariadb/mariadb_rpl.c libmariadb/mariadb_rpl.c -index 6a7e0cf..492727d 100644 +index 0019f246..daa6d242 100644 --- libmariadb/mariadb_rpl.c +++ libmariadb/mariadb_rpl.c -@@ -122,7 +122,7 @@ MARIADB_RPL_EVENT * STDCALL mariadb_rpl_fetch(MARIADB_RPL *rpl, MARIADB_RPL_EVEN - return 0; +@@ -1021,7 +1021,7 @@ MARIADB_RPL_EVENT * STDCALL mariadb_rpl_fetch(MARIADB_RPL *rpl, MARIADB_RPL_EVEN - while (1) { -- unsigned long pkt_len= ma_net_safe_read(rpl->mysql); -+ unsigned long pkt_len= ma_net_safe_read(rpl->mysql, NULL); - - if (pkt_len == packet_error) + if (rpl->mysql) { +- pkt_len= ma_net_safe_read(rpl->mysql); ++ pkt_len= ma_net_safe_read(rpl->mysql, NULL); + + if (pkt_len == packet_error) + { diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c -index 0aaaf1a..229023b 100644 +index d6df0825..af442088 100644 --- libmariadb/mariadb_stmt.c +++ libmariadb/mariadb_stmt.c -@@ -78,6 +78,9 @@ typedef struct +@@ -80,6 +80,9 @@ typedef struct } MADB_STMT_EXTENSION; static my_bool net_stmt_close(MYSQL_STMT *stmt, my_bool remove); @@ -612,18 +615,19 @@ index 0aaaf1a..229023b 100644 static my_bool is_not_null= 0; static my_bool is_null= 1; -@@ -153,8 +156,9 @@ static int stmt_unbuffered_eof(MYSQL_STMT *stmt __attribute__((unused)), +@@ -171,8 +174,9 @@ static int stmt_unbuffered_eof(MYSQL_STMT *stmt __attribute__((unused)), static int stmt_unbuffered_fetch(MYSQL_STMT *stmt, uchar **row) { ulong pkt_len; -+ my_bool is_data_packet; - +- - pkt_len= ma_net_safe_read(stmt->mysql); ++ my_bool is_data_packet; ++ + pkt_len= ma_net_safe_read(stmt->mysql, &is_data_packet); if (pkt_len == packet_error) { -@@ -162,8 +166,10 @@ static int stmt_unbuffered_fetch(MYSQL_STMT *stmt, uchar **row) +@@ -180,8 +184,11 @@ static int stmt_unbuffered_fetch(MYSQL_STMT *stmt, uchar **row) return(1); } @@ -631,11 +635,12 @@ index 0aaaf1a..229023b 100644 + if (stmt->mysql->net.read_pos[0] != 0 && !is_data_packet) { + if (stmt->mysql->server_capabilities & CLIENT_DEPRECATE_EOF) -+ ma_read_ok_packet(stmt->mysql, stmt->mysql->net.read_pos + 1, pkt_len); ++ ma_read_ok_packet(stmt->mysql, stmt->mysql->net.read_pos + 1, pkt_len); ++ *row = NULL; stmt->fetch_row_func= stmt_unbuffered_eof; return(MYSQL_NO_DATA); -@@ -195,13 +201,15 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) +@@ -213,10 +220,11 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) MYSQL_ROWS *current, **pprevious; ulong packet_len; unsigned char *p; @@ -646,6 +651,11 @@ index 0aaaf1a..229023b 100644 - while ((packet_len = ma_net_safe_read(stmt->mysql)) != packet_error) + while ((packet_len = ma_net_safe_read(stmt->mysql, &is_data_packet)) != packet_error) { + // This change is required due to the new algorithm introduced in ProxySQL in #3295. + // ******************************************************************************** +@@ -237,7 +245,8 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) + // ******************************************************************************** + p= stmt->mysql->net.read_pos; - if (packet_len > 7 || p[0] != 254) + // The check is by 'ma_net_safe_read' @@ -653,15 +663,14 @@ index 0aaaf1a..229023b 100644 { /* allocate space for rows */ if (!(current= (MYSQL_ROWS *)ma_alloc_root(&result->alloc, sizeof(MYSQL_ROWS) + packet_len))) -@@ -276,10 +284,16 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) - { +@@ -324,10 +333,14 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) + unsigned int last_status= stmt->mysql->server_status; *pprevious= 0; /* sace status info */ - p++; - stmt->upsert_status.warning_count= stmt->mysql->warning_count= uint2korr(p); - p+=2; - stmt->upsert_status.server_status= stmt->mysql->server_status= uint2korr(p); -+ + if (stmt->mysql->server_capabilities & CLIENT_DEPRECATE_EOF && !is_data_packet) { + ma_read_ok_packet(stmt->mysql, p + 1, packet_len); + stmt->upsert_status.warning_count= stmt->mysql->warning_count; @@ -670,11 +679,10 @@ index 0aaaf1a..229023b 100644 + stmt->upsert_status.warning_count= stmt->mysql->warning_count= uint2korr(p + 1); + stmt->upsert_status.server_status= stmt->mysql->server_status= uint2korr(p + 3); + } -+ + ma_status_callback(stmt->mysql, last_status); stmt->result_cursor= result->data; return(0); - } -@@ -336,30 +348,52 @@ static int stmt_cursor_fetch(MYSQL_STMT *stmt, uchar **row) +@@ -388,34 +401,57 @@ static int stmt_cursor_fetch(MYSQL_STMT *stmt, uchar **row) void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt) { ulong packet_len; @@ -684,7 +692,9 @@ index 0aaaf1a..229023b 100644 - while ((packet_len = ma_net_safe_read(stmt->mysql)) != packet_error) + while ((packet_len = ma_net_safe_read(stmt->mysql, &is_data_packet)) != packet_error) { + unsigned int last_status= stmt->mysql->server_status; uchar *pos= stmt->mysql->net.read_pos; + - if (!in_resultset && *pos == 0) /* OK */ + if (stmt->mysql->server_capabilities & CLIENT_DEPRECATE_EOF) { @@ -692,22 +702,23 @@ index 0aaaf1a..229023b 100644 - net_field_length(&pos); - net_field_length(&pos); - stmt->mysql->server_status= uint2korr(pos); -- goto end; + if (!in_resultset && *pos == 0) /* OK */ + { -+ // 'ma_read_ok_packet' now updates 'server_status' -+ ma_read_ok_packet(stmt->mysql, pos + 1, packet_len); -+ goto end; ++ // 'ma_read_ok_packet' now updates 'server_status' ++ ma_read_ok_packet(stmt->mysql, pos + 1, packet_len); ++ goto end; + } + + // We got the initial ok_packet, avoid extra checks. + in_resultset = 1; + + if (*pos != 0 && !is_data_packet) { /* Final OK */ -+ // 'ma_read_ok_packet' now updates 'server_status' -+ ma_read_ok_packet(stmt->mysql, pos + 1, packet_len); -+ goto end; ++ // 'ma_read_ok_packet' now updates 'server_status' ++ ma_read_ok_packet(stmt->mysql, pos + 1, packet_len); ++ goto end; + } + ma_status_callback(stmt->mysql, last_status); + goto end; } - if (packet_len < 8 && *pos == 254) /* EOF */ + else @@ -724,6 +735,7 @@ index 0aaaf1a..229023b 100644 + if (packet_len < 8 && *pos == 254) /* EOF */ { - stmt->mysql->server_status= uint2korr(pos + 3); + ma_status_callback(stmt->mysql, last_status); - if (in_resultset) + if (mariadb_connection(stmt->mysql)) + { @@ -741,7 +753,7 @@ index 0aaaf1a..229023b 100644 } } end: -@@ -1554,7 +1588,7 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) +@@ -1675,7 +1711,7 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) ulong packet_length; uchar *p; @@ -750,7 +762,7 @@ index 0aaaf1a..229023b 100644 return(1); p= (uchar *)stmt->mysql->net.read_pos; -@@ -1579,28 +1613,38 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) +@@ -1747,28 +1783,37 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt) return(0); } @@ -775,12 +787,11 @@ index 0aaaf1a..229023b 100644 - if (!(result= stmt->mysql->methods->db_read_rows(stmt->mysql, (MYSQL_FIELD *)0, - 7 + ma_extended_type_info_rows(stmt->mysql)))) + if (!(mthd_my_read_metadata_ex(stmt->mysql, &mt_alloc, stmt->param_count, -+ 7 + ma_extended_type_info_rows(stmt->mysql)))) ++ 7 + ma_extended_type_info_rows(stmt->mysql)))) return(1); - free_rows(result); + ma_free_root(&mt_alloc, MYF(0)); -+ return(0); } @@ -795,30 +806,29 @@ index 0aaaf1a..229023b 100644 - if (!(stmt->fields= unpack_fields(stmt->mysql, result, fields_ma_alloc_root, - stmt->field_count, 0))) + stmt->fields = -+ mthd_my_read_metadata_ex(stmt->mysql, fields_ma_alloc_root, stmt->field_count, -+ 7 + ma_extended_type_info_rows(stmt->mysql)); ++ mthd_my_read_metadata_ex(stmt->mysql, fields_ma_alloc_root, stmt->field_count, ++ 7 + ma_extended_type_info_rows(stmt->mysql)); + if (!(stmt->fields)) return(1); return(0); } -@@ -1871,6 +1915,12 @@ int stmt_read_execute_response(MYSQL_STMT *stmt) - if (!stmt->mysql) - return(1); - +@@ -2003,6 +2048,11 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt) + return (1); + } + } + /* + * NOTE: There is a relevant patch that should be applied in + * this section in case CURSOR support is added to ProxySQL, + * check: https://github.com/mysql/mysql-server/blob/ee4455a33b10f1b1886044322e4893f587b319ed/libmysql/libmysql.cc#L1994 + */ -+ + /* update affected rows, also if an error occurred */ stmt->upsert_status.affected_rows= stmt->mysql->affected_rows; - diff --git plugins/auth/my_auth.c plugins/auth/my_auth.c -index 0435b4f..c54c0e5 100644 +index 72773079..38e50b7a 100644 --- plugins/auth/my_auth.c +++ plugins/auth/my_auth.c -@@ -401,7 +401,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf) +@@ -463,7 +463,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf) } /* otherwise read the data */ @@ -827,7 +837,7 @@ index 0435b4f..c54c0e5 100644 return (int)packet_error; mpvio->last_read_packet_len= pkt_len; -@@ -617,7 +617,7 @@ retry: +@@ -691,7 +691,7 @@ retry: /* read the OK packet (or use the cached value in mysql->net.read_pos */ if (res == CR_OK) @@ -837,14 +847,14 @@ index 0435b4f..c54c0e5 100644 pkt_length= mpvio.last_read_packet_len; diff --git unittest/libmariadb/ps_bugs.c unittest/libmariadb/ps_bugs.c -index 25fd9f5..b1abcdd 100644 +index efe3d447..67effa26 100644 --- unittest/libmariadb/ps_bugs.c +++ unittest/libmariadb/ps_bugs.c -@@ -3931,6 +3931,10 @@ static int test_conc141(MYSQL *mysql) +@@ -3961,6 +3961,10 @@ static int test_conc141(MYSQL *mysql) rc= mysql_stmt_execute(stmt); check_stmt_rc(rc, stmt); -+ ++ + rc= mysql_stmt_free_result(stmt); + check_stmt_rc(rc, stmt); + @@ -852,20 +862,20 @@ index 25fd9f5..b1abcdd 100644 rc= mysql_stmt_next_result(stmt); FAIL_IF(rc==-1, "No more results and error expected"); diff --git unittest/libmariadb/ps_new.c unittest/libmariadb/ps_new.c -index 9b89d6f..39b93cb 100644 +index ea228f1c..38eaa0af 100644 --- unittest/libmariadb/ps_new.c +++ unittest/libmariadb/ps_new.c -@@ -105,6 +105,9 @@ static int test_multi_result(MYSQL *mysql) +@@ -108,6 +108,9 @@ static int test_multi_result(MYSQL *mysql) FAIL_IF(int_data[0] != 10 || int_data[1] != 20 || int_data[2] != 30, "expected 10 20 30"); + rc= mysql_stmt_free_result(stmt); // must call before next mysql_stmt_next_result + check_stmt_rc(rc, stmt); -+ ++ rc= mysql_stmt_next_result(stmt); check_stmt_rc(rc, stmt); rc= mysql_stmt_bind_result(stmt, rs_bind); -@@ -113,6 +116,8 @@ static int test_multi_result(MYSQL *mysql) +@@ -116,6 +119,8 @@ static int test_multi_result(MYSQL *mysql) FAIL_IF(mysql_stmt_field_count(stmt) != 3, "expected 3 fields"); FAIL_IF(int_data[0] != 100 || int_data[1] != 200 || int_data[2] != 300, "expected 100 200 300"); @@ -874,12 +884,11 @@ index 9b89d6f..39b93cb 100644 FAIL_IF(mysql_stmt_next_result(stmt) != 0, "expected more results"); rc= mysql_stmt_bind_result(stmt, rs_bind); -@@ -121,7 +126,10 @@ static int test_multi_result(MYSQL *mysql) +@@ -124,7 +129,9 @@ static int test_multi_result(MYSQL *mysql) FAIL_IF(mysql_stmt_field_count(stmt) != 2, "expected 2 fields"); FAIL_IF(int_data[0] != 200 || int_data[1] != 300, - "expected 100 200 300"); + "expected 200 300"); - -+ + rc= mysql_stmt_free_result(stmt); + check_stmt_rc(rc, stmt); + diff --git a/deps/mariadb-client-library/cmakelists.txt.patch b/deps/mariadb-client-library/cmakelists.txt.patch new file mode 100644 index 0000000000..32002b9158 --- /dev/null +++ b/deps/mariadb-client-library/cmakelists.txt.patch @@ -0,0 +1,22 @@ +diff --git CMakeLists.txt CMakeLists.txt +index d7150b4d..e8508f8f 100644 +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -286,7 +286,7 @@ ELSEIF() + ENDIF() + + IF(NOT DEFAULT_CHARSET) +- SET(DEFAULT_CHARSET "utf8mb4") ++ SET(DEFAULT_CHARSET "latin1") + ENDIF() + + +@@ -405,7 +405,7 @@ IF ((NOT WIN32) AND (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID + ELSEIF(CMAKE_C_COMPILER_ID MATCHES "MSVC") + SET(WARNING_AS_ERROR "/WX") + ENDIF() +-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_AS_ERROR}") ++#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_AS_ERROR}") + ENDIF() + + diff --git a/deps/mariadb-client-library/cr_new_stmt_metadata_removal.patch b/deps/mariadb-client-library/cr_new_stmt_metadata_removal.patch index 883ed84d2b..74f0b0bcf4 100644 --- a/deps/mariadb-client-library/cr_new_stmt_metadata_removal.patch +++ b/deps/mariadb-client-library/cr_new_stmt_metadata_removal.patch @@ -1,8 +1,8 @@ diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c -index bbc2831..2168065 100644 +index 47f0f2b6..7c6482ac 100644 --- libmariadb/mariadb_stmt.c +++ libmariadb/mariadb_stmt.c -@@ -2013,7 +2013,61 @@ int stmt_read_execute_response(MYSQL_STMT *stmt) +@@ -2098,7 +2098,61 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt) stmt->state= MYSQL_STMT_WAITING_USE_OR_STORE; /* in certain cases parameter types can change: For example see bug 4026 (SELECT ?), so we need to update field information */ @@ -19,7 +19,7 @@ index bbc2831..2168065 100644 + if (mysql->field_count != stmt->field_count) + { + MA_MEM_ROOT *fields_ma_alloc_root= -+ &((MADB_STMT_EXTENSION *)stmt->extension)->fields_ma_alloc_root; ++ &((MADB_STMT_EXTENSION *)stmt->extension)->fields_ma_alloc_root; + uint i; + + // 'ma_free_root' will free all the allocated memory for 'fields_ma_alloc_root' @@ -27,11 +27,11 @@ index bbc2831..2168065 100644 + // the required space for 'MYSQL_BIND'. + ma_free_root(fields_ma_alloc_root, MYF(0)); + if (!(stmt->bind= (MYSQL_BIND *)ma_alloc_root(fields_ma_alloc_root, -+ sizeof(MYSQL_BIND) * mysql->field_count)) || ++ sizeof(MYSQL_BIND) * mysql->field_count)) || + !(stmt->fields= (MYSQL_FIELD *)ma_alloc_root(fields_ma_alloc_root, -+ sizeof(MYSQL_FIELD) * mysql->field_count))) ++ sizeof(MYSQL_FIELD) * mysql->field_count))) + { -+ SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); ++ stmt_set_error(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); + return(1); + } + memset(stmt->bind, 0, sizeof(MYSQL_BIND) * mysql->field_count); @@ -65,14 +65,14 @@ index bbc2831..2168065 100644 { uint i; for (i=0; i < stmt->field_count; i++) -@@ -2025,12 +2079,8 @@ int stmt_read_execute_response(MYSQL_STMT *stmt) +@@ -2110,12 +2164,8 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt) stmt->fields[i].charsetnr= mysql->fields[i].charsetnr; stmt->fields[i].max_length= mysql->fields[i].max_length; } - } else - { - /* table was altered, see test_wl4166_2 */ -- SET_CLIENT_STMT_ERROR(stmt, CR_NEW_STMT_METADATA, SQLSTATE_UNKNOWN, 0); +- stmt_set_error(stmt, CR_NEW_STMT_METADATA, SQLSTATE_UNKNOWN, 0); - return(1); } + /*********************************************************************/ diff --git a/deps/mariadb-client-library/empty_split_compress_packet.patch b/deps/mariadb-client-library/empty_split_compress_packet.patch index 2d7aa187b6..e40d19b38d 100644 --- a/deps/mariadb-client-library/empty_split_compress_packet.patch +++ b/deps/mariadb-client-library/empty_split_compress_packet.patch @@ -1,8 +1,8 @@ diff --git libmariadb/ma_net.c libmariadb/ma_net.c -index 15be4fc..39a8138 100644 +index 2e932b17..0b1d0cce 100644 --- libmariadb/ma_net.c +++ libmariadb/ma_net.c -@@ -498,6 +498,7 @@ ulong ma_net_read(NET *net) +@@ -510,6 +510,7 @@ ulong ma_net_read(NET *net) { current+= 4; /* length + sequence_id, no more data will follow */ diff --git a/deps/mariadb-client-library/ma_alloc.c.patch b/deps/mariadb-client-library/ma_alloc.c.patch index 8464897ba9..f5fe53d07f 100644 --- a/deps/mariadb-client-library/ma_alloc.c.patch +++ b/deps/mariadb-client-library/ma_alloc.c.patch @@ -1,9 +1,13 @@ -@@ -85,7 +85,7 @@ +diff --git libmariadb/ma_alloc.c libmariadb/ma_alloc.c +index d6db279e..4526fef0 100644 +--- libmariadb/ma_alloc.c ++++ libmariadb/ma_alloc.c +@@ -86,7 +86,7 @@ void * ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size) if (! next) { /* Time to alloc new block */ get_size= MAX(Size+ALIGN_SIZE(sizeof(MA_USED_MEM)), - (mem_root->block_size & ~1) * (mem_root->block_num >> 2)); -+ (mem_root->block_size & ~1) * ( (mem_root->block_num >> 2) < 4 ? 4 : (mem_root->block_num >> 2) ) ); ++ (mem_root->block_size & ~1) * ((mem_root->block_num >> 2) < 4 ? 4 : (mem_root->block_num >> 2))); if (!(next = (MA_USED_MEM*) malloc(get_size))) { diff --git a/deps/mariadb-client-library/ma_array.c-multiplication-overflow.patch b/deps/mariadb-client-library/ma_array.c-multiplication-overflow.patch index 76bcb496ff..80e20be2bd 100644 --- a/deps/mariadb-client-library/ma_array.c-multiplication-overflow.patch +++ b/deps/mariadb-client-library/ma_array.c-multiplication-overflow.patch @@ -1,4 +1,8 @@ -@@ -46,7 +46,7 @@ +diff --git libmariadb/ma_array.c libmariadb/ma_array.c +index d067aa4a..81fc3c40 100644 +--- libmariadb/ma_array.c ++++ libmariadb/ma_array.c +@@ -46,7 +46,7 @@ my_bool ma_init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, array->max_element=init_alloc; array->alloc_increment=alloc_increment; array->size_of_element=element_size; @@ -7,7 +11,7 @@ { array->max_element=0; return(TRUE); -@@ -80,7 +80,7 @@ +@@ -80,7 +80,7 @@ unsigned char *ma_alloc_dynamic(DYNAMIC_ARRAY *array) if (array->elements == array->max_element) { char *new_ptr; @@ -16,7 +20,7 @@ array->alloc_increment)* array->size_of_element))) return 0; -@@ -111,14 +111,14 @@ +@@ -111,14 +111,14 @@ my_bool ma_set_dynamic(DYNAMIC_ARRAY *array, void * element, uint idx) char *new_ptr; size=(idx+array->alloc_increment)/array->alloc_increment; size*= array->alloc_increment; @@ -33,7 +37,7 @@ array->elements=idx+1; } memcpy(array->buffer+(idx * array->size_of_element),element, -@@ -155,7 +155,7 @@ +@@ -155,7 +155,7 @@ void ma_delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx) char *ptr=array->buffer+array->size_of_element*idx; array->elements--; memmove(ptr,ptr+array->size_of_element, @@ -42,7 +46,7 @@ } -@@ -166,7 +166,7 @@ +@@ -166,7 +166,7 @@ void ma_freeze_size(DYNAMIC_ARRAY *array) if (array->buffer && array->max_element != elements) { array->buffer=(char*) realloc(array->buffer, diff --git a/deps/mariadb-client-library/ma_charset.c.patch b/deps/mariadb-client-library/ma_charset.c.patch index 765d47da6f..9892f4cb5f 100644 --- a/deps/mariadb-client-library/ma_charset.c.patch +++ b/deps/mariadb-client-library/ma_charset.c.patch @@ -1,4 +1,17 @@ -@@ -720,7 +720,7 @@ +diff --git libmariadb/ma_charset.c libmariadb/ma_charset.c +index f6ed6f80..4a1207f1 100644 +--- libmariadb/ma_charset.c ++++ libmariadb/ma_charset.c +@@ -542,7 +542,7 @@ static unsigned int check_mb_gb18030_valid(const char * start, const char * end) + */ + + #define UTF8_MB4 "utf8mb4" +-#define UTF8_MB3 "utf8mb3" ++#define UTF8_MB3 "utf8" + + /* {{{ mysql_charsets */ + const MARIADB_CHARSET_INFO mariadb_compiled_charsets[] = +@@ -722,7 +722,7 @@ const MARIADB_CHARSET_INFO mariadb_compiled_charsets[] = { 182, 1, "utf32", "utf32_unicode_520_ci", "", 0, "UTF32", 4, 4, mysql_mbcharlen_utf32, check_mb_utf32}, { 183, 1, "utf32", "utf32_vietnamese_ci", "", 0, "UTF32", 4, 4, mysql_mbcharlen_utf32, check_mb_utf32}, @@ -7,3 +20,13 @@ { 193, 1, UTF8_MB3, UTF8_MB3"_icelandic_ci", "", 65001, "UTF-8", 1, 3, mysql_mbcharlen_utf8mb3, check_mb_utf8mb3_valid}, { 194, 1, UTF8_MB3, UTF8_MB3"_latvian_ci", "", 65001, "UTF-8", 1, 3, mysql_mbcharlen_utf8mb3, check_mb_utf8mb3_valid}, { 195, 1, UTF8_MB3, UTF8_MB3"_romanian_ci", "", 65001, "UTF-8", 1, 3, mysql_mbcharlen_utf8mb3, check_mb_utf8mb3_valid}, +@@ -1083,9 +1083,6 @@ MARIADB_CHARSET_INFO * mysql_find_charset_name(const char *name) + else + csname= (char *)name; + +- if (!strcasecmp("utf8",csname)) +- csname= "utf8mb3"; +- + do { + if (!strcasecmp(c->csname, csname)) { + return(c); diff --git a/deps/mariadb-client-library/ma_common.h.sslkeylogfile.patch b/deps/mariadb-client-library/ma_common.h.sslkeylogfile.patch deleted file mode 100644 index af13a9449c..0000000000 --- a/deps/mariadb-client-library/ma_common.h.sslkeylogfile.patch +++ /dev/null @@ -1,14 +0,0 @@ -@@ -78,12 +78,13 @@ - my_bool (*set_option)(MYSQL *mysql, const char *config_option, const char *config_value); - HASH userdata; - char *server_public_key; - char *proxy_header; - size_t proxy_header_len; - int (*io_wait)(my_socket handle, my_bool is_read, int timeout); -+ void (*ssl_keylog_callback)(const void *ssl, const char *line); - }; - - typedef struct st_connection_handler - { - struct st_ma_connection_plugin *plugin; - void *data; diff --git a/deps/mariadb-client-library/ma_context.h.patch b/deps/mariadb-client-library/ma_context.h.patch index 2aae87324f..6ac91adb2e 100644 --- a/deps/mariadb-client-library/ma_context.h.patch +++ b/deps/mariadb-client-library/ma_context.h.patch @@ -1,4 +1,8 @@ -@@ -25,6 +25,8 @@ +diff --git include/ma_context.h include/ma_context.h +index 0ad7f68b..ad26a721 100644 +--- include/ma_context.h ++++ include/ma_context.h +@@ -26,6 +26,8 @@ (This particular implementation uses Posix ucontext swapcontext().) */ diff --git a/deps/mariadb-client-library/ma_password.c.patch b/deps/mariadb-client-library/ma_password.c.patch index d6300c0bb1..a1d30811ef 100644 --- a/deps/mariadb-client-library/ma_password.c.patch +++ b/deps/mariadb-client-library/ma_password.c.patch @@ -1,56 +1,56 @@ -@@ -98,6 +98,35 @@ +diff --git libmariadb/ma_password.c libmariadb/ma_password.c +index eb6fe6a8..b327bf61 100644 +--- libmariadb/ma_password.c ++++ libmariadb/ma_password.c +@@ -98,6 +98,33 @@ void my_crypt(unsigned char *buffer, const unsigned char *s1, const unsigned cha } } +unsigned char decode_char(char x) { -+ if (x >= '0' && x <= '9') -+ return (x - 0x30); -+ else if (x >= 'A' && x <= 'F') -+ return(x - 0x37); -+ else if (x >= 'a' && x <= 'f') -+ return(x - 0x57); -+ else { -+ fprintf(stderr,"%s:%d:%s(): [ERROR in libmariadbclient]: \n", __FILE__, __LINE__, __func__); -+ return 0; -+ } ++ if (x >= '0' && x <= '9') ++ return (x - 0x30); ++ else if (x >= 'A' && x <= 'F') ++ return(x - 0x37); ++ else if (x >= 'a' && x <= 'f') ++ return(x - 0x57); ++ else { ++ fprintf(stderr,"%s:%d:%s(): [ERROR in libmariadbclient]: \n", __FILE__, __LINE__, __func__); ++ return 0; ++ } +} + +void unhex_pass(unsigned char *out, const char *in) { -+ int i=0; -+ for (i=0;iextension->mariadb_server_capabilities) & - (MARIADB_CLIENT_EXTENDED_METADATA >> 32)) != 0; diff --git a/deps/mariadb-client-library/mariadb-connector-c-3.1.9-src.tar.gz b/deps/mariadb-client-library/mariadb-connector-c-3.1.9-src.tar.gz deleted file mode 100644 index 0d0e3e6e29..0000000000 Binary files a/deps/mariadb-client-library/mariadb-connector-c-3.1.9-src.tar.gz and /dev/null differ diff --git a/deps/mariadb-client-library/mariadb-connector-c-3.3.8-src.tar.gz b/deps/mariadb-client-library/mariadb-connector-c-3.3.8-src.tar.gz new file mode 100644 index 0000000000..9389ee0624 Binary files /dev/null and b/deps/mariadb-client-library/mariadb-connector-c-3.3.8-src.tar.gz differ diff --git a/deps/mariadb-client-library/mariadb_asan.patch b/deps/mariadb-client-library/mariadb_asan.patch index ce675f06b3..cb9c9a6440 100644 --- a/deps/mariadb-client-library/mariadb_asan.patch +++ b/deps/mariadb-client-library/mariadb_asan.patch @@ -1,8 +1,8 @@ diff --git CMakeLists.txt CMakeLists.txt -index 568e4f5..cfac85b 100644 +index 206e4e03..d7150b4d 100644 --- CMakeLists.txt +++ CMakeLists.txt -@@ -136,6 +136,10 @@ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") +@@ -131,6 +131,10 @@ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") @@ -12,4 +12,4 @@ index 568e4f5..cfac85b 100644 + IF(CMAKE_COMPILER_IS_GNUCC) INCLUDE(CheckCCompilerFlag) - SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas) + SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas -Wno-stringop-truncation) diff --git a/deps/mariadb-client-library/mariadb_async.c.patch b/deps/mariadb-client-library/mariadb_async.c.patch index 09461aa752..12301dfbde 100644 --- a/deps/mariadb-client-library/mariadb_async.c.patch +++ b/deps/mariadb-client-library/mariadb_async.c.patch @@ -1,4 +1,8 @@ -@@ -479,19 +479,20 @@ +diff --git libmariadb/mariadb_async.c libmariadb/mariadb_async.c +index feb73329..f2fba5d4 100644 +--- libmariadb/mariadb_async.c ++++ libmariadb/mariadb_async.c +@@ -479,19 +479,20 @@ MK_ASYNC_CONT_BODY( struct mysql_set_character_set_params { MYSQL *mysql; const char *csname; @@ -21,7 +25,7 @@ { MK_ASYNC_START_BODY( mysql_set_character_set, -@@ -500,6 +501,7 @@ +@@ -500,6 +501,7 @@ MK_ASYNC_START_BODY( WIN_SET_NONBLOCKING(mysql) parms.mysql= mysql; parms.csname= csname; diff --git a/deps/mariadb-client-library/mariadb_client b/deps/mariadb-client-library/mariadb_client index 8ea53d8c52..718a3e0a19 120000 --- a/deps/mariadb-client-library/mariadb_client +++ b/deps/mariadb-client-library/mariadb_client @@ -1 +1 @@ -mariadb-connector-c-3.1.9-src \ No newline at end of file +mariadb-connector-c-3.3.8-src \ No newline at end of file diff --git a/deps/mariadb-client-library/mariadb_com.h.patch b/deps/mariadb-client-library/mariadb_com.h.patch index f24c5ad3b1..31c32fa015 100644 --- a/deps/mariadb-client-library/mariadb_com.h.patch +++ b/deps/mariadb-client-library/mariadb_com.h.patch @@ -1,15 +1,19 @@ -@@ -178,8 +178,8 @@ +diff --git include/mariadb_com.h include/mariadb_com.h +index 96e6e04f..7acc7403 100644 +--- include/mariadb_com.h ++++ include/mariadb_com.h +@@ -183,9 +183,7 @@ enum enum_server_command + (!(mysql->server_capabilities & CLIENT_MYSQL)) #define MARIADB_CLIENT_SUPPORTED_FLAGS (MARIADB_CLIENT_PROGRESS |\ - MARIADB_CLIENT_COM_MULTI |\ - MARIADB_CLIENT_STMT_BULK_OPERATIONS|\ -- MARIADB_CLIENT_EXTENDED_METADATA) -+ MARIADB_CLIENT_STMT_BULK_OPERATIONS\ -+ ) +- MARIADB_CLIENT_EXTENDED_METADATA|\ +- MARIADB_CLIENT_CACHE_METADATA) ++ MARIADB_CLIENT_STMT_BULK_OPERATIONS) #define CLIENT_SUPPORTED_FLAGS (CLIENT_MYSQL |\ CLIENT_FOUND_ROWS |\ -@@ -210,8 +210,6 @@ +@@ -221,8 +219,6 @@ enum enum_server_command CLIENT_LONG_FLAG |\ CLIENT_TRANSACTIONS |\ CLIENT_SECURE_CONNECTION |\ @@ -17,4 +21,4 @@ - CLIENT_PS_MULTI_RESULTS |\ CLIENT_PROTOCOL_41 |\ CLIENT_PLUGIN_AUTH |\ - CLIENT_SESSION_TRACKING |\ \ No newline at end of file + CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \ diff --git a/deps/mariadb-client-library/mariadb_dyncol.c-multiplication-overflow.patch b/deps/mariadb-client-library/mariadb_dyncol.c-multiplication-overflow.patch index 7df44d4e5a..8264af5d2a 100644 --- a/deps/mariadb-client-library/mariadb_dyncol.c-multiplication-overflow.patch +++ b/deps/mariadb-client-library/mariadb_dyncol.c-multiplication-overflow.patch @@ -1,4 +1,8 @@ -@@ -3999,13 +3999,13 @@ +diff --git libmariadb/mariadb_dyncol.c libmariadb/mariadb_dyncol.c +index 42de69ee..6b040d11 100644 +--- libmariadb/mariadb_dyncol.c ++++ libmariadb/mariadb_dyncol.c +@@ -4000,13 +4000,13 @@ mariadb_dyncol_val_long(longlong *ll, DYNAMIC_COLUMN_VALUE *val) (val->x.time_value.neg ? -1 : 1); break; case DYN_COL_DATE: diff --git a/deps/mariadb-client-library/mariadb_lib.c.collation.patch b/deps/mariadb-client-library/mariadb_lib.c.collation.patch index 3ee686ed63..6ae8090974 100644 --- a/deps/mariadb-client-library/mariadb_lib.c.collation.patch +++ b/deps/mariadb-client-library/mariadb_lib.c.collation.patch @@ -1,4 +1,8 @@ -@@ -1109,7 +1109,10 @@ mysql_init(MYSQL *mysql) +diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c +index 66b44df4..c9aec200 100644 +--- libmariadb/mariadb_lib.c ++++ libmariadb/mariadb_lib.c +@@ -1283,7 +1283,10 @@ mysql_init(MYSQL *mysql) goto error; mysql->options.report_data_truncation= 1; mysql->options.connect_timeout=CONNECT_TIMEOUT; @@ -10,7 +14,7 @@ mysql->methods= &MARIADB_DEFAULT_METHODS; strcpy(mysql->net.sqlstate, "00000"); mysql->net.last_error[0]= mysql->net.last_errno= mysql->net.extension->extended_errno= 0; -@@ -1625,11 +1628,15 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql +@@ -1918,11 +1921,15 @@ restart: } } @@ -31,7 +35,7 @@ if (!mysql->charset) { -@@ -1892,10 +1899,16 @@ my_bool STDCALL mysql_change_user(MYSQL +@@ -2208,10 +2215,16 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, *s_db= mysql->db; int rc; @@ -52,7 +56,7 @@ mysql->user= strdup(user ? user : ""); mysql->passwd= strdup(passwd ? passwd : ""); -@@ -2963,6 +2976,12 @@ mysql_optionsv(MYSQL *mysql,enum mysql_o +@@ -3492,6 +3505,12 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) OPT_SET_VALUE_STR(&mysql->options, charset_dir, arg1); break; case MYSQL_SET_CHARSET_NAME: diff --git a/deps/mariadb-client-library/mariadb_lib.c.ipv6_fix.patch b/deps/mariadb-client-library/mariadb_lib.c.ipv6_fix.patch index b9ea4be5c9..8e76009de5 100644 --- a/deps/mariadb-client-library/mariadb_lib.c.ipv6_fix.patch +++ b/deps/mariadb-client-library/mariadb_lib.c.ipv6_fix.patch @@ -1,23 +1,15 @@ -@@ -1615,6 +1615,11 @@ - if (ma_pvio_connect(pvio, &cinfo) != 0) - { - ma_pvio_close(pvio); -+ if (mysql->options.extension && mysql->options.extension->async_context && -+ mysql->options.extension->async_context->pvio) { -+ /* async_context->pvio contains dangling pointer. Setting async_context->pvio to NULL*/ -+ mysql->options.extension->async_context->pvio = NULL; -+ } - goto error; - } - -@@ -1625,6 +1630,11 @@ +diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c +index c9aec200..be4c91d1 100644 +--- libmariadb/mariadb_lib.c ++++ libmariadb/mariadb_lib.c +@@ -1752,6 +1752,11 @@ restart: if (ma_pvio_write(pvio, (unsigned char *)hdr, len) <= 0) { ma_pvio_close(pvio); + if (mysql->options.extension->async_context && -+ mysql->options.extension->async_context->pvio) { -+ /* async_context->pvio contains dangling pointer. Setting async_context->pvio to NULL*/ -+ mysql->options.extension->async_context->pvio = NULL; ++ mysql->options.extension->async_context->pvio) { ++ /* async_context->pvio contains dangling pointer. Invalidatng pvio pointer in the async context*/ ++ mysql->options.extension->async_context->pvio = NULL; + } goto error; } diff --git a/deps/mariadb-client-library/mariadb_lib.c.patch b/deps/mariadb-client-library/mariadb_lib.c.patch index 6db5e05a00..ab3bbaf2c3 100644 --- a/deps/mariadb-client-library/mariadb_lib.c.patch +++ b/deps/mariadb-client-library/mariadb_lib.c.patch @@ -1,41 +1,45 @@ diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c -index 8c2a99b..cf6114a 100644 +index e8db51a0..684aff1a 100644 --- libmariadb/mariadb_lib.c +++ libmariadb/mariadb_lib.c -@@ -1643,9 +1643,16 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, +@@ -1936,10 +1936,16 @@ restart: mysql->client_flag= client_flag; -+ { -+ volatile my_bool net_blocking = ma_pvio_is_blocking(net->pvio); -+ if (!net_blocking) -+ ma_pvio_blocking(net->pvio, TRUE, 0); - if (run_plugin_auth(mysql, scramble_data, scramble_len, - scramble_plugin, db)) - goto error; -+ if (!net_blocking) -+ ma_pvio_blocking(net->pvio, FALSE, 0); -+ } - - if (mysql->client_flag & CLIENT_COMPRESS) - net->compress= 1; -@@ -1696,6 +1703,15 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, +- if (run_plugin_auth(mysql, scramble_data, scramble_len, +- scramble_plugin, db)) +- goto error; +- ++ { ++ volatile my_bool net_blocking = ma_pvio_is_blocking(net->pvio); ++ if (!net_blocking) ++ ma_pvio_blocking(net->pvio, TRUE, 0); ++ if (run_plugin_auth(mysql, scramble_data, scramble_len, ++ scramble_plugin, db)) ++ goto error; ++ if (!net_blocking) ++ ma_pvio_blocking(net->pvio, FALSE, 0); ++ } + if (mysql->client_flag & CLIENT_COMPRESS || + mysql->client_flag & CLIENT_ZSTD_COMPRESSION) + { +@@ -2006,6 +2012,15 @@ restart: return(mysql); error: + // fix for proxysql bug #2623 + if (mysql->net.extension) { -+ free(mysql->net.extension); -+ mysql->net.extension=NULL; ++ free(mysql->net.extension); ++ mysql->net.extension=NULL; + } + if (mysql->extension) { -+ free(mysql->extension); -+ mysql->extension=NULL; ++ free(mysql->extension); ++ mysql->extension=NULL; + } - /* Free alloced memory */ - end_server(mysql); - /* only free the allocated memory, user needs to call mysql_close */ -@@ -1775,7 +1791,7 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) + /* Free allocated memory */ + free(host_list); + free(host_copy); +@@ -2087,7 +2102,7 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, mysql->db, mysql->port, mysql->unix_socket, mysql->client_flag | CLIENT_REMEMBER_OPTIONS) || @@ -44,23 +48,28 @@ index 8c2a99b..cf6114a 100644 { if (ctxt) my_context_install_suspend_resume_hook(ctxt, NULL, NULL); -@@ -1821,6 +1837,7 @@ void ma_invalidate_stmts(MYSQL *mysql, const char *function_name) +@@ -2134,10 +2149,11 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) + return(0); + } + +-void ma_invalidate_stmts(MYSQL *mysql, const char *function_name) ++void ma_invalidate_stmts(MYSQL *mysql, const char *function_name __attribute__((unused))) { if (mysql->stmts) { -+/* ++ /* LIST *li_stmt= mysql->stmts; for (; li_stmt; li_stmt= li_stmt->next) -@@ -1829,6 +1846,7 @@ void ma_invalidate_stmts(MYSQL *mysql, const char *function_name) +@@ -2146,6 +2162,7 @@ void ma_invalidate_stmts(MYSQL *mysql, const char *function_name) stmt->mysql= NULL; - SET_CLIENT_STMT_ERROR(stmt, CR_STMT_CLOSED, SQLSTATE_UNKNOWN, function_name); + stmt_set_error(stmt, CR_STMT_CLOSED, SQLSTATE_UNKNOWN, 0, function_name); } -+*/ ++ */ mysql->stmts= NULL; } } -@@ -2115,6 +2133,44 @@ mysql_close(MYSQL *mysql) +@@ -2458,6 +2475,42 @@ mysql_close(MYSQL *mysql) return; } @@ -69,28 +78,27 @@ index 8c2a99b..cf6114a 100644 +{ + if (mysql) /* Some simple safety */ + { -+ + if (mysql->methods) { -+ if (mysql->net.pvio) { -+ free_old_query(mysql); -+ mysql->status=MYSQL_STATUS_READY; /* Force command */ -+ mysql->options.reconnect=0; -+ end_server(mysql); -+ } -+ } ++ if (mysql->net.pvio) { ++ free_old_query(mysql); ++ mysql->status=MYSQL_STATUS_READY; /* Force command */ ++ mysql->options.reconnect=0; ++ end_server(mysql); ++ } ++ } + mysql_close_memory(mysql); + mysql_close_options(mysql); + mysql->host_info=mysql->user=mysql->passwd=mysql->db=0; + + // fix for proxysql bug #3204 + if (mysql->net.extension) { -+ free(mysql->net.extension); -+ mysql->net.extension=NULL; ++ free(mysql->net.extension); ++ mysql->net.extension=NULL; + } + + if (mysql->extension) { -+ free(mysql->extension); -+ mysql->extension=NULL; ++ free(mysql->extension); ++ mysql->extension=NULL; + } + + /* Clear pointers for better safety */ @@ -101,20 +109,10 @@ index 8c2a99b..cf6114a 100644 + } + return; +} -+ /************************************************************************** ** Do a query. If query returned rows, free old rows. -@@ -2189,6 +2245,8 @@ int ma_read_ok_packet(MYSQL *mysql, uchar *pos, ulong length) - char *data; - si_type= (enum enum_session_state_type)net_field_length(&pos); - switch(si_type) { -+ case SESSION_TRACK_GTIDS: -+ net_field_length(&pos); /* skip encoding */ - case SESSION_TRACK_SCHEMA: - case SESSION_TRACK_STATE_CHANGE: - case SESSION_TRACK_TRANSACTION_CHARACTERISTICS: -@@ -3670,18 +3728,27 @@ void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs) +@@ -4237,18 +4290,27 @@ void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs) mariadb_get_charset_info(mysql, cs); } @@ -147,11 +145,15 @@ index 8c2a99b..cf6114a 100644 if (!mysql_real_query(mysql, buff, (unsigned long)strlen(buff))) { mysql->charset= cs; -@@ -3691,6 +3758,7 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname) +@@ -4258,8 +4320,9 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname) } error: +- my_set_error(mysql, CR_CANT_READ_CHARSET, SQLSTATE_UNKNOWN, +- 0, csname, "compiled_in"); + if (!cs) - my_set_error(mysql, CR_CANT_READ_CHARSET, SQLSTATE_UNKNOWN, - 0, csname, "compiled_in"); ++ my_set_error(mysql, CR_CANT_READ_CHARSET, SQLSTATE_UNKNOWN, ++ 0, csname, "compiled_in"); return(mysql->net.last_errno); + } + diff --git a/deps/mariadb-client-library/mariadb_lib.c.sslkeylogfile.patch b/deps/mariadb-client-library/mariadb_lib.c.sslkeylogfile.patch deleted file mode 100644 index e0245b5828..0000000000 --- a/deps/mariadb-client-library/mariadb_lib.c.sslkeylogfile.patch +++ /dev/null @@ -1,32 +0,0 @@ -@@ -3277,12 +3277,15 @@ - case MYSQL_OPT_SSL_CRL: - OPT_SET_EXTENDED_VALUE_STR(&mysql->options, ssl_crl, (char *)arg1); - break; - case MYSQL_OPT_SSL_CRLPATH: - OPT_SET_EXTENDED_VALUE_STR(&mysql->options, ssl_crlpath, (char *)arg1); - break; -+ case MARIADB_OPT_SSL_KEYLOG_CALLBACK: -+ OPT_SET_EXTENDED_VALUE(&mysql->options, ssl_keylog_callback, arg1); -+ break; - case MYSQL_OPT_CONNECT_ATTR_DELETE: - { - uchar *h; - CHECK_OPT_EXTENSION_SET(&mysql->options); - if (hash_inited(&mysql->options.extension->connect_attrs) && - (h= (uchar *)hash_search(&mysql->options.extension->connect_attrs, (uchar *)arg1, -@@ -3614,12 +3617,15 @@ - case MYSQL_OPT_SSL_CRL: - *((char **)arg)= mysql->options.extension ? mysql->options.ssl_cipher : NULL; - break; - case MYSQL_OPT_SSL_CRLPATH: - *((char **)arg)= mysql->options.extension ? mysql->options.extension->ssl_crlpath : NULL; - break; -+ case MARIADB_OPT_SSL_KEYLOG_CALLBACK: -+ *((void(**)(const void *, const char *))arg)= mysql->options.extension ? mysql->options.extension->ssl_keylog_callback : NULL; -+ break; - case MYSQL_OPT_CONNECT_ATTRS: - /* mysql_get_optionsv(mysql, MYSQL_OPT_CONNECT_ATTRS, keys, vals, elements) */ - { - unsigned int i, *elements; - char **key= NULL; - void *arg1; diff --git a/deps/mariadb-client-library/mariadb_lib.c.x509cache.patch b/deps/mariadb-client-library/mariadb_lib.c.x509cache.patch deleted file mode 100644 index 1cbae13819..0000000000 --- a/deps/mariadb-client-library/mariadb_lib.c.x509cache.patch +++ /dev/null @@ -1,32 +0,0 @@ -@@ -127,6 +127,11 @@ - uint mysql_port=0; - my_string mysql_unix_port=0; - -+#include -+extern __thread SSL_CTX * thread_ctx; -+extern __thread char **local_x509_files; -+extern __thread char **local_x509_sha1s; -+ - #define CONNECT_TIMEOUT 0 - - struct st_mariadb_methods MARIADB_DEFAULT_METHODS; -@@ -4078,6 +4083,19 @@ - - void STDCALL mysql_thread_end(void) - { -+ if (local_x509_files != NULL) { -+ int i; -+ for (i=0; local_x509_files[i] != NULL ; i++) { -+ free(local_x509_files[i]); -+ free(local_x509_sha1s[i]); -+ } -+ free(local_x509_files); -+ free(local_x509_sha1s); -+ } -+ if (thread_ctx != NULL) { -+ SSL_CTX_free(thread_ctx); -+ thread_ctx = NULL; -+ } - } - - int STDCALL mysql_set_server_option(MYSQL *mysql, diff --git a/deps/mariadb-client-library/mariadb_rpl.c.patch b/deps/mariadb-client-library/mariadb_rpl.c.patch deleted file mode 100644 index cbdd85c744..0000000000 --- a/deps/mariadb-client-library/mariadb_rpl.c.patch +++ /dev/null @@ -1,16 +0,0 @@ -@@ -386,6 +386,15 @@ - memcpy(rpl_event->event.rows.row_data, ev, rpl_event->event.rows.row_data_size); - } - break; -+ case PREVIOUS_GTIDS_LOG_EVENT: -+ case ANONYMOUS_GTID_LOG_EVENT: -+ case WRITE_ROWS_EVENT: -+ case UPDATE_ROWS_EVENT: -+ case DELETE_ROWS_EVENT: -+ case GTID_LOG_EVENT: -+ case HEARTBEAT_LOG_EVENT_V2: -+ case ROWS_QUERY_LOG_EVENT: -+ break; - default: - free(rpl_event); - return NULL; diff --git a/deps/mariadb-client-library/mariadb_rpl.h.patch b/deps/mariadb-client-library/mariadb_rpl.h.patch deleted file mode 100644 index 039536ef51..0000000000 --- a/deps/mariadb-client-library/mariadb_rpl.h.patch +++ /dev/null @@ -1,9 +0,0 @@ -@@ -94,6 +94,8 @@ - VIEW_CHANGE_EVENT= 37, - XA_PREPARE_LOG_EVENT= 38, - -+ HEARTBEAT_LOG_EVENT_V2 = 41, -+ - /* - Add new events here - right above this comment! - Existing events (except ENUM_END_EVENT) should never change their numbers diff --git a/deps/mariadb-client-library/mariadb_rpl.patch b/deps/mariadb-client-library/mariadb_rpl.patch new file mode 100644 index 0000000000..70c1eff114 --- /dev/null +++ b/deps/mariadb-client-library/mariadb_rpl.patch @@ -0,0 +1,29 @@ +diff --git include/mariadb_rpl.h include/mariadb_rpl.h +index ea0ca4db..697e5684 100644 +--- include/mariadb_rpl.h ++++ include/mariadb_rpl.h +@@ -134,7 +134,8 @@ enum mariadb_rpl_event { + VIEW_CHANGE_EVENT= 37, + XA_PREPARE_LOG_EVENT= 38, + PARTIAL_UPDATE_ROWS_EVENT = 39, +- ++ HEARTBEAT_LOG_EVENT_V2 = 41, ++ + /* + Add new events here - right above this comment! + Existing events (except ENUM_END_EVENT) should never change their numbers +diff --git libmariadb/mariadb_rpl.c libmariadb/mariadb_rpl.c +index daa6d242..dd3f905c 100644 +--- libmariadb/mariadb_rpl.c ++++ libmariadb/mariadb_rpl.c +@@ -1888,6 +1888,9 @@ MARIADB_RPL_EVENT * STDCALL mariadb_rpl_fetch(MARIADB_RPL *rpl, MARIADB_RPL_EVEN + } + break; + } ++ case ROWS_QUERY_LOG_EVENT: ++ case HEARTBEAT_LOG_EVENT_V2: ++ break; + default: + /* We need to report an error if this event can't be ignored */ + if (!(rpl_event->flags & LOG_EVENT_IGNORABLE_F)) + diff --git a/deps/mariadb-client-library/mariadb_stmt.c.patch b/deps/mariadb-client-library/mariadb_stmt.c.patch index e9fdf69487..cb4b4f86d7 100644 --- a/deps/mariadb-client-library/mariadb_stmt.c.patch +++ b/deps/mariadb-client-library/mariadb_stmt.c.patch @@ -1,4 +1,8 @@ -@@ -131,6 +131,7 @@ my_bool mthd_supported_buffer_type(enum +diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c +index 5bcecfde..47f0f2b6 100644 +--- libmariadb/mariadb_stmt.c ++++ libmariadb/mariadb_stmt.c +@@ -149,6 +149,7 @@ my_bool mthd_supported_buffer_type(enum enum_field_types type) case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY_BLOB: @@ -6,7 +10,7 @@ case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_YEAR: return 1; -@@ -1229,6 +1230,7 @@ my_bool STDCALL mysql_stmt_bind_param(MY +@@ -1332,6 +1333,7 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind) break; case MYSQL_TYPE_STRING: case MYSQL_TYPE_JSON: diff --git a/deps/mariadb-client-library/mariadb_stmt_store_result_err.patch b/deps/mariadb-client-library/mariadb_stmt_store_result_err.patch index ac493d3299..4b49c428e4 100644 --- a/deps/mariadb-client-library/mariadb_stmt_store_result_err.patch +++ b/deps/mariadb-client-library/mariadb_stmt_store_result_err.patch @@ -1,13 +1,13 @@ diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c -index ba1617b..1c8d2e6 100644 +index 40a8ded1..d6df0825 100644 --- libmariadb/mariadb_stmt.c +++ libmariadb/mariadb_stmt.c -@@ -1838,6 +1838,9 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) +@@ -1903,6 +1903,9 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) stmt->result.data= NULL; stmt->result.rows= 0; stmt->mysql->status= MYSQL_STATUS_READY; + /* In case of error, stmt internal state needs to be reset. Otherwise state machine could be left in an -+ inconsistent state and further calls to 'mysql_stmt_execute' will halt. */ ++ inconsistent state and further calls to 'mysql_stmt_execute' will halt. */ + stmt->state= MYSQL_STMT_FETCH_DONE; return(1); } diff --git a/deps/mariadb-client-library/mysql.h.patch b/deps/mariadb-client-library/mysql.h.patch index ce8c6115da..60d293dc78 100644 --- a/deps/mariadb-client-library/mysql.h.patch +++ b/deps/mariadb-client-library/mysql.h.patch @@ -1,4 +1,8 @@ -@@ -517,7 +517,7 @@ +diff --git include/mysql.h include/mysql.h +index 76b16830..9ee86227 100644 +--- include/mysql.h ++++ include/mysql.h +@@ -531,7 +531,7 @@ const char * STDCALL mysql_info(MYSQL *mysql); unsigned long STDCALL mysql_thread_id(MYSQL *mysql); const char * STDCALL mysql_character_set_name(MYSQL *mysql); void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *cs); @@ -7,7 +11,7 @@ my_bool mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...); my_bool STDCALL mariadb_get_info(MYSQL *mysql, enum mariadb_value value, void *arg); -@@ -536,6 +536,7 @@ +@@ -550,6 +550,7 @@ MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, const char *unix_socket, unsigned long clientflag); void STDCALL mysql_close(MYSQL *sock); @@ -15,7 +19,7 @@ int STDCALL mysql_select_db(MYSQL *mysql, const char *db); int STDCALL mysql_query(MYSQL *mysql, const char *q); int STDCALL mysql_send_query(MYSQL *mysql, const char *q, -@@ -635,7 +636,7 @@ +@@ -649,7 +650,7 @@ int STDCALL mysql_stmt_next_result_start(int *ret, MYSQL_STMT *stmt); int STDCALL mysql_stmt_next_result_cont(int *ret, MYSQL_STMT *stmt, int status); int STDCALL mysql_set_character_set_start(int *ret, MYSQL *mysql, @@ -24,7 +28,7 @@ int STDCALL mysql_set_character_set_cont(int *ret, MYSQL *mysql, int status); int STDCALL mysql_change_user_start(my_bool *ret, MYSQL *mysql, -@@ -752,7 +752,7 @@ +@@ -765,7 +766,7 @@ struct st_mariadb_api { unsigned long (STDCALL *mysql_thread_id)(MYSQL *mysql); const char * (STDCALL *mysql_character_set_name)(MYSQL *mysql); void (STDCALL *mysql_get_character_set_info)(MYSQL *mysql, MY_CHARSET_INFO *cs); diff --git a/deps/mariadb-client-library/mysql.h.sslkeylogfile.patch b/deps/mariadb-client-library/mysql.h.sslkeylogfile.patch deleted file mode 100644 index 793d16f17d..0000000000 --- a/deps/mariadb-client-library/mysql.h.sslkeylogfile.patch +++ /dev/null @@ -1,16 +0,0 @@ -@@ -242,13 +242,14 @@ - MARIADB_OPT_DEBUG, - MARIADB_OPT_FOUND_ROWS, - MARIADB_OPT_MULTI_RESULTS, - MARIADB_OPT_MULTI_STATEMENTS, - MARIADB_OPT_INTERACTIVE, - MARIADB_OPT_PROXY_HEADER, -- MARIADB_OPT_IO_WAIT -+ MARIADB_OPT_IO_WAIT, -+ MARIADB_OPT_SSL_KEYLOG_CALLBACK - }; - - enum mariadb_value { - MARIADB_CHARSET_ID, - MARIADB_CHARSET_NAME, - MARIADB_CLIENT_ERRORS, diff --git a/deps/mariadb-client-library/openssl.c.sslkeylogfile.patch b/deps/mariadb-client-library/openssl.c.sslkeylogfile.patch deleted file mode 100644 index 7c53663f14..0000000000 --- a/deps/mariadb-client-library/openssl.c.sslkeylogfile.patch +++ /dev/null @@ -1,34 +0,0 @@ -@@ -529,12 +529,19 @@ - memset(buf, 0, size); - if (userdata) - strncpy(buf, (char *)userdata, size); - return (int)strlen(buf); - } - -+static void ma_tls_set_sslkeylog_callback(MYSQL *mysql, SSL_CTX *ssl_ctx) -+{ -+ if (mysql->options.extension && mysql->options.extension->ssl_keylog_callback) -+ { -+ SSL_CTX_set_keylog_callback(ssl_ctx, (void(*)(const SSL*, const char*))mysql->options.extension->ssl_keylog_callback); -+ } -+} - - static int ma_tls_set_certs(MYSQL *mysql, SSL *ssl) - { - char *certfile= mysql->options.ssl_cert, - *keyfile= mysql->options.ssl_key; - char *pw= (mysql->options.extension) ? -@@ -656,12 +663,13 @@ - if (!(ctx= SSL_CTX_new(SSLv23_client_method()))) - #endif - goto error; - if (mysql->options.extension) - options|= ma_tls_version_options(mysql->options.extension->tls_version); - SSL_CTX_set_options(ctx, options); -+ ma_tls_set_sslkeylog_callback(mysql, ctx); - #ifdef HAVE_TLS_SESSION_CACHE - SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_CLIENT); - ma_tls_sessions= (MA_SSL_SESSION *)calloc(1, sizeof(struct st_ma_tls_session) * ma_tls_session_cache_size); - SSL_CTX_sess_set_new_cb(ctx, ma_tls_session_cb); - SSL_CTX_sess_set_remove_cb(ctx, ma_tls_remove_session_cb); - #endif diff --git a/deps/mariadb-client-library/plugin_auth_CMakeLists.txt.patch b/deps/mariadb-client-library/plugin_auth_CMakeLists.txt.patch index 989b9cf567..ed4aca87d1 100644 --- a/deps/mariadb-client-library/plugin_auth_CMakeLists.txt.patch +++ b/deps/mariadb-client-library/plugin_auth_CMakeLists.txt.patch @@ -1,4 +1,8 @@ -@@ -70,7 +70,7 @@ +diff --git plugins/auth/CMakeLists.txt plugins/auth/CMakeLists.txt +index 83e324b9..7c4ed019 100644 +--- plugins/auth/CMakeLists.txt ++++ plugins/auth/CMakeLists.txt +@@ -77,7 +77,7 @@ IF(CRYPTO_PLUGIN) REGISTER_PLUGIN(TARGET caching_sha2_password TYPE MARIADB_CLIENT_PLUGIN_AUTH CONFIGURATIONS DYNAMIC STATIC OFF @@ -7,7 +11,7 @@ SOURCES ${CC_SOURCE_DIR}/plugins/auth/caching_sha2_pw.c ${CRYPT_SOURCE} LIBRARIES ${CRYPT_LIBS}) -@@ -81,7 +81,7 @@ +@@ -88,7 +88,7 @@ IF(CRYPTO_PLUGIN) REGISTER_PLUGIN(TARGET sha256_password TYPE MARIADB_CLIENT_PLUGIN_AUTH CONFIGURATIONS DYNAMIC STATIC OFF @@ -16,7 +20,7 @@ SOURCES ${AUTH_DIR}/sha256_pw.c LIBRARIES ${CRYPT_LIBS}) ENDIF() -@@ -123,6 +123,6 @@ +@@ -137,6 +137,6 @@ REGISTER_PLUGIN(TARGET mysql_old_password REGISTER_PLUGIN(TARGET mysql_clear_password TYPE MARIADB_CLIENT_PLUGIN_AUTH CONFIGURATIONS DYNAMIC STATIC OFF diff --git a/deps/mariadb-client-library/ps_buffer_stmt_read_all_rows.patch b/deps/mariadb-client-library/ps_buffer_stmt_read_all_rows.patch index 373e4c3dd9..ee0f3c8a21 100644 --- a/deps/mariadb-client-library/ps_buffer_stmt_read_all_rows.patch +++ b/deps/mariadb-client-library/ps_buffer_stmt_read_all_rows.patch @@ -1,10 +1,10 @@ diff --git libmariadb/mariadb_stmt.c libmariadb/mariadb_stmt.c -index bbc2831..e66d810 100644 +index 7c6482ac..40a8ded1 100644 --- libmariadb/mariadb_stmt.c +++ libmariadb/mariadb_stmt.c -@@ -207,6 +207,24 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) +@@ -218,6 +218,24 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt) - while ((packet_len = ma_net_safe_read(stmt->mysql, &is_data_packet)) != packet_error) + while ((packet_len = ma_net_safe_read(stmt->mysql)) != packet_error) { + // This change is required due to the new algorithm introduced in ProxySQL in #3295. + // ******************************************************************************** @@ -25,5 +25,5 @@ index bbc2831..e66d810 100644 + // ******************************************************************************** + p= stmt->mysql->net.read_pos; - // The check is by 'ma_net_safe_read' - if (p[0] == 0 || is_data_packet) + if (packet_len > 7 || p[0] != 254) + { diff --git a/deps/mariadb-client-library/sslkeylogfile.patch b/deps/mariadb-client-library/sslkeylogfile.patch new file mode 100644 index 0000000000..76766679dc --- /dev/null +++ b/deps/mariadb-client-library/sslkeylogfile.patch @@ -0,0 +1,77 @@ +diff --git include/ma_common.h include/ma_common.h +index 1ac0cb68..0d3f39b3 100644 +--- include/ma_common.h ++++ include/ma_common.h +@@ -80,6 +80,7 @@ struct st_mysql_options_extension { + char *proxy_header; + size_t proxy_header_len; + int (*io_wait)(my_socket handle, my_bool is_read, int timeout); ++ void (*ssl_keylog_callback)(const void *ssl, const char *line); + my_bool skip_read_response; + char *restricted_auth; + char *rpl_host; +diff --git include/mysql.h include/mysql.h +index 9ee86227..c07717c5 100644 +--- include/mysql.h ++++ include/mysql.h +@@ -257,7 +257,8 @@ extern const char *SQLSTATE_UNKNOWN; + MARIADB_OPT_RESTRICTED_AUTH, + MARIADB_OPT_RPL_REGISTER_REPLICA, + MARIADB_OPT_STATUS_CALLBACK, +- MARIADB_OPT_SERVER_PLUGINS ++ MARIADB_OPT_SERVER_PLUGINS, ++ MARIADB_OPT_SSL_KEYLOG_CALLBACK + }; + + enum mariadb_value { +diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c +index be4c91d1..87dd7c3e 100644 +--- libmariadb/mariadb_lib.c ++++ libmariadb/mariadb_lib.c +@@ -3634,6 +3634,9 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) + case MYSQL_OPT_SSL_CRLPATH: + OPT_SET_EXTENDED_VALUE_STR(&mysql->options, ssl_crlpath, (char *)arg1); + break; ++ case MARIADB_OPT_SSL_KEYLOG_CALLBACK: ++ OPT_SET_EXTENDED_VALUE(&mysql->options, ssl_keylog_callback, arg1); ++ break; + case MYSQL_OPT_CONNECT_ATTR_DELETE: + { + uchar *h; +@@ -4000,6 +4003,9 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...) + case MYSQL_OPT_SSL_CRLPATH: + *((char **)arg)= mysql->options.extension ? mysql->options.extension->ssl_crlpath : NULL; + break; ++ case MARIADB_OPT_SSL_KEYLOG_CALLBACK: ++ *((void(**)(const void *, const char *))arg)= mysql->options.extension ? mysql->options.extension->ssl_keylog_callback : NULL; ++ break; + case MARIADB_OPT_TLS_VERSION: + case MYSQL_OPT_TLS_VERSION: + *((char **)arg)= mysql->options.extension ? mysql->options.extension->tls_version : NULL; +diff --git libmariadb/secure/openssl.c libmariadb/secure/openssl.c +index 2a272504..67d90c6a 100644 +--- libmariadb/secure/openssl.c ++++ libmariadb/secure/openssl.c +@@ -317,6 +317,13 @@ int ma_tls_get_password(char *buf, int size, + return (int)strlen(buf); + } + ++static void ma_tls_set_sslkeylog_callback(MYSQL *mysql, SSL_CTX *ctx) ++{ ++ if (mysql->options.extension && mysql->options.extension->ssl_keylog_callback) ++ { ++ SSL_CTX_set_keylog_callback(ctx, (void(*)(const SSL*, const char*))mysql->options.extension->ssl_keylog_callback); ++ } ++} + + static int ma_tls_set_certs(MYSQL *mysql, SSL_CTX *ctx) + { +@@ -433,7 +440,7 @@ void *ma_tls_init(MYSQL *mysql) + if (mysql->options.extension) + options= ma_tls_version_options(mysql->options.extension->tls_version); + SSL_CTX_set_options(ctx, options ? options : default_options); +- ++ ma_tls_set_sslkeylog_callback(mysql, ctx); + if (ma_tls_set_certs(mysql, ctx)) + { + goto error; diff --git a/deps/mariadb-client-library/unittest_basic-t.c.patch b/deps/mariadb-client-library/unittest_basic-t.c.patch index 3f0737041a..11b156e5f7 100644 --- a/deps/mariadb-client-library/unittest_basic-t.c.patch +++ b/deps/mariadb-client-library/unittest_basic-t.c.patch @@ -1,6 +1,8 @@ ---- /tmp/basic-t.c 2017-12-28 14:55:55.958512116 +0100 -+++ unittest/libmariadb/basic-t.c 2017-12-28 14:56:08.770490417 +0100 -@@ -48,7 +48,7 @@ +diff --git unittest/libmariadb/basic-t.c unittest/libmariadb/basic-t.c +index 40a44962..9d3219be 100644 +--- unittest/libmariadb/basic-t.c ++++ unittest/libmariadb/basic-t.c +@@ -52,7 +52,7 @@ static int test_conc75(MYSQL *my) rc= mysql_query(mysql, "CREATE TABLE a (a varchar(200))"); check_mysql_rc(rc, mysql); diff --git a/deps/mariadb-client-library/unittest_charset.c.patch b/deps/mariadb-client-library/unittest_charset.c.patch index 196218d8d0..8f2212078b 100644 --- a/deps/mariadb-client-library/unittest_charset.c.patch +++ b/deps/mariadb-client-library/unittest_charset.c.patch @@ -1,19 +1,24 @@ -@@ -74,12 +74,12 @@ - char *csname= (char*) "utf8"; +diff --git unittest/libmariadb/charset.c unittest/libmariadb/charset.c +index b438f8d9..0c7c5d7d 100644 +--- unittest/libmariadb/charset.c ++++ unittest/libmariadb/charset.c +@@ -75,13 +75,13 @@ int test_client_character_set(MYSQL *mysql) char *csdefault= (char*)mysql_character_set_name(mysql); + - FAIL_IF(mysql_set_character_set(mysql, csname), mysql_error(mysql)); + FAIL_IF(mysql_set_character_set(mysql, csname, 0), mysql_error(mysql)); mysql_get_character_set_info(mysql, &cs); - FAIL_IF(strcmp(cs.csname, "utf8") || strcmp(cs.name, "utf8_general_ci"), "Character set != UTF8"); + FAIL_IF(strcmp(cs.csname, "latin2") || strcmp(cs.name, "latin2_general_ci"), + "Character set != latin2"); - FAIL_IF(mysql_set_character_set(mysql, csdefault), mysql_error(mysql)); + FAIL_IF(mysql_set_character_set(mysql, csdefault, 0), mysql_error(mysql)); return OK; } -@@ -542,7 +542,7 @@ +@@ -546,7 +546,7 @@ static int test_bug30472(MYSQL *mysql) } /* Retrieve character set information. */ @@ -22,16 +27,16 @@ bug30472_retrieve_charset_info(mysql, character_set_name_1, character_set_client_1, -@@ -551,7 +551,7 @@ +@@ -555,7 +555,7 @@ static int test_bug30472(MYSQL *mysql) /* Switch client character set. */ -- FAIL_IF(mysql_set_character_set(mysql, "utf8"), "Setting cs to utf8 failed"); -+ FAIL_IF(mysql_set_character_set(mysql, "utf8", 0), "Setting cs to utf8 failed"); +- FAIL_IF(mysql_set_character_set(mysql, "ascii"), ++ FAIL_IF(mysql_set_character_set(mysql, "ascii", 0), + "Setting cs to ascii failed"); /* Retrieve character set information. */ - -@@ -581,7 +581,7 @@ +@@ -587,7 +587,7 @@ static int test_bug30472(MYSQL *mysql) /* Call mysql_change_user() with the same username, password, database. */ rc= mysql_change_user(mysql, username, password, (schema) ? schema : "test"); @@ -40,17 +45,17 @@ check_mysql_rc(rc, mysql); /* Retrieve character set information. */ -@@ -647,7 +647,7 @@ - /* ignore ucs2 */ - if (strcmp(row[0], "ucs2") && strcmp(row[0], "utf16le") && strcmp(row[0], "utf8mb4") && - strcmp(row[0], "utf16") && strcmp(row[0], "utf32")) { +@@ -658,7 +658,7 @@ static int test_bug_54100(MYSQL *mysql) + && (strcmp(row[0], "utf8") && mariadb_connection(mysql) && mysql_get_server_version(mysql) >= 100600) + && strcmp(row[0], "utf16") + && strcmp(row[0], "utf32")) { - rc= mysql_set_character_set(mysql, row[0]); + rc= mysql_set_character_set(mysql, row[0], 0); check_mysql_rc(rc, mysql); } } -@@ -748,7 +748,7 @@ - +@@ -765,14 +765,14 @@ static int charset_auto(MYSQL *my __attribute__((unused))) + "character set is not os character set"); if (strcmp(osname, "utf8")) { - rc= mysql_set_character_set(mysql, "utf8"); @@ -58,8 +63,7 @@ check_mysql_rc(rc, mysql); csname2= mysql_character_set_name(mysql); -@@ -756,7 +756,7 @@ - + diag("Character set: %s", csname2); FAIL_IF(!strcmp(csname2, csname1), "Wrong charset: expected utf8"); - rc= mysql_set_character_set(mysql, "auto"); diff --git a/deps/mariadb-client-library/openssl.c.x509cache.patch b/deps/mariadb-client-library/x509cache.patch similarity index 70% rename from deps/mariadb-client-library/openssl.c.x509cache.patch rename to deps/mariadb-client-library/x509cache.patch index 81109405c9..08233ad408 100644 --- a/deps/mariadb-client-library/openssl.c.x509cache.patch +++ b/deps/mariadb-client-library/x509cache.patch @@ -1,4 +1,44 @@ -@@ -30,6 +30,12 @@ +diff --git libmariadb/mariadb_lib.c libmariadb/mariadb_lib.c +index 916024a8..79564a10 100644 +--- libmariadb/mariadb_lib.c ++++ libmariadb/mariadb_lib.c +@@ -133,6 +133,11 @@ my_context_install_suspend_resume_hook(struct mysql_async_context *b, + uint mysql_port=0; + my_string mysql_unix_port=0; + ++#include ++extern __thread SSL_CTX * thread_ctx; ++extern __thread char **local_x509_files; ++extern __thread char **local_x509_sha1s; ++ + #define CONNECT_TIMEOUT 0 + + struct st_mariadb_methods MARIADB_DEFAULT_METHODS; +@@ -4650,6 +4655,19 @@ my_bool STDCALL mysql_thread_init(void) + + void STDCALL mysql_thread_end(void) + { ++ if (local_x509_files != NULL) { ++ int i; ++ for (i=0; local_x509_files[i] != NULL ; i++) { ++ free(local_x509_files[i]); ++ free(local_x509_sha1s[i]); ++ } ++ free(local_x509_files); ++ free(local_x509_sha1s); ++ } ++ if (thread_ctx != NULL) { ++ SSL_CTX_free(thread_ctx); ++ thread_ctx = NULL; ++ } + } + + int STDCALL mysql_set_server_option(MYSQL *mysql, +diff --git libmariadb/secure/openssl.c libmariadb/secure/openssl.c +index 67d90c6a..26938959 100644 +--- libmariadb/secure/openssl.c ++++ libmariadb/secure/openssl.c +@@ -30,6 +30,11 @@ #include #include @@ -6,12 +46,11 @@ +#include +#include +#include -+ + #if defined(_WIN32) && !defined(_OPENSSL_Applink) && defined(HAVE_OPENSSL_APPLINK_C) #include #endif -@@ -73,6 +79,84 @@ +@@ -70,6 +75,82 @@ extern my_bool ma_tls_initialized; extern unsigned int mariadb_deinitialize_ssl; @@ -21,10 +60,8 @@ +__thread char **local_x509_sha1s = NULL; + +static int proxysql_SSL_CTX_local_x509store_add_file(SSL_CTX *ctx, const char *CAfile, int add_in_store) { -+ int found = 0; -+ int i = 0; ++ int found=0, i=0, fd=-1; + -+ int fd = -1; + struct stat statbuf; + unsigned char temp[SHA_DIGEST_LENGTH]; + char file_sha1[SHA_DIGEST_LENGTH*2+2]; @@ -36,8 +73,8 @@ + if(fstat(fd, &statbuf) == 0) { + unsigned char *fb = (unsigned char *)mmap(0, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (fb != MAP_FAILED) { ++ int i; + SHA1(fb, statbuf.st_size, temp); -+ int i; + for (i=0; i < SHA_DIGEST_LENGTH; i++) { + sprintf((char*)&(file_sha1[i*2]), "%02x", temp[i]); + } @@ -60,11 +97,11 @@ + } + + while (found == 0 && local_x509_files[i] != NULL) { -+ if (strcmp(CAfile, local_x509_files[i]) == 0) { -+ found = 1; -+ } else { -+ i++; -+ } ++ if (strcmp(CAfile, local_x509_files[i]) == 0) { ++ found = 1; ++ } else { ++ i++; ++ } + } + if (found == 1) { + if (strncmp(local_x509_sha1s[i],file_sha1,SHA_DIGEST_LENGTH*2)==0) { @@ -96,17 +133,17 @@ #define MAX_SSL_ERR_LEN 100 char tls_library_version[TLS_VERSION_LENGTH]; -@@ -456,7 +540,7 @@ +@@ -331,7 +412,7 @@ static int ma_tls_set_certs(MYSQL *mysql, SSL_CTX *ctx) + *keyfile= mysql->options.ssl_key; char *pw= (mysql->options.extension) ? mysql->options.extension->tls_pw : NULL; - SSL_CTX *ctx= SSL_get_SSL_CTX(ssl); - + int ssl_rc = 0; - /* add cipher */ if ((mysql->options.ssl_cipher && -@@ -467,16 +551,32 @@ - } + mysql->options.ssl_cipher[0] != 0)) +@@ -345,10 +426,27 @@ static int ma_tls_set_certs(MYSQL *mysql, SSL_CTX *ctx) + } /* ca_file and ca_path */ - if (!SSL_CTX_load_verify_locations(ctx, @@ -129,25 +166,11 @@ + if (mysql->options.ssl_ca != NULL) { + proxysql_SSL_CTX_local_x509store_add_file(ctx,mysql->options.ssl_ca, 0); + } -+ } ++ } + } + } + if (ssl_rc == 0) { if (mysql->options.ssl_ca || mysql->options.ssl_capath) goto error; if (SSL_CTX_set_default_verify_paths(ctx) == 0) - goto error; - } -- - if (keyfile && !certfile) - certfile= keyfile; - if (certfile && !keyfile) -@@ -566,6 +666,8 @@ - SSL_CTX_sess_set_remove_cb(ctx, ma_tls_remove_session_cb); - #endif - -+// if (local_x509store != NULL) -+// SSL_CTX_set1_cert_store(ctx, local_x509store); - if (!(ssl= SSL_new(ctx))) - goto error; - + diff --git a/deps/mariadb-client-library/zutil.c-multiplication-overflow.patch b/deps/mariadb-client-library/zutil.c-multiplication-overflow.patch index 524149f842..f1388ac893 100644 --- a/deps/mariadb-client-library/zutil.c-multiplication-overflow.patch +++ b/deps/mariadb-client-library/zutil.c-multiplication-overflow.patch @@ -1,7 +1,11 @@ -@@ -303,7 +303,7 @@ +diff --git external/zlib/zutil.c external/zlib/zutil.c +index 9543ae82..6a1ed031 100644 +--- external/zlib/zutil.c ++++ external/zlib/zutil.c +@@ -310,7 +310,7 @@ voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) unsigned size; { - if (opaque) items += size - size; /* make compiler happy */ + (void)opaque; - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : + return sizeof(uInt) > 2 ? (voidpf)malloc((long) items * size) : (voidpf)calloc(items, size); diff --git a/test/tap/tests/test_binlog_fast_forward-t.cpp b/test/tap/tests/test_binlog_fast_forward-t.cpp index 281ac0e056..6f9c98befb 100644 --- a/test/tap/tests/test_binlog_fast_forward-t.cpp +++ b/test/tap/tests/test_binlog_fast_forward-t.cpp @@ -38,13 +38,17 @@ std::vector adminQ_set1 = { int pull_replication(MYSQL *mysql, int server_id) { MARIADB_RPL_EVENT *event= NULL; MARIADB_RPL *rpl= mariadb_rpl_init(mysql); + if (!rpl) { + fprintf(stderr, "File %s, line %d, Error: mariadb_rpl_init failed\n", __FILE__, __LINE__); + return exit_status(); + } rpl->server_id= server_id; rpl->start_position= 4; rpl->flags= MARIADB_RPL_BINLOG_SEND_ANNOTATE_ROWS; - - if (mariadb_rpl_open(rpl)) + if (mariadb_rpl_open(rpl)) { + fprintf(stderr, "File %s, line %d, Error: '%d':%s\n", __FILE__, __LINE__, mysql_errno(rpl->mysql), mysql_error(rpl->mysql)); return exit_status(); - + } int num_heartbeats = 0; int num_events = 0; @@ -149,6 +153,16 @@ int main(int argc, char** argv) { __FILE__, __LINE__, mysql_error(mysqladmin)); return exit_status(); } + + const std::vector query_rules = { "INSERT OR IGNORE INTO mysql_query_rules (rule_id,active,match_digest,destination_hostgroup,multiplex,apply) VALUES\ + (-1,1,'^(SELECT @rpl_semi_sync_slave=\\?.*|SET @rpl_semi_sync_slave=\\?.*)$',0,0,1)", + "LOAD MYSQL QUERY RULES TO RUNTIME" }; + + for (const auto& query : query_rules) { + diag("Running on Admin: %s", query.c_str()); + MYSQL_QUERY(mysqladmin, query.c_str()); + } + // we now test various combination setup_replication(11, false, false, repl_queries_set1); setup_replication(12, true, false, repl_queries_set1);