Skip to content

Commit

Permalink
Revert "MDEV-9293 Connector/C integration"
Browse files Browse the repository at this point in the history
This reverts commit 7b89b9f.
  • Loading branch information
vaintroub committed Aug 19, 2016
1 parent 7b89b9f commit 31a8cf5
Show file tree
Hide file tree
Showing 61 changed files with 412 additions and 637 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ ADD_SUBDIRECTORY(strings)
ADD_SUBDIRECTORY(vio)
ADD_SUBDIRECTORY(mysys)
ADD_SUBDIRECTORY(mysys_ssl)
ADD_SUBDIRECTORY(libmariadb)
ADD_SUBDIRECTORY(libmysql)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(extra)
Expand Down
43 changes: 13 additions & 30 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,64 +26,53 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
)

ADD_DEFINITIONS(-DHAVE_OPENSSL=1)

INCLUDE_DIRECTORIES(
BEFORE
${CONNECTOR_C_INSTALLDIR}/include/mariadb)

## We will need libeay32.dll and ssleay32.dll when running client executables.
COPY_OPENSSL_DLLS(copy_openssl_client)


ADD_DEFINITIONS(-DHAVE_LIBMARIADB=1)
SET(CLIENT_LIB ${CONNECTOR_C_LIBS} mysys)

ADD_DEFINITIONS(${SSL_DEFINES})
MYSQL_ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc
${CMAKE_SOURCE_DIR}/sql/sql_string.cc)
TARGET_LINK_LIBRARIES(mysql ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(mysql mysqlclient)
IF(UNIX)
TARGET_LINK_LIBRARIES(mysql ${MY_READLINE_LIBRARY})
SET_TARGET_PROPERTIES(mysql PROPERTIES ENABLE_EXPORTS TRUE)
ENDIF(UNIX)

MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc COMPONENT Test)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqltest ${CLIENT_LIB} pcre pcreposix)
TARGET_LINK_LIBRARIES(mysqltest mysqlclient pcre pcreposix)
SET_TARGET_PROPERTIES(mysqltest PROPERTIES ENABLE_EXPORTS TRUE)


MYSQL_ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
TARGET_LINK_LIBRARIES(mysqlcheck ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient)

MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c)
TARGET_LINK_LIBRARIES(mysqldump ${CLIENT_LIB})

TARGET_LINK_LIBRARIES(mysqldump mysqlclient)

MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c)
SET_SOURCE_FILES_PROPERTIES(mysqlimport.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlimport ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)

MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c COMPONENT Server)
TARGET_LINK_LIBRARIES(mysql_upgrade ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient)
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)

MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c)
TARGET_LINK_LIBRARIES(mysqlshow ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(mysqlshow mysqlclient)

MYSQL_ADD_EXECUTABLE(mysql_plugin mysql_plugin.c)
TARGET_LINK_LIBRARIES(mysql_plugin ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(mysql_plugin mysqlclient)

MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc)
TARGET_LINK_LIBRARIES(mysqlbinlog ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient)

MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc ../sql/password.c)
TARGET_LINK_LIBRARIES(mysqladmin ${CLIENT_LIB})
MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
TARGET_LINK_LIBRARIES(mysqladmin mysqlclient)

MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c)
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlslap ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(mysqlslap mysqlclient)

# "WIN32" also covers 64 bit. "echo" is used in some files below "mysql-test/".
IF(WIN32)
Expand All @@ -92,16 +81,10 @@ ENDIF(WIN32)

# async_example is just a code example, do not install it.
ADD_EXECUTABLE(async_example async_example.c)
TARGET_LINK_LIBRARIES(async_example ${CLIENT_LIB})
TARGET_LINK_LIBRARIES(async_example mysqlclient)

SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap mysql_plugin async_example
PROPERTIES HAS_CXX TRUE)


FOREACH(t mysql mysqltest mysqltest mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysql_plugin mysqlbinlog
mysqladmin mysqlslap async_example)
ADD_DEPENDENCIES(${t} GenError mariadb_connector_c)
ENDFOREACH()

ADD_DEFINITIONS(-DHAVE_DLOPEN)

1 change: 0 additions & 1 deletion client/client_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <mysql.h>
#include <errmsg.h>
#include <my_getopt.h>
#include <mysql_version.h>

#ifndef WEXITSTATUS
# ifdef __WIN__
Expand Down
File renamed without changes.
35 changes: 5 additions & 30 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,6 @@ int main(int argc,char *argv[])

outfile[0]=0; // no (default) outfile
strmov(pager, "stdout"); // the default, if --pager wasn't given

mysql_init(&mysql);

