1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00
This commit is contained in:
Vladislav Vaintroub
2016-09-09 20:03:16 +00:00
66 changed files with 1454 additions and 928 deletions

View File

@@ -52,10 +52,12 @@ IF(WITH_RTC)
SET(RTC_OPTIONS "/RTC1 /RTCc")
ENDIF()
IF(NOT FOR_SERVER)
INCLUDE(FindCURL)
IF(CURL_FOUND)
ADD_DEFINITIONS(-DHAVE_CURL=1)
ENDIF()
ENDIF(NOT FOR_SERVER)
IF(NOT WIN32)
INCLUDE(${PROJECT_SOURCE_DIR}/cmake/FindGSSAPI.cmake)
@@ -89,10 +91,11 @@ IF(MSVC)
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(COMPILER_FLAGS "${COMPILER_FLAGS} ${RTC_OPTIONS}")
STRING(REPLACE "/Zi" "/ZI" COMPILER_FLAGS ${COMPILER_FLAGS})
ELSE()
STRING(REPLACE "/Zi" "/Z7" COMPILER_FLAGS ${COMPILER_FLAGS})
ENDIF()
MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}")
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE
STRING "overwritten by libmariadb" FORCE)
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS})
ENDIF()
ENDFOREACH()
ENDFOREACH()
@@ -106,7 +109,7 @@ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wno-uninitialized")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wvla -Wwrite-strings -Wdeclaration-after-statement")
ENDIF()
# If the build type isn't specified, set to Relwithdebinfo as default.
@@ -132,18 +135,21 @@ IF(NOT MARIADB_UNIX_ADDR)
ENDIF()
INCLUDE("${PROJECT_SOURCE_DIR}/cmake/install.cmake")
IF(NOT PLUGINDIR)
SET(PLUGINDIR "${PREFIX_INSTALL_DIR}/${PLUGIN_INSTALL_DIR}")
ENDIF()
# todo: we don't character sets in share - all is compiled in
SET(SHAREDIR "share")
SET(DEFAULT_CHARSET_HOME "${CMAKE_INSTALL_PREFIX}")
# SET(MARIADB_PLUGINDIR "${CMAKE_INSTALL_PREFIX}/lib/plugin")
INCLUDE(${PROJECT_SOURCE_DIR}/cmake/SearchLibrary.cmake)
IF(WITH_EXTERNAL_ZLIB)
FIND_PACKAGE(ZLIB QUIET)
IF(${ZLIB_FOUND})
SET(LIBZ "-z")
FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
SET(LIBZ ${ZLIB_LIBRARY})
ENDIF()
ENDIF()

View File

@@ -34,7 +34,7 @@ MARK_AS_ADVANCED(PLUGINS)
REGISTER_PLUGIN("SOCKET" "${PROJECT_SOURCE_DIR}/plugins/pvio/pvio_socket.c" "pvio_socket_plugin" "STATIC" pvio_socket 0)
IF(WIN32)
REGISTER_PLUGIN("NPIPE" "${PROJECT_SOURCE_DIR}/plugins/pvio/pvio_npipe.c" "pvio_npipe_plugin" "STATIC" pvio_npipe 1)
REGISTER_PLUGIN("SHMEM" "${PROJECT_SOURCE_DIR}/plugins/pvio/pvio_shmem.c" "pvio_shmem_plugin" "DYNAMIC" pvio_shmem 1)
REGISTER_PLUGIN("SHMEM" "${PROJECT_SOURCE_DIR}/plugins/pvio/pvio_shmem.c" "pvio_shmem_plugin" "STATIC" pvio_shmem 1)
ENDIF()
# AUTHENTICATION

View File

@@ -84,6 +84,8 @@ struct st_mariadb_session_state
struct st_mariadb_extension {
MA_CONNECTION_HANDLER *conn_hdlr;
struct st_mariadb_session_state session_state[SESSION_TRACK_TYPES];
unsigned long mariadb_client_flag; /* MariaDB specific client flags */
unsigned long mariadb_server_capabilities; /* MariaDB specific server capabilities */
};
#define OPT_HAS_EXT_VAL(a,key) \

View File

@@ -21,7 +21,6 @@
#ifndef _global_h
#define _global_h
#ifdef _WIN32
#include <ma_config_win.h>
#else
@@ -710,6 +709,7 @@ typedef char *my_string; /* String of characters */
typedef unsigned long size_s; /* Size of strings (In string-funcs) */
typedef int myf; /* Type of MyFlags in my_funcs */
typedef char my_bool; /* Small bool */
typedef unsigned long long my_ulonglong;
#if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
typedef char bool; /* Ordinary boolean values 0 1 */
#endif

View File

@@ -54,8 +54,8 @@ my_bool _hash_init(HASH *hash,uint default_array_elements, uint key_offset,
void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
void hash_free(HASH *tree);
uchar *hash_element(HASH *hash,uint idx);
gptr hash_search(HASH *info,const uchar *key,uint length);
gptr hash_next(HASH *info,const uchar *key,uint length);
void * hash_search(HASH *info,const uchar *key,uint length);
void * hash_next(HASH *info,const uchar *key,uint length);
my_bool hash_insert(HASH *info,const uchar *data);
my_bool hash_delete(HASH *hash,uchar *record);
my_bool hash_update(HASH *hash,uchar *record,uchar *old_key,uint old_key_length);

View File

@@ -55,6 +55,8 @@ enum enum_pvio_operation {
PVIO_WRITE=1
};
#define SHM_DEFAULT_NAME "MYSQL"
struct st_pvio_callback;
typedef struct st_pvio_callback {
@@ -75,7 +77,7 @@ struct st_ma_pvio {
MYSQL *mysql;
PVIO_METHODS *methods;
void (*set_error)(MYSQL *mysql, unsigned int error_nr, const char *sqlstate, const char *format, ...);
void (*callback)(MARIADB_PVIO *pvio, my_bool is_read, const char *buffer, size_t length);
void (*callback)(MARIADB_PVIO *pvio, my_bool is_read, const uchar *buffer, size_t length);
};
typedef struct st_ma_pvio_cinfo

View File

@@ -368,12 +368,12 @@ typedef struct st_ma_mem_root {
/* Prototypes for mysys and my_func functions */
extern gptr _mymalloc(size_t uSize,const char *sFile,
extern void * _mymalloc(size_t uSize,const char *sFile,
uint uLine, myf MyFlag);
extern gptr _myrealloc(gptr pPtr,size_t uSize,const char *sFile,
extern void * _myrealloc(void * pPtr,size_t uSize,const char *sFile,
uint uLine, myf MyFlag);
extern void *ma_multi_malloc(myf MyFlags, ...);
extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
extern void _myfree(void * pPtr,const char *sFile,uint uLine, myf MyFlag);
extern int _sanity(const char *sFile,unsigned int uLine);
#ifndef TERMINATE
extern void TERMINATE(FILE *file);
@@ -507,11 +507,11 @@ File create_temp_file(char *to, const char *dir, const char *pfx,
extern my_bool ma_init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
uint init_alloc,uint alloc_increment CALLER_INFO_PROTO);
#define ma_init_dynamic_array_ci(A,B,C,D) ma_init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
extern my_bool ma_insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
extern my_bool ma_insert_dynamic(DYNAMIC_ARRAY *array,void * element);
extern unsigned char *ma_alloc_dynamic(DYNAMIC_ARRAY *array);
extern unsigned char *ma_pop_dynamic(DYNAMIC_ARRAY*);
extern my_bool ma_set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
extern void ma_get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
extern my_bool ma_set_dynamic(DYNAMIC_ARRAY *array,void * element,uint array_index);
extern void ma_get_dynamic(DYNAMIC_ARRAY *array,void * element,uint array_index);
extern void ma_delete_dynamic(DYNAMIC_ARRAY *array);
extern void ma_delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
extern void ma_freeze_size(DYNAMIC_ARRAY *array);
@@ -542,8 +542,8 @@ extern void ma_free_lock(unsigned char *ptr,myf flags);
#define ma_free_lock(A,B) ma_free((A),(B))
#endif
#define ma_alloc_root_inited(A) ((A)->min_malloc != 0)
void ma_init_ma_alloc_root(MA_MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size);
gptr ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size);
void ma_init_alloc_root(MA_MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size);
void *ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size);
void ma_free_root(MA_MEM_ROOT *root, myf MyFLAGS);
char *ma_strdup_root(MA_MEM_ROOT *root,const char *str);
char *ma_memdup_root(MA_MEM_ROOT *root,const char *str, size_t len);

View File

@@ -127,7 +127,7 @@ const char *ma_tls_get_cipher(MARIADB_TLS *ssl);
Returns:
actual size of finger print
*/
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, unsigned char *fp, unsigned int fp_len);
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, char *fp, unsigned int fp_len);
/* ma_tls_get_protocol_version
returns protocol version in use

View File

@@ -171,7 +171,8 @@ enum enum_server_command
!(mysql->server_capabilities & CLIENT_MYSQL)
#define MARIADB_CLIENT_SUPPORTED_FLAGS (MARIADB_CLIENT_PROGRESS |\
MARIADB_CLIENT_COM_MULTI)
MARIADB_CLIENT_COM_MULTI |\
MARIADB_CLIENT_STMT_BULK_OPERATIONS)
#define CLIENT_SUPPORTED_FLAGS (CLIENT_MYSQL |\
CLIENT_FOUND_ROWS |\

View File

@@ -41,11 +41,11 @@ typedef struct ma_charset_info_st
{
unsigned int nr; /* so far only 1 byte for charset */
unsigned int state;
char *csname;
char *name;
char *dir;
const char *csname;
const char *name;
const char *dir;
unsigned int codepage;
char *encoding;
const char *encoding;
unsigned int char_minlen;
unsigned int char_maxlen;
unsigned int (*mb_charlen)(unsigned int c);
@@ -64,7 +64,7 @@ MARIADB_CHARSET_INFO *find_compiled_charset_by_name(const char *name);
size_t mysql_cset_escape_quotes(const MARIADB_CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len);
size_t mysql_cset_escape_slashes(const MARIADB_CHARSET_INFO *cset, char *newstr, const char *escapestr, size_t escapestr_len);
char* madb_get_os_character_set(void);
const char* madb_get_os_character_set(void);
#ifdef _WIN32
int madb_get_windows_cp(const char *charset);
#endif

View File

@@ -99,7 +99,10 @@ typedef struct st_mysql_bind
void *buffer; /* buffer to get/put data */
/* set this if you want to track data truncations happened during fetch */
my_bool *error;
unsigned char *row_ptr; /* for the current data position */
union {
unsigned char *row_ptr; /* for the current data position */
char *indicator; /* indicator variable */
} u;
void (*store_param_func)(NET *net, struct st_mysql_bind *param);
void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *,
unsigned char **row);
@@ -107,12 +110,7 @@ typedef struct st_mysql_bind
unsigned char **row);
/* output buffer length, must be set when fetching str/binary */
unsigned long buffer_length;
union {
unsigned long offset; /* offset position for char/binary fetch */
struct {
unsigned char *indicator;
};
} u;
unsigned long offset; /* offset position for char/binary fetch */
unsigned long length_value; /* Used if length is 0 */
unsigned int flags; /* special flags, e.g. for dummy bind */
unsigned int pack_length; /* Internal length for packed data */

View File

@@ -19,7 +19,7 @@
#define MARIADB_PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@"
#define MARIADB_SYSTEM_TYPE "@CMAKE_SYSTEM_NAME@"
#define MARIADB_MACHINE_TYPE "@CMAKE_SYSTEM_PROCESSOR@"
#define MARIADB_PLUGINDIR "@PREFIX_INSTALL_DIR@/@PLUGIN_INSTALL_DIR@"
#define MARIADB_PLUGINDIR "@PLUGINDIR@"
/* mysqld compile time options */
#ifndef MYSQL_CHARSET

View File

@@ -37,6 +37,7 @@ extern "C" {
#if !defined (_global_h) && !defined (MY_GLOBAL_INCLUDED) /* If not standard header */
#include <sys/types.h>
typedef char my_bool;
typedef unsigned long long my_ulonglong;
#if !defined(_WIN32)
#define STDCALL
@@ -44,8 +45,6 @@ typedef char my_bool;
#define STDCALL __stdcall
#endif
#ifndef my_socket_defined
#define my_socket_defined
#if defined(_WIN64)
@@ -152,10 +151,12 @@ extern unsigned int mariadb_deinitialize_ssl;
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
typedef struct st_mysql_data {
MYSQL_ROWS *data;
void *embedded_info;
MA_MEM_ROOT alloc;
unsigned long long rows;
unsigned int fields;
MYSQL_ROWS *data;
MA_MEM_ROOT alloc;
void *extension;
} MYSQL_DATA;
enum mariadb_com_multi {
@@ -333,8 +334,8 @@ struct st_mysql_options {
unsigned long thread_id; /* Id for connection in server */
unsigned long packet_length;
unsigned int port;
unsigned long long client_flag;
unsigned long long server_capabilities; /* changed from long to longlong in 10.2 protocol */
unsigned long client_flag;
unsigned long server_capabilities;
unsigned int protocol_version;
unsigned int field_count;
unsigned int server_status;
@@ -371,6 +372,13 @@ typedef struct st_mysql_res {
my_bool is_ps;
} MYSQL_RES;
typedef struct
{
unsigned long *p_max_allowed_packet;
unsigned long *p_net_buffer_length;
void *extension;
} MYSQL_PARAMETERS;
#ifndef _mysql_time_h_
enum enum_mysql_timestamp_type
{
@@ -385,9 +393,9 @@ typedef struct st_mysql_time
my_bool neg;
enum enum_mysql_timestamp_type time_type;
} MYSQL_TIME;
#define AUTO_SEC_PART_DIGITS 39
#endif
#define AUTO_SEC_PART_DIGITS 31
#define SEC_PART_DIGITS 6
#define MARIADB_INVALID_SOCKET -1
@@ -460,7 +468,7 @@ void my_set_error(MYSQL *mysql, unsigned int error_nr,
/* Functions to get information from the MYSQL and MYSQL_RES structures */
/* Should definitely be used if one uses shared libraries */
unsigned long long STDCALL mysql_num_rows(MYSQL_RES *res);
my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res);
unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
my_bool STDCALL mysql_eof(MYSQL_RES *res);
MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
@@ -472,11 +480,11 @@ unsigned int STDCALL mysql_field_tell(MYSQL_RES *res);
unsigned int STDCALL mysql_field_count(MYSQL *mysql);
my_bool STDCALL mysql_more_results(MYSQL *mysql);
int STDCALL mysql_next_result(MYSQL *mysql);
unsigned long long STDCALL mysql_affected_rows(MYSQL *mysql);
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
my_bool STDCALL mysql_autocommit(MYSQL *mysql, my_bool mode);
my_bool STDCALL mysql_commit(MYSQL *mysql);
my_bool STDCALL mysql_rollback(MYSQL *mysql);
unsigned long long STDCALL mysql_insert_id(MYSQL *mysql);
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
unsigned int STDCALL mysql_errno(MYSQL *mysql);
char * STDCALL mysql_error(MYSQL *mysql);
char * STDCALL mysql_info(MYSQL *mysql);
@@ -571,6 +579,11 @@ unsigned int STDCALL mysql_get_timeout_value(const MYSQL *mysql);
unsigned int STDCALL mysql_get_timeout_value_ms(const MYSQL *mysql);
my_bool STDCALL mariadb_reconnect(MYSQL *mysql);
int STDCALL mariadb_cancel(MYSQL *mysql);
void STDCALL mysql_debug(const char *debug);
unsigned long STDCALL mysql_net_read_packet(MYSQL *mysql);
unsigned long STDCALL mysql_net_field_length(unsigned char **packet);
my_bool STDCALL mysql_embedded();
MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void);
/* Async API */
int STDCALL mysql_close_start(MYSQL *sock);

View File

@@ -1,4 +1,3 @@
#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab
This library is free software; you can redistribute it and/or
@@ -16,6 +15,8 @@
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
/**
@file

View File

@@ -28,7 +28,9 @@ SET(MARIADB_LIB_SYMBOLS
mysql_close
mysql_commit
mysql_data_seek
mysql_debug
mysql_dump_debug_info
mysql_embedded
mysql_eof
mysql_errno
mysql_error
@@ -50,6 +52,7 @@ SET(MARIADB_LIB_SYMBOLS
mysql_get_host_info
mysql_get_option
mysql_get_optionv
mysql_get_parameters
mysql_get_proto_info
mysql_get_server_info
mysql_get_server_name
@@ -70,6 +73,8 @@ SET(MARIADB_LIB_SYMBOLS
mysql_load_plugin
mysql_load_plugin_v
mysql_more_results
mysql_net_field_length
mysql_net_read_packet
mysql_next_result
mysql_num_fields
mysql_num_rows
@@ -348,17 +353,21 @@ IF(WIN32)
"SOURCE_FILE:libmariadb/libmariadb.c"
"ORIGINAL_FILE_NAME:libmariadb.dll"
"FILE_DESCRIPTION:Dynamic lib for client/server communication")
SET_VERSION_INFO("TARGET:mariadbclient"
"FILE_TYPE:VFT_STATIC_LIB"
"SOURCE_FILE:libmariadb/libmariadb.c"
"ORIGINAL_FILE_NAME:mariadbclient.lib"
"FILE_DESCRIPTION:Static lib for client/server communication")
ENDIF()
ADD_LIBRARY(mariadbclient STATIC ${mariadbclient_RC} ${MARIADB_OBJECTS} ${EMPTY_FILE} mariadbclient.def)
TARGET_LINK_LIBRARIES(mariadbclient ${SYSTEM_LIBS})
ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} ${MARIADB_OBJECTS} ${EMPTY_FILE} mariadbclient.def)
TARGET_LINK_LIBRARIES(libmariadb ${SYSTEM_LIBS})
IF(FOR_SERVER)
SET_TARGET_PROPERTIES(mariadbclient PROPERTIES OUTPUT_NAME mysqlclient)
IF(WIN32)
SET_TARGET_PROPERTIES(libmariadb PROPERTIES OUTPUT_NAME libmysql)
ELSE()
SET_TARGET_PROPERTIES(libmariadb PROPERTIES OUTPUT_NAME libmysqlclient)
ENDIF()
ENDIF()
IF(UNIX)
SET_TARGET_PROPERTIES(libmariadb PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
ENDIF()
@@ -371,8 +380,6 @@ ENDIF()
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
TARGET_LINK_LIBRARIES (libmariadb "-Wl,--no-undefined")
TARGET_LINK_LIBRARIES (libmariadb "-Wl,--version-script=${PROJECT_BINARY_DIR}/libmariadb/mariadbclient.def")
TARGET_LINK_LIBRARIES (mariadbclient "-Wl,--no-undefined")
TARGET_LINK_LIBRARIES (mariadbclient "-Wl,--version-script=${PROJECT_BINARY_DIR}/libmariadb/mariadbclient.def")
ENDIF()
SET_TARGET_PROPERTIES(mariadbclient PROPERTIES IMPORTED_INTERFACE_LINK_LIBRARIES "${SYSTEM_LIBS}")
@@ -380,10 +387,6 @@ SET_TARGET_PROPERTIES(libmariadb PROPERTIES IMPORTED_INTERFACE_LINK_LIBRARIES "$
SET_TARGET_PROPERTIES(libmariadb PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION
${CPACK_PACKAGE_VERSION_MAJOR}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
#
# Installation
#
@@ -393,8 +396,25 @@ INCLUDE(${PROJECT_SOURCE_DIR}/cmake/symlink.cmake)
# There are still several projects which don't make use
# of the config program. To make sure these programs can
# use mariadb client library we provide libmysql symlinks
IF(NOT WIN32 AND WITH_MYSQLCOMPAT)
SET(INSTALL_PATH ${LIB_INSTALL_DIR}/${SUFFIX_INSTALL_DIR})
SET(INSTALL_PATH ${LIB_INSTALL_DIR}/${SUFFIX_INSTALL_DIR})
IF(NOT FOR_SERVER)
SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION
${CPACK_PACKAGE_VERSION_MAJOR}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
ELSE()
SET(SHARED_LIB_MAJOR_VERSION 18 CACHE STRING "")
SET(OS_SHARED_LIB_VERSION "${SHARED_LIB_MAJOR_VERSION}.0.0" CACHE STRING "")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET_TARGET_PROPERTIES(libmariadb PROPERTIES
VERSION ${SHARED_LIB_MAJOR_VERSION}
SOVERSION ${OS_SHARED_LIB_VERSION})
ENDIF()
create_symlink(libmysqlclient_r${CMAKE_STATIC_LIBRARY_SUFFIX} mariadbclient ${INSTALL_PATH})
create_symlink(libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX} libmariadb ${INSTALL_PATH})
ENDIF()
IF(NOT WIN32 AND WITH_MYSQLCOMPAT AND NOT FOR_SERVER)
create_symlink(libmysqlclient${CMAKE_SHARED_LIBRARY_SUFFIX} libmariadb ${INSTALL_PATH})
create_symlink(libmysqlclient_r${CMAKE_SHARED_LIBRARY_SUFFIX} libmariadb ${INSTALL_PATH})
create_symlink(libmysqlclient${CMAKE_STATIC_LIBRARY_SUFFIX} mariadbclient ${INSTALL_PATH})
@@ -404,8 +424,17 @@ ENDIF()
INSTALL(TARGETS
libmariadb mariadbclient
RUNTIME DESTINATION "${LIB_INSTALL_DIR}/${SUFFIX_INSTALL_DIR}"
LIBRARY DESTINATION "${LIB_INSTALL_DIR}/${SUFFIX_INSTALL_DIR}"
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}/${SUFFIX_INSTALL_DIR}")
RUNTIME DESTINATION "${INSTALL_PATH}"
LIBRARY DESTINATION "${INSTALL_PATH}"
ARCHIVE DESTINATION "${INSTALL_PATH}")
IF(WIN32)
# On Windows, install PDB
GET_TARGET_PROPERTY(location libmariadb LOCATION)
STRING(REPLACE ".dll" ".pdb" pdb_location ${location})
IF (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}"
pdb_location ${pdb_location})
ENDIF()
INSTALL(FILES ${pdb_location} DESTINATION "${INSTALL_PATH}")
ENDIF()

View File

@@ -21,12 +21,14 @@
#include <ma_sys.h>
#include <ma_string.h>
void ma_init_ma_alloc_root(MA_MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size)
void ma_init_alloc_root(MA_MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size)
{
mem_root->free=mem_root->used=0;
mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
mem_root->min_malloc=32;
mem_root->block_size=block_size-MALLOC_OVERHEAD-sizeof(MA_USED_MEM)-8;
mem_root->block_size= (block_size-MALLOC_OVERHEAD-sizeof(MA_USED_MEM)+8);
mem_root->error_handler=0;
mem_root->block_num= 4;
mem_root->first_block_usage= 0;
#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
if (pre_alloc_size)
{
@@ -41,7 +43,7 @@ void ma_init_ma_alloc_root(MA_MEM_ROOT *mem_root, size_t block_size, size_t pre_
#endif
}
gptr ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size)
void * ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size)
{
#if defined(HAVE_purify) && defined(EXTRA_DEBUG)
reg1 MA_USED_MEM *next;
@@ -51,55 +53,65 @@ gptr ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size)
{
if (mem_root->error_handler)
(*mem_root->error_handler)();
return((gptr) 0); /* purecov: inspected */
return((void *) 0); /* purecov: inspected */
}
next->next=mem_root->used;
mem_root->used=next;
return (gptr) (((char*) next)+ALIGN_SIZE(sizeof(MA_USED_MEM)));
return (void *) (((char*) next)+ALIGN_SIZE(sizeof(MA_USED_MEM)));
#else
size_t get_size,max_left;
gptr point;
reg1 MA_USED_MEM *next;
size_t get_size;
void * point;
reg1 MA_USED_MEM *next= 0;
reg2 MA_USED_MEM **prev;
Size= ALIGN_SIZE(Size);
prev= &mem_root->free;
max_left=0;
for (next= *prev ; next && next->left < Size ; next= next->next)
if ((*(prev= &mem_root->free)))
{
if (next->left > max_left)
max_left=next->left;
prev= &next->next;
if ((*prev)->left < Size &&
mem_root->first_block_usage++ >= 16 &&
(*prev)->left < 4096)
{
next= *prev;
*prev= next->next;
next->next= mem_root->used;
mem_root->used= next;
mem_root->first_block_usage= 0;
}
for (next= *prev; next && next->left < Size; next= next->next)
prev= &next->next;
}
if (! next)
{ /* Time to alloc new block */
get_size= Size+ALIGN_SIZE(sizeof(MA_USED_MEM));
if (max_left*4 < mem_root->block_size && get_size < mem_root->block_size)
get_size=mem_root->block_size; /* Normal alloc */
get_size= MAX(Size+ALIGN_SIZE(sizeof(MA_USED_MEM)),
(mem_root->block_size & ~1) * (mem_root->block_num >> 2));
if (!(next = (MA_USED_MEM*) calloc(1, get_size)))
if (!(next = (MA_USED_MEM*) malloc(get_size)))
{
if (mem_root->error_handler)
(*mem_root->error_handler)();
return((gptr) 0); /* purecov: inspected */
return((void *) 0); /* purecov: inspected */
}
mem_root->block_num++;
next->next= *prev;
next->size= get_size;
next->left= get_size-ALIGN_SIZE(sizeof(MA_USED_MEM));
*prev=next;
}
point= (gptr) ((char*) next+ (next->size-next->left));
point= (void *) ((char*) next+ (next->size-next->left));
if ((next->left-= Size) < mem_root->min_malloc)
{ /* Full block */
*prev=next->next; /* Remove block from list */
next->next=mem_root->used;
mem_root->used=next;
mem_root->first_block_usage= 0;
}
return(point);
#endif
}
/* deallocate everything used by ma_alloc_root */
/* deallocate everything used by alloc_root */
void ma_free_root(MA_MEM_ROOT *root, myf MyFlags)
{
@@ -129,7 +141,6 @@ void ma_free_root(MA_MEM_ROOT *root, myf MyFlags)
root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(MA_USED_MEM));
root->free->next=0;
}
return;
}
@@ -146,7 +157,7 @@ char *ma_strdup_root(MA_MEM_ROOT *root,const char *str)
char *ma_memdup_root(MA_MEM_ROOT *root, const char *str, size_t len)
{
char *pos;
if ((pos=ma_alloc_root(root,len)))
if ((pos= ma_alloc_root(root,len)))
memcpy(pos,str,len);
return pos;
}

View File

