Commit 774c65c7 authored by unknown's avatar unknown

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

into deer.(none):/home/hf/work/mysql-4.1.stmt


include/mysql.h:
  Auto merged
libmysql/libmysql.c:
  Auto merged
libmysqld/libmysqld.c:
  Auto merged
parents 11930efb dc250a6e
......@@ -558,6 +558,7 @@ typedef struct st_mysql_methods
MYSQL_ROW column, uint field_count);
MYSQL_RES * (STDCALL *list_fields)(MYSQL *mysql, const char *table,
const char *wild);
my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
} MYSQL_METHODS;
MYSQL_STMT * STDCALL mysql_prepare(MYSQL * mysql, const char *query,
......
......@@ -42,4 +42,5 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename);
#endif
MYSQL_RES * STDCALL cli_list_fields(MYSQL *mysql, const char *table, const char *wild);
my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt);
......@@ -1563,13 +1563,13 @@ static my_bool my_realloc_str(NET *net, ulong length)
1 error
*/
static my_bool read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
{
uchar *pos;
uint field_count;
ulong length, param_count;
MYSQL_DATA *fields_data;
DBUG_ENTER("read_prepare_result");
DBUG_ENTER("cli_read_prepare_result");
mysql= mysql->last_used_con;
if ((length= net_safe_read(mysql)) == packet_error)
......@@ -1593,18 +1593,8 @@ static my_bool read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
mysql->server_capabilities)))
DBUG_RETURN(1);
}
if (!(stmt->params= (MYSQL_BIND *) alloc_root(&stmt->mem_root,
sizeof(MYSQL_BIND)*
(param_count +
field_count))))
{
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate);
DBUG_RETURN(0);
}
stmt->bind= (stmt->params + param_count);
stmt->field_count= (uint) field_count;
stmt->param_count= (ulong) param_count;
mysql->status= MYSQL_STATUS_READY;
DBUG_RETURN(0);
}
......@@ -1648,14 +1638,22 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
}
init_alloc_root(&stmt->mem_root,8192,0);
if (read_prepare_result(mysql, stmt))
if ((*mysql->read_prepare_result)(mysql, stmt))
{
stmt_close(stmt, 1);
DBUG_RETURN(0);
}
if (!(stmt->params= (MYSQL_BIND *) alloc_root(&stmt->mem_root,
sizeof(MYSQL_BIND)*
(param_count +
field_count))))
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate);
stmt->bind= stmt->params + param_count;
stmt->state= MY_ST_PREPARE;
stmt->mysql= mysql;
mysql->stmts= list_add(mysql->stmts, &stmt->list);
mysql->status= MYSQL_STATUS_READY;
stmt->list.data= stmt;
DBUG_PRINT("info", ("Parameter count: %ld", stmt->param_count));
DBUG_RETURN(stmt);
......
......@@ -211,7 +211,11 @@ emb_list_fields(MYSQL *mysql, const char *table, const char *wild)
DBUG_RETURN(result);
}
my_bool STDCALL emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
{
stmt->fields= mysql->result->fields;
stmt->alloc;
}
/*
** Note that the mysql argument must be initialized with mysql_init()
......
......@@ -1407,7 +1407,8 @@ static MYSQL_METHODS client_methods=
cli_mysql_store_result,
cli_mysql_use_result,
cli_fetch_lengths,
cli_list_fields
cli_list_fields,
cli_read_prepare_result
};
MYSQL * STDCALL
......
......@@ -33,4 +33,5 @@
#undef _CUSTOMCONFIG_
#define cli_list_fields NULL
#define cli_read_prepare_result NULL
......@@ -142,6 +142,7 @@ void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used)
Send prepared stmt info to client after prepare
*/
#ifndef EMBEDDED_LIBRARY
static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
{
NET *net=&stmt->thd->net;
......@@ -150,14 +151,20 @@ static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
int4store(buff+1, stmt->stmt_id);
int2store(buff+5, columns);
int2store(buff+7, stmt->param_count);
#ifndef EMBEDDED_LIBRARY
/* This should be fixed to work with prepared statements
*/
return (my_net_write(net, buff, sizeof(buff)) || net_flush(net));
}
#else
return true;
#endif
static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
{
MYSQL_STMT *client_stmt= stmt->thd->client_stmt;
client_stmt->stmt_id= stmt->stmt_id;
client_stmt->field_count= columns;
client_stmt->param_count= stmt->param_count;
}
#endif /*!EMBEDDED_LIBRAYR*/
/*
Send information about all item parameters
......
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