Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
2be6f272
Commit
2be6f272
authored
Oct 13, 2002
by
hf@genie.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes in order to trim embedded library code
parent
55866b06
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
119 additions
and
83 deletions
+119
-83
client/mysqltest.c
client/mysqltest.c
+4
-0
libmysqld/embedded_priv.h
libmysqld/embedded_priv.h
+2
-2
libmysqld/lib_sql.cc
libmysqld/lib_sql.cc
+81
-18
libmysqld/libmysqld.c
libmysqld/libmysqld.c
+23
-54
sql/net_pkg.cc
sql/net_pkg.cc
+1
-1
sql/sql_show.cc
sql/sql_show.cc
+8
-8
No files found.
client/mysqltest.c
View file @
2be6f272
...
...
@@ -314,6 +314,10 @@ int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
my_bool
mysql_rpl_probe
(
MYSQL
*
mysql
__attribute__
((
unused
)))
{
return
1
;
}
#endif
#ifdef EMBEDDED_LIBRARY
#define mysql_send_query mysql_real_query
#endif
#define MAX_SERVER_ARGS 20
static
int
embedded_server_arg_count
=
0
;
...
...
libmysqld/embedded_priv.h
View file @
2be6f272
...
...
@@ -26,9 +26,9 @@ C_MODE_START
extern
void
start_embedded_connection
(
NET
*
net
);
extern
void
end_embedded_connection
(
NET
*
net
);
extern
void
lib_connection_phase
(
NET
*
net
,
int
phase
);
extern
bool
lib_dispatch_command
(
enum
enum_server_command
command
,
NET
*
net
,
const
char
*
arg
,
ulong
length
);
extern
void
init_embedded_mysql
(
MYSQL
*
mysql
,
int
client_flag
,
char
*
db
);
extern
void
*
create_embedded_thd
(
Vio
*
vio
,
unsigned
char
*
buff
,
int
client_flag
,
char
*
db
);
extern
NET
*
get_mysql_net
(
MYSQL
*
mysql
);
extern
my_bool
simple_command
(
MYSQL
*
mysql
,
enum
enum_server_command
command
,
const
char
*
arg
,
ulong
length
,
my_bool
skipp_check
);
C_MODE_END
libmysqld/lib_sql.cc
View file @
2be6f272
...
...
@@ -32,6 +32,7 @@
#define SCRAMBLE_LENGTH 8
C_MODE_START
#include "lib_vio.c"
#include "errmsg.h"
static
int
check_connections1
(
THD
*
thd
);
static
int
check_connections2
(
THD
*
thd
);
...
...
@@ -41,16 +42,41 @@ static bool check_user(THD *thd, enum_server_command command,
char
*
get_mysql_home
(){
return
mysql_home
;};
char
*
get_mysql_real_data_home
(){
return
mysql_real_data_home
;};
bool
lib_dispatch_command
(
enum
enum_server_command
command
,
NET
*
net
,
const
char
*
arg
,
ulong
length
)
my_bool
simple_command
(
MYSQL
*
mysql
,
enum
enum_server_command
command
,
const
char
*
arg
,
ulong
length
,
my_bool
skipp_check
)
{
NET
*
net
=
&
mysql
->
net
;
my_bool
result
=
1
;
THD
*
thd
=
(
THD
*
)
net
->
vio
->
dest_thd
;
/* Check that we are calling the client functions in right order */
if
(
mysql
->
status
!=
MYSQL_STATUS_READY
)
{
strmov
(
net
->
last_error
,
ER
(
mysql
->
net
.
last_errno
=
CR_COMMANDS_OUT_OF_SYNC
));
return
1
;
}
/* Clear result variables */
mysql
->
net
.
last_error
[
0
]
=
0
;
mysql
->
net
.
last_errno
=
0
;
mysql
->
info
=
0
;
mysql
->
affected_rows
=
~
(
my_ulonglong
)
0
;
/* Clear receive buffer and vio packet list */
net_clear
(
net
);
vio_reset
(
net
->
vio
);
thd
->
store_globals
();
// Fix if more than one connect
thd
->
net
.
last_error
[
0
]
=
0
;
// Clear error message
thd
->
net
.
last_errno
=
0
;
// thd->net.last_error[0]=0; // Clear error message
// thd->net.last_errno=0;
net_new_transaction
(
net
);
result
=
dispatch_command
(
command
,
thd
,
(
char
*
)
arg
,
length
+
1
);
net_new_transaction
(
&
thd
->
net
);
return
dispatch_command
(
command
,
thd
,
(
char
*
)
arg
,
length
+
1
);
if
(
!
skipp_check
)
result
=
net
->
last_errno
?
-
1
:
0
;
return
result
;
}
#ifdef _DUMMY
...
...
@@ -604,6 +630,7 @@ void end_embedded_connection(NET * net)
}
/* extern "C" */
C_MODE_START
NET
*
get_mysql_net
(
MYSQL
*
mysql
)
{
return
&
((
THD
*
)
mysql
->
net
.
vio
->
dest_thd
)
->
net
;
...
...
@@ -626,6 +653,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db)
mysql
->
db
=
db
;
thd
->
mysql
=
mysql
;
}
C_MODE_END
static
int
embedded_thd_net_init
(
NET
*
net
,
unsigned
char
*
buff
)
{
...
...
@@ -636,7 +664,7 @@ static int embedded_thd_net_init(NET *net, unsigned char *buff)
net
->
vio
=
NULL
;
net
->
no_send_ok
=
0
;
net
->
error
=
0
;
net
->
return_errno
=
0
;
net
->
return_status
=
0
;
net
->
timeout
=
(
uint
)
net_read_timeout
;
/* Timeout for read */
//
net->timeout=(uint) net_read_timeout; /* Timeout for read */
net
->
pkt_nr
=
net
->
compress_pkt_nr
=
0
;
net
->
write_pos
=
net
->
read_pos
=
net
->
buff
;
net
->
last_error
[
0
]
=
0
;
...
...
@@ -648,6 +676,8 @@ static int embedded_thd_net_init(NET *net, unsigned char *buff)
return
0
;
}
C_MODE_START
void
*
create_embedded_thd
(
Vio
*
vio
,
unsigned
char
*
buff
,
int
client_flag
,
char
*
db
)
{
THD
*
thd
=
new
THD
;
...
...
@@ -667,8 +697,8 @@ void *create_embedded_thd(Vio *vio, unsigned char *buff, int client_flag, char *
thd
->
dbug_thread_id
=
my_thread_id
();
thd
->
thread_stack
=
(
char
*
)
&
thd
;
if
(
thd
->
max_join_size
==
HA_POS_ERROR
)
thd
->
options
|=
OPTION_BIG_SELECTS
;
//
if (thd->max_join_size == HA_POS_ERROR)
//
thd->options |= OPTION_BIG_SELECTS;
thd
->
proc_info
=
0
;
// Remove 'login'
thd
->
command
=
COM_SLEEP
;
...
...
@@ -676,11 +706,11 @@ void *create_embedded_thd(Vio *vio, unsigned char *buff, int client_flag, char *
thd
->
set_time
();
init_sql_alloc
(
&
thd
->
mem_root
,
8192
,
8192
);
thd
->
client_capabilities
=
client_flag
;
thd
->
max_packet_length
=
max_allowed_packet
;
//
thd->max_packet_length= max_allowed_packet;
thd
->
net
.
vio
=
vio
;
if
(
thd
->
client_capabilities
&
CLIENT_INTERACTIVE
)
thd
->
inactive_timeout
=
net_interactive_timeout
;
//
if (thd->client_capabilities & CLIENT_INTERACTIVE)
//
thd->inactive_timeout= net_interactive_timeout;
if
(
thd
->
client_capabilities
&
CLIENT_TRANSACTIONS
)
thd
->
net
.
return_status
=
&
thd
->
server_status
;
...
...
@@ -691,6 +721,7 @@ void *create_embedded_thd(Vio *vio, unsigned char *buff, int client_flag, char *
return
thd
;
}
C_MODE_END
bool
send_fields
(
THD
*
thd
,
List
<
Item
>
&
list
,
uint
flag
)
{
...
...
@@ -762,7 +793,7 @@ bool send_fields(THD *thd, List<Item> &list, uint flag)
return
0
;
err:
send_error
(
&
thd
->
net
,
ER_OUT_OF_RESOURCES
);
/* purecov: inspected */
send_error
(
thd
,
ER_OUT_OF_RESOURCES
);
/* purecov: inspected */
return
1
;
/* purecov: inspected */
}
...
...
@@ -886,8 +917,8 @@ bool do_command(THD *thd)
thd
->
current_tablenr
=
0
;
packet
=
0
;
old_timeout
=
net
->
timeout
;
net
->
timeout
=
(
uint
)
thd
->
inactive_timeout
;
// Wait max for 8 hours
//
old_timeout=net->timeout;
//
net->timeout=(uint) thd->inactive_timeout; // Wait max for 8 hours
net
->
last_error
[
0
]
=
0
;
// Clear error message
net
->
last_errno
=
0
;
...
...
@@ -901,18 +932,20 @@ bool do_command(THD *thd)
else
{
packet
=
(
char
*
)
net
->
read_pos
;
command
=
(
enum
enum_server_command
)
(
uchar
)
packet
[
0
];
command
=
(
enum
enum_server_command
)
(
uchar
)
packet
[
0
];
DBUG_PRINT
(
"info"
,(
"Command on %s = %d (%s)"
,
vio_description
(
net
->
vio
),
command
,
command_name
[
command
]));
}
net
->
timeout
=
old_timeout
;
// Timeout for writing
//
net->timeout=old_timeout; // Timeout for writing
DBUG_RETURN
(
dispatch_command
(
command
,
thd
,
packet
+
1
,
(
uint
)
packet_length
));
}
void
send_ok
(
NET
*
net
,
ha_rows
affected_rows
,
ulonglong
id
,
const
char
*
message
)
send_ok
(
THD
*
thd
,
ha_rows
affected_rows
,
ulonglong
id
,
const
char
*
message
)
{
NET
*
net
=
&
thd
->
net
;
if
(
net
->
no_send_ok
)
// hack for re-parsing queries
return
;
...
...
@@ -930,6 +963,36 @@ send_ok(NET *net,ha_rows affected_rows,ulonglong id,const char *message)
DBUG_VOID_RETURN
;
}
void
send_eof
(
THD
*
thd
,
bool
no_flush
)
{
/* static char eof_buff[1]= { (char) 254 };
NET *net= &thd->net;
DBUG_ENTER("send_eof");
if (net->vio != 0)
{
if (!no_flush && (thd->client_capabilities & CLIENT_PROTOCOL_41))
{
char buff[5];
uint tmp= min(thd->total_warn_count, 65535);
buff[0]=254;
int2store(buff+1, tmp);
int2store(buff+3, 0); // No flags yet
VOID(my_net_write(net,buff,5));
VOID(net_flush(net));
}
else
{
VOID(my_net_write(net,eof_buff,1));
if (!no_flush)
VOID(net_flush(net));
}
}
DBUG_VOID_RETURN;
*/
}
int
embedded_send_row
(
THD
*
thd
,
int
n_fields
,
char
*
data
,
int
data_len
)
{
MYSQL
*
mysql
=
thd
->
mysql
;
...
...
libmysqld/libmysqld.c
View file @
2be6f272
...
...
@@ -212,39 +212,6 @@ static void free_rows(MYSQL_DATA *cur)
}
}
my_bool
simple_command
(
MYSQL
*
mysql
,
enum
enum_server_command
command
,
const
char
*
arg
,
ulong
length
,
my_bool
skipp_check
)
{
NET
*
net
=
&
mysql
->
net
;
my_bool
result
=
1
;
/* Check that we are calling the client functions in right order */
if
(
mysql
->
status
!=
MYSQL_STATUS_READY
)
{
strmov
(
net
->
last_error
,
ER
(
mysql
->
net
.
last_errno
=
CR_COMMANDS_OUT_OF_SYNC
));
goto
end
;
}
/* Clear result variables */
mysql
->
net
.
last_error
[
0
]
=
0
;
mysql
->
net
.
last_errno
=
0
;
mysql
->
info
=
0
;
mysql
->
affected_rows
=
~
(
my_ulonglong
)
0
;
/* Clear receive buffer and vio packet list */
net_clear
(
net
);
vio_reset
(
net
->
vio
);
result
=
lib_dispatch_command
(
command
,
net
,
arg
,
length
);
if
(
!
skipp_check
)
result
=
mysql
->
net
.
last_errno
?
-
1
:
0
;
end:
return
result
;
}
static
void
free_old_query
(
MYSQL
*
mysql
)
{
DBUG_ENTER
(
"free_old_query"
);
...
...
@@ -1046,22 +1013,6 @@ mysql_query(MYSQL *mysql, const char *query)
return
mysql_real_query
(
mysql
,
query
,
(
ulong
)
strlen
(
query
));
}
int
STDCALL
mysql_send_query
(
MYSQL
*
mysql
,
const
char
*
query
,
ulong
length
)
{
if
(
mysql
->
options
.
separate_thread
)
{
return
-
1
;
}
mysql
->
result
=
NULL
;
free_old_query
(
mysql
);
/* Free old result */
return
simple_command
(
mysql
,
COM_QUERY
,
query
,
length
,
1
);
}
my_bool
STDCALL
mysql_read_query_result
(
MYSQL
*
mysql
)
{
...
...
@@ -1180,6 +1131,23 @@ my_bool my_connect(my_socket s, const struct sockaddr *name, uint namelen,
#endif
}
/*
int STDCALL
mysql_send_query(MYSQL* mysql, const char* query, ulong length)
{
if (mysql->options.separate_thread)
{
return -1;
}
mysql->result= NULL;
free_old_query(mysql);
return simple_command(mysql, COM_QUERY, query, length, 1);
}
*/
int
STDCALL
mysql_real_query
(
MYSQL
*
mysql
,
const
char
*
query
,
ulong
length
)
...
...
@@ -1187,16 +1155,17 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong length)
DBUG_ENTER
(
"mysql_real_query"
);
DBUG_PRINT
(
"enter"
,(
"handle: %lx"
,
mysql
));
DBUG_PRINT
(
"query"
,(
"Query =
\"
%s
\"
"
,
query
));
/* if (mysql->options.separate_thread)
if
(
mysql
->
options
.
separate_thread
)
{
DBUG_RETURN(0)
;
return
-
1
;
}
mysql
->
result
=
NULL
;
free_old_query(mysql);
*/
if
(
mysql_send_query
(
mysql
,
query
,
length
))
free_old_query
(
mysql
);
/* Free old result */
if
(
simple_command
(
mysql
,
COM_QUERY
,
query
,
length
,
1
))
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
mysql_read_query_result
(
mysql
));
...
...
sql/net_pkg.cc
View file @
2be6f272
...
...
@@ -253,7 +253,6 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message)
DBUG_VOID_RETURN
;
}
#endif
/* EMBEDDED_LIBRARY */
/*
Send eof (= end of result set) to the client
...
...
@@ -304,6 +303,7 @@ send_eof(THD *thd, bool no_flush)
}
DBUG_VOID_RETURN
;
}
#endif
/* EMBEDDED_LIBRARY */
/****************************************************************************
...
...
sql/sql_show.cc
View file @
2be6f272
...
...
@@ -86,7 +86,7 @@ mysqld_show_dbs(THD *thd,const char *wild)
packet
->
length
(
0
);
net_store_data
(
packet
,
thd
->
variables
.
convert_set
,
file_name
);
if
(
SEND_ROW
(
thd
,
&
thd
->
net
,
field_list
.
elements
,
(
char
*
)
packet
.
ptr
(),
packet
.
length
()))
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_RETURN
(
-
1
);
}
}
...
...
@@ -126,7 +126,7 @@ int mysqld_show_open_tables(THD *thd,const char *wild)
net_store_data
(
packet
,
open_list
->
in_use
);
net_store_data
(
packet
,
open_list
->
locked
);
if
(
SEND_ROW
(
thd
,
&
thd
->
net
,
field_list
.
elements
,
(
char
*
)
packet
.
ptr
(),
packet
.
length
()))
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
{
DBUG_RETURN
(
-
1
);
}
...
...
@@ -169,7 +169,7 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild)
packet
->
length
(
0
);
net_store_data
(
packet
,
thd
->
variables
.
convert_set
,
file_name
);
if
(
SEND_ROW
(
thd
,
&
thd
->
net
,
field_list
.
elements
,
(
char
*
)
packet
.
ptr
(),
packet
.
length
()))
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_RETURN
(
-
1
);
}
send_eof
(
thd
);
...
...
@@ -636,7 +636,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
close_thread_tables
(
thd
,
0
);
}
if
(
SEND_ROW
(
thd
,
&
thd
->
net
,
field_list
.
elements
,
(
char
*
)
thd
->
packet
.
ptr
(),
thd
->
packet
.
length
()))
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_RETURN
(
-
1
);
}
send_eof
(
thd
);
...
...
@@ -763,7 +763,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
net_store_data
(
packet
,
field
->
comment
.
str
,
field
->
comment
.
length
);
}
if
(
SEND_ROW
(
thd
,
&
thd
->
net
,
field_list
.
elements
,
(
char
*
)
thd
->
packet
.
ptr
(),
thd
->
packet
.
length
()))
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_RETURN
(
-
1
);
}
}
...
...
@@ -834,7 +834,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
// now we are in business :-)
if
(
SEND_ROW
(
thd
,
&
thd
->
net
,
field_list
.
elements
,
(
char
*
)
thd
->
packet
.
ptr
(),
thd
->
packet
.
length
()))
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_RETURN
(
-
1
);
}
send_eof
(
thd
);
...
...
@@ -958,7 +958,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
/* Comment */
net_store_data
(
packet
,
convert
,
""
);
if
(
SEND_ROW
(
thd
,
&
thd
->
net
,
field_list
.
elements
,
(
char
*
)
thd
->
packet
.
ptr
(),
thd
->
packet
.
length
()))
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_RETURN
(
-
1
);
}
}
...
...
@@ -1387,7 +1387,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
else
net_store_null
(
packet
);
if
(
SEND_ROW
(
thd
,
&
thd
->
net
,
field_list
.
elements
,
(
char
*
)
thd
->
packet
.
ptr
(),
thd
->
packet
.
length
()))
(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
break
;
}
send_eof
(
thd
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment