summaryrefslogtreecommitdiff
path: root/libmysqld
diff options
context:
space:
mode:
Diffstat (limited to 'libmysqld')
-rw-r--r--libmysqld/Makefile.am6
-rw-r--r--libmysqld/examples/Makefile.am24
-rw-r--r--libmysqld/lib_sql.cc84
-rw-r--r--libmysqld/libmysqld.c3
-rw-r--r--libmysqld/libmysqld.def1
5 files changed, 74 insertions, 44 deletions
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index 17410f02fe2..3c33b56ba1c 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -28,7 +28,7 @@ DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
INCLUDES= @MT_INCLUDES@ @bdb_includes@ -I$(top_srcdir)/include \
-I$(top_srcdir)/sql -I$(top_srcdir)/sql/examples \
-I$(top_srcdir)/regex \
- -I$(top_srcdir)/extra \
+ -I$(top_builddir)/include \
$(openssl_includes) @ZLIB_INCLUDES@
noinst_LIBRARIES = libmysqld_int.a
@@ -42,7 +42,7 @@ sqlexamplessources = ha_example.cc ha_archive.cc ha_tina.cc
noinst_HEADERS = embedded_priv.h emb_qcache.h
sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
- ha_innodb.cc ha_berkeley.cc ha_heap.cc \
+ ha_innodb.cc ha_berkeley.cc ha_heap.cc ha_federated.cc \
ha_myisam.cc ha_myisammrg.cc handler.cc sql_handler.cc \
hostname.cc init.cc password.c \
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
@@ -62,7 +62,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc \
spatial.cc gstream.cc sql_help.cc tztime.cc protocol_cursor.cc \
sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
- parse_file.cc sql_view.cc sql_trigger.cc
+ parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc
libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
libmysqld_a_SOURCES=
diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am
index ba646e282b5..bd18e7154aa 100644
--- a/libmysqld/examples/Makefile.am
+++ b/libmysqld/examples/Makefile.am
@@ -1,6 +1,8 @@
-noinst_PROGRAMS = mysqltest mysql client_test
-client_sources = $(mysqltest_SOURCES) $(mysql_SOURCES)
-tests_sources= $(client_test_SOURCES)
+noinst_PROGRAMS = mysql
+bin_PROGRAMS = mysqltest_embedded mysql_client_test_embedded
+client_sources = $(mysqltest_embedded_SOURCES) $(mysql_SOURCES)
+tests_sources = $(mysql_client_test_embedded_SOURCES)
+CLEANFILES = $(client_sources) $(tests_sources)
link_sources:
for f in $(client_sources); do \
@@ -15,24 +17,20 @@ link_sources:
DEFS = -DEMBEDDED_LIBRARY
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include -I$(srcdir) \
-I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- -I$(top_srcdir)/extra $(openssl_includes)
+ -I$(top_builddir)/include $(openssl_includes)
LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS)
-mysqltest_LINK = $(CXXLINK)
-mysqltest_SOURCES = mysqltest.c
-mysqltest_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a
+mysqltest_embedded_LINK = $(CXXLINK)
+mysqltest_embedded_SOURCES = mysqltest.c
+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a
mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
my_readline.h sql_string.h completion_hash.h
mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD)
-client_test_LINK = $(CXXLINK)
-client_test_SOURCES = client_test.c
-
-clean:
- rm -f $(client_sources)
- rm -f $(tests_sources)
+mysql_client_test_embedded_LINK = $(CXXLINK)
+mysql_client_test_embedded_SOURCES = mysql_client_test.c
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 15f07667625..353f8cd6430 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -219,12 +219,13 @@ static my_bool emb_mysql_read_query_result(MYSQL *mysql)
static int emb_stmt_execute(MYSQL_STMT *stmt)
{
DBUG_ENTER("emb_stmt_execute");
+ char header[4];
+ int4store(header, stmt->stmt_id);
THD *thd= (THD*)stmt->mysql->thd;
thd->client_param_count= stmt->param_count;
thd->client_params= stmt->params;
if (emb_advanced_command(stmt->mysql, COM_EXECUTE,0,0,
- (const char*)&stmt->stmt_id,sizeof(stmt->stmt_id),
- 1) ||
+ header, sizeof(header), 1) ||
emb_mysql_read_query_result(stmt->mysql))
{
NET *net= &stmt->mysql->net;
@@ -591,6 +592,32 @@ err:
C_MODE_END
+static char *dup_str_aux(MEM_ROOT *root, const char *from, uint length,
+ CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
+{
+ uint32 dummy32;
+ uint dummy_err;
+ char *result;
+
+ /* 'tocs' is set 0 when client issues SET character_set_results=NULL */
+ if (tocs && String::needs_conversion(0, fromcs, tocs, &dummy32))
+ {
+ uint new_len= (tocs->mbmaxlen * length) / fromcs->mbminlen + 1;
+ result= (char *)alloc_root(root, new_len);
+ length= copy_and_convert(result, new_len,
+ tocs, from, length, fromcs, &dummy_err);
+ }
+ else
+ {
+ result= (char *)alloc_root(root, length + 1);
+ memcpy(result, from, length);
+ }
+
+ result[length]= 0;
+ return result;
+}
+
+
bool Protocol::send_fields(List<Item> *list, uint flags)
{
List_iterator_fast<Item> it(*list);
@@ -598,6 +625,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
MYSQL_FIELD *client_field;
MYSQL *mysql= thd->mysql;
MEM_ROOT *field_alloc;
+ CHARSET_INFO *thd_cs= thd->variables.character_set_results;
+ CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("send_fields");
@@ -616,12 +645,29 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
Send_field server_field;
item->make_field(&server_field);
- client_field->db= strdup_root(field_alloc, server_field.db_name);
- client_field->table= strdup_root(field_alloc, server_field.table_name);
- client_field->name= strdup_root(field_alloc, server_field.col_name);
- client_field->org_table= strdup_root(field_alloc, server_field.org_table_name);
- client_field->org_name= strdup_root(field_alloc, server_field.org_col_name);
- client_field->length= server_field.length;
+ client_field->db= dup_str_aux(field_alloc, server_field.db_name,
+ strlen(server_field.db_name), cs, thd_cs);
+ client_field->table= dup_str_aux(field_alloc, server_field.table_name,
+ strlen(server_field.table_name), cs, thd_cs);
+ client_field->name= dup_str_aux(field_alloc, server_field.col_name,
+ strlen(server_field.col_name), cs, thd_cs);
+ client_field->org_table= dup_str_aux(field_alloc, server_field.org_table_name,
+ strlen(server_field.org_table_name), cs, thd_cs);
+ client_field->org_name= dup_str_aux(field_alloc, server_field.org_col_name,
+ strlen(server_field.org_col_name), cs, thd_cs);
+ if (item->collation.collation == &my_charset_bin || thd_cs == NULL)
+ {
+ /* No conversion */
+ client_field->charsetnr= server_field.charsetnr;
+ client_field->length= server_field.length;
+ }
+ else
+ {
+ /* With conversion */
+ client_field->charsetnr= thd_cs->number;
+ uint char_len= server_field.length / item->collation.collation->mbmaxlen;
+ client_field->length= char_len * thd_cs->mbmaxlen;
+ }
client_field->type= server_field.type;
client_field->flags= server_field.flags;
client_field->decimals= server_field.decimals;
@@ -630,9 +676,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
client_field->name_length= strlen(client_field->name);
client_field->org_name_length= strlen(client_field->org_name);
client_field->org_table_length= strlen(client_field->org_table);
- client_field->charsetnr= server_field.charsetnr;
- client_field->catalog= strdup_root(field_alloc, "def");
+ client_field->catalog= dup_str_aux(field_alloc, "def", 3, cs, thd_cs);
client_field->catalog_length= 3;
if (INTERNAL_NUM_FIELD(client_field))
@@ -710,6 +755,7 @@ bool Protocol_prep::write()
}
cur->data= (MYSQL_ROW)(((char *)cur) + sizeof(MYSQL_ROWS));
memcpy(cur->data, packet->ptr()+1, packet->length()-1);
+ cur->length= packet->length(); /* To allow us to do sanity checks */
*data->prev_ptr= cur;
data->prev_ptr= &cur->next;
@@ -804,21 +850,3 @@ bool Protocol::net_store_data(const char *from, uint length)
return false;
}
-#if 0
-/* The same as Protocol::net_store_data but does the converstion
-*/
-bool Protocol::convert_str(const char *from, uint length)
-{
- if (!(*next_field=alloc_root(alloc, length + 1)))
- return true;
- convert->store_dest(*next_field, from, length);
- (*next_field)[length]= 0;
- if (next_mysql_field->max_length < length)
- next_mysql_field->max_length=length;
- ++next_field;
- ++next_mysql_field;
-
- return false;
-}
-#endif
-
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index a2c4be1a078..6fa41fb3fd0 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -143,6 +143,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
db ? db : "(Null)",
user ? user : "(Null)"));
+ if (!host || !host[0])
+ host= mysql->options.host;
+
if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION ||
(mysql->options.methods_to_use == MYSQL_OPT_GUESS_CONNECTION &&
host && *host && strcmp(host,LOCAL_HOST)))
diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def
index 14c6725bcb5..ea3133594f5 100644
--- a/libmysqld/libmysqld.def
+++ b/libmysqld/libmysqld.def
@@ -157,3 +157,4 @@ EXPORTS
mysql_stmt_attr_get
mysql_stmt_attr_set
mysql_stmt_field_count
+ get_defaults_files