diff options
author | unknown <monty@mashka.mysql.fi> | 2003-09-11 20:31:40 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2003-09-11 20:31:40 +0300 |
commit | 41824a35338012ff8196eb975f961d5e0f0e2a22 (patch) | |
tree | 1475a169c541e6b7aedb36103dd255fe52fc0517 /libmysql | |
parent | 07bc35e1d024e5e3b81b131a47878510f0521609 (diff) | |
parent | d32bdcb1bfc274476cdd945e66e00f3ec31253c3 (diff) | |
download | mariadb-git-41824a35338012ff8196eb975f961d5e0f0e2a22.tar.gz |
merge with 4.1 tree
client/mysqltest.c:
Auto merged
include/mysql.h:
Auto merged
libmysql/errmsg.c:
Auto merged
libmysql/libmysql.c:
Auto merged
mysql-test/mysql-test-run.sh:
Auto merged
sql/field.cc:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/share/portuguese/errmsg.txt:
Auto merged
sql/share/spanish/errmsg.txt:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
tests/client_test.c:
Auto merged
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/Makefile.am | 2 | ||||
-rw-r--r-- | libmysql/Makefile.shared | 3 | ||||
-rw-r--r-- | libmysql/dll.c | 13 | ||||
-rw-r--r-- | libmysql/errmsg.c | 36 | ||||
-rw-r--r-- | libmysql/get_password.c | 2 | ||||
-rw-r--r-- | libmysql/libmysql.c | 178 |
6 files changed, 90 insertions, 144 deletions
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 0125bd2b98d..3e026fe589a 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -42,7 +42,7 @@ link_sources: rm -f $(srcdir)/$$f; \ @LN_CP_F@ $(srcdir)/../strings/$$f $(srcdir)/$$f; \ done; \ - for f in $$vs; do \ + for f in $$vs $(vioheaders); do \ rm -f $(srcdir)/$$f; \ @LN_CP_F@ $(srcdir)/../vio/$$f $(srcdir)/$$f; \ done; \ diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 9a5869c47ff..1d431fa3624 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -47,6 +47,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \ mystringsextra= strto.c dbugobjects = dbug.lo # IT IS IN SAFEMALLOC.C sanity.lo mysysheaders = mysys_priv.h my_static.h +vioheaders = vio_priv.h mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \ my_create.lo my_delete.lo mf_tempfile.lo my_open.lo \ my_read.lo my_write.lo errors.lo \ @@ -88,7 +89,7 @@ clean-local: `echo $(vio_objects) | sed "s;\.lo;.c;g"` \ `echo $(sql_cmn_objects) | sed "s;\.lo;.c;g"` \ $(CHARSET_SRCS) $(CHARSET_OBJS) \ - $(mystringsextra) $(mysysheaders) \ + $(mystringsextra) $(mysysheaders) $(vioheaders)\ ../linked_client_sources net.c conf_to_src_SOURCES = conf_to_src.c diff --git a/libmysql/dll.c b/libmysql/dll.c index f0a67d8f091..92aa611000b 100644 --- a/libmysql/dll.c +++ b/libmysql/dll.c @@ -112,12 +112,13 @@ int _export FAR PASCAL libmain(HANDLE hModule,short cbHeapSize, #ifdef OS2 -// -// This function is called automatically by _DLL_InitTerm -// Every dll runtime enviroment is not tz enabled, so tzset() -// must be called to enable TZ handling -// Also timezone is fixed. -// +/* + This function is called automatically by _DLL_InitTerm + Every dll runtime enviroment is not tz enabled, so tzset() + must be called to enable TZ handling + Also timezone is fixed. +*/ + extern "C" unsigned long _System DllMain(unsigned long modhandle, unsigned long flag) { diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index d27e981aaab..148625129b5 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -26,24 +26,24 @@ const char *client_errors[]= { "Unbekannter MySQL Fehler", "Kann UNIX-Socket nicht anlegen (%d)", - "Keine Verbindung zu lokalem MySQL Server, socket: '%-.64s' (%d)", - "Keine Verbindung zu MySQL Server auf %-.64s (%d)", + "Keine Verbindung zu lokalem MySQL Server, socket: '%-.100s' (%d)", + "Keine Verbindung zu MySQL Server auf %-.100s (%d)", "Kann TCP/IP-Socket nicht anlegen (%d)", - "Unbekannter MySQL Server Host (%-.64s) (%d)", + "Unbekannter MySQL Server Host (%-.100s) (%d)", "MySQL Server nicht vorhanden", "Protokolle ungleich. Server Version = % d Client Version = %d", "MySQL client got out of memory", "Wrong host info", "Localhost via UNIX socket", - "%-.64s via TCP/IP", + "%-.100s via TCP/IP", "Error in server handshake", "Lost connection to MySQL server during query", "Commands out of sync; You can't run this command now", - "Verbindung ueber Named Pipe; Host: %-.64s", + "Verbindung ueber Named Pipe; Host: %-.100s", "Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)", "Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)", "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)", - "Can't initialize character set %-.64s (path: %-.64s)", + "Can't initialize character set %-.32s (path: %-.100s)", "Got packet bigger than 'max_allowed_packet'", "Embedded server", "Error on SHOW SLAVE STATUS:", @@ -82,24 +82,24 @@ const char *client_errors[]= { "Erro desconhecido do MySQL", "Não pode criar 'UNIX socket' (%d)", - "Não pode se conectar ao servidor MySQL local através do 'socket' '%-.64s' (%d)", - "Não pode se conectar ao servidor MySQL em '%-.64s' (%d)", + "Não pode se conectar ao servidor MySQL local através do 'socket' '%-.100s' (%d)", + "Não pode se conectar ao servidor MySQL em '%-.100s' (%d)", "Não pode criar 'socket TCP/IP' (%d)", - "'Host' servidor MySQL '%-.64s' (%d) desconhecido", + "'Host' servidor MySQL '%-.100s' (%d) desconhecido", "Servidor MySQL desapareceu", "Incompatibilidade de protocolos. Versão do Servidor: %d - Versão do Cliente: %d", "Cliente do MySQL com falta de memória", "Informação inválida de 'host'", "Localhost via 'UNIX socket'", - "%-.64s via 'TCP/IP'", + "%-.100s via 'TCP/IP'", "Erro na negociação de acesso ao servidor", "Conexão perdida com servidor MySQL durante 'query'", "Comandos fora de sincronismo. Você não pode executar este comando agora", - "%-.64s via 'named pipe'", + "%-.100s via 'named pipe'", "Não pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "Não pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "Não pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", - "Não pode inicializar conjunto de caracteres %-.64s (caminho %-.64s)", + "Não pode inicializar conjunto de caracteres %-.32s (caminho %-.100s)", "Obteve pacote maior do que 'max_allowed_packet'", "Embedded server" "Error on SHOW SLAVE STATUS:", @@ -136,24 +136,24 @@ const char *client_errors[]= { "Unknown MySQL error", "Can't create UNIX socket (%d)", - "Can't connect to local MySQL server through socket '%-.64s' (%d)", - "Can't connect to MySQL server on '%-.64s' (%d)", + "Can't connect to local MySQL server through socket '%-.100s' (%d)", + "Can't connect to MySQL server on '%-.100s' (%d)", "Can't create TCP/IP socket (%d)", - "Unknown MySQL Server Host '%-.64s' (%d)", + "Unknown MySQL Server Host '%-.100s' (%d)", "MySQL server has gone away", "Protocol mismatch. Server Version = %d Client Version = %d", "MySQL client run out of memory", "Wrong host info", "Localhost via UNIX socket", - "%-.64s via TCP/IP", + "%-.100s via TCP/IP", "Error in server handshake", "Lost connection to MySQL server during query", "Commands out of sync; You can't run this command now", - "%-.64s via named pipe", + "%-.100s via named pipe", "Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)", - "Can't initialize character set %-.64s (path: %-.64s)", + "Can't initialize character set %-.32s (path: %-.100s)", "Got packet bigger than 'max_allowed_packet'", "Embedded server", "Error on SHOW SLAVE STATUS:", diff --git a/libmysql/get_password.c b/libmysql/get_password.c index e6221ea556e..0e3b2dcb0ae 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -78,7 +78,7 @@ char *get_tty_password(char *opt_message) char *pos=to,*end=to+sizeof(to)-1; int i=0; DBUG_ENTER("get_tty_password"); - fprintf(stdout,opt_message ? opt_message : "Enter password: "); + _cputs(opt_message ? opt_message : "Enter password: "); for (;;) { char tmp; diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 3058efb83cb..68f596c833d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -155,9 +155,16 @@ void STDCALL mysql_server_end() { /* If library called my_init(), free memory allocated by it */ if (!org_my_init_done) + { my_end(0); +#ifndef THREAD + /* Remove TRACING, if enabled by mysql_debug() */ + DBUG_POP(); +#endif + } else mysql_thread_end(); + mysql_client_init= org_my_init_done= 0; } #endif /*EMBEDDED_LIBRARY*/ @@ -1708,10 +1715,10 @@ unsigned int alloc_stmt_fields(MYSQL_STMT *stmt) */ MYSQL_RES * STDCALL -mysql_prepare_result(MYSQL_STMT *stmt) +mysql_get_metadata(MYSQL_STMT *stmt) { MYSQL_RES *result; - DBUG_ENTER("mysql_prepare_result"); + DBUG_ENTER("mysql_get_metadata"); if (!stmt->field_count || !stmt->fields) { @@ -1751,7 +1758,6 @@ mysql_param_result(MYSQL_STMT *stmt) } - /******************************************************************** Prepare-execute, and param handling *********************************************************************/ @@ -1766,6 +1772,7 @@ static void store_param_type(NET *net, uint type) net->write_pos+=2; } + /**************************************************************************** Functions to store parameter data from a prepared statement. @@ -1781,7 +1788,6 @@ static void store_param_type(NET *net, uint type) 1 Error (Can't alloc net->buffer) ****************************************************************************/ - static void store_param_tinyint(NET *net, MYSQL_BIND *param) { *(net->write_pos++)= (uchar) *param->buffer; @@ -2078,8 +2084,6 @@ my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt) static my_bool int_is_null_true= 1; /* Used for MYSQL_TYPE_NULL */ static my_bool int_is_null_false= 0; -static my_bool int_is_null_dummy; -static unsigned long param_length_is_dummy; /* Setup the parameter data buffers from application @@ -2415,7 +2419,10 @@ static void send_data_long(MYSQL_BIND *param, longlong value) char tmp[22]; /* Enough for longlong */ uint length= (uint)(longlong10_to_str(value,(char *)tmp,10)-tmp); ulong copy_length= min((ulong)length-param->offset, param->buffer_length); - memcpy(buffer, (char *)tmp+param->offset, copy_length); + if ((long) copy_length < 0) + copy_length=0; + else + memcpy(buffer, (char *)tmp+param->offset, copy_length); *param->length= length; if (copy_length != param->buffer_length) @@ -2463,7 +2470,10 @@ static void send_data_double(MYSQL_BIND *param, double value) char tmp[128]; uint length= my_sprintf(tmp,(tmp,"%g",value)); ulong copy_length= min((ulong)length-param->offset, param->buffer_length); - memcpy(buffer, (char *)tmp+param->offset, copy_length); + if ((long) copy_length < 0) + copy_length=0; + else + memcpy(buffer, (char *)tmp+param->offset, copy_length); *param->length= length; if (copy_length != param->buffer_length) @@ -2528,15 +2538,19 @@ static void send_data_str(MYSQL_BIND *param, char *value, uint length) case MYSQL_TYPE_BLOB: *param->length= length; length= min(length-param->offset, param->buffer_length); - memcpy(buffer, value+param->offset, length); + if ((long) length > 0) + memcpy(buffer, value+param->offset, length); break; default: *param->length= length; length= min(length-param->offset, param->buffer_length); - memcpy(buffer, value+param->offset, length); + if ((long) length < 0) + length= 0; + else + memcpy(buffer, value+param->offset, length); if (length != param->buffer_length) buffer[length]= '\0'; - } + } } @@ -2598,15 +2612,16 @@ static void send_data_time(MYSQL_BIND *param, MYSQL_TIME ltime, /* Fetch data to buffers */ -static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row, - my_bool field_is_unsigned) +static void fetch_results(MYSQL_BIND *param, MYSQL_FIELD *field, uchar **row) { ulong length; - + enum enum_field_types field_type= field->type; + switch (field_type) { case MYSQL_TYPE_TINY: { char value= (char) **row; + uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); longlong data= ((field_is_unsigned) ? (longlong) (unsigned char) value: (longlong) value); send_data_long(param,data); @@ -2617,6 +2632,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row, case MYSQL_TYPE_YEAR: { short value= sint2korr(*row); + uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); longlong data= ((field_is_unsigned) ? (longlong) (unsigned short) value: (longlong) value); send_data_long(param,data); @@ -2626,6 +2642,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row, case MYSQL_TYPE_LONG: { long value= sint4korr(*row); + uint field_is_unsigned= (field->flags & UNSIGNED_FLAG); longlong data= ((field_is_unsigned) ? (longlong) (unsigned long) value: (longlong) value); send_data_long(param,data); @@ -2774,24 +2791,6 @@ static void fetch_result_str(MYSQL_BIND *param, uchar **row) *row+= length; } -static uint default_binary_field_length(uint field_type) -{ - switch(field_type) { - case MYSQL_TYPE_TINY: - return 1; - case MYSQL_TYPE_SHORT: - return 2; - case MYSQL_TYPE_LONG: - case MYSQL_TYPE_FLOAT: - return 4; - case MYSQL_TYPE_LONGLONG: - case MYSQL_TYPE_DOUBLE: - return 8; - default: - return 0; - } -} - /* Setup the bind buffers for resultset processing @@ -2831,10 +2830,10 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) This is to make the excute code easier */ if (!param->is_null) - param->is_null= &int_is_null_dummy; + param->is_null= ¶m->internal_is_null; if (!param->length) - param->length= ¶m_length_is_dummy; + param->length= ¶m->internal_length; param->param_number= param_count++; param->offset= 0; @@ -2938,10 +2937,7 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row) if (field->type == bind->buffer_type) (*bind->fetch_result)(bind, &row); else - { - my_bool field_is_unsigned= (field->flags & UNSIGNED_FLAG) ? 1: 0; - fetch_results(bind, field->type, &row, field_is_unsigned); - } + fetch_results(bind, field, &row); } if (!((bit<<=1) & 255)) { @@ -2963,8 +2959,8 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt) uchar *row; DBUG_ENTER("mysql_fetch"); - stmt->last_fetched_column= 0; /* reset */ - if (stmt->result_buffered) /* buffered */ + stmt->last_fetched_column= 0; /* reset */ + if (stmt->result_buffered) /* buffered */ { MYSQL_RES *res; @@ -2979,7 +2975,7 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt) row= (uchar *)res->data_cursor->data; res->data_cursor= res->data_cursor->next; } - else /* un-buffered */ + else /* un-buffered */ { if (packet_error == net_safe_read(mysql)) { @@ -3005,107 +3001,55 @@ no_data: /* - Fetch only specified column data to buffers + Fetch datat for one specified column data + + SYNOPSIS + mysql_fetch_column() + stmt Prepared statement handler + bind Where date should be placed. Should be filled in as + when calling mysql_bind_param() + column Column to fetch (first column is 0) + ulong offset Offset in result data (to fetch blob in pieces) + This is normally 0 + RETURN + 0 ok + 1 error */ int STDCALL mysql_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, - my_ulonglong icol, - ulong offset) + uint column, ulong offset) { - uchar *row; - my_bool null_data; - + MYSQL_BIND *param= stmt->bind+column; DBUG_ENTER("mysql_fetch_column"); - if (!(row= stmt->current_row)) + if (!stmt->current_row) goto no_data; #ifdef CHECK_EXTRA_ARGUMENTS - if (!bind || icol >= stmt->field_count) + if (column >= stmt->field_count) { - set_stmt_errmsg(stmt, "Invalid column descriptor or offset",1, - unknown_sqlstate); + set_stmt_errmsg(stmt, "Invalid column descriptor",1, unknown_sqlstate); DBUG_RETURN(1); } #endif - /* column '0' == first column */ - if (stmt->res_buffers) - { - /* - Already buffers are parsed and cached to stmt->bind - during mysql_fetch() call. - */ - MYSQL_BIND *param= stmt->bind+icol; - null_data= param->null_field; - row= param->inter_buffer; - } - else - { - if (stmt->last_fetched_column == icol+1) - { - /* - Data buffer is already parsed during the last call, get - the cached information - */ - if (!stmt->last_fetched_buffer) - null_data= 1; - else - { - null_data= 0; - row= stmt->last_fetched_buffer; - } - } - else - { - /* - Advance the data buffer to icol position and cache - the information for subsequent calls - */ - uint bit= icol > 6 ? 1 : 4; - stmt->last_fetched_column= icol+1; - - if (row[icol/8] & (bit << icol & 7)) - { - stmt->last_fetched_buffer= 0; - null_data= 1; - } - else - { - uint length, i; - - null_data= 0; - row+= (stmt->field_count+9)/8; /* skip null bits */ - - for (i=0; i < icol; i++) - { - if (!(length= default_binary_field_length((uint)(stmt->fields[i]. - type)))) - length= net_field_length(&row); - row+= length; - } - stmt->last_fetched_buffer= row; - } - } - } - if (null_data) + if (param->null_field) { if (bind->is_null) *bind->is_null= 1; } else { - MYSQL_FIELD *field= stmt->fields+icol; - my_bool field_is_unsigned= (field->flags & UNSIGNED_FLAG) ? 1: 0; - + MYSQL_FIELD *field= stmt->fields+column; + uchar *row= param->inter_buffer; bind->offset= offset; if (bind->is_null) *bind->is_null= 0; if (bind->length) /* Set the length if non char/binary types */ - *bind->length= default_binary_field_length(field->type); + *bind->length= *param->length; else - bind->length= ¶m_length_is_dummy; - fetch_results(bind, field->type, &row, field_is_unsigned); + bind->length= ¶m->internal_length; /* Needed for fetch_result() */ + fetch_results(bind, field, &row); } DBUG_RETURN(0); |