Skip to content

Commit 02d3d7e

Browse files
author
hf@deer.(none)
committed
SCRUM:
Here is another pack of changes about gathering common client code in sql-common/client.c. Now i symlink the client.c from sql/ and libmysql/. These directories have client_settings.h files to be included to client.c. It contains defines and declarations to compile client.c in appropriate manner. Also i've added include/sql_common.h, containing declarations of what is exported from client.c I removed as many #ifdef-s from client.c as i dared to. I think it's better push it with some extra #ifdef-s now (of course, if everythihg besides it is ok) so other people can check the code.
1 parent 6bc3473 commit 02d3d7e

File tree

14 files changed

+624
-367
lines changed

14 files changed

+624
-367
lines changed

Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ linked_netware_sources:
7070

7171
#avoid recursive make calls in sql directory
7272
linked_server_sources:
73-
cd sql; rm -f mini_client_errors.c;@LN_CP_F@ ../libmysql/errmsg.c mini_client_errors.c; rm -f pack.c;@LN_CP_F@ ../sql-common/pack.c pack.c
73+
cd sql; rm -f mini_client_errors.c;\
74+
@LN_CP_F@ ../libmysql/errmsg.c mini_client_errors.c;\
75+
rm -f pack.c;@LN_CP_F@ ../sql-common/pack.c pack.c;\
76+
rm -f client.c;@LN_CP_F@ ../sql-common/client.c client.c
7477
echo timestamp > linked_server_sources
7578

7679
# Create permission databases

include/mysql.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ typedef struct st_mysql_res {
296296
#define MANAGER_CLIENT_ERR 450
297297
#define MANAGER_INTERNAL_ERR 500
298298

299+
#ifndef MYSQL_SERVER
300+
#define MYSQL_CLIENT
301+
#endif
302+
299303

300304

301305
typedef struct st_mysql_manager

include/sql_common.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; either version 2 of the License, or
6+
(at your option) any later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program; if not, write to the Free Software
15+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16+
17+
18+
#ifndef _sql_common_h
19+
#define _sql_common_h
20+
21+
extern const char *unknown_sqlstate;
22+
23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
27+
ulong STDCALL net_field_length(uchar **packet);
28+
my_ulonglong net_field_length_ll(uchar **packet);
29+
30+
MYSQL_FIELD *unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
31+
my_bool default_value, uint server_capabilities);
32+
my_bool advanced_command(MYSQL *mysql, enum enum_server_command command,
33+
const char *header, ulong header_length,
34+
const char *arg, ulong arg_length, my_bool skip_check);
35+
void free_rows(MYSQL_DATA *cur);
36+
MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields,
37+
uint field_count);
38+
my_bool mysql_autenticate(MYSQL *mysql, const char *passwd);
39+
void fetch_lengths(ulong *to, MYSQL_ROW column, uint field_count);
40+
void free_old_query(MYSQL *mysql);
41+
void end_server(MYSQL *mysql);
42+
my_bool mysql_reconnect(MYSQL *mysql);
43+
#ifdef __cplusplus
44+
}
45+
#endif
46+
47+
#ifdef MYSQL_SERVER
48+
#define protocol_41(A) FALSE
49+
#else
50+
#define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)
51+
#endif
52+
53+
#endif /* _sql_common_h */

libmysql/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# This file is public domain and comes with NO WARRANTY of any kind
1919

2020
target = libmysqlclient.la
21-
target_defs = -DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -DMYSQL_CLIENT
21+
target_defs = -DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@
2222
LIBS = @CLIENT_LIBS@
2323
INCLUDES = -I$(top_srcdir)/include $(openssl_includes)
2424

@@ -79,7 +79,8 @@ nh = my_global.h config-win32.h dbug.h errmsg.h \
7979
m_ctype.h m_string.h \
8080
my_alarm.h my_config.h my_dir.h my_list.h my_net.h my_sys.h \
8181
mysql.h mysql_com.h mysql_version.h mysqld_error.h \
82-
mysys_err.h my_pthread.h thr_alarm.h violite.h hash.h
82+
mysys_err.h my_pthread.h thr_alarm.h violite.h hash.h \
83+
sql_common.h ../libmysql/client_settings.h
8384
# Get a list of the needed objects
8485
lobjs = $(mysysobjects1) $(dbugobjects) $(mystringsobjects) $(sqlobjects)
8586

libmysql/Makefile.shared

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
6363
my_pread.lo mf_cache.lo md5.lo sha1.lo\
6464
my_getopt.lo my_gethostbyname.lo my_port.lo
6565
sqlobjects = net.lo
66-
sql_cmn_objects = pack.lo
66+
sql_cmn_objects = pack.lo client.lo
6767

6868
# Not needed in the minimum library
6969
mysysobjects2 = my_lib.lo

libmysql/client_settings.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; either version 2 of the License, or
6+
(at your option) any later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program; if not, write to the Free Software
15+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16+
17+
18+
#ifndef _client_settings_h
19+
#define _client_settings_h
20+
static my_bool mysql_client_init=0;
21+
extern uint mysql_port;
22+
extern my_string mysql_unix_port;
23+
24+
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \
25+
| CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS \
26+
| CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
27+
28+
29+
#ifdef __WIN__
30+
#define CONNECT_TIMEOUT 20
31+
#else
32+
#define CONNECT_TIMEOUT 0
33+
#endif
34+
35+
#ifdef HAVE_SMEM
36+
char *shared_memory_base_name=0;
37+
const char *def_shared_memory_base_name=default_shared_memory_base_name;
38+
#endif
39+
40+
static my_bool org_my_init_done=0;
41+
42+
sig_handler pipe_sig_handler(int sig __attribute__((unused)));
43+
my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list);
44+
void read_user_name(char *name);
45+
my_bool send_file_to_server(MYSQL *mysql, const char *filename);
46+
47+
/*
48+
Let the user specify that we don't want SIGPIPE; This doesn't however work
49+
with threaded applications as we can have multiple read in progress.
50+
*/
51+
52+
#if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD)
53+
#define init_sigpipe_variables sig_return old_signal_handler=(sig_return) 0;
54+
#define set_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler)
55+
#define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler);
56+
#else
57+
#define init_sigpipe_variables
58+
#define set_sigpipe(mysql)
59+
#define reset_sigpipe(mysql)
60+
#endif
61+
#endif /* _client_settings_h */

0 commit comments

Comments
 (0)