@@ -55,9 +55,9 @@ my_bool ma_init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
}
my_bool ma_insert_dynamic(DYNAMIC_ARRAY *array, gptr element)
my_bool ma_insert_dynamic(DYNAMIC_ARRAY *array, void *element)
{
gptr buffer;
void *buffer;
if (array->elements == array->max_element)
{ /* Call only when nessesary */
if (!(buffer=ma_alloc_dynamic(array)))
@@ -87,7 +87,7 @@ unsigned char *ma_alloc_dynamic(DYNAMIC_ARRAY *array)
array->buffer=new_ptr;
array->max_element+=array->alloc_increment;
}
return array->buffer+(array->elements++ * array->size_of_element);
return (unsigned char *)array->buffer+(array->elements++ * array->size_of_element);
}
@@ -96,12 +96,12 @@ unsigned char *ma_alloc_dynamic(DYNAMIC_ARRAY *array)
unsigned char *ma_pop_dynamic(DYNAMIC_ARRAY *array)
{
if (array->elements)
return array->buffer+(--array->elements * array->size_of_element);
return (unsigned char *)array->buffer+(--array->elements * array->size_of_element);
return 0;
}
my_bool ma_set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
my_bool ma_set_dynamic(DYNAMIC_ARRAY *array, void * element, uint idx)
{
if (idx >= array->elements)
{
@@ -127,7 +127,7 @@ my_bool ma_set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
}
void ma_get_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
void ma_get_dynamic(DYNAMIC_ARRAY *array, void * element, uint idx)
{
if (idx >= array->elements)
{

View File

@@ -696,7 +696,7 @@ const MARIADB_CHARSET_INFO * mysql_find_charset_nr(unsigned int charsetnr)
MARIADB_CHARSET_INFO * mysql_find_charset_name(const char *name)
{
MARIADB_CHARSET_INFO *c = (MARIADB_CHARSET_INFO *)mariadb_compiled_charsets;
char *csname;
const char *csname;
if (!strcasecmp(name, MADB_AUTODETECT_CHARSET_NAME))
csname= madb_get_os_character_set();
@@ -844,10 +844,10 @@ size_t mysql_cset_escape_slashes(const MARIADB_CHARSET_INFO * cset, char *newstr
/* {{{ MADB_OS_CHARSET */
struct st_madb_os_charset {
char *identifier;
char *description;
char *charset;
char *iconv_cs;
const char *identifier;
const char *description;
const char *charset;
const char *iconv_cs;
unsigned char supported;
};
@@ -1086,7 +1086,7 @@ struct st_madb_os_charset MADB_OS_CHARSET[]=
/* }}} */
/* {{{ madb_get_os_character_set */
char *madb_get_os_character_set()
const char *madb_get_os_character_set()
{
unsigned int i= 0;
char *p= NULL;
@@ -1195,7 +1195,7 @@ size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, MARIAD
*errorcode= errno;
goto error;
}
if ((rc= iconv(conv, (char **)&from, from_len, &to, to_len)) == -1)
if ((rc= iconv(conv, (char **)&from, from_len, &to, to_len)) == (size_t)-1)
{
*errorcode= errno;
goto error;

View File

@@ -97,23 +97,20 @@ static int is_not_initialized(MYSQL *mysql, const char *name)
return 1;
}
static int get_plugin_nr(int type)
static int get_plugin_nr(uint type)
{
uint i= 0;
for(; valid_plugins[i][1]; i++)
if (valid_plugins[i][0]== type)
if (valid_plugins[i][0] == type)
return i;
return -1;
}
static my_bool check_plugin_version(struct st_mysql_client_plugin *plugin, unsigned int version, char *errmsg)
static const char *check_plugin_version(struct st_mysql_client_plugin *plugin, unsigned int version)
{
if (plugin->interface_version < version ||
(plugin->interface_version >> 8) > (version >> 8))
{
errmsg= "Incompatible client plugin interface";
return 1;
}
return "Incompatible client plugin interface";
return 0;
}
@@ -165,7 +162,7 @@ static struct st_mysql_client_plugin *
add_plugin(MYSQL *mysql, struct st_mysql_client_plugin *plugin, void *dlhandle,
int argc, va_list args)
{
char *errmsg;
const char *errmsg;
struct st_client_plugin_int plugin_int, *p;
char errbuf[1024];
int plugin_nr;
@@ -180,11 +177,8 @@ add_plugin(MYSQL *mysql, struct st_mysql_client_plugin *plugin, void *dlhandle,
errmsg= "Unknown client plugin type";
goto err1;
}
if (check_plugin_version(plugin, valid_plugins[plugin_nr][1], errbuf))
{
errmsg= errbuf;
if ((errmsg= check_plugin_version(plugin, valid_plugins[plugin_nr][1])))
goto err1;
}
/* Call the plugin initialization function, if any */
if (plugin->init && plugin->init(errbuf, sizeof(errbuf), argc, args))
@@ -250,7 +244,7 @@ static void load_env_plugins(MYSQL *mysql)
free_env= plugs= strdup(s);
do {
if (s= strchr(plugs, ';'))
if ((s= strchr(plugs, ';')))
*s= '\0';
mysql_load_plugin(mysql, plugs, -1, 0);
plugs= s + 1;
@@ -283,7 +277,7 @@ int mysql_client_plugin_init()
memset(&mysql, 0, sizeof(mysql)); /* dummy mysql for set_mysql_extended_error */
pthread_mutex_init(&LOCK_load_client_plugin, MY_MUTEX_INIT_SLOW);
ma_init_ma_alloc_root(&mem_root, 128, 128);
ma_init_alloc_root(&mem_root, 128, 128);
memset(&plugin_list, 0, sizeof(plugin_list));

View File

@@ -128,6 +128,7 @@ my_context_init(struct my_context *c, size_t stack_size)
#if SIZEOF_CHARP > SIZEOF_INT*2
#error Error: Unable to store pointer in 2 ints on this architecture
#endif
memset(c, 0, sizeof(*c));
if (!(c->stack= malloc(stack_size)))
return -1; /* Out of memory */

View File

@@ -95,9 +95,9 @@ static inline char*
hash_key(HASH *hash,const uchar *record,uint *length,my_bool first)
{
if (hash->get_key)
return (*hash->get_key)(record,(uint *)length,first);
return (char *)(*hash->get_key)(record,(uint *)length,first);
*length=hash->key_length;
return (uchar*) record+hash->key_offset;
return (char*) record+hash->key_offset;
}
/* Calculate pos according to keys */
@@ -202,7 +202,7 @@ unsigned int rec_hashnr(HASH *hash,const uchar *record)
/* Search after a record based on a key */
/* Sets info->current_ptr to found record */
gptr hash_search(HASH *hash,const uchar *key,uint length)
void* hash_search(HASH *hash,const uchar *key,uint length)
{
HASH_LINK *pos;
uint flag,idx;
@@ -237,7 +237,7 @@ gptr hash_search(HASH *hash,const uchar *key,uint length)
/* Get next record with identical key */
/* Can only be called if previous calls was hash_search */
gptr hash_next(HASH *hash,const uchar *key,uint length)
void *hash_next(HASH *hash,const uchar *key,uint length)
{
HASH_LINK *pos;
uint idx;

View File

@@ -57,7 +57,7 @@ void ma_init(void)
void ma_end(int infoflag)
void ma_end(int infoflag __attribute__((unused)))
{
#ifdef _WIN32
WSACleanup( );

View File

@@ -109,7 +109,7 @@ int mysql_local_infile_read(void *ptr, char * buf, unsigned int buf_len)
count= ma_read((void *)buf, 1, (size_t)buf_len, info->fp);
if (count < 0)
if (count == (size_t)-1)
{
info->error_no = errno;
snprintf((char *)info->error_msg, sizeof(info->error_msg),
@@ -202,7 +202,7 @@ my_bool mysql_handle_local_infile(MYSQL *conn, const char *filename)
if (!(conn->options.client_flag & CLIENT_LOCAL_FILES)) {
my_set_error(conn, CR_UNKNOWN_ERROR, SQLSTATE_UNKNOWN, "Load data local infile forbidden");
/* write empty packet to server */
ma_net_write(&conn->net, "", 0);
ma_net_write(&conn->net, (unsigned char *)"", 0);
ma_net_flush(&conn->net);
goto infile_error;
}
@@ -219,7 +219,7 @@ my_bool mysql_handle_local_infile(MYSQL *conn, const char *filename)
tmp_errno= conn->options.local_infile_error(info, tmp_buf, sizeof(tmp_buf));
my_set_error(conn, tmp_errno, SQLSTATE_UNKNOWN, tmp_buf);
ma_net_write(&conn->net, "", 0);
ma_net_write(&conn->net, (unsigned char *)"", 0);
ma_net_flush(&conn->net);
goto infile_error;
}
@@ -227,7 +227,7 @@ my_bool mysql_handle_local_infile(MYSQL *conn, const char *filename)
/* read data */
while ((bufread= conn->options.local_infile_read(info, (char *)buf, buflen)) > 0)
{
if (ma_net_write(&conn->net, (char *)buf, bufread))
if (ma_net_write(&conn->net, (unsigned char *)buf, bufread))
{
my_set_error(conn, CR_SERVER_LOST, SQLSTATE_UNKNOWN, NULL);
goto infile_error;
@@ -235,7 +235,8 @@ my_bool mysql_handle_local_infile(MYSQL *conn, const char *filename)
}
/* send empty packet for eof */
if (ma_net_write(&conn->net, "", 0) || ma_net_flush(&conn->net))
if (ma_net_write(&conn->net, (unsigned char *)"", 0) ||
ma_net_flush(&conn->net))
{
my_set_error(conn, CR_SERVER_LOST, SQLSTATE_UNKNOWN, NULL);
goto infile_error;

View File

@@ -228,7 +228,7 @@ ma_net_write(NET *net, const uchar *packet, size_t len)
int3store(buff,max_len);
buff[3]= (uchar)net->pkt_nr++;
if (ma_net_write_buff(net,(char*) buff,NET_HEADER_SIZE) ||
ma_net_write_buff(net, packet, max_len))
ma_net_write_buff(net, (char *)packet, max_len))
return 1;
packet+= max_len;
len-= max_len;
@@ -237,7 +237,7 @@ ma_net_write(NET *net, const uchar *packet, size_t len)
int3store(buff, len);
buff[3]= (uchar)net->pkt_nr++;
if (ma_net_write_buff(net,(char*) buff,NET_HEADER_SIZE) ||
ma_net_write_buff(net, packet, len))
ma_net_write_buff(net, (char *)packet, len))
return 1;
return 0;
}
@@ -325,19 +325,22 @@ ma_net_write_buff(NET *net,const char *packet, size_t len)
return 0;
}
unsigned char *mysql_net_store_length(unsigned char *packet, size_t length);
int net_add_multi_command(NET *net, uchar command, const uchar *packet,
size_t length)
{
size_t left_length;
size_t required_length, current_length;
required_length= length + 1 + COMP_HEADER_SIZE + NET_HEADER_SIZE;
/* 9 - maximum possible length of data stored in net length format */
required_length= length + 1 + COMP_HEADER_SIZE + NET_HEADER_SIZE + 9;
/* We didn't allocate memory in ma_net_init since it was too early to
* detect if the server supports COM_MULTI command */
if (!net->extension->mbuff)
{
size_t alloc_size= (required_length + IO_SIZE - 1) & ~(IO_SIZE - 1);
if (!(net->extension->mbuff= (char *)malloc(alloc_size)))
if (!(net->extension->mbuff= (unsigned char *)malloc(alloc_size)))
{
net->last_errno=ER_OUT_OF_RESOURCES;
net->error=2;
@@ -358,8 +361,8 @@ int net_add_multi_command(NET *net, uchar command, const uchar *packet,
goto error;
net->extension->mbuff_pos = net->extension->mbuff + current_length;
}
int3store(net->extension->mbuff_pos, length + 1);
net->extension->mbuff_pos+= 3;
net->extension->mbuff_pos= mysql_net_store_length(net->extension->mbuff_pos,
length + 1);
*net->extension->mbuff_pos= command;
net->extension->mbuff_pos++;
memcpy(net->extension->mbuff_pos, packet, length);
@@ -417,7 +420,7 @@ ma_net_real_write(NET *net,const char *packet,size_t len)
pos=(char*) packet; end=pos+len;
while (pos != end)
{
if ((ssize_t) (length=ma_pvio_write(net->pvio,pos,(size_t) (end-pos))) <= 0)
if ((ssize_t) (length=ma_pvio_write(net->pvio,(uchar *)pos,(size_t) (end-pos))) <= 0)
{
net->error=2; /* Close socket */
net->last_errno= ER_NET_ERROR_ON_WRITE;
@@ -457,7 +460,7 @@ ma_real_read(NET *net, size_t *complen)
while (remain > 0)
{
/* First read is done with non blocking mode */
if ((ssize_t) (length=ma_pvio_cache_read(net->pvio,(char*) pos,remain)) <= 0L)
if ((ssize_t) (length=ma_pvio_cache_read(net->pvio, pos,remain)) <= 0L)
{
len= packet_error;
net->error=2; /* Close socket */

View File

@@ -70,7 +70,7 @@ MARIADB_PVIO *ma_pvio_init(MA_PVIO_CINFO *cinfo)
* pvio_namedpipe
* pvio_sharedmed
*/
char *pvio_plugins[] = {"pvio_socket", "pvio_npipe", "pvio_shmem"};
const char *pvio_plugins[] = {"pvio_socket", "pvio_npipe", "pvio_shmem"};
int type;
MARIADB_PVIO_PLUGIN *pvio_plugin;
MARIADB_PVIO *pvio= NULL;
@@ -139,9 +139,11 @@ MARIADB_PVIO *ma_pvio_init(MA_PVIO_CINFO *cinfo)
/* {{{ my_bool ma_pvio_is_alive */
my_bool ma_pvio_is_alive(MARIADB_PVIO *pvio)
{
if (!pvio)
return FALSE;
if (pvio->methods->is_alive)
return pvio->methods->is_alive(pvio);
return FALSE;
return TRUE;
}
/* }}} */
@@ -311,8 +313,7 @@ static size_t ma_pvio_write_async(MARIADB_PVIO *pvio, const uchar *buffer, size_
for (;;)
{
if (pvio->methods->async_write)
res= pvio->methods->async_write(pvio, buffer, length);
res= pvio->methods->async_write(pvio, buffer, length);
if (res >= 0 || IS_BLOCKING_ERROR())
return res;
b->events_to_wait_for= MYSQL_WAIT_WRITE;
@@ -521,8 +522,8 @@ my_bool ma_pvio_start_ssl(MARIADB_PVIO *pvio)
return 1;
if (pvio->mysql->options.extension &&
(pvio->mysql->options.extension->tls_fp && pvio->mysql->options.extension->tls_fp[0]) ||
(pvio->mysql->options.extension->tls_fp_list && pvio->mysql->options.extension->tls_fp_list[0]))
((pvio->mysql->options.extension->tls_fp && pvio->mysql->options.extension->tls_fp[0]) ||
(pvio->mysql->options.extension->tls_fp_list && pvio->mysql->options.extension->tls_fp_list[0])))
{
if (ma_pvio_tls_check_fp(pvio->ctls,

View File

@@ -306,7 +306,7 @@ static void convert_froma_string(MYSQL_BIND *r_param, char *buffer, size_t len)
case MYSQL_TYPE_NEWDECIMAL:
default:
{
char *start= buffer + r_param->u.offset; /* stmt_fetch_column sets offset */
char *start= buffer + r_param->offset; /* stmt_fetch_column sets offset */
char *end= buffer + len;
size_t copylen= 0;
@@ -402,7 +402,9 @@ static void convert_from_long(MYSQL_BIND *r_param, const MYSQL_FIELD *field, lon
/* {{{ ps_fetch_null */
static
void ps_fetch_null(MYSQL_BIND *r_param, const MYSQL_FIELD * field, unsigned char **row)
void ps_fetch_null(MYSQL_BIND *r_param __attribute__((unused)),
const MYSQL_FIELD * field __attribute__((unused)),
unsigned char **row __attribute__((unused)))
{
/* do nothing */
}
@@ -509,7 +511,7 @@ void ps_fetch_int64(MYSQL_BIND *r_param, const MYSQL_FIELD * const field,
default:
{
longlong sval= (longlong)sint8korr(*row);
longlong lval= field->flags & UNSIGNED_FLAG ? (ulonglong) sval : (longlong)sval;
longlong lval= field->flags & UNSIGNED_FLAG ? (longlong)(ulonglong) sval : (longlong)sval;
convert_from_long(r_param, field, lval, field->flags & UNSIGNED_FLAG);
(*row) += 8;
}
@@ -518,7 +520,7 @@ void ps_fetch_int64(MYSQL_BIND *r_param, const MYSQL_FIELD * const field,
}
/* }}} */
static void convert_from_float(MYSQL_BIND *r_param, const MYSQL_FIELD *field, float val, int size)
static void convert_from_float(MYSQL_BIND *r_param, const MYSQL_FIELD *field, float val, int size __attribute__((unused)))
{
double check_trunc_val= (val > 0) ? floor(val) : -floor(-val);
char *buf= (char *)r_param->buffer;
@@ -616,7 +618,7 @@ static void convert_from_float(MYSQL_BIND *r_param, const MYSQL_FIELD *field, fl
}
}
static void convert_from_double(MYSQL_BIND *r_param, const MYSQL_FIELD *field, double val, int size)
static void convert_from_double(MYSQL_BIND *r_param, const MYSQL_FIELD *field, double val, int size __attribute__((unused)))
{
double check_trunc_val= (val > 0) ? floor(val) : -floor(-val);
char *buf= (char *)r_param->buffer;
@@ -902,8 +904,9 @@ void ps_fetch_datetime(MYSQL_BIND *r_param, const MYSQL_FIELD * field,
/* {{{ ps_fetch_string */
static
void ps_fetch_string(MYSQL_BIND *r_param, const MYSQL_FIELD *field,
unsigned char **row)
void ps_fetch_string(MYSQL_BIND *r_param,
const MYSQL_FIELD *field __attribute__((unused)),
unsigned char **row)
{
/* C-API differs from PHP. While PHP just converts string to string,
C-API needs to convert the string to the defined type with in
@@ -918,43 +921,32 @@ void ps_fetch_string(MYSQL_BIND *r_param, const MYSQL_FIELD *field,
/* {{{ ps_fetch_bin */
static
void ps_fetch_bin(MYSQL_BIND *r_param, const MYSQL_FIELD *field,
void ps_fetch_bin(MYSQL_BIND *r_param,
const MYSQL_FIELD *field __attribute__((unused)),
unsigned char **row)
{
ulong field_length;
size_t copylen;
ulong field_length= *r_param->length= net_field_length(row);
uchar *current_pos= (*row) + r_param->offset,
*end= (*row) + field_length;
size_t copylen= 0;
/* If r_praram->buffer_type is not a binary type or binary_flag isn't set,
we do conversion from string */
if (!(field->flags & BINARY_FLAG) ||
(r_param->buffer_type != MYSQL_TYPE_NEWDECIMAL &&
r_param->buffer_type != MYSQL_TYPE_DECIMAL &&
r_param->buffer_type != MYSQL_TYPE_GEOMETRY &&
r_param->buffer_type != MYSQL_TYPE_ENUM &&
r_param->buffer_type != MYSQL_TYPE_SET &&
r_param->buffer_type != MYSQL_TYPE_TINY_BLOB &&
r_param->buffer_type != MYSQL_TYPE_MEDIUM_BLOB &&
r_param->buffer_type != MYSQL_TYPE_LONG_BLOB &&
r_param->buffer_type != MYSQL_TYPE_BLOB))
if (current_pos < end)
{
ps_fetch_string(r_param, field, row);
return;
copylen= end - current_pos;
if (r_param->buffer_length)
{
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)
((char *)r_param->buffer)[copylen]= 0;
}
}
field_length= net_field_length(row);
copylen= MIN(field_length, r_param->buffer_length);
memcpy(r_param->buffer, *row, copylen);
*r_param->error= copylen < field_length;
*r_param->error= copylen > r_param->buffer_length;
/* don't count trailing zero if we fetch into string */
if (r_param->buffer_type == MYSQL_TYPE_STRING &&
!*r_param->error)
!*r_param->error)
field_length--;
*r_param->length= field_length;
(*row) += field_length;
(*row)+= field_length;
}
/* }}} */

View File

@@ -51,7 +51,7 @@
my_bool ma_tls_initialized= FALSE;
unsigned int mariadb_deinitialize_ssl= 1;
char *ssl_protocol_version[5]= {"TLS1.0", "TLS1.1", "TLS1.2"};
const char *ssl_protocol_version[5]= {"TLS1.0", "TLS1.1", "TLS1.2"};
MARIADB_TLS *ma_pvio_tls_init(MYSQL *mysql)
{
@@ -119,11 +119,14 @@ my_bool ma_pvio_tls_get_protocol_version(MARIADB_TLS *ctls, struct st_ssl_versio
return ma_tls_get_protocol_version(ctls, version);
}
static my_bool ma_pvio_tls_compare_fp(char *fp1, unsigned int fp1_len,
char *fp2, unsigned int fp2_len)
static my_bool ma_pvio_tls_compare_fp(const char *fp1, unsigned int fp1_len,
const char *fp2, unsigned int fp2_len)
{
char hexstr[64];
if (fp1_len != fp2_len)
return 1;
fp1_len= (unsigned int)mysql_hex_string(hexstr, fp1, fp1_len);
#ifdef WIN32
if (strnicmp(hexstr, fp2, fp1_len) != 0)
@@ -137,14 +140,14 @@ static my_bool ma_pvio_tls_compare_fp(char *fp1, unsigned int fp1_len,
my_bool ma_pvio_tls_check_fp(MARIADB_TLS *ctls, const char *fp, const char *fp_list)
{
unsigned int cert_fp_len= 64;
unsigned char cert_fp[64];
char cert_fp[64];
my_bool rc=1;
MYSQL *mysql= ctls->pvio->mysql;
if ((cert_fp_len= ma_tls_get_finger_print(ctls, cert_fp, cert_fp_len)) < 1)
goto end;
if (fp)
rc= ma_pvio_tls_compare_fp(cert_fp, cert_fp_len, (char *)fp, (unsigned int)strlen(fp));
rc= ma_pvio_tls_compare_fp(cert_fp, cert_fp_len, fp, (unsigned int)strlen(fp));
else if (fp_list)
{
MA_FILE *fp;

View File

@@ -14,6 +14,7 @@
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
*/
/*
MySQL non-blocking client library functions.
@@ -353,7 +354,7 @@ MK_ASYNC_START_BODY(
parms.db= db;
parms.port= port;
parms.unix_socket= unix_socket;
parms.client_flags= client_flags;
parms.client_flags= client_flags | CLIENT_REMEMBER_OPTIONS;
},
NULL,
r_ptr,
@@ -387,34 +388,34 @@ MK_ASYNC_INTERNAL_BODY(
int STDCALL
mysql_real_query_start(int *ret, MYSQL *mysql, const char *stmt_str, size_t length)
{
int res;
struct mysql_async_context *b;
struct mysql_real_query_params parms;
b= mysql->options.extension->async_context;
int res;
struct mysql_async_context *b;
struct mysql_real_query_params parms;
b= mysql->options.extension->async_context;
{
WIN_SET_NONBLOCKING(mysql)
parms.mysql= mysql;
parms.stmt_str= stmt_str;
parms.length= length;
}
b->active= 1;
b->active= 1;
res= my_context_spawn(&b->async_context, mysql_real_query_start_internal, &parms);
b->active= b->suspended= 0;
if (res > 0)
{
/* Suspended. */
b->suspended= 1;
return b->events_to_wait_for;
}
if (res < 0)
{
set_mariadb_error((mysql), CR_OUT_OF_MEMORY, unknown_sqlstate);
*ret= 1;
}
else
*ret= b->ret_result.r_int;
b->active= b->suspended= 0;
if (res > 0)
{
/* Suspended. */
b->suspended= 1;
return b->events_to_wait_for;
}
if (res < 0)
{
set_mariadb_error((mysql), CR_OUT_OF_MEMORY, unknown_sqlstate);
*ret= 1;
}
else
*ret= b->ret_result.r_int;
return 0;
}

View File

@@ -38,7 +38,7 @@ MARIADB_CHARSET_INFO * STDCALL mysql_get_charset_by_nr(uint cs_number)
return (mariadb_compiled_charsets[i].nr) ? (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[i] : NULL;
}
my_bool set_default_charset(uint cs, myf flags)
my_bool set_default_charset(uint cs, myf flags __attribute__((unused)))
{
MARIADB_CHARSET_INFO *new_charset;
new_charset = mysql_get_charset_by_nr(cs);
@@ -60,7 +60,7 @@ MARIADB_CHARSET_INFO * STDCALL mysql_get_charset_by_name(const char *cs_name)
return (mariadb_compiled_charsets[i].nr) ? (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[i] : NULL;
}
my_bool set_default_charset_by_name(const char *cs_name, myf flags)
my_bool set_default_charset_by_name(const char *cs_name, myf flags __attribute__((unused)))
{
MARIADB_CHARSET_INFO *new_charset;
new_charset = mysql_get_charset_by_name(cs_name);

View File

@@ -1004,6 +1004,8 @@ dynamic_column_value_len(DYNAMIC_COLUMN_VALUE *value,
return 3;
case DYN_COL_DYNCOL:
return value->x.string.value.length;
default:
break;
}
DBUG_ASSERT(0);
return 0;
@@ -1592,6 +1594,8 @@ data_store(DYNAMIC_COLUMN *str, DYNAMIC_COLUMN_VALUE *value,
return dynamic_column_dyncol_store(str, &value->x.string.value);
case DYN_COL_NULL:
break; /* Impossible */
default:
break;
}
DBUG_ASSERT(0);
return ER_DYNCOL_OK; /* Impossible */

View File

@@ -1,20 +1,20 @@
/************************************************************************************
Copyright (C) 2000, 2012 MySQL AB & MySQL Finland AB & TCX DataKonsult AB,
Monty Program AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
Part of this code includes code from the PHP project which
@@ -77,6 +77,7 @@
extern ulong max_allowed_packet; /* net.c */
extern ulong net_buffer_length; /* net.c */
static MYSQL_PARAMETERS mariadb_internal_parameters= {&max_allowed_packet, &net_buffer_length, 0};
static my_bool mysql_client_init=0;
static void mysql_close_options(MYSQL *mysql);
extern my_bool ma_init_done;
@@ -112,19 +113,7 @@ my_context_install_suspend_resume_hook(struct mysql_async_context *b,
uint mysql_port=0;
my_string mysql_unix_port=0;
static char *mariadb_protocols[]= {"TCP",
#ifndef WIN32
"SOCKET",
#else
"PIPE", "MEMORY",
#endif
0};
#ifdef _WIN32
#define CONNECT_TIMEOUT 20
#else
#define CONNECT_TIMEOUT 0
#endif
struct st_mariadb_methods MARIADB_DEFAULT_METHODS;
@@ -170,7 +159,7 @@ void net_get_error(char *buf, size_t buf_len,
if (*p == '#')
{
memcpy(sqlstate, ++p, SQLSTATE_LENGTH);
p+= SQLSTATE_LENGTH;
p+= SQLSTATE_LENGTH;
}
error_msg_len= buf_len - (p - buf);
error_msg_len= MIN(error_msg_len, error_len - 1);
@@ -218,7 +207,7 @@ restart:
if (last_errno== 65535 &&
((mariadb_connection(mysql) && (mysql->server_capabilities & CLIENT_PROGRESS)) ||
(!(mysql->server_capabilities & CLIENT_MYSQL) && mysql->server_capabilities & MARIADB_CLIENT_PROGRESS)))
(!(mysql->extension->mariadb_server_capabilities & MARIADB_CLIENT_PROGRESS >> 32))))
{
if (cli_report_progress(mysql, (uchar *)pos, (uint) (len-1)))
{
@@ -373,7 +362,7 @@ mthd_my_send_cmd(MYSQL *mysql,enum enum_server_command command, const char *arg,
if (multi == MARIADB_COM_MULTI_BEGIN)
{
/* todo: error handling */
return(net_add_multi_command(&mysql->net, command, arg, length));
return(net_add_multi_command(&mysql->net, command, (uchar *)arg, length));
}
if (mysql->net.pvio == 0)
@@ -443,7 +432,7 @@ static void free_old_query(MYSQL *mysql)
{
if (mysql->fields)
ma_free_root(&mysql->field_alloc,MYF(0));
ma_init_ma_alloc_root(&mysql->field_alloc,8192,0); /* Assume rowlength < 8192 */
ma_init_alloc_root(&mysql->field_alloc,8192,0); /* Assume rowlength < 8192 */
mysql->fields=0;
mysql->field_count=0; /* For API */
mysql->info= 0;
@@ -567,10 +556,10 @@ enum enum_option_type {
struct st_default_options {
enum mysql_option option;
enum enum_option_type type;
char *conf_key;
const char *conf_key;
};
struct st_default_options mariadb_defaults[] =
struct st_default_options mariadb_defaults[] =
{
{MARIADB_OPT_PORT, MARIADB_OPTION_INT,"port"},
{MARIADB_OPT_UNIXSOCKET, MARIADB_OPTION_STR, "socket"},
@@ -726,7 +715,7 @@ static size_t rset_field_offsets[]= {
MYSQL_FIELD *
unpack_fields(MYSQL_DATA *data,MA_MEM_ROOT *alloc,uint fields,
my_bool default_value, my_bool long_flag_protocol)
my_bool default_value, my_bool long_flag_protocol __attribute__((unused)))
{
MYSQL_ROWS *row;
MYSQL_FIELD *field,*result;
@@ -747,7 +736,7 @@ unpack_fields(MYSQL_DATA *data,MA_MEM_ROOT *alloc,uint fields,
*(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1])= 0;
break;
default:
*(char **)(((char *)field) + rset_field_offsets[i*2])=
*(char **)(((char *)field) + rset_field_offsets[i*2])=
ma_strdup_root(alloc, (char *)row->data[i]);
*(unsigned int *)(((char *)field) + rset_field_offsets[i*2+1])=
(uint)(row->data[i+1] - row->data[i] - 1);
@@ -808,7 +797,7 @@ MYSQL_DATA *mthd_my_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
return(0);
}
ma_init_ma_alloc_root(&result->alloc,8192,0); /* Assume rowlength < 8192 */
ma_init_alloc_root(&result->alloc,8192,0); /* Assume rowlength < 8192 */
result->alloc.min_malloc=sizeof(MYSQL_ROWS);
prev_ptr= &result->data;
result->rows=0;
@@ -890,7 +879,7 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
if ((pkt_len=(uint) ma_net_safe_read(mysql)) == packet_error)
return -1;
if (pkt_len <= 8 && mysql->net.read_pos[0] == 254)
{
mysql->warning_count= uint2korr(mysql->net.read_pos + 1);
@@ -1014,11 +1003,11 @@ mysql_get_ssl_cipher(MYSQL *mysql)
** NB! Errors are not reported until you do mysql_real_connect.
**************************************************************************/
uchar *ma_send_connect_attr(MYSQL *mysql, uchar *buffer)
char *ma_send_connect_attr(MYSQL *mysql, unsigned char *buffer)
{
if (mysql->server_capabilities & CLIENT_CONNECT_ATTRS)
{
buffer= mysql_net_store_length((unsigned char *)buffer, (mysql->options.extension) ?
buffer= (unsigned char *)mysql_net_store_length((unsigned char *)buffer, (mysql->options.extension) ?
mysql->options.extension->connect_attrs_len : 0);
if (mysql->options.extension &&
hash_inited(&mysql->options.extension->connect_attrs))
@@ -1028,24 +1017,24 @@ uchar *ma_send_connect_attr(MYSQL *mysql, uchar *buffer)
{
size_t len;
uchar *p= hash_element(&mysql->options.extension->connect_attrs, i);
len= strlen((char *)p);
buffer= mysql_net_store_length(buffer, len);
memcpy(buffer, p, len);
buffer+= (len);
p+= (len + 1);
len= strlen(p);
len= strlen((char *)p);
buffer= mysql_net_store_length(buffer, len);
memcpy(buffer, p, len);
buffer+= len;
}
}
}
return buffer;
return (char *)buffer;
}
/** set some default attributes */
static my_bool
static my_bool
ma_set_connect_attrs(MYSQL *mysql)
{
char buffer[255];
@@ -1082,13 +1071,13 @@ ma_set_connect_attrs(MYSQL *mysql)
** before calling mysql_real_connect !
*/
MYSQL * STDCALL
MYSQL * STDCALL
mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,unsigned long client_flag)
{
char *end;
char *connection_handler= (mysql->options.extension) ?
char *connection_handler= (mysql->options.extension) ?
mysql->options.extension->connection_handler : 0;
if (!mysql->methods)
@@ -1164,7 +1153,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
SET_CLIENT_ERROR(mysql, CR_ALREADY_CONNECTED, SQLSTATE_UNKNOWN, 0);
return(NULL);
}
/* use default options */
if (mysql->options.my_cnf_file || mysql->options.my_cnf_group)
{
@@ -1214,7 +1203,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
cinfo.unix_socket= unix_socket;
cinfo.port= port;
cinfo.mysql= mysql;
/*
** Grab a socket and connect it to the server
*/
@@ -1232,8 +1221,15 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
else
#endif
#else
if (mysql->options.protocol == MYSQL_PROTOCOL_MEMORY ||
mysql->options.shared_memory_base_name)
{
cinfo.host= mysql->options.shared_memory_base_name;
cinfo.type= PVIO_TYPE_SHAREDMEM;
sprintf(host_info=buff,ER(CR_SHARED_MEMORY_CONNECTION), cinfo.host ? cinfo.host : SHM_DEFAULT_NAME);
}
/* named pipe */
if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE ||
else if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE ||
(host && strcmp(host,LOCAL_HOST_NAMEDPIPE) == 0))
{
cinfo.type= PVIO_TYPE_NAMEDPIPE;
@@ -1270,7 +1266,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
net->max_packet_size= mysql->options.max_allowed_packet;
ma_pvio_keepalive(net->pvio);
strcpy(mysql->net.sqlstate, "00000");
strcpy(mysql->net.sqlstate, "00000");
/* Get version info */
mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */
@@ -1283,7 +1279,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
errno);
goto error;
}
*/
*/
if ((pkt_length=ma_net_safe_read(mysql)) == packet_error)
{
if (mysql->net.last_errno == CR_SERVER_LOST)
@@ -1383,7 +1379,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
/* check if MariaD2B specific capabilities are available */
if (is_maria && !(mysql->server_capabilities & CLIENT_MYSQL))
{
mysql->server_capabilities|= (ulonglong) uint4korr(end + 14) << 32;
mysql->extension->mariadb_server_capabilities= (ulonglong) uint4korr(end + 14);
}
}
@@ -1415,7 +1411,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
goto error;
}
}
/* Set character set */
if (mysql->options.charset_name)
mysql->charset= mysql_find_charset_name(mysql->options.charset_name);
@@ -1453,7 +1449,7 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
errno);
goto error;
}
}
}
if (mysql->options.init_command)
{
@@ -1491,6 +1487,9 @@ error:
end_server(mysql);
/* only free the allocated memory, user needs to call mysql_close */
mysql_close_memory(mysql);
if (!(client_flag & CLIENT_REMEMBER_OPTIONS) &&
!mysql->options.extension->async_context)
mysql_close_options(mysql);
return(0);
}
@@ -1567,8 +1566,8 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql)
my_context_install_suspend_resume_hook(ctxt, NULL, NULL);
/* don't free options (CONC-118) */
memset(&tmp_mysql.options, 0, sizeof(struct st_mysql_options));
my_set_error(mysql, tmp_mysql.net.last_errno,
tmp_mysql.net.sqlstate,
my_set_error(mysql, tmp_mysql.net.last_errno,
tmp_mysql.net.sqlstate,
tmp_mysql.net.last_error);
mysql_close(&tmp_mysql);
return(1);
@@ -1641,18 +1640,18 @@ mysql_get_timeout_value_ms(const MYSQL *mysql)
}
/**************************************************************************
** Change user and database
** Change user and database
**************************************************************************/
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
const char *passwd, const char *db)
{
const MARIADB_CHARSET_INFO *s_cs= mysql->charset;
char *s_user= mysql->user,
*s_passwd= mysql->passwd,
char *s_user= mysql->user,
*s_passwd= mysql->passwd,
*s_db= mysql->db;
int rc;
if (!user)
user="";
if (!passwd)
@@ -1793,7 +1792,7 @@ static void mysql_close_memory(MYSQL *mysql)
free(mysql->db);
free(mysql->unix_socket);
free(mysql->server_version);
mysql->host_info= mysql->host= mysql->unix_socket=
mysql->host_info= mysql->host= mysql->unix_socket=
mysql->server_version=mysql->user=mysql->passwd=mysql->db=0;
}
@@ -1808,7 +1807,7 @@ void my_set_error(MYSQL *mysql,
mysql->net.last_errno= error_nr;
ma_strmake(mysql->net.sqlstate, sqlstate, SQLSTATE_LENGTH);
va_start(ap, format);
vsnprintf(mysql->net.last_error, MYSQL_ERRMSG_SIZE,
vsnprintf(mysql->net.last_error, MYSQL_ERRMSG_SIZE,
format ? format : ER(error_nr), ap);
va_end(ap);
return;
@@ -1868,7 +1867,7 @@ mysql_close(MYSQL *mysql)
free(mysql->net.extension);
mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
/* Clear pointers for better safety */
memset((char*) &mysql->options, 0, sizeof(mysql->options));
@@ -1898,7 +1897,7 @@ mysql_query(MYSQL *mysql, const char *query)
Send the query and return so we can do something else.
Needs to be followed by mysql_read_query_result() when we want to
finish processing it.
*/
*/
int STDCALL
mysql_send_query(MYSQL* mysql, const char* query, size_t length)
@@ -1925,9 +1924,9 @@ get_info:
size_t item_len;
mysql->affected_rows= net_field_length_ll(&pos);
mysql->insert_id= net_field_length_ll(&pos);
mysql->server_status=uint2korr(pos);
mysql->server_status=uint2korr(pos);
pos+=2;
mysql->warning_count=uint2korr(pos);
mysql->warning_count=uint2korr(pos);
pos+=2;
if (pos < mysql->net.read_pos+length && (item_len= net_field_length(&pos)))
mysql->info=(char*) pos;
@@ -2101,7 +2100,7 @@ mysql_real_query(MYSQL *mysql, const char *query, size_t length)
if (OPT_HAS_EXT_VAL(mysql, multi_command))
is_multi= mysql->options.extension->multi_command;
if (length == -1)
if (length == (size_t)-1)
length= strlen(query);
free_old_query(mysql);
@@ -2440,7 +2439,7 @@ mysql_kill(MYSQL *mysql,ulong pid)
{
char buff[12];
int4store(buff,pid);
/* if we kill our own thread, reading the response packet will fail */
/* if we kill our own thread, reading the response packet will fail */
return(ma_simple_command(mysql, COM_PROCESS_KILL,buff,4,0,0));
}
@@ -2538,7 +2537,7 @@ static size_t get_store_length(size_t length)
return 9;
}
uchar *ma_get_hash_keyval(const uchar *hash_entry,
uchar *ma_get_hash_keyval(const uchar *hash_entry,
unsigned int *length,
my_bool not_used __attribute__((unused)))
{
@@ -2547,7 +2546,7 @@ uchar *ma_get_hash_keyval(const uchar *hash_entry,
key_length + 1 value (\0 terminated)
*/
uchar *p= (uchar *)hash_entry;
size_t len= strlen(p);
size_t len= strlen((char *)p);
*length= (unsigned int)len;
return p;
}
@@ -2562,20 +2561,23 @@ int mariadb_flush_multi_command(MYSQL *mysql)
int rc;
size_t length= mysql->net.extension->mbuff_pos - mysql->net.extension->mbuff;
rc= ma_simple_command(mysql, COM_MULTI, mysql->net.extension->mbuff,
rc= ma_simple_command(mysql, COM_MULTI, (char *)mysql->net.extension->mbuff,
length, 1, 0);
/* reset multi_buff */
mysql->net.extension->mbuff_pos= mysql->net.extension->mbuff;
/* don't read result for mysql_stmt_execute_direct() */
if (!rc)
if (mysql->net.extension->mbuff && length > 3 &&
(mysql->net.extension->mbuff[3] == COM_STMT_PREPARE ||
mysql->net.extension->mbuff[3] == COM_STMT_EXECUTE ||
mysql->net.extension->mbuff[3] == COM_STMT_CLOSE))
{
uchar *p= (uchar *)mysql->net.extension->mbuff;
unsigned long len= net_field_length(&p);
if (len && (*p == COM_STMT_PREPARE ||
*p == COM_STMT_EXECUTE ||
*p == COM_STMT_CLOSE))
return rc;
else
return mysql->methods->db_read_query_result(mysql);
}
return rc;
}
@@ -2584,7 +2586,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
{
va_list ap;
void *arg1;
size_t stacksize;
size_t stacksize;
struct mysql_async_context *ctxt;
va_start(ap, option);
@@ -2629,6 +2631,11 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
case MYSQL_OPT_PROTOCOL:
mysql->options.protocol= *((uint *)arg1);
break;
#ifdef _WIN32
case MYSQL_SHARED_MEMORY_BASE_NAME:
OPT_SET_VALUE_STR(&mysql->options, shared_memory_base_name, arg1);
break;
#endif
case MYSQL_OPT_READ_TIMEOUT:
mysql->options.read_timeout= *(uint *)arg1;
break;
@@ -2642,7 +2649,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
CHECK_OPT_EXTENSION_SET(&mysql->options);
if (mysql->options.extension)
mysql->options.extension->report_progress=
(void (*)(const MYSQL *, uint, uint, double, const char *, uint)) arg1;
(void (*)(const MYSQL *, uint, uint, double, const char *, uint)) arg1;
break;
case MYSQL_PLUGIN_DIR:
OPT_SET_EXTENDED_VALUE_STR(&mysql->options, plugin_dir, (char *)arg1);
@@ -2738,14 +2745,14 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
arg1 ? (uint)strlen((char *)arg1) : 0)))
{
uchar *p= h;
size_t key_len= strlen(p);
size_t key_len= strlen((char *)p);
mysql->options.extension->connect_attrs_len-= key_len + get_store_length(key_len);
p+= key_len + 1;
key_len= strlen(p);
key_len= strlen((char *)p);
mysql->options.extension->connect_attrs_len-= key_len + get_store_length(key_len);
hash_delete(&mysql->options.extension->connect_attrs, h);
}
}
break;
case MYSQL_OPT_CONNECT_ATTR_RESET:
@@ -2778,7 +2785,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
break;
case MARIADB_OPT_FOUND_ROWS:
mysql->options.client_flag|= CLIENT_FOUND_ROWS;
break;
break;
case MARIADB_OPT_INTERACTIVE:
mysql->options.client_flag|= CLIENT_INTERACTIVE;
break;
@@ -2814,8 +2821,10 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
}
}
/* check if key is already in buffer */
if (p= (uchar *)hash_search(&mysql->options.extension->userdata, (uchar *)key,
(uint)strlen((char *)key)))
p= (uchar *)hash_search(&mysql->options.extension->userdata,
(uchar *)key,
(uint)strlen(key));
if (p)
{
p+= strlen(key) + 1;
memcpy(p, &data, sizeof(void *));
@@ -2829,7 +2838,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
}
p= buffer;
strcpy(p, key);
strcpy((char *)p, key);
p+= strlen(key) + 1;
memcpy(p, &data, sizeof(void *));
@@ -2847,7 +2856,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
void *arg2= va_arg(ap, void *);
size_t key_len= arg1 ? strlen((char *)arg1) : 0,
value_len= arg2 ? strlen((char *)arg2) : 0;
size_t storage_len= key_len + value_len +
size_t storage_len= key_len + value_len +
get_store_length(key_len) +
get_store_length(value_len);
@@ -2855,7 +2864,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
* to increase lengths */
key_len++;
value_len++;
CHECK_OPT_EXTENSION_SET(&mysql->options);
if (!key_len ||
storage_len + mysql->options.extension->connect_attrs_len > 0xFFFF)
@@ -2876,10 +2885,10 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
if ((buffer= (uchar *)malloc(key_len + value_len)))
{
uchar *p= buffer;
strcpy(p, arg1);
strcpy((char *)p, arg1);
p+= (strlen(arg1) + 1);
if (arg2)
strcpy(p, arg2);
strcpy((char *)p, arg2);
if (hash_insert(&mysql->options.extension->connect_attrs, buffer))
{
@@ -2919,7 +2928,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
OPT_SET_EXTENDED_VALUE_STR(&mysql->options, tls_pw, (char *)arg1);
break;
case MARIADB_OPT_COM_MULTI:
if (&mysql->net.pvio &&
if (&mysql->net.pvio &&
!(mysql->server_capabilities & CLIENT_MYSQL))
{
enum mariadb_com_multi type= *(enum mariadb_com_multi *)arg1;
@@ -2929,7 +2938,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, multi_command, type);
break;
case MARIADB_COM_MULTI_CANCEL:
if (!mysql->options.extension ||
if (!mysql->options.extension ||
mysql->options.extension->multi_command != MARIADB_COM_MULTI_BEGIN)
return(-1);
/* reset multi_buff */
@@ -2937,7 +2946,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, multi_command, MARIADB_COM_MULTI_END);
break;
case MARIADB_COM_MULTI_END:
if (!mysql->options.extension ||
if (!mysql->options.extension ||
mysql->options.extension->multi_command != MARIADB_COM_MULTI_BEGIN)
return(-1);
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, multi_command, MARIADB_COM_MULTI_END);
@@ -3003,13 +3012,13 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
*((char **)arg)= mysql->options.my_cnf_group;
break;
case MYSQL_SET_CHARSET_DIR:
/* not supported in this version. Since all character sets
/* not supported in this version. Since all character sets
are internally available, we don't throw an error */
*((char **)arg)= NULL;
break;
case MYSQL_SET_CHARSET_NAME:
if (mysql->charset)
*((char **)arg)= mysql->charset->csname;
*((const char **)arg)= mysql->charset->csname;
else
*((char **)arg)= mysql->options.charset_name;
break;
@@ -3080,18 +3089,18 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
case MYSQL_OPT_CONNECT_ATTRS:
/* mysql_get_optionsv(mysql, MYSQL_OPT_CONNECT_ATTRS, keys, vals, elements) */
{
int i, *elements;
unsigned int i, *elements;
char **key= NULL;
void *arg1;
char **val= NULL;
if (arg)
key= *(char ***)arg;
arg1= va_arg(ap, char **);
if (arg1)
val= *(char ***)arg1;
if (!(elements= va_arg(ap, unsigned int *)))
goto error;
@@ -3112,13 +3121,13 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
{
uchar *p= hash_element(&mysql->options.extension->connect_attrs, i);
if (key)
key[i]= p;
p+= strlen(p) + 1;
key[i]= (char *)p;
p+= strlen((char *)p) + 1;
if (val)
val[i]= p;
val[i]= (char *)p;
}
}
}
}
break;
case MYSQL_OPT_MAX_ALLOWED_PACKET:
*((unsigned long *)arg)= (mysql) ? mysql->options.max_allowed_packet :
@@ -3204,7 +3213,7 @@ mysql_options4(MYSQL *mysql,enum mysql_option option, const void *arg1, const vo
****************************************************************************/
/* MYSQL_RES */
unsigned long long STDCALL mysql_num_rows(MYSQL_RES *res)
my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res)
{
return res->row_count;
}
@@ -3247,15 +3256,15 @@ unsigned int STDCALL mysql_field_count(MYSQL *mysql)
return mysql->field_count;
}
unsigned long long STDCALL mysql_affected_rows(MYSQL *mysql)
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
{
return (mysql)->affected_rows;
}
my_bool STDCALL mysql_autocommit(MYSQL *mysql, my_bool mode)
{
return((my_bool) mysql_real_query(mysql, (mode) ? "SET autocommit=1" :
"SET autocommit=0", 16));
return((my_bool) mysql_real_query(mysql, (mode) ? "SET autocommit=1" :
"SET autocommit=0", 16));
}
my_bool STDCALL mysql_commit(MYSQL *mysql)
@@ -3268,7 +3277,7 @@ my_bool STDCALL mysql_rollback(MYSQL *mysql)
return((my_bool)mysql_real_query(mysql, "ROLLBACK", sizeof("ROLLBACK")));
}
unsigned long long STDCALL mysql_insert_id(MYSQL *mysql)
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
{
return (mysql)->insert_id;
}
@@ -3280,7 +3289,7 @@ uint STDCALL mysql_errno(MYSQL *mysql)
char * STDCALL mysql_error(MYSQL *mysql)
{
return mysql ? (mysql)->net.last_error : "";
return mysql ? (mysql)->net.last_error : (char *)"";
}
char *STDCALL mysql_info(MYSQL *mysql)
@@ -3403,7 +3412,7 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname)
}
error:
my_set_error(mysql, CR_CANT_READ_CHARSET, SQLSTATE_UNKNOWN,
my_set_error(mysql, CR_CANT_READ_CHARSET, SQLSTATE_UNKNOWN,
0, csname, "compiled_in");
return(mysql->net.last_errno);
}
@@ -3418,6 +3427,16 @@ const char * STDCALL mysql_sqlstate(MYSQL *mysql)
return mysql->net.sqlstate;
}
#ifndef _WIN32
#include <signal.h>
static void ignore_sigpipe()
{
signal(SIGPIPE, SIG_IGN);
}
#else
#define ignore_sigpipe()
#endif
#ifdef _WIN32
static int mysql_once_init()
#else
@@ -3459,6 +3478,7 @@ static void mysql_once_init()
}
if (!mysql_ps_subsystem_initialized)
mysql_init_ps_subsystem();
ignore_sigpipe();
mysql_client_init = 1;
#ifdef _WIN32
return 0;
@@ -3502,7 +3522,7 @@ void STDCALL mysql_server_end(void)
ma_end(0);
#ifdef HAVE_TLS
ma_pvio_tls_end();
#endif
#endif
mysql_client_init= 0;
ma_init_done= 0;
}
@@ -3516,7 +3536,7 @@ void STDCALL mysql_thread_end(void)
{
}
int STDCALL mysql_set_server_option(MYSQL *mysql,
int STDCALL mysql_set_server_option(MYSQL *mysql,
enum enum_mysql_set_option option)
{
char buffer[2];
@@ -3553,8 +3573,8 @@ my_bool STDCALL mariadb_connection(MYSQL *mysql)
const char * STDCALL
mysql_get_server_name(MYSQL *mysql)
{
if (mysql->options.extension &&
mysql->options.extension->db_driver != NULL)
if (mysql->options.extension &&
mysql->options.extension->db_driver != NULL)
return mysql->options.extension->db_driver->name;
return mariadb_connection(mysql) ? "MariaDB" : "MySQL";
}
@@ -3568,7 +3588,7 @@ static my_socket mariadb_get_socket(MYSQL *mysql)
}
/* if an asynchronous connect is in progress, we need to obtain
pvio handle from async_context until the connection was
pvio handle from async_context until the connection was
successfully established.
*/
else if (mysql->options.extension && mysql->options.extension->async_context &&
@@ -3650,18 +3670,18 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
case MARIADB_TLS_LIBRARY:
#ifdef HAVE_TLS
#ifdef HAVE_GNUTLS
*((char **)arg)= "GNUTLS";
*((const char **)arg)= "GNUTLS";
#elif HAVE_OPENSSL
*((char **)arg)= "OPENSSL";
*((const char **)arg)= "OPENSSL";
#elif HAVE_SCHANNEL
*((char **)arg)= "SCHANNEL";
*((const char **)arg)= "SCHANNEL";
#endif
#else
*((char **)arg)= "OFF";
#endif
break;
case MARIADB_CLIENT_VERSION:
*((char **)arg)= MARIADB_CLIENT_VERSION_STR;
*((const char **)arg)= MARIADB_CLIENT_VERSION_STR;
break;
case MARIADB_CLIENT_VERSION_ID:
*((size_t *)arg)= MARIADB_VERSION_ID;
@@ -3674,7 +3694,7 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
break;
case MARIADB_CONNECTION_SERVER_TYPE:
if (mysql)
*((char **)arg)= mariadb_connection(mysql) ? "MariaDB" : "MySQL";
*((const char **)arg)= mariadb_connection(mysql) ? "MariaDB" : "MySQL";
else
goto error;
break;
@@ -3808,7 +3828,7 @@ my_bool STDCALL mariadb_get_info(MYSQL *mysql, enum mariadb_value value, void *a
return mariadb_get_infov(mysql, value, arg);
}
/*
/*
Immediately aborts connection, making all subsequent read/write operations fail.
Does not invalidate memory used for mysql structure, nor closes any communication
channels - mysql_close is still needed.
@@ -3826,6 +3846,42 @@ int STDCALL mariadb_cancel(MYSQL *mysql)
return pvio->methods->shutdown(pvio);
}
}
/* compatibility functions for MariaDB */
void STDCALL
mysql_debug(const char *debug __attribute__((unused)))
{
return;
}
/********************************************************************
mysql_net_ functions - low-level API to MySQL protocol
*********************************************************************/
ulong STDCALL mysql_net_read_packet(MYSQL *mysql)
{
return ma_net_safe_read(mysql);
}
ulong STDCALL mysql_net_field_length(uchar **packet)
{
return net_field_length(packet);
}
my_bool STDCALL mysql_embedded(void)
{
#ifdef EMBEDDED_LIBRARY
return 1;
#else
return 0;
#endif
}
MYSQL_PARAMETERS *STDCALL
mysql_get_parameters(void)
{
return &mariadb_internal_parameters;
}
#undef STDCALL
/* API functions for usage in dynamic plugins */
struct st_mariadb_api MARIADB_API=

View File

@@ -13,7 +13,7 @@
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
Part of this code includes code from the PHP project which
@@ -21,7 +21,7 @@
*****************************************************************************/
/* The implementation for prepared statements was ported from PHP's mysqlnd
extension, written by Andrey Hristov, Georg Richter and Ulf Wendel
extension, written by Andrey Hristov, Georg Richter and Ulf Wendel
Original file header:
+----------------------------------------------------------------------+
@@ -54,6 +54,7 @@
#include <signal.h>
#include <time.h>
#include <mysql/client_plugin.h>
#include <ma_common.h>
#define STMT_NUM_OFS(type, a,r) ((type *)(a))[r]
#define MADB_RESET_ERROR 1
@@ -78,6 +79,23 @@ MYSQL_FIELD * unpack_fields(MYSQL_DATA *data,MA_MEM_ROOT *alloc,uint fields, my_
static my_bool is_not_null= 0;
static my_bool is_null= 1;
void stmt_set_error(MYSQL_STMT *stmt,
unsigned int error_nr,
const char *sqlstate,
const char *format,
...)
{
va_list ap;
stmt->last_errno= error_nr;
ma_strmake(stmt->sqlstate, sqlstate, SQLSTATE_LENGTH);
va_start(ap, format);
vsnprintf(stmt->last_error, MYSQL_ERRMSG_SIZE,
format ? format : ER(error_nr), ap);
va_end(ap);
return;
}
my_bool mthd_supported_buffer_type(enum enum_field_types type)
{
switch (type) {
@@ -115,7 +133,8 @@ my_bool mthd_supported_buffer_type(enum enum_field_types type)
static my_bool madb_reset_stmt(MYSQL_STMT *stmt, unsigned int flags);
static my_bool mysql_stmt_internal_reset(MYSQL_STMT *stmt, my_bool is_close);
static int stmt_unbuffered_eof(MYSQL_STMT *stmt, uchar **row)
static int stmt_unbuffered_eof(MYSQL_STMT *stmt __attribute__((unused)),
uchar **row __attribute__((unused)))
{
return MYSQL_NO_DATA;
}
@@ -195,7 +214,7 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt)
cp++; /* skip first byte */
null_ptr= cp;
cp+= (stmt->field_count + 9) / 8;
for (i=0; i < stmt->field_count; i++)
{
if (!(*null_ptr & bit_offset))
@@ -233,7 +252,7 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt)
}
}
current->length= packet_len;
result->rows++;
result->rows++;
} else /* end of stream */
{
*pprevious= 0;
@@ -241,14 +260,14 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt)
p++;
stmt->upsert_status.warning_count= stmt->mysql->warning_count= uint2korr(p);
p+=2;
stmt->mysql->server_status= uint2korr(p);
stmt->result_cursor= result->data;
stmt->upsert_status.server_status= stmt->mysql->server_status= uint2korr(p);
stmt->result_cursor= result->data;
return(0);
}
}
stmt->result_cursor= 0;
SET_CLIENT_STMT_ERROR(stmt, stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate,
stmt->mysql->net.last_error);
stmt->mysql->net.last_error);
return(1);
}
@@ -266,8 +285,8 @@ static int stmt_cursor_fetch(MYSQL_STMT *stmt, uchar **row)
/* do we have some prefetched rows available ? */
if (stmt->result_cursor)
return(stmt_buffered_fetch(stmt, row));
if (stmt->mysql->server_status & SERVER_STATUS_LAST_ROW_SENT)
stmt->mysql->server_status&= ~SERVER_STATUS_LAST_ROW_SENT;
if (stmt->upsert_status.server_status & SERVER_STATUS_LAST_ROW_SENT)
stmt->upsert_status.server_status&= ~SERVER_STATUS_LAST_ROW_SENT;
else
{
int4store(buf, stmt->stmt_id);
@@ -279,7 +298,7 @@ static int stmt_cursor_fetch(MYSQL_STMT *stmt, uchar **row)
/* free previously allocated buffer */
ma_free_root(&result->alloc, MYF(MY_KEEP_PREALLOC));
result->data= 0;
result->rows= 0;
result->rows= 0;
if (stmt->mysql->methods->db_stmt_read_all_rows(stmt))
return(1);
@@ -318,14 +337,14 @@ int mthd_stmt_fetch_to_bind(MYSQL_STMT *stmt, unsigned char *row)
if (*null_ptr & bit_offset)
{
*stmt->bind[i].is_null= 1;
stmt->bind[i].row_ptr= NULL;
stmt->bind[i].u.row_ptr= NULL;
} else
{
stmt->bind[i].row_ptr= row;
{
stmt->bind[i].u.row_ptr= row;
if (stmt->bind[i].flags & MADB_BIND_DUMMY)
{
unsigned long length;
if (mysql_ps_fetch_functions[stmt->fields[i].type].pack_len >= 0)
length= mysql_ps_fetch_functions[stmt->fields[i].type].pack_len;
else
@@ -467,8 +486,8 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p, unsigned long r
t_buffer[1]= t->neg ? 1 : 0;
int4store(t_buffer + 2, t->day);
t_buffer[6]= (uchar) t->hour;
t_buffer[7]= (uchar) t->minute;
t_buffer[6]= (uchar) t->hour;
t_buffer[7]= (uchar) t->minute;
t_buffer[8]= (uchar) t->second;
if (t->second_part)
{
@@ -496,11 +515,11 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p, unsigned long r
6 1 minute
7 1 second
8-11 4 secondpart
*/
*/
MYSQL_TIME *t= (MYSQL_TIME *)ma_get_buffer_offset(stmt, stmt->params[column].buffer_type,
stmt->params[column].buffer, row_nr);
char t_buffer[MAX_DATETIME_STR_LEN];
uint len;
uint len= 0;
int2store(t_buffer + 1, t->year);
t_buffer[3]= (char) t->month;
@@ -511,7 +530,7 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p, unsigned long r
if (t->second_part)
{
int4store(t_buffer + 8, t->second_part);
len= 12;
len= 11;
}
else if (t->hour || t->minute || t->second)
len= 7;
@@ -581,7 +600,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
1st byte: parameter type
2nd byte flag:
unsigned flag (32768)
indicator variable exists (16384)
indicator variable exists (16384)
------------------------------------------
Pre 10.2 protocol
n data from bind_buffer
@@ -589,7 +608,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
if indicator variable exists
1st byte: indicator variable
2nd-n: data
*/
size_t length= 1024;
@@ -598,10 +617,17 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
uint i, j, num_rows= 1;
my_bool bulk_supported= stmt->array_size > 0 &&
(!(stmt->mysql->server_capabilities & CLIENT_MYSQL) &&
(stmt->mysql->server_capabilities & MARIADB_CLIENT_STMT_BULK_OPERATIONS));
(stmt->mysql->extension->mariadb_server_capabilities & MARIADB_CLIENT_STMT_BULK_OPERATIONS >> 32));
uchar *start= NULL, *p;
if (!bulk_supported && stmt->array_size > 0)
{
stmt_set_error(stmt, CR_FUNCTION_NOT_SUPPORTED, SQLSTATE_UNKNOWN,
CER(CR_FUNCTION_NOT_SUPPORTED), "Bulk operation");
return NULL;
}
/* preallocate length bytes */
/* check: gr */
@@ -639,7 +665,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
memset(p, 0, null_count);
p += null_count;
}
int1store(p, stmt->send_types_to_server);
int1store(p, stmt->send_types_to_server);
p++;
free_bytes= length - (p - start);
@@ -664,7 +690,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
/* check if parameter requires indicator variable */
if (bulk_supported && stmt->params[i].u.indicator)
buffer_type|= 16384;
int2store(p, buffer_type);
int2store(p, buffer_type);
p+= 2;
}
}
@@ -676,12 +702,12 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
{
ulong size= 0;
my_bool has_data= TRUE;
uchar indicator= 0;
char indicator= 0;
if (bulk_supported && stmt->params[i].u.indicator)
{
if (stmt->row_size)
indicator= *(uchar *)(stmt->params[i].u.indicator + j * stmt->row_size);
indicator= *(char *)(stmt->params[i].u.indicator + j * stmt->row_size);
else
indicator= stmt->params[i].u.indicator[j];
/* check if we need to send data */
@@ -690,7 +716,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
has_data= FALSE;
size= 1;
}
if (stmt->params[i].long_data_used)
{
has_data= FALSE;
@@ -719,8 +745,11 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_SET:
size+= 5; /* max 8 bytes for size */
if (indicator == STMT_INDICATOR_NTS || (!stmt->row_size && stmt->params[i].length[j] == -1))
size+= strlen(ma_get_buffer_offset(stmt, stmt->params[i].buffer_type, stmt->params[i].buffer,j));
if (indicator == STMT_INDICATOR_NTS ||
(!stmt->row_size && stmt->params[i].length[j] == (unsigned long)-1))
size+= strlen(ma_get_buffer_offset(stmt,
stmt->params[i].buffer_type,
stmt->params[i].buffer,j));
else
if (!stmt->row_size)
size+= (size_t)stmt->params[i].length[j];
@@ -748,7 +777,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
}
if (!stmt->array_size)
{
if ((stmt->params[i].is_null && *stmt->params[i].is_null) ||
if ((stmt->params[i].is_null && *stmt->params[i].is_null) ||
stmt->params[i].buffer_type == MYSQL_TYPE_NULL ||
!stmt->params[i].buffer)
{
@@ -779,7 +808,7 @@ mem_error:
*******************************************************************************
\fn unsigned long long mysql_stmt_affected_rows
\brief returns the number of affected rows from last mysql_stmt_execute
\brief returns the number of affected rows from last mysql_stmt_execute
call
\param[in] stmt The statement handle
@@ -914,15 +943,15 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND *bind)
break;
case MYSQL_TYPE_TINY:
stmt->params[i].buffer_length= 1;
break;
break;
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_YEAR:
stmt->params[i].buffer_length= 2;
break;
break;
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_FLOAT:
stmt->params[i].buffer_length= 4;
break;
break;
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_DOUBLE:
stmt->params[i].buffer_length= 8;
@@ -972,13 +1001,13 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
if (!stmt->field_count)
{
SET_CLIENT_STMT_ERROR(stmt, CR_NO_STMT_METADATA, SQLSTATE_UNKNOWN, 0);
return(1);
return(1);
}
if (!bind)
return(1);
/* In case of a stored procedure we don't allocate memory for bind
/* In case of a stored procedure we don't allocate memory for bind
in mysql_stmt_prepare
*/
@@ -989,7 +1018,7 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
if (!(stmt->bind= (MYSQL_BIND *)ma_alloc_root(fields_ma_alloc_root, stmt->field_count * sizeof(MYSQL_BIND))))
{
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
return(1);
return(1);
}
}
@@ -1075,10 +1104,10 @@ static my_bool net_stmt_close(MYSQL_STMT *stmt, my_bool remove)
if (stmt->state > MYSQL_STMT_INITTED)
{
int4store(stmt_id, stmt->stmt_id);
if (stmt->mysql->methods->db_command(stmt->mysql,COM_STMT_CLOSE, stmt_id,
if (stmt->mysql->methods->db_command(stmt->mysql,COM_STMT_CLOSE, stmt_id,
sizeof(stmt_id), 1, stmt))
{
SET_CLIENT_STMT_ERROR(stmt, stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate, stmt->mysql->net.last_error);
SET_CLIENT_STMT_ERROR(stmt, stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate, stmt->mysql->net.last_error);
return 1;
}
}
@@ -1133,7 +1162,7 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt)
unsigned char *row;
int rc;
if (stmt->state <= MYSQL_STMT_EXECUTED)
if (stmt->state <= MYSQL_STMT_EXECUTED)
{
SET_CLIENT_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
return(1);
@@ -1172,13 +1201,13 @@ int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt)
int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, unsigned int column, unsigned long offset)
{
if (stmt->state < MYSQL_STMT_USER_FETCHING || column >= stmt->field_count ||
if (stmt->state < MYSQL_STMT_USER_FETCHING || column >= stmt->field_count ||
stmt->state == MYSQL_STMT_FETCH_DONE) {
SET_CLIENT_STMT_ERROR(stmt, CR_NO_DATA, SQLSTATE_UNKNOWN, 0);
return(1);
}
if (!stmt->bind[column].row_ptr)
if (!stmt->bind[column].u.row_ptr)
{
/* we set row_ptr only for columns which contain data, so this must be a NULL column */
if (bind[0].is_null)
@@ -1188,9 +1217,9 @@ int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, unsigned
{
unsigned char *save_ptr;
if (bind[0].length)
*bind[0].length= stmt->bind[column].length_value;
else
*bind[0].length= *stmt->bind[column].length;
else
bind[0].length= &stmt->bind[column].length_value;
if (bind[0].is_null)
*bind[0].is_null= 0;
else
@@ -1198,10 +1227,10 @@ int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, unsigned
if (!bind[0].error)
bind[0].error= &bind[0].error_value;
*bind[0].error= 0;
bind[0].u.offset= offset;
save_ptr= stmt->bind[column].row_ptr;
mysql_ps_fetch_functions[stmt->fields[column].type].func(&bind[0], &stmt->fields[column], &stmt->bind[column].row_ptr);
stmt->bind[column].row_ptr= save_ptr;
bind[0].offset= offset;
save_ptr= stmt->bind[column].u.row_ptr;
mysql_ps_fetch_functions[stmt->fields[column].type].func(&bind[0], &stmt->fields[column], &stmt->bind[column].u.row_ptr);
stmt->bind[column].u.row_ptr= save_ptr;
}
return(0);
}
@@ -1213,7 +1242,7 @@ unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt)
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
{
return madb_reset_stmt(stmt, MADB_RESET_LONGDATA | MADB_RESET_STORED |
return madb_reset_stmt(stmt, MADB_RESET_LONGDATA | MADB_RESET_STORED |
MADB_RESET_BUFFER | MADB_RESET_ERROR);
}
@@ -1229,7 +1258,7 @@ MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql)
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
return(NULL);
}
/* fill mysql's stmt list */
stmt->list.data= stmt;
@@ -1246,9 +1275,9 @@ MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql)
/* set default */
stmt->prefetch_rows= 1;
ma_init_ma_alloc_root(&stmt->mem_root, 2048, 0);
ma_init_ma_alloc_root(&stmt->result.alloc, 4096, 0);
ma_init_ma_alloc_root(&((MADB_STMT_EXTENSION *)stmt->extension)->fields_ma_alloc_root, 2048, 0);
ma_init_alloc_root(&stmt->mem_root, 2048, 2048);
ma_init_alloc_root(&stmt->result.alloc, 4096, 4096);
ma_init_alloc_root(&((MADB_STMT_EXTENSION *)stmt->extension)->fields_ma_alloc_root, 2048, 2048);
return(stmt);
}
@@ -1304,7 +1333,7 @@ my_bool mthd_stmt_get_result_metadata(MYSQL_STMT *stmt)
if (!(stmt->fields= unpack_fields(result,fields_ma_alloc_root,
stmt->field_count, 0,
stmt->mysql->server_capabilities & CLIENT_LONG_FLAG)))
return(1);
return(1);
return(0);
}
@@ -1315,7 +1344,7 @@ int STDCALL mysql_stmt_warning_count(MYSQL_STMT *stmt)
int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t length)
{
MYSQL *mysql= stmt->mysql;
MYSQL *mysql= stmt->mysql;
int rc= 1;
enum mariadb_com_multi multi= MARIADB_COM_MULTI_END;
@@ -1326,7 +1355,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t lengt
return(1);
}
if (length == -1)
if (length == (size_t) -1)
length= strlen(query);
mysql_get_optionv(mysql, MARIADB_OPT_COM_MULTI, &multi);
@@ -1354,7 +1383,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t lengt
stmt->field_count= 0;
int4store(stmt_id, stmt->stmt_id);
if (mysql->methods->db_command(mysql, COM_STMT_CLOSE, stmt_id,
if (mysql->methods->db_command(mysql, COM_STMT_CLOSE, stmt_id,
sizeof(stmt_id), 1, stmt))
goto fail;
}
@@ -1377,7 +1406,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t lengt
}
/* allocated bind buffer for parameters */
if (stmt->field_count &&
if (stmt->field_count &&
stmt->mysql->methods->db_stmt_get_result_metadata(stmt))
{
goto fail;
@@ -1387,7 +1416,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t lengt
if (!(stmt->params= (MYSQL_BIND *)ma_alloc_root(&stmt->mem_root, stmt->param_count * sizeof(MYSQL_BIND))))
{
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
goto fail;
goto fail;
}
memset(stmt->params, '\0', stmt->param_count * sizeof(MYSQL_BIND));
}
@@ -1398,7 +1427,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t lengt
if (!(stmt->bind= (MYSQL_BIND *)ma_alloc_root(fields_ma_alloc_root, stmt->field_count * sizeof(MYSQL_BIND))))
{
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
goto fail;
goto fail;
}
}
stmt->state = MYSQL_STMT_PREPARED;
@@ -1407,7 +1436,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t lengt
fail:
stmt->state= MYSQL_STMT_INITTED;
SET_CLIENT_STMT_ERROR(stmt, mysql->net.last_errno, mysql->net.sqlstate,
mysql->net.last_error);
mysql->net.last_error);
return(rc);
}
@@ -1444,7 +1473,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
int4store(buff, stmt->stmt_id);
int4store(buff + STMT_ID_LENGTH, (int)~0);
if (stmt->mysql->methods->db_command(stmt->mysql, COM_STMT_FETCH,
if (stmt->mysql->methods->db_command(stmt->mysql, COM_STMT_FETCH,
buff, sizeof(buff), 1, stmt))
return(1);
/* todo: cursor */
@@ -1543,11 +1572,11 @@ int stmt_read_execute_response(MYSQL_STMT *stmt)
{
MYSQL *mysql= stmt->mysql;
int ret;
if (!mysql)
return(1);
ret= test((mysql->methods->db_read_stmt_result &&
ret= test((mysql->methods->db_read_stmt_result &&
mysql->methods->db_read_stmt_result(mysql)));
/* if a reconnect occured, our connection handle is invalid */
if (!stmt->mysql)
@@ -1713,9 +1742,12 @@ int stmt_execute_send(MYSQL_STMT *stmt)
}
request= (char *)mysql_stmt_execute_generate_request(stmt, &request_len);
ret= stmt->mysql->methods->db_command(mysql, COM_STMT_EXECUTE, request,
if (!request)
return 1;
ret= stmt->mysql->methods->db_command(mysql, COM_STMT_EXECUTE, request,
request_len, 1, stmt);
if (request)
free(request);
@@ -1780,7 +1812,7 @@ static my_bool madb_reset_stmt(MYSQL_STMT *stmt, unsigned int flags)
{
mysql->methods->db_stmt_flush_unbuffered(stmt);
mysql->status= MYSQL_STATUS_READY;
}
}
}
if (flags & MADB_RESET_SERVER)
@@ -1827,7 +1859,7 @@ static my_bool mysql_stmt_internal_reset(MYSQL_STMT *stmt, my_bool is_close)
/* connection could be invalid, e.g. after mysql_stmt_close or failed reconnect
attempt (see bug CONC-97) */
SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0);
return(1);
return(1);
}
if (stmt->state >= MYSQL_STMT_USER_FETCHING &&
@@ -1851,9 +1883,9 @@ static my_bool mysql_stmt_internal_reset(MYSQL_STMT *stmt, my_bool is_close)
if (stmt->field_count)
{
while (mysql_stmt_next_result(stmt) == 0);
while (mysql_stmt_next_result(stmt) == 0);
stmt->mysql->status= MYSQL_STATUS_READY;
}
}
}
if (!is_close)
ret= madb_reset_stmt(stmt, MADB_RESET_SERVER);
@@ -1864,7 +1896,7 @@ static my_bool mysql_stmt_internal_reset(MYSQL_STMT *stmt, my_bool is_close)
stmt->upsert_status.server_status= mysql->server_status;
stmt->upsert_status.warning_count= mysql->warning_count;
mysql->status= MYSQL_STATUS_READY;
return(ret);
}
@@ -1884,7 +1916,7 @@ MYSQL_RES * STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt)
res->eof= 1;
res->fields= stmt->fields;
res->field_count= stmt->field_count;
res->field_count= stmt->field_count;
return(res);
}
@@ -1948,8 +1980,8 @@ my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
ret= stmt->mysql->methods->db_command(stmt->mysql, COM_STMT_SEND_LONG_DATA,
(char *)cmd_buff, packet_len, 1, stmt);
free(cmd_buff);
return(ret);
}
return(ret);
}
return(0);
}
@@ -1963,7 +1995,7 @@ unsigned long long STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt)
return stmt->result.rows;
}
MYSQL_RES* STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt)
MYSQL_RES* STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt __attribute__((unused)))
{
/* server doesn't deliver any information yet,
so we just return NULL
@@ -1981,7 +2013,7 @@ my_bool STDCALL mysql_stmt_more_results(MYSQL_STMT *stmt)
return (stmt &&
stmt->mysql &&
((stmt->mysql->server_status & SERVER_MORE_RESULTS_EXIST) ||
(stmt->mysql->server_status & SERVER_PS_OUT_PARAMS)));
(stmt->mysql->server_status & SERVER_PS_OUT_PARAMS)));
}
int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
@@ -2004,9 +2036,9 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
if (!mysql_stmt_more_results(stmt))
return(-1);
if (stmt->state > MYSQL_STMT_EXECUTED &&
if (stmt->state > MYSQL_STMT_EXECUTED &&
stmt->state < MYSQL_STMT_FETCH_DONE)
madb_reset_stmt(stmt, MADB_RESET_ERROR | MADB_RESET_BUFFER | MADB_RESET_LONGDATA);
madb_reset_stmt(stmt, MADB_RESET_ERROR | MADB_RESET_BUFFER | MADB_RESET_LONGDATA);
stmt->state= MYSQL_STMT_WAITING_USE_OR_STORE;
if (mysql_next_result(stmt->mysql))
@@ -2054,7 +2086,7 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
return(1);
}
if (length == -1)
if (length == (size_t) -1)
length= strlen(stmt_str);
/* clear flags */
@@ -2078,7 +2110,7 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
stmt->field_count= 0;
int4store(stmt_id, stmt->stmt_id);
if (mysql->methods->db_command(mysql, COM_STMT_CLOSE, stmt_id,
if (mysql->methods->db_command(mysql, COM_STMT_CLOSE, stmt_id,
sizeof(stmt_id), 1, stmt))
goto fail;
}
@@ -2108,7 +2140,7 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
}
/* allocated bind buffer for parameters */
if (stmt->field_count &&
if (stmt->field_count &&
stmt->mysql->methods->db_stmt_get_result_metadata(stmt))
{
goto fail;
@@ -2121,7 +2153,7 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
if (!(stmt->bind= (MYSQL_BIND *)ma_alloc_root(fields_ma_alloc_root, stmt->field_count * sizeof(MYSQL_BIND))))
{
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
goto fail;
goto fail;
}
}
stmt->state = MYSQL_STMT_PREPARED;
@@ -2131,6 +2163,6 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
fail:
stmt->state= MYSQL_STMT_INITTED;
SET_CLIENT_STMT_ERROR(stmt, mysql->net.last_errno, mysql->net.sqlstate,
mysql->net.last_error);
mysql->net.last_error);
return 1;
}

View File

@@ -39,6 +39,91 @@ extern unsigned int mariadb_deinitialize_ssl;
static int my_verify_callback(gnutls_session_t ssl);
struct st_cipher_map {
const char *openssl_name;
const char *priority;
gnutls_kx_algorithm_t kx;
gnutls_cipher_algorithm_t cipher;
gnutls_mac_algorithm_t mac;
};
const struct st_cipher_map gtls_ciphers[]=
{
{"DHE-RSA-AES256-GCM-SHA384", ":+AEAD:+DHE-RSA:+AES-256-GCM",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_AES_256_GCM, GNUTLS_MAC_AEAD},
{"DHE-RSA-AES256-SHA256", ":+SHA256:+DHE-RSA:+AES-256-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_AES_256_CBC, GNUTLS_MAC_SHA256},
{"DHE-RSA-AES256-SHA", ":+SHA1:+DHE-RSA:+AES-256-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_AES_256_CBC, GNUTLS_MAC_SHA1},
{"DHE-RSA-CAMELLIA256-SHA", ":+SHA1:+DHE-RSA:+CAMELLIA-256-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_CAMELLIA_256_CBC, GNUTLS_MAC_SHA1},
{"AES256-GCM-SHA384", ":+AEAD:+RSA:+AES-256-GCM",
GNUTLS_KX_RSA, GNUTLS_CIPHER_AES_256_GCM, GNUTLS_MAC_AEAD},
{"AES256-SHA256", ":+SHA256:+RSA:+AES-256-CBC",
GNUTLS_KX_RSA, GNUTLS_CIPHER_AES_256_CBC, GNUTLS_MAC_SHA256},
{"AES256-SHA", ":+SHA1:+RSA:+AES-256-CBC",
GNUTLS_KX_RSA, GNUTLS_CIPHER_AES_256_CBC, GNUTLS_MAC_SHA1},
{"CAMELLIA256-SHA", ":+SHA1:+RSA:+CAMELLIA-256-CBC",
GNUTLS_KX_RSA, GNUTLS_CIPHER_CAMELLIA_256_CBC, GNUTLS_MAC_SHA1},
{"DHE-RSA-AES128-GCM-SHA256", ":+AEAD:+DHE-RSA:+AES-128-GCM",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_AES_128_GCM, GNUTLS_MAC_AEAD},
{"DHE-RSA-AES128-SHA256", ":+SHA256:+DHE-RSA:+AES-128-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_AES_128_CBC, GNUTLS_MAC_SHA256},
{"DHE-RSA-AES128-SHA", ":+SHA1:+DHE-RSA:+AES-128-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_AES_128_CBC, GNUTLS_MAC_SHA1},
{"DHE-RSA-CAMELLIA128-SHA", ":+SHA1:+DHE-RSA:+CAMELLIA-128-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_CAMELLIA_128_CBC, GNUTLS_MAC_SHA1},
{"AES128-GCM-SHA256", ":+AEAD:+RSA:+AES-128-GCM",
GNUTLS_KX_RSA, GNUTLS_CIPHER_AES_128_GCM, GNUTLS_MAC_AEAD},
{"AES128-SHA256", ":+SHA256:+RSA:+AES-128-CBC",
GNUTLS_KX_RSA, GNUTLS_CIPHER_AES_128_CBC, GNUTLS_MAC_SHA256},
{"AES128-SHA", ":+SHA1:+RSA:+AES-128-CBC",
GNUTLS_KX_RSA, GNUTLS_CIPHER_AES_128_CBC, GNUTLS_MAC_SHA1},
{"CAMELLIA128-SHA", ":+SHA1:+RSA:+CAMELLIA-128-CBC",
GNUTLS_KX_RSA, GNUTLS_CIPHER_CAMELLIA_128_CBC, GNUTLS_MAC_SHA1},
{"EDH-RSA-DES-CBC3-SHA", ":+SHA1:+DHE-RSA:+3DES-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_3DES_CBC, GNUTLS_MAC_SHA1},
{"DES-CBC3-SHA", ":+SHA1:+RSA:+3DES-CBC",
GNUTLS_KX_RSA, GNUTLS_CIPHER_3DES_CBC, GNUTLS_MAC_SHA1},
{"DHE-RSA-AES256-SHA", ":+SHA1:+DHE-RSA:+AES-256-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_AES_256_CBC, GNUTLS_MAC_SHA1},
{"DHE-RSA-CAMELLIA256-SHA", ":+SHA1:+DHE-RSA:+CAMELLIA-256-CBC",
GNUTLS_KX_DHE_RSA, GNUTLS_CIPHER_CAMELLIA_256_CBC, GNUTLS_MAC_SHA1},
{"AES256-SHA", ":+SHA1:+RSA:+AES-256-CBC",
GNUTLS_KX_RSA, GNUTLS_CIPHER_AES_256_CBC, GNUTLS_MAC_SHA1},
{"CAMELLIA256-SHA", ":+SHA1:+RSA:+CAMELLIA-256-CBC:",
GNUTLS_KX_RSA, GNUTLS_CIPHER_CAMELLIA_256_CBC, GNUTLS_MAC_SHA1},
{NULL, NULL, 0, 0, 0}
};
static const char *openssl_cipher_name(gnutls_kx_algorithm_t kx,
gnutls_cipher_algorithm_t cipher,
gnutls_mac_algorithm_t mac)
{
unsigned int i=0;
while (gtls_ciphers[i].openssl_name)
{
if (gtls_ciphers[i].kx == kx &&
gtls_ciphers[i].cipher == cipher &&
gtls_ciphers[i].mac == mac)
return gtls_ciphers[i].openssl_name;
i++;
}
return NULL;
}
static const char *get_priority(const char *cipher_name)
{
unsigned int i= 0;
while (gtls_ciphers[i].openssl_name)
{
if (strcmp(gtls_ciphers[i].openssl_name, cipher_name) == 0)
return gtls_ciphers[i].priority;
i++;
}
return NULL;
}
#define MAX_SSL_ERR_LEN 100
static void ma_tls_set_error(MYSQL *mysql, int ssl_errno)
@@ -58,7 +143,7 @@ static void ma_tls_set_error(MYSQL *mysql, int ssl_errno)
ssl_error_reason);
return;
}
snprintf(ssl_error, MAX_SSL_ERR_LEN, "SSL errno=%lu", ssl_errno, mysql->charset);
snprintf(ssl_error, MAX_SSL_ERR_LEN, "SSL errno=%d", ssl_errno);
pvio->set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN,
ssl_error);
}
@@ -78,7 +163,7 @@ static void ma_tls_get_error(char *errmsg, size_t length, int ssl_errno)
strncpy(errmsg, ssl_error_reason, length);
return;
}
snprintf(errmsg, length, "SSL errno=%lu", ssl_errno);
snprintf(errmsg, length, "SSL errno=%d", ssl_errno);
}
/*
@@ -147,11 +232,42 @@ void ma_tls_end()
return;
}
static int ma_gnutls_set_ciphers(gnutls_session_t ssl, char *cipher_str)
{
const char *err;
char *token;
#define PRIO_SIZE 1024
char prio[PRIO_SIZE];
if (!cipher_str)
return gnutls_priority_set_direct(ssl, "NORMAL", &err);
token= strtok(cipher_str, ":");
strcpy(prio, "NONE:+VERS-TLS-ALL:+SIGN-ALL:+COMP-NULL");
while (token)
{
const char *p= get_priority(token);
/* if cipher was not found, we pass the original token to
the priority string, this will allow to specify gnutls
specific settings via cipher */
if (!p)
{
strncat(prio, ":", PRIO_SIZE - strlen(prio) - 1);
strncat(prio, token, PRIO_SIZE - strlen(prio) - 1);
}
else
strncat(prio, p, PRIO_SIZE - strlen(prio) - 1);
token = strtok(NULL, ":");
}
return gnutls_priority_set_direct(ssl, prio , &err);
}
static int ma_tls_set_certs(MYSQL *mysql)
{
char *certfile= mysql->options.ssl_cert,
*keyfile= mysql->options.ssl_key;
char *cipher= NULL;
int ssl_error= 0;
if (mysql->options.ssl_ca)
@@ -177,17 +293,14 @@ static int ma_tls_set_certs(MYSQL *mysql)
if (certfile || keyfile)
{
if ((ssl_error= gnutls_certificate_set_x509_key_file2(GNUTLS_xcred,
certfile, keyfile,
GNUTLS_X509_FMT_PEM,
OPT_HAS_EXT_VAL(mysql, tls_pw) ? mysql->options.extension->tls_pw : NULL,
0)) < 0)
certfile, keyfile, GNUTLS_X509_FMT_PEM,
OPT_HAS_EXT_VAL(mysql, tls_pw) ? mysql->options.extension->tls_pw : NULL,
0)) < 0)
goto error;
}
return 1;
error:
if (cipher)
free(cipher);
return ssl_error;
}
@@ -195,7 +308,6 @@ void *ma_tls_init(MYSQL *mysql)
{
gnutls_session_t ssl= NULL;
int ssl_error= 0;
const char *err;
pthread_mutex_lock(&LOCK_gnutls_config);
@@ -205,8 +317,8 @@ void *ma_tls_init(MYSQL *mysql)
if ((ssl_error = gnutls_init(&ssl, GNUTLS_CLIENT & GNUTLS_NONBLOCK)) < 0)
goto error;
gnutls_session_set_ptr(ssl, (void *)mysql);
ssl_error= gnutls_priority_set_direct(ssl, "NORMAL", &err);
ssl_error= ma_gnutls_set_ciphers(ssl, mysql->options.ssl_cipher);
if (ssl_error < 0)
goto error;
@@ -276,6 +388,8 @@ my_bool ma_tls_connect(MARIADB_TLS *ctls)
{
ma_tls_set_error(mysql, ret);
/* restore blocking mode */
gnutls_deinit((gnutls_session_t )ctls->ssl);
ctls->ssl= NULL;
if (!blocking)
pvio->methods->blocking(pvio, FALSE, 0);
return 1;
@@ -297,14 +411,16 @@ size_t ma_tls_write(MARIADB_TLS *ctls, const uchar* buffer, size_t length)
my_bool ma_tls_close(MARIADB_TLS *ctls)
{
gnutls_bye((gnutls_session_t )ctls->ssl, GNUTLS_SHUT_WR);
gnutls_deinit((gnutls_session_t )ctls->ssl);
ctls->ssl= NULL;
if (ctls->ssl)
{
gnutls_bye((gnutls_session_t )ctls->ssl, GNUTLS_SHUT_WR);
gnutls_deinit((gnutls_session_t )ctls->ssl);
ctls->ssl= NULL;
}
return 0;
}
int ma_tls_verify_server_cert(MARIADB_TLS *ctls)
int ma_tls_verify_server_cert(MARIADB_TLS *ctls __attribute__((unused)))
{
/* server verification is already handled before */
return 0;
@@ -312,9 +428,17 @@ int ma_tls_verify_server_cert(MARIADB_TLS *ctls)
const char *ma_tls_get_cipher(MARIADB_TLS *ctls)
{
gnutls_kx_algorithm_t kx;
gnutls_cipher_algorithm_t cipher;
gnutls_mac_algorithm_t mac;
if (!ctls || !ctls->ssl)
return NULL;
return gnutls_cipher_get_name (gnutls_cipher_get((gnutls_session_t )ctls->ssl));
mac= gnutls_mac_get((gnutls_session_t)ctls->ssl);
cipher= gnutls_cipher_get((gnutls_session_t)ctls->ssl);
kx= gnutls_kx_get((gnutls_session_t)ctls->ssl);
return openssl_cipher_name(kx, cipher, mac);
}
static int my_verify_callback(gnutls_session_t ssl)
@@ -388,7 +512,7 @@ static int my_verify_callback(gnutls_session_t ssl)
return 0;
}
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, unsigned char *fp, unsigned int len)
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, char *fp, unsigned int len)
{
MYSQL *mysql;
size_t fp_len= len;

View File

@@ -1,186 +0,0 @@
#ifdef _WIN32
#define SCHANNEL_CIPHER(a,b,c,d,e) ,a,b,c,d,e
#else
#define SCHANNEL_CIPHER(a,b,c,d,e)
#endif
struct st_cipher_suite {
const char *rfc_name;
const char *openssl_name;
const char *gnutls_name;
const char *nss_name;
#ifdef _WIN32
ALG_ID exch;
ALG_ID encrypt;
ALG_ID hash;
ALG_ID sign;
int strength;
#endif
};
const struct st_cipher_suite tls_ciphers[] =
{
{ /* RFC cipher ID 0x000013 */
"TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
"DHE-DSS-DES-CBC3-SHA",
"TLS_DHE_DSS_3DES_EDE_CBC_SHA1",
"TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA"
SCHANNEL_CIPHER(CALG_DH_EPHEM, CALG_3DES, CALG_SHA1, CALG_DSS_SIGN, 0)
},
{ "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
"DHE-DSS-AES128-SHA",
"TLS_DHE_DSS_AES_128_CBC_SHA1",
"TLS_DHE_DSS_WITH_AES_128_CBC_SHA"
SCHANNEL_CIPHER(CALG_DH_EPHEM, CALG_AES_128, CALG_SHA1,CALG_DSS_SIGN, 0)
},
{ "TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
"DHE-DSS-AES256-SHA",
"TLS_DHE_DSS_AES_256_CBC_SHA1",
"TLS_DHE_DSS_WITH_AES_256_CBC_SHA"
SCHANNEL_CIPHER(CALG_DH_EPHEM, CALG_AES_256, CALG_SHA1, CALG_DSS_SIGN, 0)
},
{ "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
"DHE-DSS-AES256-SHA256",
"TLS_DHE_DSS_AES_256_CBC_SHA256",
"TLS_DHE_DSS_WITH_AES_256_CBC_SHA256"
SCHANNEL_CIPHER(CALG_DH_EPHEM, CALG_AES_256, CALG_SHA_256, CALG_DSS_SIGN, 0)
},
{ "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
"DHE-RSA-AES128-GCM-SHA256",
"TLS_DHE_RSA_AES_128_GCM_SHA256",
"TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
SCHANNEL_CIPHER(CALG_DH_EPHEM, CALG_AES_128, CALG_SHA_128, 0, 0
)},
{ "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
"DHE-RSA-AES256-GCM-SHA384",
"TLS_DHE_RSA_AES_256_GCM_SHA384",
NULL
SCHANNEL_CIPHER(CALG_DH_EPHEM, CALG_AES_256, CALG_SHA384, 0, 0)
},
{ "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
"ECDHE-ECDSA-AES128-SHA",
"TLS_ECDHE_ECDSA_AES_128_CBC_SHA1",
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"
SCHANNEL_CIPHER(CALG_ECDSA, CALG_AES128, CALG_SHA1, 0, 0)
},
{ "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"ECDHE-ECDSA-AES128-GCM-SHA256",
"TLS_ECDHE_ECDSA_AES_128_GCM_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
SCHANNEL_CIPHER(CALG_ECDSA, CALG_AES128, CALG_SHA256, 0, 0)
},
{ "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA384",
NULL,
NULL,
NULL
SCHANNEL_CIPHER(CALG_ECDSA, CALG_AES128, CALG_SHA384, 0, 0)
},
{ "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
"ECDHE-ECDSA-AES256-SHA",
"TLS_ECDHE_ECDSA_AES_256_CBC_SHA1",
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"
SCHANNEL_CIPHER(CALG_ECDSA, CALG_AES256, CALG_SHA1, 0, 0)
},
{ "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
"ECDHE-ECDSA-AES256-SHA384",
"TLS_ECDHE_ECDSA_AES_256_CBC_SHA384",
NULL
SCHANNEL_CIPHER(CALG_ECDSA, CALG_AES256, CALG_SHA384, 0, 0)
},
{ "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
"ECDHE-RSA-AES128-SHA",
"TLS_ECDHE_RSA_AES_128_CBC_SHA1",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"
SCHANNEL_CIPHER(0xAE06, CALG_AES128, CALG_SHA1, 0, 0)
},
{ "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
"ECDHE-RSA-AES128-SHA256",
"TLS_ECDHE_RSA_AES_128_CBC_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
SCHANNEL_CIPHER(0xAE06, CALG_AES128, CALG_SHA256, 0, 0)
},
{ "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA256",
NULL,
NULL,
NULL
SCHANNEL_CIPHER(0xAE06, CALG_AES256, CALG_SHA256, 0, 0)
},
{ "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
"ECDHE-RSA-AES256-SHA384",
"TLS_ECDHE_RSA_AES_256_CBC_SHA384",
NULL
SCHANNEL_CIPHER(0xAE06, CALG_AES256, CALG_SHA384, 0, 0)
},
{ "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA",
NULL,
NULL,
"TLS_RSA_EXPORT_WITH_DES40_CBC_SHA"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_3DES, CALG_SHA1, 0, 0)
},
{ "TLS_RSA_WITH_3DES_EDE_CBC_SHA",
NULL,
"TLS_RSA_3DES_EDE_CBC_SHA1",
"TLS_RSA_WITH_3DES_EDE_CBC_SHA"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_3DES, CALG_SHA1, 0, 0)
},
{ "TLS_RSA_WITH_AES_128_CBC_SHA",
"AES128-SHA",
"TLS_RSA_AES_128_CBC_SHA1",
"TLS_RSA_WITH_AES_128_CBC_SHA"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_AES_128, CALG_SHA1, 0, 0)
},
{ "TLS_RSA_WITH_AES_128_CBC_SHA256",
"AES128-SHA256",
"TLS_RSA_AES_128_CBC_SHA256",
"TLS_RSA_WITH_AES_128_CBC_SHA256"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_AES_128, CALG_SHA256, 0, 0)
},
{ "TLS_RSA_WITH_AES_128_GCM_SHA256",
"AES128-GCM-SHA256",
"TLS_RSA_AES_128_GCM_SHA256",
"TLS_RSA_WITH_AES_128_GCM_SHA256"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_AES_128, CALG_SHA256, 0, 0)
},
{ "TLS_RSA_WITH_AES_256_CBC_SHA",
"AES256-SHA",
"TLS_RSA_AES_256_CBC_SHA1",
"TLS_RSA_WITH_AES_256_CBC_SHA"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_AES_256, CALG_SHA1, 0, 0)
},
{ "TLS_RSA_WITH_AES_256_CBC_SHA256",
"AES256-SHA256",
"TLS_RSA_AES_256_CBC_SHA256",
"TLS_RSA_WITH_AES_256_CBC_SHA256"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_AES_256, CALG_SHA_256,0, 0)
},
{ "TLS_RSA_WITH_AES_256_GCM_SHA384",
"AES256-GCM-SHA384",
"TLS_RSA_AES_256_GCM_SHA384",
NULL
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_AES_256, CALG_SHA384, 0, 0)
},
{ "TLS_RSA_WITH_NULL_SHA256",
"NULL-SHA256",
"TLS_RSA_NULL_SHA256",
"TLS_RSA_WITH_NULL_SHA256"
SCHANNEL_CIPHER(CALG_RSA_KEYX, 0, CALG_SHA_256, 0, 0)
},
{ "TLS_RSA_WITH_RC4_128_MD5",
NULL,
"TLS_RSA_ARCFOUR_128_MD5",
"TLS_RSA_WITH_RC4_128_MD5"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_RC4, CALG_MD5, 0, 0)
},
{ "TLS_RSA_WITH_RC4_128_SHA",
NULL,
"TLS_RSA_ARCFOUR_128_SHA1",
"TLS_RSA_WITH_RC4_128_SHA"
SCHANNEL_CIPHER(CALG_RSA_KEYX, CALG_RC4, CALG_SHA1,0, 0)
},
{ NULL,
NULL,
NULL,
NULL
SCHANNEL_CIPHER(0, 0, 0, 0, 0)}
};

