diff options
author | unknown <tim@black.box> | 2001-09-16 21:41:22 -0400 |
---|---|---|
committer | unknown <tim@black.box> | 2001-09-16 21:41:22 -0400 |
commit | 5fffbb123615ad0b256652390467b33ed2919afc (patch) | |
tree | 7ff6a4243043fa71bd04fa3434bd8e13992df771 /client | |
parent | 34925f8d823c700c939f0622b6af85001458a226 (diff) | |
download | mariadb-git-5fffbb123615ad0b256652390467b33ed2919afc.tar.gz |
Add some examples for using libmysqld, including a hack for running the
mysql test suite.
A few minor libmysqld fixes.
Add mysql_server_init() and _end() to mysql.cc and mysqltest.c, so they
can be linked against libmysqlclient or libmysqld.
sql/mysqld.cc:
have unireg_end() exit(), instead of pthread_exit()
if inside the EMBEDDED_LIBRARY. This is a hack
which hopefully won't be needed. But without it,
the program hangs at end.
client/mysql.cc:
Don't call mysql_ssl_clear() unless HAVE_OPENSSL.
client/mysqltest.c:
Add mysql_server_init() and _end().
acinclude.m4:
change .. to $(top_builddir) in innodb_libs
Makefile.am:
Add libmysqld/examples to link_sources target
configure.in:
output libmysqld/examples/Makefile
Also, change .. to $(top_builddir) in readline_link
BitKeeper/etc/ignore:
added linked_libmysqldex_sources
mysql-test/mysql-test-run.sh:
use latin1, not latin1_de, in tests
libmysqld/libmysqld.c:
Add replication functions.
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 9 | ||||
-rw-r--r-- | client/mysqltest.c | 15 |
2 files changed, 24 insertions, 0 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index ec8b6689dcd..658f9941d50 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -248,6 +248,7 @@ static COMMANDS commands[] = { }; static const char *load_default_groups[]= { "mysql","client",0 }; +static const char *server_default_groups[]= { "server", "mysql_SERVER", 0 }; #ifdef HAVE_READLINE extern "C" void add_history(char *command); /* From readline directory */ @@ -275,6 +276,7 @@ int main(int argc,char *argv[]) { char buff[80]; + mysql_server_init(0, NULL, server_default_groups); MY_INIT(argv[0]); DBUG_ENTER("main"); DBUG_PROCESS(argv[0]); @@ -368,6 +370,7 @@ int main(int argc,char *argv[]) if (opt_outfile) end_tee(); mysql_end(0); + mysql_server_end(); #ifndef _lint DBUG_RETURN(0); // Keep compiler happy #endif @@ -377,9 +380,11 @@ sig_handler mysql_end(int sig) { if (connected) mysql_close(&mysql); +#ifdef HAVE_OPENSSL else mysql_ssl_clear(&mysql); /* SSL data structres should be freed even if connection was not made */ +#endif #ifdef HAVE_READLINE if (!status.batch && !quick && !opt_html && !opt_xml) { @@ -2217,9 +2222,11 @@ sql_real_connect(char *host,char *database,char *user,char *password, mysql_close(&mysql); connected= 0; } +#ifdef HAVE_OPENSSL else mysql_ssl_clear(&mysql); /* SSL data structres should be freed even if connection was not made */ +#endif mysql_init(&mysql); if (opt_connect_timeout) { @@ -2571,6 +2578,7 @@ static void mysql_end_timer(ulong start_time,char *buff) strmov(strend(buff),")"); } +#ifndef EMBEDDED_SERVER /* Keep sql_string library happy */ gptr sql_alloc(unsigned int Size) @@ -2582,3 +2590,4 @@ void sql_element_free(void *ptr) { my_free((gptr) ptr,MYF(0)); } +#endif /* EMBEDDED_SERVER */ diff --git a/client/mysqltest.c b/client/mysqltest.c index f269dd373c6..c70c371af3c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1931,12 +1931,26 @@ static void init_var_hash() var_from_env("BIG_TEST", opt_big_test ? "1" : "0"); } +static const char *embedded_server_args[] = { + "", /* XXX: argv[0] is program name - we should fix the API */ + "--datadir=.", + "--language=/home/tim/my/4/sql/share/english", + "--skip-innodb", + NullS +}; +static const char *embedded_server_groups[] = { + "mysql-test-server", + NullS +}; + int main(int argc, char** argv) { int error = 0; struct st_query* q; my_bool require_file=0, q_send_flag=0; char save_file[FN_REFLEN]; + mysql_server_init(sizeof(embedded_server_args) / sizeof(char *) - 1, + embedded_server_args, embedded_server_groups); MY_INIT(argv[0]); save_file[0]=0; @@ -2100,6 +2114,7 @@ int main(int argc, char** argv) printf("ok\n"); } + mysql_server_end(); free_used_memory(); exit(error ? 1 : 0); return error ? 1 : 0; /* Keep compiler happy */ |