{
char *tmp=getenv("PAGER");
if (tmp && strlen(tmp))
Expand Down Expand Up @@ -1206,6 +1203,7 @@ int main(int argc,char *argv[])
glob_buffer.realloc(512);
completion_hash_init(&ht, 128);
init_alloc_root(&hash_mem_root, 16384, 0, MYF(0));
bzero((char*) &mysql, sizeof(mysql));
if (sql_connect(current_host,current_db,current_user,opt_password,
opt_silent))
{
Expand Down Expand Up @@ -1367,8 +1365,6 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user,
opt_ssl_capath, opt_ssl_cipher);
mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl);
mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath);
char enforce= 1;
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &enforce);
}
mysql_options(mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
(char*)&opt_ssl_verify_server_cert);
Expand Down Expand Up @@ -4621,23 +4617,6 @@ sql_real_connect(char *host,char *database,char *user,char *password,
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
if (using_opt_local_infile)
mysql_options(&mysql,MYSQL_OPT_LOCAL_INFILE, (char*) &opt_local_infile);
#if !defined(EMBEDDED_LIBRARY)
if (opt_use_ssl)
{
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher);
mysql_options(&mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl);
mysql_options(&mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath);
}
mysql_options(&mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
(my_bool*)&opt_ssl_verify_server_cert);
#endif
if (opt_protocol)
mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
#ifdef HAVE_SMEM
if (shared_memory_base_name)
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
if (safe_updates)
{
char init_command[100];
Expand All @@ -4662,13 +4641,12 @@ sql_real_connect(char *host,char *database,char *user,char *password,
}
return -1; // Retryable
}

charset_info= get_charset_by_name(mysql.charset->name, MYF(0));


charset_info= mysql.charset;

connected=1;
#ifndef EMBEDDED_LIBRARY
mysql_options(&mysql, MYSQL_OPT_RECONNECT, &debug_info_flag);
mysql.reconnect= debug_info_flag; // We want to know if this happens

/*
CLIENT_PROGRESS_OBSOLETE is set only if we requested it in
Expand All @@ -4677,10 +4655,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
if (mysql.client_flag & CLIENT_PROGRESS_OBSOLETE)
mysql_options(&mysql, MYSQL_PROGRESS_CALLBACK, (void*) report_progress);
#else
{
my_bool reconnect= 1;
mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
}
mysql.reconnect= 1;
#endif
#ifdef HAVE_READLINE
build_completion_hash(opt_rehash, 1);
Expand Down
1 change: 0 additions & 1 deletion client/mysql_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <mysql.h>
#include <my_getopt.h>
#include <my_dir.h>
#include <mysql_version.h>

#define SHOW_VERSION "1.0.0"
#define PRINT_VERSION do { printf("%s Ver %s Distrib %s\n", \
Expand Down
28 changes: 10 additions & 18 deletions client/mysqladmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
#include <sys/stat.h>
#include <mysql.h>
#include <sql_common.h>
#include <mysql_version.h>
#include <welcome_copyright_notice.h>
#include <my_rnd.h>
#include <password.h>

#define ADMIN_VERSION "9.1"
#define MAX_MYSQL_VAR 512
Expand Down Expand Up @@ -442,7 +440,7 @@ int main(int argc,char *argv[])
didn't signal for us to die. Otherwise, signal failure.
*/

if (mysql.net.pvio == 0)
if (mysql.net.vio == 0)
{
if (option_wait && !interrupted)
{
Expand Down Expand Up @@ -523,8 +521,7 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
if (mysql_real_connect(mysql,host,user,opt_password,NullS,tcp_port,
unix_port, CLIENT_REMEMBER_OPTIONS))
{
my_bool reconnect= 1;
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
mysql->reconnect= 1;
if (info)
{
fputs("\n",stderr);
Expand All @@ -545,16 +542,16 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
{
fprintf(stderr,
"Check that mysqld is running and that the socket: '%s' exists!\n",
unix_port ? unix_port : MYSQL_UNIX_ADDR);
unix_port ? unix_port : mysql_unix_port);
}
else if (mysql_errno(mysql) == CR_CONN_HOST_ERROR ||
mysql_errno(mysql) == CR_UNKNOWN_HOST)
{
fprintf(stderr,"Check that mysqld is running on %s",host);
fprintf(stderr," and that the port is %d.\n",
tcp_port ? tcp_port: MYSQL_PORT);
tcp_port ? tcp_port: mysql_port);
fprintf(stderr,"You can check this by doing 'telnet %s %d'\n",
host, tcp_port ? tcp_port: MYSQL_PORT);
host, tcp_port ? tcp_port: mysql_port);
}
}
return 1;
Expand Down Expand Up @@ -1080,9 +1077,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
}
if (old)
my_make_scrambled_password_323(crypted_pw, typed_password, sizeof(crypted_pw));
make_scrambled_password_323(crypted_pw, typed_password);
else
my_make_scrambled_password(crypted_pw, typed_password, sizeof(crypted_pw));
make_scrambled_password(crypted_pw, typed_password);
}
else
crypted_pw[0]=0; /* No password */
Expand Down Expand Up @@ -1190,9 +1187,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
break;
}
case ADMIN_PING:
{
my_bool reconnect= 0;
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
mysql->reconnect=0; /* We want to know of reconnects */
if (!mysql_ping(mysql))
{
if (option_silent < 2)
Expand All @@ -1202,8 +1197,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
{
if (mysql_errno(mysql) == CR_SERVER_GONE_ERROR)
{
reconnect= 1;
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
mysql->reconnect=1;
if (!mysql_ping(mysql))
puts("connection was down, but mysqld is now alive");
}
Expand All @@ -1214,10 +1208,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
return -1;
}
}
reconnect=1; /* Automatic reconnect is default */
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
mysql->reconnect=1; /* Automatic reconnect is default */
break;
}
default:
my_printf_error(0, "Unknown command: '%-.60s'", error_flags, argv[0]);
return 1;
Expand Down
22 changes: 5 additions & 17 deletions client/mysqlbinlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,14 @@