View File

@@ -49,10 +49,14 @@ static SSL_CTX *SSL_context= NULL;
#define MAX_SSL_ERR_LEN 100
static pthread_mutex_t LOCK_openssl_config;
#if OPENSSL_VERSION_NUMBER < 0x10100000L
static pthread_mutex_t *LOCK_crypto= NULL;
#endif
#if OPENSSL_USE_BIOMETHOD
static int ma_bio_read(BIO *h, char *buf, int size);
static int ma_bio_write(BIO *h, const char *buf, int size);
static BIO_METHOD ma_BIO_methods;
static BIO_METHOD ma_BIO_method;
#endif
static void ma_tls_set_error(MYSQL *mysql)
{
@@ -96,13 +100,13 @@ static void ma_tls_get_error(char *errmsg, size_t length)
snprintf(errmsg, length, "SSL errno=%lu", ssl_errno);
}
#if (OPENSSL_VERSION_NUMBER < 0x10100000)
#if OPENSSL_VERSION_NUMBER < 0x10100000L
/*
thread safe callbacks for OpenSSL
Crypto call back functions will be
set during ssl_initialization
*/
#if (OPENSSL_VERSION_NUMBER < 0x10000000)
#if OPENSSL_VERSION_NUMBER < 0x10000000L
static unsigned long my_cb_threadid(void)
{
/* cast pthread_t to unsigned long */
@@ -123,14 +127,14 @@ typedef struct st_ma_tls_session {
} MA_SSL_SESSION;
MA_SSL_SESSION *ma_tls_sessions= NULL;
unsigned int ma_tls_session_cache_size= 128;
int ma_tls_session_cache_size= 128;
static char *ma_md4_hash(const char *host, const char *user, unsigned int port, char *md4)
{
char buffer[195]; /* MAX_USERNAME_LEN + MAX_HOST_NAME_LEN + 2 + 5 */
snprintf(buffer, 194, "%s@%s:%d", user ? user : "", host, port);
buffer[194]= 0;
MD4(buffer, strlen(buffer), md4);
MD4((unsigned char *)buffer, strlen(buffer), (unsigned char *)md4);
return md4;
}
@@ -156,6 +160,7 @@ MA_SSL_SESSION *ma_tls_get_session(MYSQL *mysql)
}
#if OPENSSL_USE_BIOMETHOD
static int ma_bio_read(BIO *bio, char *buf, int size)
{
MARIADB_PVIO *pvio= (MARIADB_PVIO *)bio->ptr;
@@ -174,6 +179,7 @@ static int ma_bio_write(BIO *bio, const char *buf, int size)
BIO_clear_retry_flags(bio);
return (int)rc;
}
#endif
static int ma_tls_session_cb(SSL *ssl, SSL_SESSION *session)
{
@@ -203,7 +209,8 @@ static int ma_tls_session_cb(SSL *ssl, SSL_SESSION *session)
return 0;
}
static void ma_tls_remove_session_cb(SSL_CTX* ctx, SSL_SESSION* session)
static void ma_tls_remove_session_cb(SSL_CTX* ctx __attribute__((unused)),
SSL_SESSION* session)
{
int i;
for (i=0; i < ma_tls_session_cache_size; i++)
@@ -216,8 +223,10 @@ static void ma_tls_remove_session_cb(SSL_CTX* ctx, SSL_SESSION* session)
}
#endif
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
static void my_cb_locking(int mode, int n, const char *file, int line)
#if OPENSSL_VERSION_NUMBER < 0x10100000L
static void my_cb_locking(int mode, int n,
const char *file __attribute__((unused)),
int line __attribute__((unused)))
{
if (mode & CRYPTO_LOCK)
pthread_mutex_lock(&LOCK_crypto[n]);
@@ -239,7 +248,7 @@ static int ssl_thread_init()
pthread_mutex_init(&LOCK_crypto[i], NULL);
}
#if (OPENSSL_VERSION_NUMBER < 0x10000000)
#if OPENSSL_VERSION_NUMBER < 0x10000000L
CRYPTO_set_id_callback(my_cb_threadid);
#else
CRYPTO_THREADID_set_callback(my_cb_threadid);
@@ -293,7 +302,7 @@ int ma_tls_start(char *errmsg, size_t errmsg_len)
/* lock mutex to prevent multiple initialization */
pthread_mutex_init(&LOCK_openssl_config,MY_MUTEX_INIT_FAST);
pthread_mutex_lock(&LOCK_openssl_config);
#if (OPENSSL_VERSION_NUMBER >= 0x10100000)
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL);
#else
if (ssl_thread_init())
@@ -311,7 +320,7 @@ int ma_tls_start(char *errmsg, size_t errmsg_len)
SSL_load_error_strings();
/* digests and ciphers */
OpenSSL_add_all_algorithms();
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
if (!(SSL_context= SSL_CTX_new(TLS_client_method())))
#else
if (!(SSL_context= SSL_CTX_new(SSLv23_client_method())))
@@ -327,11 +336,11 @@ int ma_tls_start(char *errmsg, size_t errmsg_len)
SSL_CTX_sess_set_remove_cb(SSL_context, ma_tls_remove_session_cb);
#endif
disable_sigpipe();
memcpy(&ma_BIO_methods, BIO_s_socket(), sizeof(BIO_METHOD));
ma_BIO_methods.bread= ma_bio_read;
ma_BIO_methods.bwrite= ma_bio_write;
#if OPENSSL_USE_BIOMETHOD
memcpy(&ma_BIO_method, BIO_s_socket(), sizeof(BIO_METHOD));
ma_BIO_method.bread= ma_bio_read;
ma_BIO_method.bwrite= ma_bio_write;
#endif
rc= 0;
ma_tls_initialized= TRUE;
end:
@@ -355,16 +364,18 @@ void ma_tls_end()
{
if (ma_tls_initialized)
{
int i;
pthread_mutex_lock(&LOCK_openssl_config);
#if OPENSSL_VERSION_NUMBER < 0x10100000L
CRYPTO_set_locking_callback(NULL);
CRYPTO_set_id_callback(NULL);
for (i=0; i < CRYPTO_num_locks(); i++)
pthread_mutex_destroy(&LOCK_crypto[i]);
{
int i;
for (i=0; i < CRYPTO_num_locks(); i++)
pthread_mutex_destroy(&LOCK_crypto[i]);
}
ma_free((gptr)LOCK_crypto);
LOCK_crypto= NULL;
#endif
if (SSL_context)
{
@@ -373,7 +384,7 @@ void ma_tls_end()
}
if (mariadb_deinitialize_ssl)
{
#if OPENSSL_VERSION_NUMBER < 0x10100000
#if OPENSSL_VERSION_NUMBER < 0x10100000L
ERR_remove_state(0);
#endif
EVP_cleanup();
@@ -389,7 +400,9 @@ void ma_tls_end()
return;
}
int ma_tls_get_password(char *buf, int size, int rwflag, void *userdata)
int ma_tls_get_password(char *buf, int size,
int rwflag __attribute__((unused)),
void *userdata)
{
memset(buf, 0, size);
if (userdata)
@@ -518,7 +531,10 @@ my_bool ma_tls_connect(MARIADB_TLS *ctls)
MYSQL *mysql;
MARIADB_PVIO *pvio;
int rc;
#if OPENSSL_USE_BIOMETHOD
BIO_METHOD *bio_method= NULL;
BIO *bio;
#endif
mysql= (MYSQL *)SSL_get_app_data(ssl);
pvio= mysql->net.pvio;
@@ -529,10 +545,14 @@ my_bool ma_tls_connect(MARIADB_TLS *ctls)
SSL_clear(ssl);
bio= BIO_new(&ma_BIO_methods);
#if OPENSSL_USE_BIOMETHOD
bio= BIO_new(&ma_BIO_method);
bio->ptr= pvio;
SSL_set_bio(ssl, bio, bio);
BIO_set_fd(bio, mysql_get_socket(mysql), BIO_NOCLOSE);
#else
SSL_set_fd(ssl, mysql_get_socket(mysql));
#endif
while (try_connect && (rc= SSL_connect(ssl)) == -1)
{
@@ -601,6 +621,9 @@ my_bool ma_tls_close(MARIADB_TLS *ctls)
if ((rc= SSL_shutdown(ssl)))
break;
/* Since we transferred ownership of BIO to ssl, BIO will
automatically freed - no need for an explicit BIO_free_all */
SSL_free(ssl);
ctls->ssl= NULL;
@@ -678,7 +701,7 @@ const char *ma_tls_get_cipher(MARIADB_TLS *ctls)
return SSL_get_cipher_name(ctls->ssl);
}
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, unsigned char *fp, unsigned int len)
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, char *fp, unsigned int len)
{
EVP_MD *digest= (EVP_MD *)EVP_sha1();
X509 *cert;
@@ -706,7 +729,7 @@ unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, unsigned char *fp, unsig
return 0;
}
fp_len= len;
if (!X509_digest(cert, digest, fp, &fp_len))
if (!X509_digest(cert, digest, (unsigned char *)fp, &fp_len))
{
ma_free(fp);
my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN,

View File

@@ -305,10 +305,11 @@ my_bool ma_tls_connect(MARIADB_TLS *ctls)
my_bool rc= 1;
SC_CTX *sctx;
SECURITY_STATUS sRet;
PCCERT_CONTEXT pRemoteCertContext = NULL,
PCCERT_CONTEXT pRemoteCertContext= NULL,
pLocalCertContext= NULL;
ALG_ID AlgId[MAX_ALG_ID];
WORD validTokens = 0;
if (!ctls || !ctls->pvio)
return 1;;
@@ -326,7 +327,6 @@ my_bool ma_tls_connect(MARIADB_TLS *ctls)
ZeroMemory(&Cred, sizeof(SCHANNEL_CRED));
WORD validTokens = 0;
/* Set cipher */
if (mysql->options.ssl_cipher)
{
@@ -536,7 +536,7 @@ const char *ma_tls_get_cipher(MARIADB_TLS *ctls)
return NULL;
}
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, unsigned char *fp, unsigned int len)
unsigned int ma_tls_get_finger_print(MARIADB_TLS *ctls, char *fp, unsigned int len)
{
SC_CTX *sctx= (SC_CTX *)ctls->ssl;
PCCERT_CONTEXT pRemoteCertContext = NULL;

View File

@@ -13,7 +13,7 @@ static char *mariadb_progname;
#define CFLAGS INCLUDE " @CMAKE_C_FLAGS@"
#define VERSION "@MARIADB_CLIENT_VERSION@"
#define PLUGIN_DIR "@PREFIX_INSTALL_DIR@/@SUFFIX_INSTALL_DIR@/@PLUGIN_INSTALL_DIR@"
#define SOCKET "@MARIADBL_UNIX_ADDR@"
#define SOCKET "@MARIADB_UNIX_ADDR@"
#define PORT "@MARIADB_PORT@"
static struct option long_options[]=
@@ -31,7 +31,7 @@ static struct option long_options[]=
{NULL, 0, 0, 0}
};
static char *values[]=
static const char *values[]=
{
CFLAGS,
NULL,

View File

@@ -1,3 +1,6 @@
IF(FOR_SERVER)
RETURN()
ENDIF()
FILE(GLOB plugin_dirs ${PROJECT_SOURCE_DIR}/plugins/*)
FOREACH(dir ${plugin_dirs})
IF (EXISTS ${dir}/CMakeLists.txt)

View File

@@ -79,7 +79,7 @@ struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ =
RETURNS
Input buffer
*/
static char *auth_dialog_native_prompt(MYSQL *mysql,
static char *auth_dialog_native_prompt(MYSQL *mysql __attribute__((unused)),
int type,
const char *prompt,
char *buffer,
@@ -103,7 +103,7 @@ static char *auth_dialog_native_prompt(MYSQL *mysql,
}
else
{
get_tty_password("", buffer, buffer_len - 1);
get_tty_password((char *)"", buffer, buffer_len - 1);
}
return buffer;
}
@@ -138,7 +138,7 @@ static int auth_dialog_open(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
my_bool first_loop= TRUE;
do {
if ((packet_length= vio->read_packet(vio, &packet)) < 0)
if ((packet_length= vio->read_packet(vio, &packet)) == (size_t)-1)
/* read error */
return CR_ERROR;
@@ -170,7 +170,7 @@ static int auth_dialog_open(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
response= mysql->passwd;
}
if (!response ||
vio->write_packet(vio, response, (int)strlen(response) + 1))
vio->write_packet(vio, (uchar *)response, (int)strlen(response) + 1))
return CR_ERROR;
first_loop= FALSE;

View File

@@ -9,7 +9,7 @@ typedef struct st_mysql_client_plugin_AUTHENTICATION auth_plugin_t;
static int client_mpvio_write_packet(struct st_plugin_vio*, const uchar*, size_t);
static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql);
extern void read_user_name(char *name);
extern uchar *ma_send_connect_attr(MYSQL *mysql, uchar *buffer);
extern char *ma_send_connect_attr(MYSQL *mysql, unsigned char *buffer);
typedef struct {
int (*read_packet)(struct st_plugin_vio *vio, uchar **buf);
@@ -141,7 +141,7 @@ static int send_change_user_packet(MCPVIO_EXT *mpvio,
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
end= ma_strmake(end, mpvio->plugin->name, NAME_LEN) + 1;
end= ma_send_connect_attr(mysql, end);
end= ma_send_connect_attr(mysql, (unsigned char *)end);
res= ma_simple_command(mysql, COM_CHANGE_USER,
buff, (ulong)(end-buff), 1, NULL);
@@ -218,8 +218,8 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
memset(buff + 9, 0, 32-9);
if (!(mysql->server_capabilities & CLIENT_MYSQL))
{
mysql->client_flag |= MARIADB_CLIENT_SUPPORTED_FLAGS;
int4store(buff + 28, mysql->client_flag >> 32);
mysql->extension->mariadb_client_flag = MARIADB_CLIENT_SUPPORTED_FLAGS >> 32;
int4store(buff + 28, mysql->extension->mariadb_client_flag);
}
end= buff+32;
}
@@ -249,7 +249,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
Send mysql->client_flag, max_packet_size - unencrypted otherwise
the server does not know we want to do SSL
*/
if (ma_net_write(net, (char*)buff, (size_t) (end-buff)) || ma_net_flush(net))
if (ma_net_write(net, (unsigned char *)buff, (size_t) (end-buff)) || ma_net_flush(net))
{
my_set_error(mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN,
ER(CR_SERVER_LOST_EXTENDED),
@@ -298,10 +298,10 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
end= ma_strmake(end, mpvio->plugin->name, NAME_LEN) + 1;
end= ma_send_connect_attr(mysql, end);
end= ma_send_connect_attr(mysql, (unsigned char *)end);
/* Write authentication package */
if (ma_net_write(net, buff, (size_t) (end-buff)) || ma_net_flush(net))
if (ma_net_write(net, (unsigned char *)buff, (size_t) (end-buff)) || ma_net_flush(net))
{
my_set_error(mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN,
ER(CR_SERVER_LOST_EXTENDED),
@@ -405,7 +405,7 @@ static int client_mpvio_write_packet(struct st_plugin_vio *mpv,
if (mpvio->mysql->thd)
res= 1; /* no chit-chat in embedded */
else
res= ma_net_write(net, (char *)pkt, pkt_len) || ma_net_flush(net);
res= ma_net_write(net, (unsigned char *)pkt, pkt_len) || ma_net_flush(net);
if (res)
my_set_error(mpvio->mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN,
ER(CR_SERVER_LOST_EXTENDED),

View File

@@ -36,7 +36,8 @@
#endif
/* function prototypes */
int aurora_init(char *errormsg, size_t errormsg_size,
int aurora_init(char *errormsg __attribute__((unused)),
size_t errormsg_size __attribute__((unused)),
int unused __attribute__((unused)),
va_list unused1 __attribute__((unused)));
@@ -82,7 +83,7 @@ struct st_mariadb_api *mariadb_api= NULL;
typedef struct st_aurora_instance {
char *host;
int port;
unsigned int port;
time_t blacklisted;
int type;
} AURORA_INSTANCE;
@@ -132,7 +133,8 @@ my_bool aurora_switch_connection(MYSQL *mysql, AURORA *aurora, int type)
*
* plugin initialization function
*/
int aurora_init(char *errormsg, size_t errormsg_size,
int aurora_init(char *errormsg __attribute__((unused)),
size_t errormsg_size __attribute__((unused)),
int unused __attribute__((unused)),
va_list unused1 __attribute__((unused)))
{
@@ -247,7 +249,7 @@ int aurora_get_instance_type(MYSQL *mysql)
int rc= -1;
MA_CONNECTION_HANDLER *save_hdlr= mysql->extension->conn_hdlr;
char *query= "select variable_value from information_schema.global_variables where variable_name='INNODB_READ_ONLY' AND variable_value='OFF'";
const char *query= "select variable_value from information_schema.global_variables where variable_name='INNODB_READ_ONLY' AND variable_value='OFF'";
if (!mysql)
return -1;
@@ -519,7 +521,7 @@ my_bool aurora_find_primary(AURORA *aurora)
/* {{{ MYSQL *aurora_connect */
MYSQL *aurora_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd,
const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag)
const char *db, unsigned int port, const char *unix_socket __attribute__((unused)), unsigned long client_flag)
{
AURORA *aurora= NULL;
MA_CONNECTION_HANDLER *save_hdlr= mysql->extension->conn_hdlr;
@@ -595,7 +597,7 @@ my_bool aurora_reconnect(MYSQL *mysql)
{
AURORA *aurora;
MA_CONNECTION_HANDLER *save_hdlr= mysql->extension->conn_hdlr;
int i;
unsigned int i;
/* We can't determine if a new primary was promotoed, or if
* line just dropped - we will close both primary and replica
@@ -716,7 +718,7 @@ my_bool is_replica_stmt(MYSQL *mysql, const char *buffer)
/* {{{ int aurora_command */
int aurora_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
size_t length, my_bool skipp_check, void *opt_arg)
size_t length __attribute__((unused)), my_bool skipp_check __attribute__((unused)), void *opt_arg __attribute__((unused)))
{
MA_CONNECTION_HANDLER *save_hdlr= mysql->extension->conn_hdlr;
AURORA *aurora= (AURORA *)save_hdlr->data;

View File

@@ -79,7 +79,7 @@ typedef struct st_conn_repl {
my_bool round_robin;
char *url;
char *host[2];
int port[2];
unsigned int port[2];
unsigned int current_type;
} REPL_DATA;
@@ -298,7 +298,9 @@ static my_bool is_slave_stmt(MYSQL *mysql, const char *buffer)
int repl_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
size_t length, my_bool skipp_check, void *opt_arg)
size_t length,
my_bool skipp_check __attribute__((unused)),
void *opt_arg __attribute__((unused)))
{
REPL_DATA *data= (REPL_DATA *)mysql->extension->conn_hdlr->data;

View File

@@ -46,6 +46,7 @@ int pvio_npipe_keepalive(MARIADB_PVIO *pvio);
my_bool pvio_npipe_get_handle(MARIADB_PVIO *pvio, void *handle);
my_bool pvio_npipe_is_blocking(MARIADB_PVIO *pvio);
int pvio_npipe_shutdown(MARIADB_PVIO *pvio);
my_bool pvio_npipe_is_alive(MARIADB_PVIO *pvio);
struct st_ma_pvio_methods pvio_npipe_methods= {
pvio_npipe_set_timeout,
@@ -62,7 +63,7 @@ struct st_ma_pvio_methods pvio_npipe_methods= {
pvio_npipe_keepalive,
pvio_npipe_get_handle,
pvio_npipe_is_blocking,
NULL,
pvio_npipe_is_alive,
NULL,
pvio_npipe_shutdown
};
@@ -367,4 +368,16 @@ int pvio_npipe_shutdown(MARIADB_PVIO *pvio)
}
return 1;
}
my_bool pvio_npipe_is_alive(MARIADB_PVIO *pvio)
{
HANDLE handle;
if (!pvio || !pvio->data)
return FALSE;
handle= ((struct st_pvio_npipe *)pvio->data)->pipe;
/* Copy data fron named pipe without removing it */
if (PeekNamedPipe(handle, NULL, 0, NULL, NULL, NULL))
return TRUE;
return test(GetLastError() != ERROR_BROKEN_PIPE);
}
#endif

View File

@@ -29,7 +29,6 @@
#include <string.h>
#include <ma_string.h>
#define SHM_DEFAULT_NAME "MYSQL"
#define PVIO_SHM_BUFFER_SIZE 16000 + 4
my_bool pvio_shm_set_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout);
@@ -41,6 +40,8 @@ my_bool pvio_shm_blocking(MARIADB_PVIO *pvio, my_bool value, my_bool *old_value)
my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo);
my_bool pvio_shm_close(MARIADB_PVIO *pvio);
int pvio_shm_shutdown(MARIADB_PVIO *pvio);
my_bool pvio_shm_is_alive(MARIADB_PVIO *pvio);
my_bool pvio_shm_get_handle(MARIADB_PVIO *pvio, void *handle);
struct st_ma_pvio_methods pvio_shm_methods= {
pvio_shm_set_timeout,
@@ -55,9 +56,9 @@ struct st_ma_pvio_methods pvio_shm_methods= {
pvio_shm_close,
NULL,
NULL,
pvio_shm_get_handle,
NULL,
NULL,
NULL,
pvio_shm_is_alive,
NULL,
pvio_shm_shutdown
};
@@ -262,9 +263,7 @@ my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
*/
base_memory_name= (cinfo->mysql->options.shared_memory_base_name) ?
cinfo->mysql->options.shared_memory_base_name : SHM_DEFAULT_NAME;
base_memory_name= (cinfo->host) ? cinfo->host : SHM_DEFAULT_NAME;
if (!(shm_name= (char *)LocalAlloc(LMEM_ZEROINIT, strlen(base_memory_name) + 40)))
{
@@ -447,5 +446,24 @@ int pvio_shm_shutdown(MARIADB_PVIO *pvio)
return (SetEvent(pvio_shm->event[PVIO_SHM_CONNECTION_CLOSED]) ? 0 : 1);
return 1;
}
my_bool pvio_shm_is_alive(MARIADB_PVIO *pvio)
{
PVIO_SHM *pvio_shm;
if (!pvio || !pvio->data)
return FALSE;
pvio_shm= (PVIO_SHM *)pvio->data;
return WaitForSingleObject(pvio_shm->event[PVIO_SHM_CONNECTION_CLOSED], 0);
}
my_bool pvio_shm_get_handle(MARIADB_PVIO *pvio, void *handle)
{
PVIO_SHM *pvio_shm;
*(HANDLE **)handle= 0;
if (!pvio || !pvio->data)
return FALSE;
*(HANDLE **)handle= (HANDLE **)((PVIO_SHM*)pvio->data)->event;
return TRUE;
}
#endif

View File

@@ -33,6 +33,7 @@
#include <mariadb_async.h>
#include <ma_common.h>
#include <string.h>
#include <time.h>
#ifndef _WIN32
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
@@ -58,6 +59,8 @@
#define SOCKET_ERROR -1
#endif
#define DNS_TIMEOUT 30
/* Function prototypes */
my_bool pvio_socket_set_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout);
@@ -132,10 +135,10 @@ struct st_pvio_socket {
static my_bool pvio_socket_initialized= FALSE;
static int pvio_socket_init(char *errmsg,
size_t errmsg_length,
int unused,
va_list va)
static int pvio_socket_init(char *errmsg __attribute__((unused)),
size_t errmsg_length __attribute__((unused)),
int unused __attribute__((unused)),
va_list va __attribute__((unused)))
{
pvio_socket_initialized= TRUE;
return 0;
@@ -386,13 +389,13 @@ ssize_t ma_send(int socket, const uchar *buffer, size_t length, int flags)
size_t pvio_socket_async_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
{
ssize_t r= -1;
struct st_pvio_socket *csock= NULL;
#ifndef _WIN32
int write_flags= MSG_DONTWAIT;
#ifdef MSG_NOSIGNAL
write_flags|= MSG_NOSIGNAL;
#endif
#endif
struct st_pvio_socket *csock= NULL;
if (!pvio || !pvio->data)
return -1;
@@ -435,13 +438,13 @@ size_t pvio_socket_async_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t l
size_t pvio_socket_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
{
ssize_t r= -1;
struct st_pvio_socket *csock= NULL;
#ifndef _WIN32
int send_flags= MSG_DONTWAIT;
#ifdef MSG_NOSIGNAL
send_flags|= MSG_NOSIGNAL;
#endif
#endif
struct st_pvio_socket *csock= NULL;
if (!pvio || !pvio->data)
return -1;
@@ -735,6 +738,7 @@ pvio_socket_connect_sync_or_async(MARIADB_PVIO *pvio,
my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
{
struct st_pvio_socket *csock= NULL;
MYSQL *mysql;
if (!pvio || !cinfo)
return 1;
@@ -746,7 +750,7 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
}
pvio->data= (void *)csock;
csock->socket= -1;
pvio->mysql= cinfo->mysql;
mysql= pvio->mysql= cinfo->mysql;
pvio->type= cinfo->type;
if (cinfo->type == PVIO_TYPE_UNIXSOCKET)
@@ -783,6 +787,12 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
char server_port[NI_MAXSERV];
int gai_rc;
int rc= 0;
time_t start_t= time(NULL);
#ifdef _WIN32
DWORD wait_gai;
#else
unsigned int wait_gai;
#endif
memset(&server_port, 0, NI_MAXSERV);
snprintf(server_port, NI_MAXSERV, "%d", cinfo->port);
@@ -797,9 +807,22 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
* bind_address */
if (cinfo->mysql->options.bind_address)
{
gai_rc= getaddrinfo(cinfo->mysql->options.bind_address, 0,
&hints, &bind_res);
if (gai_rc != 0)
wait_gai= 1;
while ((gai_rc= getaddrinfo(cinfo->mysql->options.bind_address, 0,
&hints, &bind_res)) == EAI_AGAIN)
{
unsigned int timeout= mysql->options.connect_timeout ?
mysql->options.connect_timeout : DNS_TIMEOUT;
if (time(NULL) - start_t > timeout)
break;
#ifndef _WIN32
usleep(wait_gai);
#else
Sleep(wait_gai);
#endif
wait_gai*= 2;
}
if (gai_rc != 0 || !bind_res)
{
PVIO_SET_ERROR(cinfo->mysql, CR_BIND_ADDR_FAILED, SQLSTATE_UNKNOWN,
CER(CR_BIND_ADDR_FAILED), cinfo->mysql->options.bind_address, gai_rc);
@@ -807,8 +830,22 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
}
}
/* Get the address information for the server using getaddrinfo() */
gai_rc= getaddrinfo(cinfo->host, server_port, &hints, &res);
if (gai_rc != 0)
wait_gai= 1;
while ((gai_rc= getaddrinfo(cinfo->host, server_port,
&hints, &res) == EAI_AGAIN))
{
unsigned int timeout= mysql->options.connect_timeout ?
mysql->options.connect_timeout : DNS_TIMEOUT;
if (time(NULL) - start_t > timeout)
break;
#ifndef _WIN32
usleep(wait_gai);
#else
Sleep(wait_gai);
#endif
wait_gai*= 2;
}
if (gai_rc != 0 || !res)
{
PVIO_SET_ERROR(cinfo->mysql, CR_UNKNOWN_HOST, SQLSTATE_UNKNOWN,
ER(CR_UNKNOWN_HOST), cinfo->host, gai_rc);

View File

@@ -63,7 +63,7 @@ struct st_mysql_client_plugin _mysql_client_plugin_declaration_ =
NULL
};
static char *commands[]= {
static const char *commands[]= {
"COM_SLEEP",
"COM_QUIT",
"COM_INIT_DB",
@@ -279,7 +279,7 @@ void trace_callback(int mode, MYSQL *mysql, const uchar *buffer, size_t length)
{
char *p= (char *)buffer;
p+= 4; /* packet length */
if (*p != 0xFF) /* protocol version 0xFF indicates error */
if ((uchar)*p != 0xFF) /* protocol version 0xFF indicates error */
{
p+= strlen(p + 1) + 2;
thread_id= uint4korr(p);
@@ -329,7 +329,7 @@ void trace_callback(int mode, MYSQL *mysql, const uchar *buffer, size_t length)
else
{
p++;
if (*p == 0xFF)
if ((uchar)*p == 0xFF)
printf("%8lu: CONNECT_ERROR(%d)\n", info->thread_id, uint4korr(p+1));
else
printf("%8lu: CONNECT_SUCCESS(host=%s,user=%s,db=%s)\n", info->thread_id,
@@ -395,7 +395,7 @@ void trace_callback(int mode, MYSQL *mysql, const uchar *buffer, size_t length)
len= uint3korr(p);
p+= 4;
is_error= ((unsigned int)len == -1);
is_error= (len == -1);
switch(info->last_command) {
case COM_STMT_EXECUTE:

View File

@@ -25,8 +25,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/unittest/mytap)
ADD_DEFINITIONS(-DLIBMARIADB)
SET(API_TESTS "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs"
"sp" "result" "connection" "misc" "ps_new" "sqlite3" "thread" "features-10_2"
SET(API_TESTS "performance" "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs" "sp" "result" "connection" "misc" "ps_new" "sqlite3" "thread" "features-10_2"
"bulk1" )
IF(WITH_DYNCOL)
SET(API_TESTS ${API_TESTS} "dyncol")

View File

@@ -132,7 +132,7 @@ wait_for_mysql(MYSQL *mysql, int status)
#endif
}
static int async1(MYSQL *my)
static int async1(MYSQL *unused __attribute__((unused)))
{
int err= 0, rc;
MYSQL mysql, *ret;
@@ -211,7 +211,7 @@ static int async1(MYSQL *my)
return OK;
}
static int test_conc131(MYSQL *my)
static int test_conc131(MYSQL *unused __attribute__((unused)))
{
int rc;
/* this test needs to run under valgrind */
@@ -227,7 +227,7 @@ static int test_conc131(MYSQL *my)
return OK;
}
static int test_conc129(MYSQL *my)
static int test_conc129(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;

View File

@@ -40,7 +40,7 @@ static int test_conc75(MYSQL *my)
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS);
my_test_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS);
rc= mysql_query(mysql, "DROP TABLE IF EXISTS a");
check_mysql_rc(rc, mysql);
@@ -72,7 +72,7 @@ static int test_conc75(MYSQL *my)
}
static int test_conc74(MYSQL *my)
static int test_conc74(MYSQL *unused __attribute__((unused)))
{
int rc;
MYSQL *mysql;
@@ -80,7 +80,7 @@ static int test_conc74(MYSQL *my)
mysql= mysql_init(NULL);
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS))
if (!my_test_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS))
{
diag("Error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -119,7 +119,7 @@ static int test_conc71(MYSQL *my)
mysql_options(mysql, MYSQL_INIT_COMMAND, "/*!40101 SET SQL_MODE='' */");
mysql_options(mysql, MYSQL_INIT_COMMAND, "/*!40101 set @@session.wait_timeout=28800 */");
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
diag("kill server");
@@ -149,7 +149,7 @@ static int test_conc70(MYSQL *my)
mysql_query(my, "SET global max_allowed_packet=1024*1024*22");
mysql_options(mysql, MYSQL_OPT_COMPRESS, (void *)1);
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
@@ -207,7 +207,7 @@ static int test_conc68(MYSQL *my)
mysql_query(my, "SET global max_allowed_packet=1024*1024*22");
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
@@ -247,7 +247,7 @@ static int test_conc68(MYSQL *my)
}
static int basic_connect(MYSQL *mysql)
static int basic_connect(MYSQL *unused __attribute__((unused)))
{
MYSQL_ROW row;
MYSQL_RES *res;
@@ -257,7 +257,7 @@ static int basic_connect(MYSQL *mysql)
MYSQL *my= mysql_init(NULL);
FAIL_IF(!my, "mysql_init() failed");
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(my, "SELECT @@version");
@@ -371,7 +371,7 @@ static int test_bug12001(MYSQL *mysql)
/* connection options */
struct my_option_st opt_utf8[] = {
{MYSQL_SET_CHARSET_NAME, "utf8"},
{MYSQL_SET_CHARSET_NAME, (char *)"utf8"},
{0, NULL}
};
@@ -647,7 +647,7 @@ static int test_status(MYSQL *mysql)
static int bug_conc1(MYSQL *mysql)
{
mysql_real_connect(mysql, hostname, username, password, schema,
my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0);
diag("errno: %d", mysql_errno(mysql));
FAIL_IF(mysql_errno(mysql) != CR_ALREADY_CONNECTED,
@@ -655,7 +655,7 @@ static int bug_conc1(MYSQL *mysql)
return OK;
}
static int test_options_initcmd(MYSQL *my)
static int test_options_initcmd(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
MYSQL_RES *res;
@@ -663,7 +663,7 @@ static int test_options_initcmd(MYSQL *my)
mysql_options(mysql, MYSQL_INIT_COMMAND, "DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a int)");
mysql_options(mysql, MYSQL_INIT_COMMAND, "INSERT INTO t1 VALUES (1),(2),(3)");
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname,
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
@@ -678,7 +678,7 @@ static int test_options_initcmd(MYSQL *my)
return OK;
}
static int test_extended_init_values(MYSQL *my)
static int test_extended_init_values(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
@@ -692,7 +692,7 @@ static int test_extended_init_values(MYSQL *my)
return OK;
}
static int test_reconnect_maxpackage(MYSQL *my)
static int test_reconnect_maxpackage(MYSQL *unused __attribute__((unused)))
{
int rc;
ulong max_packet= 0;
@@ -708,7 +708,7 @@ static int test_reconnect_maxpackage(MYSQL *my)
SKIP_CONNECTION_HANDLER;
mysql= mysql_init(NULL);
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname,
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
@@ -752,7 +752,7 @@ static int test_reconnect_maxpackage(MYSQL *my)
return OK;
}
static int test_compressed(MYSQL *my)
static int test_compressed(MYSQL *unused __attribute__((unused)))
{
int rc;
MYSQL *mysql= mysql_init(NULL);
@@ -760,7 +760,7 @@ static int test_compressed(MYSQL *my)
my_bool reconnect= 1;
mysql_options(mysql, MYSQL_OPT_COMPRESS, (void *)1);
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname,
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);

View File

@@ -20,7 +20,7 @@
#define TEST_ARRAY_SIZE 1024
char *rand_str(size_t length) {
char charset[] = "0123456789"
const char charset[] = "0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *dest= (char *)malloc(length+1);
@@ -36,17 +36,17 @@ char *rand_str(size_t length) {
static int bulk1(MYSQL *mysql)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
char *stmt_str= "INSERT INTO bulk1 VALUES (?,?)";
unsigned long array_size= TEST_ARRAY_SIZE;
const char *stmt_str= "INSERT INTO bulk1 VALUES (?,?)";
unsigned int array_size= TEST_ARRAY_SIZE;
int rc;
int i;
unsigned int i;
char **buffer;
unsigned long *lengths;
unsigned int *vals;
MYSQL_BIND bind[2];
MYSQL_RES *res;
MYSQL_ROW row;
int intval;
unsigned int intval;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk1");
check_mysql_rc(rc, mysql);
@@ -60,7 +60,7 @@ static int bulk1(MYSQL *mysql)
/* allocate memory */
buffer= calloc(TEST_ARRAY_SIZE, sizeof(char *));
lengths= (unsigned long *)calloc(sizeof(long), TEST_ARRAY_SIZE);
vals= (int *)calloc(sizeof(int), TEST_ARRAY_SIZE);
vals= (unsigned int *)calloc(sizeof(int), TEST_ARRAY_SIZE);
for (i=0; i < TEST_ARRAY_SIZE; i++)
{
@@ -74,7 +74,7 @@ static int bulk1(MYSQL *mysql)
bind[0].buffer= (int *)&vals[0];
bind[1].buffer_type= MYSQL_TYPE_STRING;
bind[1].buffer= (void *)buffer;
bind[1].length= (long *)lengths;
bind[1].length= (unsigned long *)lengths;
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
check_stmt_rc(rc, stmt);
@@ -130,9 +130,9 @@ static int bulk2(MYSQL *mysql)
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
int rc;
MYSQL_BIND bind;
int i;
unsigned long array_size=1024;
uchar indicator[1024];
unsigned int i;
unsigned int array_size=1024;
char indicator[1024];
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk2");
check_mysql_rc(rc, mysql);
@@ -159,6 +159,8 @@ static int bulk2(MYSQL *mysql)
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
mysql_stmt_close(stmt);
return OK;
}

View File

@@ -37,7 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/* set connection options */
struct my_option_st opt_bug8378[] = {
{MYSQL_SET_CHARSET_NAME, "gbk"},
{MYSQL_SET_CHARSET_NAME, (char *) "gbk"},
{0, NULL}
};
@@ -120,7 +120,7 @@ int test_escaping(MYSQL *mysql)
{
int i= 0, rc, len;
char out[20];
char *escape_chars[] = {"'", "\x0", "\n", "\r", "\\", "\0", NULL};
const char *escape_chars[] = {"'", "\x0", "\n", "\r", "\\", "\0", NULL};
/* reset sql_mode, mysql_change_user call doesn't reset it */
rc= mysql_query(mysql, "SET sql_mode=''");
@@ -659,9 +659,9 @@ static int test_bug_54100(MYSQL *mysql)
/* We need this internal function for the test */
static int test_utf16_utf32_noboms(MYSQL *mysql)
static int test_utf16_utf32_noboms(MYSQL *mysql __attribute__((unused)))
{
char *csname[]= {"utf16", "utf16le", "utf32", "utf8"};
const char *csname[]= {"utf16", "utf16le", "utf32", "utf8"};
MARIADB_CHARSET_INFO *csinfo[sizeof(csname)/sizeof(char*)];
const int UTF8= sizeof(csname)/sizeof(char*) - 1;
@@ -676,7 +676,7 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
int i, error;
size_t rc, in_len, out_len;
for (i= 0; i < sizeof(csname)/sizeof(char*); ++i)
for (i= 0; i < (int)(sizeof(csname)/sizeof(char*)); ++i)
{
csinfo[i]= mariadb_get_charset_by_name(csname[i]);
@@ -693,9 +693,9 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
out_len= sizeof(buffer);
diag("Converting %s->%s", csname[i], csname[UTF8]);
rc= mariadb_convert_string(in_string[i], &in_len, csinfo[i], buffer, &out_len, csinfo[UTF8], &error);
rc= mariadb_convert_string((char *)in_string[i], &in_len, csinfo[i], buffer, &out_len, csinfo[UTF8], &error);
FAIL_IF(rc == -1, "Conversion failed");
FAIL_IF(rc == (size_t)-1, "Conversion failed");
FAIL_IF(rc != in_oct_len[UTF8], "Incorrect number of written bytes");
if (memcmp(buffer, in_string[UTF8], rc) != 0)
@@ -709,9 +709,9 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
out_len= sizeof(buffer);
diag("Converting %s->%s", csname[UTF8], csname[i]);
rc= mariadb_convert_string(in_string[UTF8], &in_len, csinfo[UTF8], buffer, &out_len, csinfo[i], &error);
rc= mariadb_convert_string((char *)in_string[UTF8], &in_len, csinfo[UTF8], buffer, &out_len, csinfo[i], &error);
FAIL_IF(rc==-1, "Conversion failed");
FAIL_IF(rc == (size_t)-1, "Conversion failed");
diag("rc=%lu oct_len: %lu", rc, in_oct_len[i]);
FAIL_IF(rc != in_oct_len[i], "Incorrect number of written bytes");
@@ -726,10 +726,10 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
return OK;
}
static int charset_auto(MYSQL *my)
static int charset_auto(MYSQL *my __attribute__((unused)))
{
const char *csname1, *csname2;
char *osname;
const char *osname;
MYSQL *mysql= mysql_init(NULL);
int rc;
@@ -737,7 +737,7 @@ static int charset_auto(MYSQL *my)
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, "auto");
FAIL_IF(!mysql_real_connect(mysql, hostname, username,
FAIL_IF(!my_test_connect(mysql, hostname, username,
password, schema, port, socketname, 0),
mysql_error(mysql));

View File

@@ -57,7 +57,7 @@ static int test_conc66(MYSQL *my)
check_mysql_rc(rc, my);
rc= mysql_query(my, "FLUSH PRIVILEGES");
check_mysql_rc(rc, my);
if (!mysql_real_connect(mysql, hostname, NULL,
if (!my_test_connect(mysql, hostname, NULL,
NULL, schema, port, socketname, 0))
{
diag("Error: %s", mysql_error(mysql));
@@ -441,13 +441,13 @@ static int test_bug31669(MYSQL *mysql)
}
/**
Bug# 33831 mysql_real_connect() should fail if
Bug# 33831 my_test_connect() should fail if
given an already connected MYSQL handle.
*/
static int test_bug33831(MYSQL *mysql)
{
FAIL_IF(mysql_real_connect(mysql, hostname, username,
FAIL_IF(my_test_connect(mysql, hostname, username,
password, schema, port, socketname, 0),
"Error expected");
@@ -476,7 +476,7 @@ static int test_opt_reconnect(MYSQL *mysql)
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
if (!(mysql_real_connect(mysql, hostname, username,
if (!(my_test_connect(mysql, hostname, username,
password, schema, port,
socketname, 0)))
{
@@ -496,7 +496,7 @@ static int test_opt_reconnect(MYSQL *mysql)
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
FAIL_UNLESS(reconnect == 0, "reconnect != 0");
if (!(mysql_real_connect(mysql, hostname, username,
if (!(my_test_connect(mysql, hostname, username,
password, schema, port,
socketname, 0)))
{
@@ -527,7 +527,7 @@ static int test_compress(MYSQL *mysql)
if (!(mysql_real_connect(mysql, hostname, username,
if (!(my_test_connect(mysql, hostname, username,
password, schema, port,
socketname, 0)))
{
@@ -565,7 +565,7 @@ static int test_reconnect(MYSQL *mysql)
mysql_get_option(mysql1, MYSQL_OPT_RECONNECT, &reconnect);
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
if (!(mysql_real_connect(mysql1, hostname, username,
if (!(my_test_connect(mysql1, hostname, username,
password, schema, port,
socketname, 0)))
{
@@ -599,7 +599,7 @@ int test_conc21(MYSQL *mysql)
MYSQL_RES *res= NULL;
MYSQL_ROW row;
char tmp[256];
int check_server_version= 0;
unsigned int check_server_version= 0;
int major=0, minor= 0, patch=0;
rc= mysql_query(mysql, "SELECT @@version");
@@ -621,12 +621,12 @@ int test_conc21(MYSQL *mysql)
return OK;
}
int test_conc26(MYSQL *my)
int test_conc26(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, "utf8");
FAIL_IF(mysql_real_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS),
FAIL_IF(my_test_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS),
"Error expected");
FAIL_IF(!mysql->options.charset_name || strcmp(mysql->options.charset_name, "utf8") != 0,
@@ -634,7 +634,7 @@ int test_conc26(MYSQL *my)
mysql_close(mysql);
mysql= mysql_init(NULL);
FAIL_IF(mysql_real_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, 0),
FAIL_IF(my_test_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, 0),
"Error expected");
FAIL_IF(mysql->options.charset_name, "Error: options not freed");
mysql_close(mysql);
@@ -642,14 +642,14 @@ int test_conc26(MYSQL *my)
return OK;
}
int test_connection_timeout(MYSQL *my)
int test_connection_timeout(MYSQL *unused __attribute__((unused)))
{
unsigned int timeout= 5;
time_t start, elapsed;
MYSQL *mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (unsigned int *)&timeout);
start= time(NULL);
if (mysql_real_connect(mysql, "192.168.1.101", "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
if (my_test_connect(mysql, "192.168.1.101", "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
{
diag("Error expected - maybe you have to change hostname");
return FAIL;
@@ -661,7 +661,7 @@ int test_connection_timeout(MYSQL *my)
return OK;
}
int test_connection_timeout2(MYSQL *my)
int test_connection_timeout2(MYSQL *unused __attribute__((unused)))
{
unsigned int timeout= 5;
time_t start, elapsed;
@@ -669,7 +669,7 @@ int test_connection_timeout2(MYSQL *my)
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (unsigned int *)&timeout);
mysql_options(mysql, MYSQL_INIT_COMMAND, "set @a:=SLEEP(6)");
start= time(NULL);
if (mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
if (my_test_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
{
diag("timeout error expected");
return FAIL;
@@ -681,7 +681,7 @@ int test_connection_timeout2(MYSQL *my)
return OK;
}
int test_connection_timeout3(MYSQL *my)
int test_connection_timeout3(MYSQL *unused __attribute__((unused)))
{
unsigned int timeout= 5;
unsigned int read_write_timeout= 10;
@@ -693,7 +693,7 @@ int test_connection_timeout3(MYSQL *my)
mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (unsigned int *)&read_write_timeout);
mysql_options(mysql, MYSQL_INIT_COMMAND, "set @a:=SLEEP(6)");
start= time(NULL);
if (mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
if (my_test_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
{
diag("timeout error expected");
elapsed= time(NULL) - start;
@@ -710,7 +710,7 @@ int test_connection_timeout3(MYSQL *my)
mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (unsigned int *)&read_write_timeout);
mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (unsigned int *)&read_write_timeout);
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
if (!my_test_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
{
diag("Error: %s", mysql_error(mysql));
return FAIL;
@@ -756,9 +756,9 @@ static int test_conc118(MYSQL *mysql)
return OK;
}
static int test_wrong_bind_address(MYSQL *my)
static int test_wrong_bind_address(MYSQL *unused __attribute__((unused)))
{
char *bind_addr= "100.188.111.112";
const char *bind_addr= "100.188.111.112";
MYSQL *mysql;
if (!hostname || !strcmp(hostname, "localhost"))
@@ -770,7 +770,7 @@ static int test_wrong_bind_address(MYSQL *my)
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_BIND, bind_addr);
if (mysql_real_connect(mysql, hostname, username,
if (my_test_connect(mysql, hostname, username,
password, schema, port, socketname, 0))
{
diag("Error expected");
@@ -815,7 +815,7 @@ static int test_bind_address(MYSQL *my)
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_BIND, bind_addr);
if (!mysql_real_connect(mysql, bind_addr, username,
if (!my_test_connect(mysql, bind_addr, username,
password, schema, port, socketname, 0))
{
diag("Error: %s\n", mysql_error(mysql));
@@ -827,7 +827,7 @@ static int test_bind_address(MYSQL *my)
return OK;
}
static int test_get_options(MYSQL *my)
static int test_get_options(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
int options_int[]= {MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_LOCAL_INFILE,
@@ -843,18 +843,19 @@ static int test_get_options(MYSQL *my)
MYSQL_OPT_SSL_CIPHER, MYSQL_OPT_BIND, MARIADB_OPT_SSL_FP, MARIADB_OPT_SSL_FP_LIST,
MARIADB_OPT_TLS_PASSPHRASE, 0};
char *init_command[3]= {"SET @a:=1", "SET @b:=2", "SET @c:=3"};
const char *init_command[3]= {"SET @a:=1", "SET @b:=2", "SET @c:=3"};
int elements= 0;
char **command;
int intval[2]= {1, 0};
my_bool boolval[2]= {1, 0};
char *char1= "test", *char2;
const char *char1= "test";
char *char2;
int i;
MYSQL *userdata;
char *attr_key[] = {"foo1", "foo2", "foo3"};
char *attr_val[] = {"bar1", "bar2", "bar3"};
const char *attr_key[] = {"foo1", "foo2", "foo3"};
const char *attr_val[] = {"bar1", "bar2", "bar3"};
char **key, **val;
for (i=0; options_int[i]; i++)
@@ -906,7 +907,7 @@ static int test_get_options(MYSQL *my)
free(val);
mysql_optionsv(mysql, MARIADB_OPT_USERDATA, "my_app", (void *)mysql);
mysql_get_optionv(mysql, MARIADB_OPT_USERDATA, "my_app", &userdata);
mysql_get_optionv(mysql, MARIADB_OPT_USERDATA, (char *)"my_app", &userdata);
FAIL_IF(mysql != userdata, "wrong userdata");
mysql_close(mysql);
@@ -921,7 +922,7 @@ static int test_sess_track_db(MYSQL *mysql)
if (!(mysql->server_capabilities & CLIENT_SESSION_TRACKING))
{
diag("Server doesn't support session tracking (cap=%llu)", mysql->server_capabilities);
diag("Server doesn't support session tracking (cap=%lu)", mysql->server_capabilities);
return SKIP;
}
@@ -941,13 +942,15 @@ static int test_sess_track_db(MYSQL *mysql)
"session_track_get_first failed");
FAIL_IF(strncmp(data, "testc", len), "Expected new schema 'testc'");
diag("charset: %s", mysql->charset->csname);
rc= mysql_query(mysql, "SET NAMES utf8");
check_mysql_rc(rc, mysql);
FAIL_IF(strcmp(mysql->charset->csname, "utf8"), "Expected charset 'utf8'");
if (!mysql_session_track_get_first(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &len))
do {
printf("# SESSION_TRACK_VARIABLES: %*.*s\n", (int)len, (int)len, data);
} while (!mysql_session_track_get_next(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &len));
diag("charset: %s", mysql->charset->csname);
FAIL_IF(strcmp(mysql->charset->csname, "utf8"), "Expected charset 'utf8'");
rc= mysql_query(mysql, "SET NAMES latin1");
check_mysql_rc(rc, mysql);

View File

@@ -24,11 +24,21 @@ static int create_dyncol_named(MYSQL *mysql)
DYNAMIC_COLUMN_VALUE *vals;
uint i, column_count= 6;
int rc;
char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5", "Val6"};
MYSQL_LEX_STRING keys1[]= {{"key1", 4}, {"key2", 4}, {"key3", 4}, {"key4", 4}, {"key5", 4}, {"key6", 4}},
keys2[]= {{"key1", 4}, {"key1", 4}, {"key3", 4}, {"key4", 4}, {"key5", 4}, {"key6", 4}},
keys3[]= {{"\x70\x61\x72\x61\x00\x30", 6}, {"\x70\x61\x72\x61\x00\x31", 6}, {"\x70\x61\x72\x61\x00\x32", 6},
{"\x70\x61\x72\x61\x00\x33", 6}, {"\x70\x61\x72\x61\x00\x34", 6}, {"\x70\x61\x72\x61\x00\x35", 6}};
const char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5", "Val6"};
MYSQL_LEX_STRING keys1[]= {{(char *)"key1", 4}, {(char *)"key2", 4},
{(char *)"key3", 4}, {(char *)"key4", 4},
{(char *)"key5", 4}, {(char *)"key6", 4}},
keys2[]= {{(char *)"key1", 4}, {(char *)"key1", 4},
{(char *)"key3", 4}, {(char *)"key4", 4},
{(char *)"key5", 4}, {(char *)"key6", 4}},
keys3[]= {{(char *)"\x70\x61\x72\x61\x00\x30", 6},
{(char *)"\x70\x61\x72\x61\x00\x31", 6},
{(char *)"\x70\x61\x72\x61\x00\x32", 6},
{(char *)"\x70\x61\x72\x61\x00\x33", 6},
{(char *)"\x70\x61\x72\x61\x00\x34", 6},
{(char *)"\x70\x61\x72\x61\x00\x35", 6}};
MYSQL_LEX_STRING *my_keys;
uint my_count;
@@ -37,7 +47,7 @@ static int create_dyncol_named(MYSQL *mysql)
for (i=0; i < column_count; i++)
{
vals[i].type= DYN_COL_STRING;
vals[i].x.string.value.str= strval[i];
vals[i].x.string.value.str= (char *)strval[i];
vals[i].x.string.value.length= strlen(strval[i]);
vals[i].x.string.charset= (MARIADB_CHARSET_INFO *)mysql->charset;
diag("%s", keys3[i].str);
@@ -87,7 +97,7 @@ static int create_dyncol_named(MYSQL *mysql)
FAIL_IF(rc < 0, "update failed");
mariadb_dyncol_free(&dyncol);
keys3[0].str= "test";
keys3[0].str= (char *)"test";
for (i=0; i < column_count; i++)
diag("%s", my_keys[i].str);
@@ -96,7 +106,7 @@ static int create_dyncol_named(MYSQL *mysql)
return OK;
}
static int mdev_4994(MYSQL *mysql)
static int mdev_4994(MYSQL *unused __attribute__((unused)))
{
DYNAMIC_COLUMN dyncol;
uint key= 1;
@@ -121,22 +131,22 @@ static int create_dyncol_num(MYSQL *mysql)
MYSQL_LEX_STRING *my_keys;
DYNAMIC_COLUMN_VALUE *my_vals;
int rc;
char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
const char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
uint keys1[5]= {1,2,3,4,5},
keys2[5]= {1,2,2,4,5};
MYSQL_LEX_STRING key1= {"1",1};
MYSQL_LEX_STRING key1= {(char *)"1",1};
for (i=0; i < column_count; i++)
{
vals[i].type= DYN_COL_STRING;
vals[i].x.string.value.str= strval[i];
vals[i].x.string.value.str= (char *)strval[i];
vals[i].x.string.value.length= strlen(strval[i]);
vals[i].x.string.charset= (MARIADB_CHARSET_INFO *)mysql->charset;
}
FAIL_IF(mariadb_dyncol_create_many_num(&dyncol, column_count, keys1, vals, 1) <0, "Error (keys1)");
vals[0].x.string.value.str= strval[1];
vals[0].x.string.value.str= (char *)strval[1];
rc= mariadb_dyncol_update_many_named(&dyncol,1, &key1, vals);
diag("update: %d", rc);
@@ -163,10 +173,10 @@ static int mdev_x1(MYSQL *mysql)
int rc;
uint i;
uint num_keys[5]= {1,2,3,4,5};
char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
const char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
DYNAMIC_COLUMN_VALUE vals[5];
DYNAMIC_COLUMN dynstr;
MYSQL_LEX_STRING my_key= {"1", 2};
MYSQL_LEX_STRING my_key= {(char *)"1", 2};
uint unpack_columns;
MYSQL_LEX_STRING *unpack_keys;
DYNAMIC_COLUMN_VALUE *unpack_vals;
@@ -174,7 +184,7 @@ static int mdev_x1(MYSQL *mysql)
for (i=0; i < 5; i++)
{
vals[i].type= DYN_COL_STRING;
vals[i].x.string.value.str= strval[i];
vals[i].x.string.value.str= (char *)strval[i];
vals[i].x.string.value.length= strlen(strval[i]);
vals[i].x.string.charset= (MARIADB_CHARSET_INFO *)mysql->charset;
}
@@ -233,7 +243,7 @@ static int mdev_x1(MYSQL *mysql)
return OK;
}
static int dyncol_column_count(MYSQL *mysql)
static int dyncol_column_count(MYSQL *unused __attribute__((unused)))
{
DYNAMIC_COLUMN dyncol;
uint column_count= 5;

View File

@@ -44,7 +44,7 @@ static int test_ps_client_warnings(MYSQL *mysql)
{
int rc;
MYSQL_STMT *stmt;
char *query= "DROP TABLE IF EXISTS test_non_exists";
const char *query= "DROP TABLE IF EXISTS test_non_exists";
rc= mysql_query(mysql, "DROP TABLE if exists test_non_exists");
check_mysql_rc(rc, mysql);
@@ -109,7 +109,7 @@ static int test_ps_client_errors(MYSQL *mysql)
{
int rc;
MYSQL_STMT *stmt;
char *query= "DROP TABLE test_non_exists";
const char *query= "DROP TABLE test_non_exists";
rc= mysql_query(mysql, "DROP TABLE if exists test_non_exists");
check_mysql_rc(rc, mysql);

View File

@@ -175,7 +175,7 @@ static int com_multi_ps2(MYSQL *mysql)
MYSQL_BIND bind[2];
int intval= 3, rc;
int i;
char *varval= "com_multi_ps2";
const char *varval= "com_multi_ps2";
unsigned int param_count= 2;
if (!have_com_multi)
@@ -189,7 +189,7 @@ static int com_multi_ps2(MYSQL *mysql)
bind[0].buffer_type= MYSQL_TYPE_SHORT;
bind[0].buffer= &intval;
bind[1].buffer_type= MYSQL_TYPE_STRING;
bind[1].buffer= varval;
bind[1].buffer= (char *)varval;
bind[1].buffer_length= strlen(varval);
stmt= mysql_stmt_init(mysql);
@@ -271,7 +271,7 @@ static int execute_direct_example(MYSQL *mysql)
MYSQL_BIND bind[2];
int intval= 1;
int param_count= 2;
char *strval= "execute_direct_example";
const char *strval= "execute_direct_example";
/* Direct execution without parameters */
if (mariadb_stmt_execute_direct(stmt, "DROP TABLE IF EXISTS execute_direct", -1))
@@ -283,7 +283,7 @@ static int execute_direct_example(MYSQL *mysql)
bind[0].buffer_type= MYSQL_TYPE_SHORT;
bind[0].buffer= &intval;
bind[1].buffer_type= MYSQL_TYPE_STRING;
bind[1].buffer= strval;
bind[1].buffer= (char *)strval;
bind[1].buffer_length= strlen(strval);
/* set number of parameters */

View File

@@ -187,7 +187,7 @@ static int test_fetch_seek(MYSQL *mysql)
int rc;
int32 c1;
char c2[11], c3[20];
char *query = "SELECT * FROM t1";
const char *query = "SELECT * FROM t1";
rc= mysql_query(mysql, "drop table if exists t1");
check_mysql_rc(rc, mysql);
@@ -268,19 +268,19 @@ static int test_fetch_seek(MYSQL *mysql)
static int test_fetch_offset(MYSQL *mysql)
{
MYSQL_STMT *stmt;
MYSQL_BIND my_bind[1];
char data[11];
ulong length;
MYSQL_BIND my_bind[2];
char data[11], chunk[5];
ulong length[2];
int rc;
my_bool is_null;
char *query = "SELECT * FROM t1";
my_bool is_null[2];
const char *query = "SELECT * FROM t1";
rc= mysql_query(mysql, "drop table if exists t1");
check_mysql_rc(rc, mysql);
rc= mysql_query(mysql, "create table t1(a char(10))");
rc= mysql_query(mysql, "create table t1(a char(10), b mediumblob)");
check_mysql_rc(rc, mysql);
rc= mysql_query(mysql, "insert into t1 values('abcdefghij'), (null)");
rc= mysql_query(mysql, "insert into t1 values('abcdefghij', 'klmnopqrstzy'), (null, null)");
check_mysql_rc(rc, mysql);
stmt= mysql_stmt_init(mysql);
@@ -293,8 +293,14 @@ static int test_fetch_offset(MYSQL *mysql)
my_bind[0].buffer_type= MYSQL_TYPE_STRING;
my_bind[0].buffer= (void *)data;
my_bind[0].buffer_length= 11;
my_bind[0].is_null= &is_null;
my_bind[0].length= &length;
my_bind[0].is_null= &is_null[0];
my_bind[0].length= &length[0];
my_bind[1].buffer_type= MYSQL_TYPE_MEDIUM_BLOB;
my_bind[1].buffer= NULL;
my_bind[1].buffer_length= 0;
my_bind[1].is_null= &is_null[1];
my_bind[1].length= &length[1];
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc,stmt);
@@ -312,32 +318,60 @@ static int test_fetch_offset(MYSQL *mysql)
check_stmt_rc(rc,stmt);
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc,stmt);
FAIL_UNLESS(rc == MYSQL_DATA_TRUNCATED, "rc != MYSQL_DATA_TRUNCATED");
data[0]= '\0';
rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0);
rc= mysql_stmt_fetch_column(stmt, &my_bind[0], 0, 0);
check_stmt_rc(rc,stmt);
FAIL_IF(!(strncmp(data, "abcd", 4) == 0 && length == 10), "Wrong value");
FAIL_IF(!(strncmp(data, "abcdefghij", 11) == 0 && length[0] == 10), "Wrong value");
FAIL_IF(my_bind[0].error_value, "No truncation, but error is set");
rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 5);
rc= mysql_stmt_fetch_column(stmt, &my_bind[0], 0, 5);
check_stmt_rc(rc,stmt);
FAIL_IF(!(strncmp(data, "fg", 2) == 0 && length == 10), "Wrong value");
FAIL_IF(!(strncmp(data, "fghij", 6) == 0 && length[0] == 10), "Wrong value");
FAIL_IF(my_bind[0].error_value, "No truncation, but error is set");
rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 9);
rc= mysql_stmt_fetch_column(stmt, &my_bind[0], 0, 9);
check_stmt_rc(rc,stmt);
FAIL_IF(!(strncmp(data, "j", 1) == 0 && length == 10), "Wrong value");
FAIL_IF(!(strncmp(data, "j", 2) == 0 && length[0] == 10), "Wrong value");
FAIL_IF(my_bind[0].error_value, "No truncation, but error is set");
/* Now blob field */
my_bind[1].buffer= chunk;
my_bind[1].buffer_length= sizeof(chunk);
rc= mysql_stmt_fetch_column(stmt, &my_bind[1], 1, 0);
check_stmt_rc(rc,stmt);
FAIL_IF(!(strncmp(chunk, "klmno", 5) == 0 && length[1] == 12), "Wrong value");
FAIL_IF(my_bind[1].error_value == '\0', "Truncation, but error is not set");
rc= mysql_stmt_fetch_column(stmt, &my_bind[1], 1, 5);
check_stmt_rc(rc,stmt);
FAIL_IF(!(strncmp(chunk, "pqrst", 5) == 0 && length[1] == 12), "Wrong value");
FAIL_IF(my_bind[1].error_value == '\0', "Truncation, but error is not set");
rc= mysql_stmt_fetch_column(stmt, &my_bind[1], 1, 10);
check_stmt_rc(rc,stmt);
FAIL_IF(!(strncmp(chunk, "zy", 2) == 0 && length[1] == 12), "Wrong value");
FAIL_IF(my_bind[1].error_value, "No truncation, but error is set");
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc,stmt);
is_null= 0;
memset(is_null, 0, sizeof(is_null));
rc= mysql_stmt_fetch_column(stmt, my_bind, 0, 0);
rc= mysql_stmt_fetch_column(stmt, &my_bind[0], 0, 0);
check_stmt_rc(rc,stmt);
FAIL_IF(is_null != 1, "Null flag not set");
FAIL_IF(is_null[0] != 1, "Null flag not set");
rc= mysql_stmt_fetch_column(stmt, &my_bind[1], 1, 0);
check_stmt_rc(rc,stmt);
FAIL_IF(is_null[1] != 1, "Null flag not set");
rc= mysql_stmt_fetch(stmt);
FAIL_IF(rc != MYSQL_NO_DATA, "Expected MYSQL_NO_DATA");
@@ -362,7 +396,7 @@ static int test_fetch_column(MYSQL *mysql)
char c2[20], bc2[20];
ulong l1, l2, bl1, bl2;
int rc, c1, bc1;
char *query= "SELECT * FROM t1 ORDER BY c2 DESC";
const char *query= "SELECT * FROM t1 ORDER BY c2 DESC";
rc= mysql_query(mysql, "drop table if exists t1");
check_mysql_rc(rc, mysql);
@@ -482,7 +516,7 @@ static int test_fetch_nobuffs(MYSQL *mysql)
MYSQL_BIND my_bind[4];
char str[4][50];
int rc;
char *query = "SELECT DATABASE(), CURRENT_USER(), \
const char *query = "SELECT DATABASE(), CURRENT_USER(), \
CURRENT_DATE(), CURRENT_TIME()";
stmt = mysql_stmt_init(mysql);
@@ -619,7 +653,7 @@ static int test_fetch_date(MYSQL *mysql)
MYSQL_BIND my_bind[8];
my_bool is_null[8];
ulong length[8];
char *query= "SELECT * FROM test_bind_result";
const char *query= "SELECT * FROM test_bind_result";
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result");
check_mysql_rc(rc, mysql);

View File

@@ -164,7 +164,7 @@ static int bug31418_impl()
return OK;
}
static int test_bug31418(MYSQL *mysql)
static int test_bug31418(MYSQL *unused __attribute__((unused)))
{
int i;
/* Run test case for BUG#31418 for three different connections. */
@@ -312,7 +312,7 @@ static int test_wl4166_1(MYSQL *mysql)
ulong length[7];
my_bool is_null[7];
MYSQL_BIND my_bind[7];
static char *query;
const char *query;
int rc;
int i;
@@ -910,7 +910,7 @@ static int test_connect_attrs(MYSQL *my)
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "foo1", "bar1");
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "foo2", "bar2");
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
if (!(mysql->server_capabilities & CLIENT_CONNECT_ATTRS))
@@ -955,11 +955,11 @@ static int test_conc_114(MYSQL *mysql)
}
/* run with valgrind */
static int test_conc117(MYSQL *mysql)
static int test_conc117(MYSQL *unused __attribute__((unused)))
{
my_bool reconnect= 1;
MYSQL *my= mysql_init(NULL);
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
mysql_kill(my, mysql_thread_id(my));
@@ -973,12 +973,12 @@ static int test_conc117(MYSQL *mysql)
return OK;
}
static int test_read_timeout(MYSQL *mysql)
static int test_read_timeout(MYSQL *unused __attribute__((unused)))
{
int timeout= 5, rc;
MYSQL *my= mysql_init(NULL);
mysql_options(my, MYSQL_OPT_READ_TIMEOUT, &timeout);
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(my, "SELECT SLEEP(50)");
@@ -1034,7 +1034,7 @@ static int test_remote2(MYSQL *my)
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "http://localhost/test.cnf");
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "test");
mysql_real_connect(mysql, hostname, username, password, schema,
my_test_connect(mysql, hostname, username, password, schema,
0, socketname, 0), mysql_error(my);
diag("port: %d", mysql->port);
mysql_close(mysql);
@@ -1122,7 +1122,7 @@ static int test_zerofill(MYSQL *mysql)
rc= mysql_query(mysql, "SELECT a FROM t1");
check_mysql_rc(rc, mysql);
if (res= mysql_store_result(mysql))
if ((res= mysql_store_result(mysql)))
{
row= mysql_fetch_row(res);
diag("zerofill: %s", row[0]);

View File

@@ -113,15 +113,25 @@ struct my_tests_st
int connection;
ulong connect_flags;
struct my_option_st *options;
char *skipmsg;
const char *skipmsg;
};
static char *schema = 0;
MYSQL *my_test_connect(MYSQL *mysql,
const char *host,
const char *user,
const char *passwd,
const char *db,
unsigned int port,
const char *unix_socket,
unsigned long clientflag);
static const char *schema = 0;
static char *hostname = 0;
static char *password = 0;
static unsigned int port = 0;
static char *socketname = 0;
static char *username = 0;
static int force_tls= 0;
/*
static struct my_option test_options[] =
{
@@ -159,11 +169,13 @@ static struct my_option test_options[] =
int do_verify_prepare_field(MYSQL_RES *result,
unsigned int no, const char *name,
const char *org_name,
enum enum_field_types type,
enum enum_field_types type __attribute__((unused)),
const char *table,
const char *org_table, const char *db,
unsigned long length, const char *def,
const char *file, int line)
unsigned long length __attribute__((unused)),
const char *def __attribute__((unused)),
const char *file __attribute__((unused)),
int line __attribute__((unused)))
{
MYSQL_FIELD *field;
/* MARIADB_CHARSET_INFO *cs; */
@@ -311,6 +323,7 @@ static void usage()
printf("-p password\n");
printf("-d database\n");
printf("-S socketname\n");
printf("-t force use of TLS\n");
printf("-P port number\n");
printf("? displays this help and exits\n");
}
@@ -319,7 +332,7 @@ void get_options(int argc, char **argv)
{
int c= 0;
while ((c=getopt(argc,argv, "h:u:p:d:P:S:?")) >= 0)
while ((c=getopt(argc,argv, "h:u:p:d:w:P:S:t:?")) >= 0)
{
switch(c) {
case 'h':
@@ -340,6 +353,9 @@ void get_options(int argc, char **argv)
case 'S':
socketname= optarg;
break;
case 't':
force_tls= 1;
break;
case '?':
usage();
exit(0);
@@ -353,7 +369,7 @@ void get_options(int argc, char **argv)
}
int check_variable(MYSQL *mysql, char *variable, char *value)
int check_variable(MYSQL *mysql, const char *variable, const char *value)
{
char query[MAX_TEST_QUERY_LENGTH];
MYSQL_RES *result;
@@ -379,7 +395,8 @@ int check_variable(MYSQL *mysql, char *variable, char *value)
* returns a new connection. This function will be called, if the test doesn't
* use default_connection.
*/
MYSQL *test_connect(struct my_tests_st *test) {
MYSQL *test_connect(struct my_tests_st *test)
{
MYSQL *mysql;
int i= 0;
int timeout= 10;
@@ -388,7 +405,6 @@ MYSQL *test_connect(struct my_tests_st *test) {
diag("%s", "mysql_init failed - exiting");
return(NULL);
}
mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, &truncation_report);
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
@@ -406,7 +422,7 @@ MYSQL *test_connect(struct my_tests_st *test) {
i++;
}
}
if (!(mysql_real_connect(mysql, hostname, username, password,
if (!(my_test_connect(mysql, hostname, username, password,
schema, port, socketname, (test) ? test->connect_flags:0)))
{
diag("Couldn't establish connection to server %s. Error (%d): %s",
@@ -448,10 +464,33 @@ void get_envvars() {
schema= "testc";
if (!port && (envvar= getenv("MYSQL_TEST_PORT")))
port= atoi(envvar);
if (!force_tls && (envvar= getenv("MYSQL_TEST_TLS")))
force_tls= atoi(envvar);
if (!socketname && (envvar= getenv("MYSQL_TEST_SOCKET")))
socketname= envvar;
}
MYSQL *my_test_connect(MYSQL *mysql,
const char *host,
const char *user,
const char *passwd,
const char *db,
unsigned int port,
const char *unix_socket,
unsigned long clientflag)
{
if (force_tls)
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &force_tls);
mysql= mysql_real_connect(mysql, host, user, passwd, db, port, unix_socket, clientflag);
if (mysql && force_tls && !mysql_get_ssl_cipher(mysql))
{
diag("Error: TLS connection not established");
return NULL;
}
return mysql;
}
void run_tests(struct my_tests_st *test) {
int i, rc, total=0;
MYSQL *mysql, *mysql_default= NULL; /* default connection */

View File

@@ -0,0 +1,76 @@
/*
Copyright (c) 2016 MariaDB Corporation AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
Some basic tests of the client API.
*/
#include "my_test.h"
#include "ma_common.h"
static int perf1(MYSQL *mysql)
{
int rc;
MYSQL_STMT *stmt;
const char *stmtstr= "SELECT s.emp_no, s.salary, e.emp_no, e.first_name, e.last_name, e.gender FROM salaries s, employees e WHERE s.emp_no = e.emp_no";
rc= mysql_select_db(mysql, "employees");
if (rc)
{
diag("Employees database not installed");
return SKIP;
}
stmt= mysql_stmt_init(mysql);
diag("prepare");
rc= mysql_stmt_prepare(stmt, stmtstr, strlen(stmtstr));
check_stmt_rc(rc, stmt);
diag("execute");
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
diag("store");
rc= mysql_stmt_store_result(stmt);
check_stmt_rc(rc, stmt);
diag("fetch");
while (!mysql_stmt_fetch(stmt));
mysql_stmt_close(stmt);
return OK;
}
struct my_tests_st my_tests[] = {
{"perf1", perf1, TEST_CONNECTION_NEW, 0, NULL, NULL},
{NULL, NULL, 0, 0, NULL, NULL}
};
int main(int argc, char **argv)
{
if (argc > 1)
get_options(argc, argv);
get_envvars();
run_tests(my_tests);
return(exit_status());
}

View File

@@ -47,20 +47,20 @@ static int test_conc97(MYSQL *mysql)
return OK;
}
static int test_conc83(MYSQL *my)
static int test_conc83(MYSQL *unused __attribute__((unused)))
{
MYSQL_STMT *stmt;
int rc;
MYSQL *mysql= mysql_init(NULL);
my_bool reconnect= 1;
char *query= "SELECT 1,2,3 FROM DUAL";
const char *query= "SELECT 1,2,3 FROM DUAL";
stmt= mysql_stmt_init(mysql);
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
FAIL_IF(!(mysql_real_connect(mysql, hostname, username, password,
schema, port, socketname, 0)), "mysql_real_connect failed");
FAIL_IF(!(my_test_connect(mysql, hostname, username, password,
schema, port, socketname, 0)), "my_test_connect failed");
/* 1. Status is inited, so prepare should work */
@@ -91,7 +91,7 @@ static int test_conc60(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
char *query= "SELECT * FROM agendas";
const char *query= "SELECT * FROM agendas";
my_bool x= 1;
stmt= mysql_stmt_init(mysql);
@@ -184,7 +184,6 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
{
MYSQL_STMT *stmt= 0;
uint rc, i, count= row_count;
ulong length[4]= {0,0,0,0};
MYSQL_BIND my_bind[4];
my_bool is_null[4]= {0,0,0,0};
MYSQL_TIME tm[4];
@@ -203,7 +202,6 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
its members.
*/
memset(my_bind, '\0', sizeof(my_bind));
memset(tm, 0, sizeof(tm));
my_bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP;
my_bind[1].buffer_type= MYSQL_TYPE_TIME;
@@ -214,9 +212,7 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
{
my_bind[i].buffer= (void *) &tm[i];
my_bind[i].is_null= &is_null[i];
my_bind[i].length= &length[i];
my_bind[i].buffer_length= 30;
length[i]= 20;
my_bind[i].buffer_length= sizeof(MYSQL_TIME);
}
second_part= 0;
@@ -236,6 +232,7 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
{
for (i= 0; i < (int) array_elements(my_bind); i++)
{
memset(&tm[i], 0, sizeof(MYSQL_TIME));
tm[i].neg= 0;
tm[i].second_part= second_part+count;
if (my_bind[i].buffer_type != MYSQL_TYPE_TIME)
@@ -828,8 +825,8 @@ static int test_prepare_alter(MYSQL *mysql)
mysql_new= mysql_init(NULL);
FAIL_IF(!mysql_new, "mysql_init failed");
FAIL_IF(!(mysql_real_connect(mysql_new, hostname, username, password,
schema, port, socketname, 0)), "mysql_real_connect failed");
FAIL_IF(!(my_test_connect(mysql_new, hostname, username, password,
schema, port, socketname, 0)), "my_test_connect failed");
rc= mysql_query(mysql_new, "ALTER TABLE test_prep_alter change id id_new varchar(20)");
diag("Error: %d %s", mysql_errno(mysql_new), mysql_error(mysql_new));
check_mysql_rc(rc, mysql_new);
@@ -3414,7 +3411,6 @@ static int test_double_compare(MYSQL *mysql)
my_bind[1].buffer= (void *)&real_data;
my_bind[1].buffer_length= sizeof(real_data);
my_bind[1].length= &length[1];
length[1]= 10;
/* double */
my_bind[2].buffer_type= MYSQL_TYPE_DOUBLE;
@@ -3422,6 +3418,7 @@ static int test_double_compare(MYSQL *mysql)
tiny_data= 1;
strcpy(real_data, "10.2");
length[1]= strlen(real_data);
double_data= 34.5;
rc= mysql_stmt_bind_param(stmt, my_bind);
check_stmt_rc(rc, stmt);
@@ -3561,7 +3558,7 @@ static int test_multi_stmt(MYSQL *mysql)
MYSQL_BIND my_bind[2];
ulong length[2];
my_bool is_null[2];
static char *query;
const char *query;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_multi_table");
check_mysql_rc(rc, mysql);
@@ -3850,7 +3847,7 @@ static int test_order_param(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
static char *query;
const char *query;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
check_mysql_rc(rc, mysql);
@@ -4680,7 +4677,7 @@ static int test_long_data1(MYSQL *mysql)
int rc;
MYSQL_BIND bind[1];
char query[MAX_TEST_QUERY_LENGTH];
char *data= "12345";
const char *data= "12345";
rc= mysql_autocommit(mysql, TRUE);
check_mysql_rc(rc, mysql);
@@ -4718,7 +4715,7 @@ int test_blob_9000(MYSQL *mysql)
MYSQL_STMT *stmt;
int rc;
char buffer[9200];
char *query= "INSERT INTO tb9000 VALUES (?)";
const char *query= "INSERT INTO tb9000 VALUES (?)";
rc= mysql_query(mysql, "DROP TABLE IF EXISTS tb9000");
check_mysql_rc(rc, mysql);
@@ -4746,7 +4743,7 @@ int test_fracseconds(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
char *str= "SELECT NOW(6)";
const char *str= "SELECT NOW(6)";
char buffer[60], buffer1[60];
MYSQL_BIND bind[2];
@@ -4821,7 +4818,7 @@ int test_notrunc(MYSQL *mysql)
my_bool error= 0;
unsigned long len= 1;
char *query= "SELECT '1234567890', 'foo' FROM DUAL";
const char *query= "SELECT '1234567890', 'foo' FROM DUAL";
mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, &trunc);
@@ -4860,7 +4857,53 @@ int test_notrunc(MYSQL *mysql)
return OK;
}
static int test_bit2tiny(MYSQL *mysql)
{
MYSQL_BIND bind[2];
char data[11];
unsigned long length[2];
my_bool is_null[2], error[2];
const char *query = "SELECT val FROM justbit";
MYSQL_STMT *stmt;
int rc;
mysql_query(mysql, "DROP TABLE IF EXISTS justbit");
mysql_query(mysql, "CREATE TABLE justbit(val bit(1) not null)");
mysql_query(mysql, "INSERT INTO justbit values (1)");
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, query, strlen(query));
check_stmt_rc(rc, stmt);
memset(bind, '\0', sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[0].buffer= &data[0];
bind[0].buffer_length= 1;
bind[0].is_null= &is_null[0];
bind[0].length= &length[0];
bind[0].error= &error[0];
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_bind_result(stmt, bind);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_store_result(stmt);
check_stmt_rc(rc, stmt);
mysql_stmt_fetch(stmt);
FAIL_IF(data[0] != 1, "Value should be 1");
mysql_stmt_free_result(stmt);
mysql_stmt_close(stmt);
return OK;
}
struct my_tests_st my_tests[] = {
{"test_bit2tiny", test_bit2tiny, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc97", test_conc97, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc83", test_conc83, TEST_CONNECTION_NONE, 0, NULL, NULL},
{"test_conc60", test_conc60, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},

View File

@@ -39,7 +39,7 @@ static int cmp_double(double *a, double *b)
static int test_conc67(MYSQL *mysql)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
char *query= "SELECT a,b FROM conc67 WHERE a=?";
const char *query= "SELECT a,b FROM conc67 WHERE a=?";
int rc, i;
MYSQL_BIND bind[2];
char val[20];
@@ -61,7 +61,7 @@ static int test_conc67(MYSQL *mysql)
check_stmt_rc(rc, stmt);
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS, &prefetch_rows);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_prepare(stmt, query, strlen(query));
check_stmt_rc(rc, stmt);
@@ -77,7 +77,7 @@ static int test_conc67(MYSQL *mysql)
res= mysql_stmt_result_metadata(stmt);
mysql_free_result(res);
memset(bind, 0, 2 * sizeof(MYSQL_BIND));
i= 0;
@@ -261,7 +261,7 @@ static int test_bug1180(MYSQL *mysql)
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
rowcount= 0;
while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
rowcount++;
@@ -528,9 +528,9 @@ static int test_bug12744(MYSQL *mysql)
rc= mysql_options(mysql, MYSQL_OPT_RECONNECT, "1");
check_mysql_rc(rc, mysql);
rc= mysql_kill(mysql, mysql_thread_id(mysql));
sleep(4);
rc= mysql_ping(mysql);
rc= mysql_ping(mysql);
check_mysql_rc(rc, mysql);
rc= mysql_stmt_close(stmt);
@@ -545,8 +545,8 @@ static int test_bug1500(MYSQL *mysql)
MYSQL_BIND my_bind[3];
int rc= 0;
int32 int_data[3]= {2, 3, 4};
char *data;
char *query;
const char *data;
const char *query;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bg1500");
@@ -1293,7 +1293,7 @@ static int test_bug23383(MYSQL *mysql)
rc= mysql_stmt_prepare(stmt, insert_query, strlen(insert_query));
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
check_stmt_rc(rc, stmt);
row_count= mysql_stmt_affected_rows(stmt);
FAIL_UNLESS(row_count == 2, "row_count != 2");
@@ -1305,7 +1305,7 @@ static int test_bug23383(MYSQL *mysql)
rc= mysql_stmt_prepare(stmt, update_query, strlen(update_query));
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
check_stmt_rc(rc, stmt);
row_count= mysql_stmt_affected_rows(stmt);
FAIL_UNLESS(row_count == 0, "rowcount != 0");
@@ -1901,22 +1901,22 @@ static int test_ps_query_cache(MYSQL *mysql)
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
test_ps_query_cache_result(1, "hh", 2, 2, "hh", 2, 1, "ii", 2);
r_metadata= mysql_stmt_result_metadata(stmt);
FAIL_UNLESS(r_metadata != NULL, "");
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc,stmt);
FAIL_UNLESS((r_int_data == 1) && (r_str_length == 2) &&
r_metadata= mysql_stmt_result_metadata(stmt);
FAIL_UNLESS(r_metadata != NULL, "");
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc,stmt);
FAIL_UNLESS((r_int_data == 1) && (r_str_length == 2) &&
(strcmp(r_str_data, "hh") == 0), "test_ps_query_cache_result failure"); \
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc,stmt);
FAIL_UNLESS((r_int_data == 2) && (r_str_length == 2) &&
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc,stmt);
FAIL_UNLESS((r_int_data == 2) && (r_str_length == 2) &&
(strcmp(r_str_data, "hh") == 0), "test_ps_query_cache_result failure"); \
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc,stmt);
FAIL_UNLESS((r_int_data == 1) && (r_str_length == 2) &&
rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc,stmt);
FAIL_UNLESS((r_int_data == 1) && (r_str_length == 2) &&
(strcmp(r_str_data, "ii") == 0), "test_ps_query_cache_result failure"); \
rc= mysql_stmt_fetch(stmt);
FAIL_UNLESS(rc == MYSQL_NO_DATA, "rc != MYSQL_NO_DATA");
rc= mysql_stmt_fetch(stmt);
FAIL_UNLESS(rc == MYSQL_NO_DATA, "rc != MYSQL_NO_DATA");
mysql_free_result(r_metadata);
@@ -2184,8 +2184,8 @@ static int test_bug4026(MYSQL *mysql)
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_stmt_rc(rc, stmt);
/* Bind input buffers */
memset(my_bind, '\0', sizeof(MYSQL_BIND) * 2);
memset(&time_in, '\0', sizeof(MYSQL_TIME));
memset(my_bind, '\0', sizeof(MYSQL_BIND) * 2);
memset(&time_in, '\0', sizeof(MYSQL_TIME));
memset(&time_out, '\0', sizeof(MYSQL_TIME));
memset(&datetime_in, '\0', sizeof(MYSQL_TIME));
memset(&datetime_out, '\0', sizeof(MYSQL_TIME));
@@ -2247,7 +2247,7 @@ static int test_bug4030(MYSQL *mysql)
stmt_text= "SELECT '23:59:59.123456', '2003-12-31', "
"'2003-12-31 23:59:59.123456'";
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_stmt_rc(rc, stmt);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
/* Bind output buffers */
@@ -2476,14 +2476,14 @@ static int test_bug4236(MYSQL *mysql)
stmt1= mysql_stmt_init(mysql1);
stmt_text= "SELECT 2";
rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text));
check_stmt_rc(rc, stmt);
check_stmt_rc(rc, stmt);
stmt->stmt_id= stmt1->stmt_id;
rc= mysql_stmt_execute(stmt);
FAIL_IF(!rc, "Error expected");
mysql_stmt_close(stmt1);
mysql_close(mysql1);
mysql_close(mysql1);
/* Restore original statement id to be able to reprepare it */
stmt->stmt_id= backup.stmt_id;
@@ -2516,7 +2516,7 @@ static int test_bug5126(MYSQL *mysql)
stmt= mysql_stmt_init(mysql);
stmt_text= "SELECT a, b FROM t1";
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_stmt_rc(rc, stmt);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
/* Bind output buffers */
@@ -2722,7 +2722,7 @@ static int test_bug5315(MYSQL *mysql)
rc= mysql_stmt_execute(stmt);
FAIL_UNLESS(rc != 0, "Error expected");
rc= mysql_stmt_close(stmt);
check_stmt_rc(rc, stmt);
@@ -2741,7 +2741,7 @@ static int test_bug5399(MYSQL *mysql)
Ascii 97 is 'a', which gets mapped to Ascii 65 'A' unless internal
statement id hash in the server uses binary collation.
*/
#define NUM_OF_USED_STMT 97
#define NUM_OF_USED_STMT 97
MYSQL_STMT *stmt_list[NUM_OF_USED_STMT];
MYSQL_STMT **stmt;
MYSQL_BIND my_bind[1];
@@ -3028,7 +3028,7 @@ static int test_bug8330(MYSQL *mysql)
int i, rc;
const char *query= "select a,b from t1 where a=?";
MYSQL_BIND my_bind[2];
long lval[2];
long lval[2]= {1,2};
stmt_text= "drop table if exists t1";
/* in case some previos test failed */
@@ -3344,7 +3344,7 @@ static int test_decimal_bug(MYSQL *mysql)
stmt= mysql_stmt_init(mysql);
FAIL_IF(!stmt, mysql_error(mysql));
rc= mysql_stmt_prepare(stmt, "select c1 from test_decimal_bug where c1=?",
rc= mysql_stmt_prepare(stmt, "select c1 from test_decimal_bug where c1=?",
strlen("select c1 from test_decimal_bug where c1=?"));
check_stmt_rc(rc, stmt);
@@ -3354,6 +3354,7 @@ static int test_decimal_bug(MYSQL *mysql)
*/
memset(my_bind, '\0', sizeof(my_bind));
memset(data, 0, sizeof(data));
my_bind[0].buffer_type= MYSQL_TYPE_NEWDECIMAL;
my_bind[0].buffer= (void *)data;
my_bind[0].buffer_length= 25;
@@ -3460,13 +3461,13 @@ static int test_explain_bug(MYSQL *mysql)
if (verify_prepare_field(result, 0, "Field", "COLUMN_NAME",
mysql_get_server_version(mysql) <= 50000 ?
MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING,
0, 0,
0, 0,
mysql_get_server_version(mysql) <= 50400 ? "" : "information_schema",
64, 0))
goto error;
if (verify_prepare_field(result, 1, "Type", "COLUMN_TYPE", MYSQL_TYPE_BLOB,
0, 0,
0, 0,
mysql_get_server_version(mysql) <= 50400 ? "" : "information_schema",
0, 0))
goto error;
@@ -3474,7 +3475,7 @@ static int test_explain_bug(MYSQL *mysql)
if (verify_prepare_field(result, 2, "Null", "IS_NULLABLE",
mysql_get_server_version(mysql) <= 50000 ?
MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING,
0, 0,
0, 0,
mysql_get_server_version(mysql) <= 50400 ? "" : "information_schema",
3, 0))
goto error;
@@ -3482,7 +3483,7 @@ static int test_explain_bug(MYSQL *mysql)
if (verify_prepare_field(result, 3, "Key", "COLUMN_KEY",
mysql_get_server_version(mysql) <= 50000 ?
MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING,
0, 0,
0, 0,
mysql_get_server_version(mysql) <= 50400 ? "" : "information_schema",
3, 0))
goto error;
@@ -3491,7 +3492,7 @@ static int test_explain_bug(MYSQL *mysql)
{
/* The patch for bug#23037 changes column type of DEAULT to blob */
if (verify_prepare_field(result, 4, "Default", "COLUMN_DEFAULT",
MYSQL_TYPE_BLOB, 0, 0,
MYSQL_TYPE_BLOB, 0, 0,
mysql_get_server_version(mysql) <= 50400 ? "" : "information_schema",
0, 0))
goto error;
@@ -3503,7 +3504,7 @@ static int test_explain_bug(MYSQL *mysql)
MYSQL_TYPE_BLOB :
mysql_get_server_version(mysql) <= 50000 ?
MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING,
0, 0,
0, 0,
mysql_get_server_version(mysql) <= 50400 ? "" : "information_schema",
mysql_get_server_version(mysql) >= 50027 ? 0 :64, 0))
goto error;
@@ -3512,7 +3513,7 @@ static int test_explain_bug(MYSQL *mysql)
if (verify_prepare_field(result, 5, "Extra", "EXTRA",
mysql_get_server_version(mysql) <= 50000 ?
MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING,
0, 0,
0, 0,
mysql_get_server_version(mysql) <= 50400 ? "" : "information_schema",
27, 0))
goto error;
@@ -3572,7 +3573,7 @@ static int test_explain_bug(MYSQL *mysql)
goto error;
}
if (verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING, "", "", "",
if (verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING, "", "", "",
NAME_CHAR_LEN*16, 0))
goto error;
@@ -3748,16 +3749,16 @@ static int test_bug53311(MYSQL *mysql)
int rc;
MYSQL_STMT *stmt;
int i;
char *query= "INSERT INTO bug53311 VALUES (1)";
const char *query= "INSERT INTO bug53311 VALUES (1)";
rc= mysql_options(mysql, MYSQL_OPT_RECONNECT, "1");
check_mysql_rc(rc, mysql);
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bug53311");
check_mysql_rc(rc, mysql);
check_mysql_rc(rc, mysql);
rc= mysql_query(mysql, "CREATE TABLE bug53311 (a int)");
check_mysql_rc(rc, mysql);
check_mysql_rc(rc, mysql);
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, query, strlen(query));
@@ -3768,7 +3769,7 @@ static int test_bug53311(MYSQL *mysql)
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
}
/* kill connection */
rc= mysql_kill(mysql, mysql_thread_id(mysql));
sleep(1);
@@ -3836,7 +3837,7 @@ end:
static int test_conc_5(MYSQL *mysql)
{
char *query= "SELECT a FROM t1";
const char *query= "SELECT a FROM t1";
MYSQL_RES *res;
MYSQL_STMT *stmt;
MYSQL_FIELD *fields;
@@ -3873,7 +3874,7 @@ static int test_conc_5(MYSQL *mysql)
static int test_conc141(MYSQL *mysql)
{
int rc;
char *query= "CALL p_conc141";
const char *query= "CALL p_conc141";
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
rc= mysql_query(mysql, "DROP TABLE IF EXISTS conc141");
@@ -4107,7 +4108,7 @@ static int test_conc167(MYSQL *mysql)
char buffer[100];
int bit1=0, bit2=0;
int rc;
char *stmt_str= "SELECT a,b,c FROM conc168";
const char *stmt_str= "SELECT a,b,c FROM conc168";
rc= mysql_query(mysql, "DROP TABLE IF EXISTS conc168");
check_mysql_rc(rc, mysql);
@@ -4153,7 +4154,7 @@ static int test_conc177(MYSQL *mysql)
MYSQL_STMT *stmt;
int rc;
MYSQL_BIND bind[2];
char *stmt_str= "SELECT a,b FROM t1";
const char *stmt_str= "SELECT a,b FROM t1";
char buf1[128], buf2[128];
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
@@ -4228,7 +4229,7 @@ static int test_conc179(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
char *stmtstr= "CREATE TABLE t1 (`blurb_id` int NOT NULL DEFAULT 0, `blurb` text default '', PRIMARY KEY (blurb_id)) ENGINE='FEDERATED' DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'";
const char *stmtstr= "CREATE TABLE t1 (`blurb_id` int NOT NULL DEFAULT 0, `blurb` text default '', PRIMARY KEY (blurb_id)) ENGINE='FEDERATED' DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'";
rc= mysql_query(mysql, "set sql_mode=''");
check_mysql_rc(rc, mysql);
@@ -4240,8 +4241,8 @@ static int test_conc179(MYSQL *mysql)
rc= mysql_stmt_prepare(stmt, stmtstr, strlen(stmtstr));
check_stmt_rc(rc, stmt);
FAIL_IF(mysql_warning_count(mysql) != 3, "expected 3 warnings");
FAIL_IF(mysql_stmt_warning_count(stmt) != 3, "expected 3 warnings");
FAIL_IF(mysql_warning_count(mysql) < 2, "expected 2 or more warnings");
FAIL_IF(mysql_stmt_warning_count(stmt) < 2, "expected 2 or more warnings");
mysql_stmt_close(stmt);
@@ -4300,7 +4301,7 @@ static int test_conc181(MYSQL *mysql)
MYSQL_STMT *stmt;
int rc;
MYSQL_BIND bind;
char *stmt_str= "SELECT a FROM t1";
const char *stmt_str= "SELECT a FROM t1";
float f=1;
my_bool err= 0;
@@ -4332,8 +4333,81 @@ static int test_conc181(MYSQL *mysql)
return OK;
}
static int test_conc198(MYSQL *mysql)
{
MYSQL_STMT *stmt1, *stmt2;
MYSQL_BIND my_bind[1];
int32 a;
int rc;
int num_rows= 0;
ulong type;
ulong prefetch_rows= 3;
mysql_query(mysql, "drop table if exists t1");
mysql_query(mysql, "create table t1 (id integer not null primary key)");
rc= mysql_query(mysql, "insert into t1 (id) values "
" (1), (2), (3), (4), (5), (6), (7), (8), (9)");
check_mysql_rc(rc, mysql);
stmt1= mysql_stmt_init(mysql);
stmt2= mysql_stmt_init(mysql);
/* Not implemented in 5.0 */
type= (ulong) CURSOR_TYPE_SCROLLABLE;
rc= mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (void*) &type);
FAIL_UNLESS(rc, "Error expected");
rc= mysql_stmt_attr_set(stmt2, STMT_ATTR_CURSOR_TYPE, (void*) &type);
FAIL_UNLESS(rc, "Error expected");
type= (ulong) CURSOR_TYPE_READ_ONLY;
rc= mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (void*) &type);
check_stmt_rc(rc, stmt1);
rc= mysql_stmt_attr_set(stmt2, STMT_ATTR_CURSOR_TYPE, (void*) &type);
check_stmt_rc(rc, stmt2);
rc= mysql_stmt_attr_set(stmt1, STMT_ATTR_PREFETCH_ROWS,
(void*) &prefetch_rows);
check_stmt_rc(rc, stmt1);
rc= mysql_stmt_attr_set(stmt2, STMT_ATTR_PREFETCH_ROWS,
(void*) &prefetch_rows);
check_stmt_rc(rc, stmt2);
rc= mysql_stmt_prepare(stmt1, "SELECT * FROM t1 ORDER by id ASC" , -1);
check_stmt_rc(rc, stmt1);
rc= mysql_stmt_prepare(stmt2, "SELECT * FROM t1 ORDER by id DESC", -1);
check_stmt_rc(rc, stmt2);
rc= mysql_stmt_execute(stmt1);
check_stmt_rc(rc, stmt1);
rc= mysql_stmt_execute(stmt2);
check_stmt_rc(rc, stmt2);
memset(my_bind, '\0', sizeof(my_bind));
my_bind[0].buffer_type= MYSQL_TYPE_LONG;
my_bind[0].buffer= (void*) &a;
my_bind[0].buffer_length= sizeof(a);
mysql_stmt_bind_result(stmt1, my_bind);
mysql_stmt_bind_result(stmt2, my_bind);
while ((rc= mysql_stmt_fetch(stmt1)) == 0)
++num_rows;
FAIL_UNLESS(num_rows == 9, "num_rows != 9");
num_rows= 0;
while ((rc= mysql_stmt_fetch(stmt2)) == 0)
++num_rows;
FAIL_UNLESS(num_rows == 9, "num_rows != 9");
rc= mysql_stmt_close(stmt1);
rc= mysql_stmt_close(stmt2);
FAIL_UNLESS(rc == 0, "");
rc= mysql_query(mysql, "drop table t1");
check_mysql_rc(rc, mysql);
return OK;
}
struct my_tests_st my_tests[] = {
{"test_conc198", test_conc198, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc182", test_conc182, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc181", test_conc181, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc179", test_conc179, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
@@ -4355,12 +4429,12 @@ struct my_tests_st my_tests[] = {
{"test_bug15510", test_bug15510, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug15518", test_bug15518, TEST_CONNECTION_NEW | TEST_CONNECTION_DONT_CLOSE, CLIENT_MULTI_STATEMENTS, NULL , NULL},
{"test_bug15613", test_bug15613, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug16144", test_bug16144, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug16144", test_bug16144, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug1664", test_bug1664, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug1946", test_bug1946, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug2247", test_bug2247, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug2248", test_bug2248, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug20152", test_bug20152, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug20152", test_bug20152, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug23383", test_bug23383, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug27592", test_bug27592, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug28934", test_bug28934, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
@@ -4374,8 +4448,8 @@ struct my_tests_st my_tests[] = {
{"test_bug4172", test_bug4172, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug4231", test_bug4231, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug4236", test_bug4236, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug5126", test_bug5126, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug5194", test_bug5194, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug5126", test_bug5126, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug5194", test_bug5194, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug5315", test_bug5315, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug5399", test_bug5399, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug6046", test_bug6046, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
@@ -4390,13 +4464,13 @@ struct my_tests_st my_tests[] = {
{"test_ps_null_param", test_ps_null_param, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_ps_query_cache", test_ps_query_cache, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_ushort_bug", test_ushort_bug, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_field_misc", test_field_misc, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_mem_overun", test_mem_overun, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_field_misc", test_field_misc, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_mem_overun", test_mem_overun, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_decimal_bug", test_decimal_bug, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_explain_bug", test_explain_bug, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_sshort_bug", test_sshort_bug, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_stiny_bug", test_stiny_bug, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
{"test_bug53311", test_bug53311, TEST_CONNECTION_NEW, 0, NULL , NULL},
{"test_bug53311", test_bug53311, TEST_CONNECTION_NEW, 0, NULL , NULL},
{NULL, NULL, 0, 0, NULL, NULL}
};

View File

@@ -135,7 +135,7 @@ int test_sp_params(MYSQL *mysql)
MYSQL_STMT *stmt;
int a[] = {10,20,30};
MYSQL_BIND bind[3];
char *stmtstr= "CALL P1(?,?,?)";
const char *stmtstr= "CALL P1(?,?,?)";
char res[3][20];
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
@@ -219,7 +219,7 @@ int test_sp_reset(MYSQL *mysql)
MYSQL_STMT *stmt;
int a[] = {10,20,30};
MYSQL_BIND bind[3];
char *stmtstr= "CALL P1(?,?,?)";
const char *stmtstr= "CALL P1(?,?,?)";
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
check_mysql_rc(rc, mysql);
@@ -274,7 +274,7 @@ int test_sp_reset1(MYSQL *mysql)
MYSQL_BIND bind[1];
char tmp[20];
char *stmtstr= "CALL P1(?)";
const char *stmtstr= "CALL P1(?)";
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
check_mysql_rc(rc, mysql);
@@ -332,7 +332,7 @@ int test_sp_reset2(MYSQL *mysql)
MYSQL_STMT *stmt;
MYSQL_BIND bind[4];
long l[4];
char *stmtstr= "CALL P1()";
const char *stmtstr= "CALL P1()";
memset(l, 0, sizeof(l));
@@ -425,7 +425,7 @@ int test_query(MYSQL *mysql)
MYSQL_BIND bind[1];
char tmp[20];
char *stmtstr= "CALL P1(?)";
const char *stmtstr= "CALL P1(?)";
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
check_mysql_rc(rc, mysql);

View File

@@ -123,7 +123,7 @@ static int test_ssl(MYSQL *mysql)
res= mysql_store_result(mysql);
row= mysql_fetch_row(res);
diag("user: %s", row[0]);
if (p= strchr(row[0], '@'))
if ((p= strchr(row[0], '@')))
strcpy(sslhost, p+1);
mysql_free_result(res);
}
@@ -131,7 +131,7 @@ static int test_ssl(MYSQL *mysql)
return OK;
}
static int test_ssl_cipher(MYSQL *unused)
static int test_ssl_cipher(MYSQL *unused __attribute__((unused)))
{
MYSQL *my;
MYSQL_RES *res;
@@ -162,7 +162,7 @@ static int test_ssl_cipher(MYSQL *unused)
return OK;
}
static int test_conc95(MYSQL *my)
static int test_conc95(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -180,7 +180,7 @@ static int test_conc95(MYSQL *my)
NULL);
if (!mysql_real_connect(mysql, hostname, "ssluser1", sslpw, schema,
port, socketname, 0))
port, socketname, 0))
{
diag("could not establish x509 connection. Error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -190,7 +190,7 @@ static int test_conc95(MYSQL *my)
return OK;
}
static int test_multi_ssl_connections(MYSQL *unused)
static int test_multi_ssl_connections(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql[50], *my;
int i, rc;
@@ -255,7 +255,7 @@ static int test_multi_ssl_connections(MYSQL *unused)
}
#ifndef WIN32
static void ssl_thread(void *dummy)
static void ssl_thread(void *unused __attribute__((unused)))
#else
DWORD WINAPI ssl_thread(void *dummy)
#endif
@@ -343,7 +343,7 @@ static int test_ssl_threads(MYSQL *mysql)
return OK;
}
static int test_phpbug51647(MYSQL *my)
static int test_phpbug51647(MYSQL *unused __attribute__((unused)))
{
MYSQL* mysql;
@@ -365,7 +365,7 @@ static int test_phpbug51647(MYSQL *my)
return OK;
}
static int test_password_protected(MYSQL *my)
static int test_password_protected(MYSQL *unused __attribute__((unused)))
{
MYSQL* mysql;
@@ -390,7 +390,7 @@ static int test_password_protected(MYSQL *my)
}
static int test_conc50(MYSQL *my)
static int test_conc50(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -411,7 +411,7 @@ static int test_conc50(MYSQL *my)
return OK;
}
static int test_conc50_1(MYSQL *my)
static int test_conc50_1(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -433,7 +433,7 @@ static int test_conc50_1(MYSQL *my)
return OK;
}
static int test_conc50_2(MYSQL *my)
static int test_conc50_2(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -453,10 +453,13 @@ static int test_conc50_2(MYSQL *my)
return OK;
}
static int test_conc127(MYSQL *my)
static int test_conc127(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
diag("test disabled - for testing disable other tests or run this test as first test");
return SKIP;
if (check_skip_ssl())
return SKIP;
@@ -474,7 +477,7 @@ static int test_conc127(MYSQL *my)
return OK;
}
static int test_conc50_3(MYSQL *my)
static int test_conc50_3(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -507,7 +510,7 @@ static int test_conc50_3(MYSQL *my)
return OK;
}
static int test_conc50_4(MYSQL *my)
static int test_conc50_4(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -527,7 +530,7 @@ static int test_conc50_4(MYSQL *my)
return OK;
}
static int verify_ssl_server_cert(MYSQL *my)
static int verify_ssl_server_cert(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
uint verify= 1;
@@ -550,7 +553,7 @@ static int verify_ssl_server_cert(MYSQL *my)
return OK;
}
static int test_bug62743(MYSQL *my)
static int test_bug62743(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -638,7 +641,7 @@ DWORD WINAPI thread_conc102(void)
check_mysql_rc(rc, mysql);
pthread_mutex_unlock(&LOCK_test);
check_mysql_rc(rc, mysql);
if (res= mysql_store_result(mysql))
if ((res= mysql_store_result(mysql)))
mysql_free_result(res);
end:
mysql_close(mysql);
@@ -702,7 +705,7 @@ static int test_conc_102(MYSQL *mysql)
const char *ssl_cert_finger_print= "@SSL_CERT_FINGER_PRINT@";
static int test_ssl_fp(MYSQL *unused)
static int test_ssl_fp(MYSQL *unused __attribute__((unused)))
{
MYSQL *my;
MYSQL_RES *res;
@@ -741,7 +744,7 @@ static int test_ssl_fp(MYSQL *unused)
return OK;
}
static int test_ssl_fp_list(MYSQL *unused)
static int test_ssl_fp_list(MYSQL *unused __attribute__((unused)))
{
MYSQL *my;
@@ -763,7 +766,7 @@ static int test_ssl_fp_list(MYSQL *unused)
return OK;
}
static int test_ssl_version(MYSQL *mysql)
static int test_ssl_version(MYSQL *unused __attribute__((unused)))
{
unsigned int iversion;
const char *version, *library;
@@ -794,7 +797,7 @@ static int test_ssl_version(MYSQL *mysql)
}
#ifdef HAVE_SCHANNEL
static int test_schannel_cipher(MYSQL *mysql)
static int test_schannel_cipher(MYSQL *unused __attribute__((unused)))
{
MYSQL *my;
unsigned int cipher_strength= 256;
@@ -819,11 +822,67 @@ static int test_schannel_cipher(MYSQL *mysql)
}
#endif
#ifdef HAVE_GNUTLS
static int test_cipher_mapping(MYSQL *unused __attribute__((unused)))
{
unsigned int i=0;
const char *ciphers[]= { "DHE-RSA-AES256-GCM-SHA384", "DHE-RSA-AES256-SHA256", "DHE-RSA-AES256-SHA",
"DHE-RSA-CAMELLIA256-SHA", "AES256-GCM-SHA384", "AES256-SHA256",
"AES256-SHA", "CAMELLIA256-SHA", "DHE-RSA-AES128-GCM-SHA256",
"DHE-RSA-AES128-SHA256", "DHE-RSA-AES128-SHA", "DHE-RSA-CAMELLIA128-SHA",
"AES128-GCM-SHA256", "AES128-SHA256", "AES128-SHA", "CAMELLIA128-SHA",
"EDH-RSA-DES-CBC3-SHA", "DES-CBC3-SHA", "DHE-RSA-AES256-SHA",
"DHE-RSA-CAMELLIA256-SHA", "AES256-SHA", "CAMELLIA256-SHA",
NULL };
if (check_skip_ssl())
return SKIP;
while (ciphers[i] != NULL)
{
MYSQL *mysql= mysql_init(NULL);
MYSQL_ROW row;
MYSQL_RES *res;
char c[100];
int rc;
mysql_options(mysql, MYSQL_OPT_SSL_CIPHER, ciphers[i]);
diag("%s", ciphers[i]);
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(mysql));
if (strcmp(ciphers[i], mysql_get_ssl_cipher(mysql)) != 0)
{
diag("expected: %s instead of %s", ciphers[i], mysql_get_ssl_cipher(mysql));
mysql_close(mysql);
return FAIL;
}
rc= mysql_query(mysql, "SHOW STATUS LIKE 'ssl_cipher'");
check_mysql_rc(rc, mysql);
res= mysql_store_result(mysql);
row= mysql_fetch_row(res);
strcpy(c, row[1]);
mysql_free_result(res);
mysql_close(mysql);
if (strcmp(ciphers[i], c) != 0)
{
diag("expected: %s instead of %s", ciphers[i], c);
return FAIL;
}
i++;
}
return OK;
}
#endif
struct my_tests_st my_tests[] = {
{"test_ssl", test_ssl, TEST_CONNECTION_NEW, 0, NULL, NULL},
// {"test_conc127", test_conc127, TEST_CONNECTION_NEW, 0, NULL, NULL},
#ifdef HAVE_GNUTLS
{"test_cipher_mapping", test_cipher_mapping, TEST_CONNECTION_NONE, 0, NULL, NULL},
#endif
{"test_conc127", test_conc127, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_ssl_fp", test_ssl_fp, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_ssl_fp_list", test_ssl_fp_list, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc50", test_conc50, TEST_CONNECTION_NEW, 0, NULL, NULL},

View File

@@ -4,7 +4,7 @@
#include "my_test.h"
#include "ma_pvio.h"
static int aurora1(MYSQL *my)
static int aurora1(MYSQL *unused __attribute__((unused)))
{
int rc;
my_bool read_only= 1;
@@ -54,7 +54,7 @@ static int aurora1(MYSQL *my)
return OK;
}
static int test_wrong_user(MYSQL *my)
static int test_wrong_user(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
@@ -68,7 +68,7 @@ static int test_wrong_user(MYSQL *my)
return OK;
}
static int test_reconnect(MYSQL *my)
static int test_reconnect(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
MYSQL_RES *res;

View File

@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "my_test.h"
static int test_conc_173(MYSQL *my)
static int test_conc_173(MYSQL *unused __attribute__((unused)))
{
MYSQL mysql;
int arg;

View File

@@ -4,7 +4,7 @@
#include "my_test.h"
#include <ma_pthread.h>
static int basic_connect(MYSQL *mysql)
static int basic_connect(MYSQL *unused __attribute__((unused)))
{
MYSQL_ROW row;
MYSQL_RES *res;
@@ -14,7 +14,7 @@ static int basic_connect(MYSQL *mysql)
MYSQL *my= mysql_init(NULL);
FAIL_IF(!my, "mysql_init() failed");
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(my, "SELECT @@version");
@@ -123,7 +123,7 @@ DWORD WINAPI thread_conc27(void)
MYSQL_RES *res;
mysql_thread_init();
mysql= mysql_init(NULL);
if(!mysql_real_connect(mysql, hostname, username, password, schema,
if(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0))
{
diag(">Error: %s", mysql_error(mysql));