Commit bcae5017 authored by paul@ice.snake.net's avatar paul@ice.snake.net

Merge paul@bk-internal.mysql.com:/home/bk/mysql-4.1

into ice.snake.net:/Volumes/ice2/MySQL/bk/mysql-4.1
parents fb15e3e7 dabc0e77
......@@ -710,6 +710,7 @@ void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt);
my_bool STDCALL mysql_commit(MYSQL * mysql);
my_bool STDCALL mysql_rollback(MYSQL * mysql);
......
......@@ -1640,70 +1640,46 @@ myodbc_remove_escape(MYSQL *mysql,char *name)
}
/********************************************************************
Implementation of new client API for 4.1 version.
Implementation of new client-server prototypes for 4.1 version
starts from here ..
mysql_* are real prototypes used by applications
mysql_stmt_* are real prototypes used by applications.
To make API work in embedded library all functions performing
real I/O are prefixed with 'cli_' (abbreviated from 'Call Level
Interface'). This functions are invoked via pointers set in
MYSQL::methods structure. Embedded counterparts, prefixed with
'emb_' reside in libmysqld/lib_sql.cc.
*********************************************************************/
/********************************************************************
Misc Utility functions
********************************************************************/
/*
Set the internal stmt error messages
*/
static void set_stmt_error(MYSQL_STMT * stmt, int errcode,
const char *sqlstate)
{
DBUG_ENTER("set_stmt_error");
DBUG_PRINT("enter", ("error: %d '%s'", errcode, ER(errcode)));
DBUG_ASSERT(stmt != 0);
stmt->last_errno= errcode;
strmov(stmt->last_error, ER(errcode));
strmov(stmt->sqlstate, sqlstate);
DBUG_VOID_RETURN;
}
/******************* Declarations ***********************************/
/*
Copy error message to statement handler
These functions are called by function pointer MYSQL_STMT::read_row_func.
Each function corresponds to one of the read methods:
- mysql_stmt_fetch without prior mysql_stmt_store_result,
- mysql_stmt_fetch when result is stored,
- mysql_stmt_fetch when there are no rows (always returns MYSQL_NO_DATA)
*/
void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
const char *sqlstate)
{
DBUG_ENTER("set_stmt_error_msg");
DBUG_PRINT("enter", ("error: %d/%s '%s'", errcode, sqlstate, err));
DBUG_ASSERT(stmt != 0);
stmt->last_errno= errcode;
if (err && err[0])
strmov(stmt->last_error, err);
strmov(stmt->sqlstate, sqlstate);
DBUG_VOID_RETURN;
}
static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row);
static int stmt_read_row_buffered(MYSQL_STMT *stmt, unsigned char **row);
static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row);
/**************** Misc utility functions ****************************/
/*
Reallocate the NET package to be at least of 'length' bytes
SYNPOSIS
my_realloc_str()
net The NET structure to modify
int length Ensure that net->buff is at least this big
net The NET structure to modify
length Ensure that net->buff is at least this big
RETURN VALUES
0 ok
1 Error
*/
static my_bool my_realloc_str(NET *net, ulong length)
......@@ -1719,20 +1695,54 @@ static my_bool my_realloc_str(NET *net, ulong length)
DBUG_RETURN(res);
}
/********************************************************************
Prepare related implementations
********************************************************************/
static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row);
static int stmt_read_row_buffered(MYSQL_STMT *stmt, unsigned char **row);
static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row);
/*
Set statement error code, sqlstate, and error message
from given errcode and sqlstate.
*/
static void set_stmt_error(MYSQL_STMT * stmt, int errcode,
const char *sqlstate)
{
DBUG_ENTER("set_stmt_error");
DBUG_PRINT("enter", ("error: %d '%s'", errcode, ER(errcode)));
DBUG_ASSERT(stmt != 0);
stmt->last_errno= errcode;
strmov(stmt->last_error, ER(errcode));
strmov(stmt->sqlstate, sqlstate);
DBUG_VOID_RETURN;
}
/*
Set statement error code, sqlstate, and error message.
*/
void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
const char *sqlstate)
{
DBUG_ENTER("set_stmt_errmsg");
DBUG_PRINT("enter", ("error: %d/%s '%s'", errcode, sqlstate, err));
DBUG_ASSERT(stmt != 0);
stmt->last_errno= errcode;
if (err && err[0])
strmov(stmt->last_error, err);
strmov(stmt->sqlstate, sqlstate);
DBUG_VOID_RETURN;
}
/*
Read the prepared statement results ..
Read and unpack server reply to COM_PREPARE command (sent from
mysql_stmt_prepare).
NOTE
This is only called for connection to servers that supports
prepared statements (and thus the 4.1 protocol)
SYNOPSIS
cli_read_prepare_result()
mysql connection handle
stmt statement handle
RETURN VALUES
0 ok
......@@ -1752,7 +1762,9 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
pos= (uchar*) mysql->net.read_pos;
stmt->stmt_id= uint4korr(pos+1); pos+= 5;
/* Number of columns in result set */
field_count= uint2korr(pos); pos+= 2;
/* Number of placeholders in the statement */
param_count= uint2korr(pos); pos+= 2;
if (param_count != 0)
......@@ -1802,10 +1814,30 @@ MYSQL_STMT * STDCALL mysql_prepare(MYSQL *mysql, const char *query,
#endif
/*
Allocate memory and init prepared statement structure
Allocate memory and init prepared statement structure.
SYNOPSIS
mysql_stmt_init()
mysql connection handle
mysql connection handle
DESCRIPTION
This is an entry point of the new API. Returned handle stands for
a server-side prepared statement. Memory for this structure (~700
bytes) is allocated using 'malloc'. Once created, the handle can be
reused many times. Created statement handle is bound to connection
handle provided to this call: it's lifetime is limited by lifetime
of connection.
'mysql_stmt_init()' is a pure local call, server side structure is
created only in mysql_stmt_prepare.
Next steps you may want to make:
- set a statement attribute (mysql_stmt_attr_set()),
- prepare statement handle with a query (mysql_stmt_prepare()),
- close statement handle and free it's memory (mysql_stmt_close()),
- reset statement with mysql_stmt_reset() (a no-op which will
just return).
Behaviour of the rest of API calls on this statement is not defined yet
(though we're working on making each wrong call sequence return
error).
RETURN VALUE
statement structure upon success and NULL if out of
......@@ -1838,27 +1870,41 @@ mysql_stmt_init(MYSQL *mysql)
DBUG_RETURN(stmt);
}
/*
Prepare server side statement with query:
Prepare server side statement with query.
SYNOPSIS
mysql_stmt_prepare()
query statement to prepare
length statement length
stmt statement handle
query statement to prepare
length statement length
DESCRIPTION
- if this is a re-prepare of the statement, first close previous data
Associate statement with statement handle. This is done both on
client and server sides. At this point the server parses given query
and creates an internal structure to represent it.
Next steps you may want to make:
- find out if this statement returns a result set by
calling mysql_stmt_field_count(), and get result set metadata
with mysql_stmt_result_metadata(),
- if query contains placeholders, bind input parameters to placeholders
using mysql_stmt_bind_param(),
- otherwise proceed directly to mysql_stmt_execute().
IMPLEMENTATION NOTES
- if this is a re-prepare of the statement, first close previous data
structure on the server and free old statement data
- send the query to server and get back number of placeholders,
- then send the query to server and get back number of placeholders,
number of columns in result set (if any), and result set metadata.
At the same time allocate memory for input and output parameters
At the same time allocate memory for input and output parameters
to have less checks in mysql_stmt_bind_{param, result}.
RETURN VALUES
0 success
!0 error
!0 error
*/
int STDCALL
mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
{
......@@ -1938,8 +1984,10 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
}
/*
Get the execute query meta information for non-select
statements.
Get result set metadata from reply to mysql_stmt_execute.
This is used mainly for SHOW commands, as metadata for these
commands is sent only with result set.
To be removed when all commands will fully support prepared mode.
*/
static unsigned int alloc_stmt_fields(MYSQL_STMT *stmt)
......@@ -1983,8 +2031,31 @@ static unsigned int alloc_stmt_fields(MYSQL_STMT *stmt)
}
/*
Returns prepared meta information in the form of resultset
to client.
Returns prepared statement metadata in the form of a result set.
SYNOPSIS
mysql_stmt_result_metadata()
stmt statement handle
RETURN
NULL statement contains no result set or out of memory.
In the latter case you can retreive error message
with mysql_stmt_error.
MYSQL_RES a result set with no rows
DESCRIPTION
This function should be used after mysql_stmt_execute().
You can safely check that prepared statement has a result set by calling
mysql_stmt_num_fields(): if number of fields is not zero, you can call
this function to get fields metadata.
Next steps you may want to make:
- find out number of columns in result set by calling
mysql_num_fields(res) (the same value is returned by
mysql_stmt_num_fields)
- fetch metadata for any column with mysql_fetch_field,
mysql_fetch_field_direct, mysql_fetch_fields, mysql_field_seek.
- free returned MYSQL_RES structure with mysql_free_result.
- proceed to binding of output parameters.
*/
MYSQL_RES * STDCALL
......@@ -2016,8 +2087,9 @@ mysql_stmt_result_metadata(MYSQL_STMT *stmt)
}
/*
Returns parameter columns meta information in the form of
resultset.
Returns parameter columns meta information in the form of
result set.
XXX: not implemented yet.
*/
MYSQL_RES * STDCALL
......@@ -2036,12 +2108,8 @@ mysql_stmt_param_metadata(MYSQL_STMT *stmt)
}
/********************************************************************
Prepare-execute, and param handling
*********************************************************************/
/****************************************************************************
Functions to store parameter data from a prepared statement.
/*
Functions to store parameter data in network packet.
All functions have the following characteristics:
......@@ -2053,7 +2121,7 @@ mysql_stmt_param_metadata(MYSQL_STMT *stmt)
RETURN VALUES
0 ok
1 Error (Can't alloc net->buffer)
****************************************************************************/
*/
static void store_param_tinyint(NET *net, MYSQL_BIND *param)
{
......@@ -2162,7 +2230,8 @@ static void store_param_datetime(NET *net, MYSQL_BIND *param)
static void store_param_str(NET *net, MYSQL_BIND *param)
{
ulong length= param->length ? *param->length : param->buffer_length;
/* param->length is always set in mysql_stmt_bind_param */
ulong length= *param->length;
char *to= (char *) net_store_length((char *) net->write_pos, length);
memcpy(to, param->buffer, length);
net->write_pos= (uchar*) to+length;
......@@ -2529,6 +2598,16 @@ my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt)
}
/*
Returns the number of result columns for the most recent query
run on this statement.
*/
unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt)
{
return stmt->field_count;
}
/*
Return last inserted id for auto_increment columns
*/
......@@ -2538,6 +2617,7 @@ my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt)
return stmt->insert_id;
}
static my_bool int_is_null_true= 1; /* Used for MYSQL_TYPE_NULL */
static my_bool int_is_null_false= 0;
......@@ -2630,6 +2710,11 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
param->store_param_func= store_param_str;
/*
For variable length types we expect user to set
length or buffer_length. Otherwise mysql_stmt_execute
will just fail.
*/
break;
default:
strmov(stmt->sqlstate, unknown_sqlstate);
......@@ -2671,7 +2756,6 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
1 error
*/
my_bool STDCALL
mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
const char *data, ulong length)
......@@ -2769,6 +2853,7 @@ static uint read_binary_time(MYSQL_TIME *tm, uchar **pos)
uchar *to;
uint length;
/* net_field_length will set pos to the first byte of data */
if (!(length= net_field_length(pos)))
{
set_zero_time(tm);
......
......@@ -131,3 +131,4 @@ EXPORTS
mysql_stmt_insert_id
mysql_stmt_attr_get
mysql_stmt_attr_set
mysql_stmt_field_count
......@@ -210,7 +210,13 @@ static ulong get_param_length(uchar **packet, ulong len)
if (len < 5)
return 0;
(*packet)+=9; // Must be 254 when here
/* TODO: why uint4korr here? (should be uint8korr) */
/*
In our client-server protocol all numbers bigger than 2^24
stored as 8 bytes with uint8korr. Here we always know that
parameter length is less than 2^4 so don't look at the second
4 bytes. But still we need to obey the protocol hence 9 in the
assignment above.
*/
return (ulong) uint4korr(pos+1);
}
#else
......
......@@ -19,12 +19,6 @@
protocol
Main author: venu ( venu@mysql.com )
NOTES:
- To be able to test which fields are used, we are not clearing
the MYSQL_BIND with bzero() but instead just clearing the fields that
are used by the API.
***************************************************************************/
#include <my_global.h>
......@@ -790,17 +784,11 @@ static void test_tran_bdb()
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* create the table 'mytran_demo' of type BDB' or 'InnoDB' */
rc= mysql_query(mysql, "CREATE TABLE my_demo_transaction( "
"col1 int , col2 varchar(30)) TYPE= BDB");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* insert a row and commit the transaction */
rc= mysql_query(mysql, "INSERT INTO my_demo_transaction VALUES(10, 'venu')");
myquery(rc);
......@@ -869,17 +857,11 @@ static void test_tran_innodb()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS my_demo_transaction");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* create the table 'mytran_demo' of type BDB' or 'InnoDB' */
rc= mysql_query(mysql, "CREATE TABLE my_demo_transaction(col1 int, "
"col2 varchar(30)) TYPE= InnoDB");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* insert a row and commit the transaction */
rc= mysql_query(mysql, "INSERT INTO my_demo_transaction VALUES(10, 'venu')");
myquery(rc);
......@@ -943,9 +925,6 @@ static void test_prepare_simple()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_simple");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prepare_simple("
"id int, name varchar(50))");
myquery(rc);
......@@ -1014,9 +993,6 @@ static void test_prepare_field_result()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_field_result");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prepare_field_result(int_c int, "
"var_c varchar(50), ts_c timestamp(14), "
"char_c char(3), date_c date, extra tinyint)");
......@@ -1065,9 +1041,6 @@ static void test_prepare_syntax()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_syntax");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prepare_syntax("
"id int, name varchar(50), extra int)");
myquery(rc);
......@@ -1111,9 +1084,6 @@ static void test_prepare()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS my_prepare");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE my_prepare(col1 tinyint, "
"col2 varchar(15), col3 int, "
"col4 smallint, col5 bigint, "
......@@ -1283,9 +1253,6 @@ static void test_double_compare()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_double_compare");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_double_compare(col1 tinyint, "
" col2 float, col3 double )");
myquery(rc);
......@@ -1364,9 +1331,6 @@ static void test_null()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_null");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_null(col1 int, col2 varchar(50))");
myquery(rc);
......@@ -1543,9 +1507,6 @@ static void test_fetch_null()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_fetch_null");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_fetch_null("
" col1 tinyint, col2 smallint, "
" col3 int, col4 bigint, "
......@@ -1556,9 +1517,6 @@ static void test_fetch_null()
" col11 char(20))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_fetch_null (col11) "
"VALUES (1000), (88), (389789)");
myquery(rc);
......@@ -1670,18 +1628,12 @@ static void test_select_direct()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_select(id int, id1 tinyint, "
" id2 float, "
" id3 double, "
" name varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* insert a row and commit the transaction */
rc= mysql_query(mysql, "INSERT INTO test_select VALUES(10, 5, 2.3, 4.5, 'venu')");
myquery(rc);
......@@ -1716,15 +1668,9 @@ static void test_select_prepare()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_select(id int, name varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* insert a row and commit the transaction */
rc= mysql_query(mysql, "INSERT INTO test_select VALUES(10, 'venu')");
myquery(rc);
......@@ -1744,17 +1690,11 @@ static void test_select_prepare()
rc= mysql_query(mysql, "DROP TABLE test_select");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_select(id tinyint, id1 int, "
" id2 float, id3 float, "
" name varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* insert a row and commit the transaction */
rc= mysql_query(mysql, "INSERT INTO test_select(id, id1, id2, name) VALUES(10, 5, 2.3, 'venu')");
myquery(rc);
......@@ -1792,22 +1732,13 @@ static void test_select()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_select(id int, name varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* insert a row and commit the transaction */
rc= mysql_query(mysql, "INSERT INTO test_select VALUES(10, 'venu')");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* now insert the second row, and rollback the transaction */
rc= mysql_query(mysql, "INSERT INTO test_select VALUES(20, 'mysql')");
myquery(rc);
......@@ -2282,16 +2213,10 @@ static void test_simple_update()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_update");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_update(col1 int, "
" col2 varchar(50), col3 int )");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_update VALUES(1, 'MySQL', 100)");
myquery(rc);
......@@ -2364,16 +2289,10 @@ static void test_long_data()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_long_data(col1 int, "
" col2 long varchar, col3 long varbinary)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
strmov(query, "INSERT INTO test_long_data(col1, col2) VALUES(?)");
stmt= mysql_simple_prepare(mysql, query);
check_stmt_r(stmt);
......@@ -2454,15 +2373,9 @@ static void test_long_data_str()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data_str");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_long_data_str(id int, longstr long varchar)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
strmov(query, "INSERT INTO test_long_data_str VALUES(?, ?)");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
......@@ -2550,15 +2463,9 @@ static void test_long_data_str1()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data_str");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_long_data_str(longstr long varchar, blb long varbinary)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
strmov(query, "INSERT INTO test_long_data_str VALUES(?, ?)");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
......@@ -2707,15 +2614,9 @@ static void test_long_data_bin()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data_bin");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_long_data_bin(id int, longbin long varbinary)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
strmov(query, "INSERT INTO test_long_data_bin VALUES(?, ?)");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
......@@ -2789,16 +2690,10 @@ static void test_simple_delete()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_simple_delete");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_simple_delete(col1 int, \
col2 varchar(50), col3 int )");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_simple_delete VALUES(1, 'MySQL', 100)");
myquery(rc);
......@@ -2875,14 +2770,9 @@ static void test_update()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_update");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_update(col1 int primary key auto_increment, \
col2 varchar(50), col3 int )");
myquery(rc);
rc= mysql_commit(mysql);
rc= mysql_query(mysql, "CREATE TABLE test_update("
"col1 int primary key auto_increment, "
"col2 varchar(50), col3 int )");
myquery(rc);
strmov(query, "INSERT INTO test_update(col2, col3) VALUES(?, ?)");
......@@ -2972,13 +2862,10 @@ static void test_prepare_noparam()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS my_prepare");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE my_prepare(col1 int , col2 varchar(50))");
rc= mysql_query(mysql, "CREATE TABLE my_prepare(col1 int, col2 varchar(50))");
myquery(rc);
/* insert by prepare */
strmov(query, "INSERT INTO my_prepare VALUES(10, 'venu')");
stmt= mysql_simple_prepare(mysql, query);
......@@ -3025,15 +2912,9 @@ static void test_bind_result()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_result(col1 int , col2 varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(10, 'venu')");
myquery(rc);
......@@ -3124,22 +3005,17 @@ static void test_bind_result_ext()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, \
c3 int, c4 bigint, \
c5 float, c6 double, \
c7 varbinary(10), \
c8 varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 tinyint, "
" c2 smallint, "
" c3 int, c4 bigint, "
" c5 float, c6 double, "
" c7 varbinary(10), "
" c8 varchar(50))");
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(19, 2999, 3999, 4999999, \
2345.6, 5678.89563, \
'venu', 'mysql')");
rc= mysql_query(mysql, "INSERT INTO test_bind_result "
"VALUES (19, 2999, 3999, 4999999, "
" 2345.6, 5678.89563, 'venu', 'mysql')");
myquery(rc);
rc= mysql_commit(mysql);
......@@ -3246,9 +3122,6 @@ static void test_bind_result_ext1()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, \
c3 int, c4 bigint, \
c5 float, c6 double, \
......@@ -3256,9 +3129,6 @@ static void test_bind_result_ext1()
c8 varchar(10))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(120, 2999, 3999, 54, \
2.6, 58.89, \
'206', '6.7')");
......@@ -3505,9 +3375,6 @@ static void test_fetch_date()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 date, c2 time, \
c3 timestamp(14), \
c4 year, \
......@@ -3516,9 +3383,6 @@ static void test_fetch_date()
c7 timestamp(6))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES('2002-01-02', \
'12:49:00', \
'2002-01-02 17:46:59', \
......@@ -3632,9 +3496,6 @@ static void test_fetch_str()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 char(10), \
c2 char(10), \
c3 char(20), \
......@@ -3644,9 +3505,6 @@ static void test_fetch_str()
c7 char(20))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
bind_fetch(3);
}
......@@ -3662,9 +3520,6 @@ static void test_fetch_long()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 int unsigned, \
c2 int unsigned, \
c3 int, \
......@@ -3674,9 +3529,6 @@ static void test_fetch_long()
c7 int)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
bind_fetch(4);
}
......@@ -3692,9 +3544,6 @@ static void test_fetch_short()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 smallint unsigned, \
c2 smallint, \
c3 smallint unsigned, \
......@@ -3704,9 +3553,6 @@ static void test_fetch_short()
c7 smallint unsigned)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
bind_fetch(5);
}
......@@ -3722,9 +3568,6 @@ static void test_fetch_tiny()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 tinyint unsigned, \
c2 tinyint, \
c3 tinyint unsigned, \
......@@ -3734,9 +3577,6 @@ static void test_fetch_tiny()
c7 tinyint unsigned)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
bind_fetch(3);
}
......@@ -3753,9 +3593,6 @@ static void test_fetch_bigint()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 bigint, \
c2 bigint, \
c3 bigint unsigned, \
......@@ -3765,9 +3602,6 @@ static void test_fetch_bigint()
c7 bigint unsigned)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
bind_fetch(2);
}
......@@ -3784,9 +3618,6 @@ static void test_fetch_float()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 float(3), \
c2 float, \
c3 float unsigned, \
......@@ -3796,9 +3627,6 @@ static void test_fetch_float()
c7 float(10) unsigned)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
bind_fetch(2);
}
......@@ -3815,18 +3643,12 @@ static void test_fetch_double()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 double(5, 2), "
"c2 double unsigned, c3 double unsigned, "
"c4 double unsigned, c5 double unsigned, "
"c6 double unsigned, c7 double unsigned)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
bind_fetch(3);
}
......@@ -3849,9 +3671,6 @@ static void test_prepare_ext()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_ext");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
sql= (char *)"CREATE TABLE test_prepare_ext\
(\
c1 tinyint, \
......@@ -3969,18 +3788,12 @@ static void test_field_names()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_names2");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_field_names1(id int, name varchar(50))");
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_field_names2(id int, name varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* with table name included with TRUE column name */
rc= mysql_query(mysql, "SELECT id as 'id-alias' FROM test_field_names1");
myquery(rc);
......@@ -4074,9 +3887,6 @@ static void test_insert()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_insert");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prep_insert(col1 tinyint, \
col2 varchar(50))");
myquery(rc);
......@@ -4151,9 +3961,6 @@ static void test_prepare_resultset()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_resultset");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prepare_resultset(id int, \
name varchar(50), extra double)");
myquery(rc);
......@@ -4186,9 +3993,6 @@ static void test_field_flags()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_flags");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_field_flags(id int NOT NULL AUTO_INCREMENT PRIMARY KEY, \
id1 int NOT NULL, \
id2 int UNIQUE, \
......@@ -4198,9 +4002,6 @@ static void test_field_flags()
KEY(id3, id4))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
/* with table name included with TRUE column name */
rc= mysql_query(mysql, "SELECT * FROM test_field_flags");
myquery(rc);
......@@ -4462,9 +4263,6 @@ static void test_insert_meta()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_insert");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prep_insert(col1 tinyint, \
col2 varchar(50), col3 varchar(30))");
myquery(rc);
......@@ -4527,9 +4325,6 @@ static void test_update_meta()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_update");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prep_update(col1 tinyint, \
col2 varchar(50), col3 varchar(30))");
myquery(rc);
......@@ -4596,9 +4391,6 @@ static void test_select_meta()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_select");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_prep_select(col1 tinyint, \
col2 varchar(50), col3 varchar(30))");
myquery(rc);
......@@ -4663,9 +4455,6 @@ static void test_func_fields()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_dateformat");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_dateformat(id int, \
ts timestamp)");
myquery(rc);
......@@ -5241,15 +5030,9 @@ static void test_store_result()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')");
myquery(rc);
......@@ -5365,15 +5148,9 @@ static void test_store_result1()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')");
myquery(rc);
......@@ -5429,15 +5206,9 @@ static void test_store_result2()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')");
myquery(rc);
......@@ -5522,18 +5293,12 @@ static void test_subselect()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_sub2");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_sub1(id int)");
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_sub2(id int, id1 int)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO test_sub1 values(2)");
myquery(rc);
......@@ -5777,9 +5542,6 @@ static void test_date()
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
test_bind_date_conv(5);
}
......@@ -5802,9 +5564,6 @@ static void test_date_date()
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
test_bind_date_conv(3);
}
......@@ -5827,9 +5586,6 @@ static void test_date_time()
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
test_bind_date_conv(3);
}
......@@ -5852,9 +5608,6 @@ static void test_date_ts()
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
test_bind_date_conv(2);
}
......@@ -5874,9 +5627,6 @@ static void test_date_dt()
" c2 datetime, c3 datetime, c4 date)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
test_bind_date_conv(2);
}
......@@ -5961,7 +5711,6 @@ static void test_pure_coverage()
mysql_stmt_close(stmt);
mysql_query(mysql, "DROP TABLE test_pure");
mysql_commit(mysql);
}
......@@ -6535,6 +6284,7 @@ static void test_field_misc()
result= mysql_stmt_result_metadata(stmt);
mytest(result);
assert(mysql_stmt_field_count(stmt) == mysql_num_fields(result));
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
......@@ -8052,9 +7802,6 @@ static void test_sqlmode()
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_piping");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE test_piping(name varchar(10))");
myquery(rc);
......@@ -8189,9 +7936,6 @@ static void test_ts()
rc= mysql_query(mysql, "CREATE TABLE test_ts(a DATE, b TIME, c TIMESTAMP)");
myquery(rc);
rc= mysql_commit(mysql);
myquery(rc);
stmt= mysql_simple_prepare(mysql, "INSERT INTO test_ts VALUES(?, ?, ?), (?, ?, ?)");
check_stmt(stmt);
......
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