#include <algorithm>

#ifdef LIBMARIADB
#define my_net_write ma_net_write
#define net_flush ma_net_flush
#define net_safe_read ma_net_safe_read
#define my_net_read ma_net_read
#endif

Rpl_filter *binlog_filter= 0;

#define BIN_LOG_HEADER_SIZE 4
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)


#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)

/* Needed for Rpl_filter */
CHARSET_INFO* system_charset_info= &my_charset_utf8_general_ci;

Expand All @@ -90,11 +86,6 @@ static const char *load_groups[]=
static void error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
static void warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);


extern "C" ulong my_net_read(NET *net);
extern "C" unsigned char *mysql_net_store_length(unsigned char *packet, size_t length);
#define net_store_length mysql_net_store_length

static bool one_database=0, to_last_remote_log= 0, disable_log_bin= 0;
static bool opt_hexdump= 0, opt_version= 0;
const char *base64_output_mode_names[]=
Expand Down Expand Up @@ -1773,7 +1764,6 @@ static int parse_args(int *argc, char*** argv)
*/
static Exit_status safe_connect()
{
my_bool reconnect= 1;
/* Close any old connections to MySQL */
if (mysql)
mysql_close(mysql);
Expand Down Expand Up @@ -1819,7 +1809,7 @@ static Exit_status safe_connect()
error("Failed on connect: %s", mysql_error(mysql));
return ERROR_STOP;
}
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
mysql->reconnect= 1;
return OK_CONTINUE;
}

Expand Down Expand Up @@ -2283,7 +2273,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,

for (;;)
{
len= net_safe_read(mysql);
len= cli_safe_read(mysql);
if (len == packet_error)
{
error("Got error reading packet from server: %s", mysql_error(mysql));
Expand Down Expand Up @@ -2853,8 +2843,6 @@ struct encryption_service_st encryption_handler=
#include "my_decimal.h"
#include "decimal.c"
#include "my_decimal.cc"
#include "../sql-common/my_time.c"
#include "password.c"
#include "log_event.cc"
#include "log_event_old.cc"
#include "rpl_utility.cc"
Expand Down
3 changes: 1 addition & 2 deletions client/mysqlcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,6 @@ static void print_result()

static int dbConnect(char *host, char *user, char *passwd)
{
my_bool reconnect= 1;
DBUG_ENTER("dbConnect");
if (verbose > 1)
{
Expand Down Expand Up @@ -1125,7 +1124,7 @@ static int dbConnect(char *host, char *user, char *passwd)
DBerror(&mysql_connection, "when trying to connect");
DBUG_RETURN(1);
}
mysql_options(&mysql_connection, MYSQL_OPT_RECONNECT, &reconnect);
mysql_connection.reconnect= 1;
DBUG_RETURN(0);
} /* dbConnect */

Expand Down
4 changes: 1 addition & 3 deletions client/mysqldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,6 @@ static void maybe_exit(int error)
static int connect_to_db(char *host, char *user,char *passwd)
{
char buff[20+FN_REFLEN];
my_bool reconnect;
DBUG_ENTER("connect_to_db");

verbose_msg("-- Connecting to %s...\n", host ? host : "localhost");
Expand Down Expand Up @@ -1698,8 +1697,7 @@ static int connect_to_db(char *host, char *user,char *passwd)
As we're going to set SQL_MODE, it would be lost on reconnect, so we
cannot reconnect.
*/
reconnect= 0;
mysql_options(&mysql_connection, MYSQL_OPT_RECONNECT, &reconnect);
mysql->reconnect= 0;
my_snprintf(buff, sizeof(buff), "/*!40100 SET @@SQL_MODE='%s' */",
compatible_mode_normal_str);
if (mysql_query_with_error_report(mysql, 0, buff))
Expand Down
Loading

0 comments on commit 31a8cf5

Please sign in to comment.