Commit 0d520670 authored by unknown's avatar unknown

Merge work.mysql.com:/home/bk/mysql-4.1

into myvenu.com:/home/venu/bk/src-4.1


mysql-test/r/create.result:
  Auto merged
parents ac2aea8c db67a2ee
...@@ -439,13 +439,12 @@ typedef struct st_mysql_bind ...@@ -439,13 +439,12 @@ typedef struct st_mysql_bind
{ {
long *length; /* output length pointer */ long *length; /* output length pointer */
gptr buffer; /* buffer */ gptr buffer; /* buffer */
unsigned long buffer_length; /* buffer length */
enum enum_field_types buffer_type; /* buffer type */ enum enum_field_types buffer_type; /* buffer type */
enum enum_field_types field_type; /* field type */
my_bool is_null; /* NULL indicator */ my_bool is_null; /* NULL indicator */
my_bool is_long_data; /* long data indicator */ my_bool is_long_data; /* long data indicator */
/* The following are for internal use. Set by mysql_bind_param */ /* The following are for internal use. Set by mysql_bind_param */
unsigned long buffer_length; /* buffer length */
long bind_length; /* Default length of data */ long bind_length; /* Default length of data */
my_bool long_ended; /* All data supplied for long */ my_bool long_ended; /* All data supplied for long */
unsigned int param_number; /* For null count and error messages */ unsigned int param_number; /* For null count and error messages */
...@@ -511,6 +510,7 @@ MYSQL_RES *STDCALL mysql_prepare_result(MYSQL_STMT *stmt); ...@@ -511,6 +510,7 @@ MYSQL_RES *STDCALL mysql_prepare_result(MYSQL_STMT *stmt);
#define MYSQL_NO_DATA 100 #define MYSQL_NO_DATA 100
#define MYSQL_NEED_DATA 99 #define MYSQL_NEED_DATA 99
#define MYSQL_NULL_DATA (-1) #define MYSQL_NULL_DATA (-1)
#define MYSQL_LONG_DATA (-2)
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT) #define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
......
...@@ -4097,8 +4097,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param) ...@@ -4097,8 +4097,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param)
DBUG_PRINT("enter",("type: %d, buffer:%lx, length: %d", param->buffer_type, DBUG_PRINT("enter",("type: %d, buffer:%lx, length: %d", param->buffer_type,
param->buffer ? param->buffer : "0", *param->length)); param->buffer ? param->buffer : "0", *param->length));
if (param->is_null || param->buffer_type == MYSQL_TYPE_NULL || if (param->is_null || *param->length == MYSQL_NULL_DATA)
*param->length == MYSQL_NULL_DATA)
store_param_null(net, param); store_param_null(net, param);
else else
{ {
...@@ -4190,7 +4189,7 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt) ...@@ -4190,7 +4189,7 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
for (param= stmt->params; param < param_end; param++) for (param= stmt->params; param < param_end; param++)
{ {
/* Check for long data which has not been propery given/terminated */ /* Check for long data which has not been propery given/terminated */
if (param->is_long_data) if (param->is_long_data || *param->length == MYSQL_LONG_DATA)
{ {
if (!param->long_ended) if (!param->long_ended)
DBUG_RETURN(MYSQL_NEED_DATA); DBUG_RETURN(MYSQL_NEED_DATA);
...@@ -4281,7 +4280,7 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind) ...@@ -4281,7 +4280,7 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
/* Setup data copy functions for the different supported types */ /* Setup data copy functions for the different supported types */
switch (param->buffer_type) { switch (param->buffer_type) {
case MYSQL_TYPE_NULL: case MYSQL_TYPE_NULL:
param->is_null=1; param->is_null= 1;
break; break;
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
param->bind_length= 1; param->bind_length= 1;
...@@ -4412,41 +4411,32 @@ mysql_send_long_data(MYSQL_STMT *stmt, uint param_number, ...@@ -4412,41 +4411,32 @@ mysql_send_long_data(MYSQL_STMT *stmt, uint param_number,
1 Error (Can't alloc net->buffer) 1 Error (Can't alloc net->buffer)
****************************************************************************/ ****************************************************************************/
/* Return the default binary data length for the common types */
static ulong get_field_length(uint type) static unsigned int get_binary_length(uint type)
{ {
ulong length; switch(type) {
switch (type) {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
length= 1; return 1;
break;
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_YEAR: case MYSQL_TYPE_YEAR:
length= 2; return 2;
break;
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
length= 4; return 4;
break;
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_DOUBLE:
length= 8; return 8;
break;
default: default:
length= 0; return 0;
} }
return length;
} }
/* Convert Numeric to buffer types */
static void send_data_long(MYSQL_BIND *param, longlong value) static void send_data_long(MYSQL_BIND *param, longlong value)
{ {
char *buffer= param->buffer; char *buffer= param->buffer;
*param->length= get_field_length(param->buffer_type);
switch(param->buffer_type) { switch(param->buffer_type) {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
*param->buffer= (uchar) value; *param->buffer= (uchar) value;
break; break;
...@@ -4480,13 +4470,12 @@ static void send_data_long(MYSQL_BIND *param, longlong value) ...@@ -4480,13 +4470,12 @@ static void send_data_long(MYSQL_BIND *param, longlong value)
} }
} }
/* Convert Double to buffer types */
static void send_data_double(MYSQL_BIND *param, double value) static void send_data_double(MYSQL_BIND *param, double value)
{ {
char *buffer= param->buffer; char *buffer= param->buffer;
*param->length= get_field_length(param->buffer_type);
switch(param->buffer_type) { switch(param->buffer_type) {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
*buffer= (uchar)value; *buffer= (uchar)value;
break; break;
...@@ -4520,63 +4509,64 @@ static void send_data_double(MYSQL_BIND *param, double value) ...@@ -4520,63 +4509,64 @@ static void send_data_double(MYSQL_BIND *param, double value)
} }
} }
static void send_data_str(MYSQL_BIND *param, char *value, uint src_length) /* Convert string to buffer types */
static void send_data_str(MYSQL_BIND *param, char *value, uint length)
{ {
char *buffer= param->buffer; char *buffer= param->buffer;
*param->length= get_field_length(param->buffer_type);
switch(param->buffer_type) { switch(param->buffer_type) {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
*buffer= (char)*value; {
uchar data= (uchar)my_strntol(system_charset_info,value,length,NULL,10);
*buffer= data;
break; break;
}
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
{ {
short data= (short)sint2korr(value); short data= (short)my_strntol(system_charset_info,value,length,NULL,10);
int2store(buffer, data); int2store(buffer, data);
break; break;
} }
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
{ {
int32 data= (int32)sint4korr(value); int32 data= (int32)my_strntol(system_charset_info,value,length,NULL,10);
int4store(buffer, data); int4store(buffer, data);
break; break;
} }
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
{ {
longlong data= sint8korr(value); longlong data= my_strntoll(system_charset_info,value,length,NULL,10);
int8store(buffer, data); int8store(buffer, data);
break; break;
} }
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
{ {
float data; float data = (float)my_strntod(system_charset_info,value,length,NULL);
float4get(data, value);
float4store(buffer, data); float4store(buffer, data);
break; break;
} }
case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_DOUBLE:
{ {
double data; double data= my_strntod(system_charset_info,value,length,NULL);
float8get(data, value);
float8store(buffer, data); float8store(buffer, data);
break; break;
} }
default: default:
*param->length= src_length; *param->length= length;
memcpy(buffer, value, src_length); memcpy(buffer, value, length);
buffer[src_length]='\0'; buffer[length]='\0';
} }
} }
/* Fetch data to buffers */
static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param, static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param,
uint field_type, uchar **row) uint field_type, uchar **row)
{ {
ulong length; ulong length;
length= get_field_length(field_type); length= (ulong)get_binary_length(field_type);
switch (field_type) {
switch (field_type) {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
{ {
uchar value= (uchar) **row; uchar value= (uchar) **row;
...@@ -4813,27 +4803,21 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) ...@@ -4813,27 +4803,21 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
/* Setup data copy functions for the different supported types */ /* Setup data copy functions for the different supported types */
switch (param->buffer_type) { switch (param->buffer_type) {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
param->bind_length= 1;
param->fetch_result= fetch_result_tinyint; param->fetch_result= fetch_result_tinyint;
break; break;
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
param->bind_length= 2;
param->fetch_result= fetch_result_short; param->fetch_result= fetch_result_short;
break; break;
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
param->bind_length= 4;
param->fetch_result= fetch_result_int32; param->fetch_result= fetch_result_int32;
break; break;
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
param->bind_length= 8;
param->fetch_result= fetch_result_int64; param->fetch_result= fetch_result_int64;
break; break;
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
param->bind_length= 4;
param->fetch_result= fetch_result_float; param->fetch_result= fetch_result_float;
break; break;
case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_DOUBLE:
param->bind_length= 8;
param->fetch_result= fetch_result_double; param->fetch_result= fetch_result_double;
break; break;
case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
...@@ -4842,7 +4826,6 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) ...@@ -4842,7 +4826,6 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
case MYSQL_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
param->bind_length= 0;
param->fetch_result= fetch_result_str; param->fetch_result= fetch_result_str;
break; break;
default: default:
...@@ -4852,6 +4835,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) ...@@ -4852,6 +4835,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
} }
if (!param->length) if (!param->length)
param->length= &param->bind_length; param->length= &param->bind_length;
*param->length= (long)get_binary_length(param->buffer_type);
} }
stmt->res_buffers= 1; stmt->res_buffers= 1;
DBUG_RETURN(0); DBUG_RETURN(0);
......
drop table if exists t1,t2; drop table if exists t1,t2,t3;
create table t1 (b char(0)); create table t1 (b char(0));
insert into t1 values (""),(null); insert into t1 values (""),(null);
select * from t1; select * from t1;
......
...@@ -13,3 +13,20 @@ set SQL_WARNINGS=0; ...@@ -13,3 +13,20 @@ set SQL_WARNINGS=0;
drop temporary table if exists not_exists; drop temporary table if exists not_exists;
Warnings: Warnings:
Note 1051 Unknown table 'not_exists' Note 1051 Unknown table 'not_exists'
drop table if exists not_exists_table;
Warnings:
Note 1051 Unknown table 'not_exists_table'
show warnings limit 1;
Level Code Message
Note 1051 Unknown table 'not_exists_table'
drop database if exists not_exists_db;
Warnings:
Note 1008 Can't drop database 'not_exists_db'. Database doesn't exist
show count(*) warnings;
@@session.warning_count
1
create table t1(id int);
create table if not exists t1(id int);
select @@warning_count;
@@warning_count
0
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# #
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2,t3;
--enable_warnings --enable_warnings
create table t1 (b char(0)); create table t1 (b char(0));
......
...@@ -19,3 +19,10 @@ set SQL_WARNINGS=0; ...@@ -19,3 +19,10 @@ set SQL_WARNINGS=0;
# Test other warnings # Test other warnings
drop temporary table if exists not_exists; drop temporary table if exists not_exists;
drop table if exists not_exists_table;
show warnings limit 1;
drop database if exists not_exists_db;
show count(*) warnings;
create table t1(id int);
create table if not exists t1(id int);
select @@warning_count;
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment