Commit bf017a2e authored by hf@deer.(none)'s avatar hf@deer.(none)

SCRUM

Prepared statements in embedded server
Several changes in library code with two goals:
to make mysql_prepare_stmt working in embedded server
to get rid of #define mysql_interface_func mysql->methods->interface_func
in user's interface
parent e63e2229
......@@ -250,7 +250,6 @@ typedef struct st_mysql
LIST *stmts; /* list of all statements */
const struct st_mysql_methods *methods;
struct st_mysql_res *result;
void *thd;
} MYSQL;
......@@ -359,6 +358,8 @@ int STDCALL mysql_send_query(MYSQL *mysql, const char *q,
unsigned long length);
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
unsigned long length);
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
/* perform query on master */
my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q,
unsigned long length);
......@@ -427,6 +428,8 @@ MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result);
MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
const char *wild);
unsigned long STDCALL mysql_escape_string(char *to,const char *from,
unsigned long from_length);
unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
......@@ -538,9 +541,7 @@ typedef struct st_mysql_stmt
#define mysql_read_query_result(mysql) (*(mysql)->methods->read_query_result)(mysql)
#define mysql_store_result(mysql) (*(mysql)->methods->store_result)(mysql)
#define mysql_use_result(mysql) (*(mysql)->methods->use_result)(mysql)
#define mysql_list_fields(mysql, table, wild) (*(mysql)->methods->list_fields)(mysql, table, wild)
typedef struct st_mysql_methods
{
......@@ -552,12 +553,12 @@ typedef struct st_mysql_methods
const char *arg,
unsigned long arg_length,
my_bool skip_check);
MYSQL_RES * (STDCALL *store_result)(MYSQL *mysql);
MYSQL_DATA *(STDCALL *read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
uint fields);
MYSQL_RES * (STDCALL *use_result)(MYSQL *mysql);
void (STDCALL *fetch_lengths)(unsigned long *to,
MYSQL_ROW column, uint field_count);
MYSQL_RES * (STDCALL *list_fields)(MYSQL *mysql, const char *table,
const char *wild);
MYSQL_FIELD * (STDCALL *list_fields)(MYSQL *mysql);
my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
} MYSQL_METHODS;
......
......@@ -28,8 +28,6 @@ my_ulonglong net_field_length_ll(uchar **packet);
MYSQL_FIELD *unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
my_bool default_value, uint server_capabilities);
void free_rows(MYSQL_DATA *cur);
MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields,
uint field_count);
my_bool mysql_autenticate(MYSQL *mysql, const char *passwd);
void free_old_query(MYSQL *mysql);
void end_server(MYSQL *mysql);
......
......@@ -41,6 +41,16 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename);
#define reset_sigpipe(mysql)
#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);
void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group);
MYSQL * STDCALL
cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,ulong client_flag);
void STDCALL cli_mysql_close(MYSQL *mysql);
MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql);
my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt);
MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
uint fields);
......@@ -973,6 +973,19 @@ mysql_list_tables(MYSQL *mysql, const char *wild)
DBUG_RETURN (mysql_store_result(mysql));
}
MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql)
{
MYSQL_DATA *query;
if (!(query= cli_read_rows(mysql,(MYSQL_FIELD*) 0,
protocol_41(mysql) ? 8 : 6)))
return NULL;
mysql->field_count= query->rows;
return unpack_fields(query,&mysql->field_alloc,
query->rows, 1, mysql->server_capabilities);
}
/**************************************************************************
List all fields in a table
If wild is given then only the fields matching wild is returned
......@@ -981,36 +994,29 @@ mysql_list_tables(MYSQL *mysql, const char *wild)
**************************************************************************/
MYSQL_RES * STDCALL
cli_list_fields(MYSQL *mysql, const char *table, const char *wild)
mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
{
MYSQL_RES *result;
MYSQL_DATA *query;
MYSQL_FIELD *fields;
char buff[257],*end;
DBUG_ENTER("mysql_list_fields");
DBUG_PRINT("enter",("table: '%s' wild: '%s'",table,wild ? wild : ""));
LINT_INIT(query);
end=strmake(strmake(buff, table,128)+1,wild ? wild : "",128);
free_old_query(mysql);
if (simple_command(mysql,COM_FIELD_LIST,buff,(ulong) (end-buff),1) ||
!(query = read_rows(mysql,(MYSQL_FIELD*) 0,
protocol_41(mysql) ? 8 : 6)))
!(fields= (*mysql->methods->list_fields)(mysql)))
DBUG_RETURN(NULL);
free_old_query(mysql);
if (!(result = (MYSQL_RES *) my_malloc(sizeof(MYSQL_RES),
MYF(MY_WME | MY_ZEROFILL))))
{
free_rows(query);
DBUG_RETURN(NULL);
}
result->methods= mysql->methods;
result->field_alloc=mysql->field_alloc;
mysql->fields=0;
result->field_count = (uint) query->rows;
result->fields= unpack_fields(query,&result->field_alloc,
result->field_count, 1,
mysql->server_capabilities);
result->field_count = mysql->field_count;
result->fields= fields;
result->eof=1;
DBUG_RETURN(result);
}
......@@ -1031,7 +1037,7 @@ mysql_list_processes(MYSQL *mysql)
free_old_query(mysql);
pos=(uchar*) mysql->net.read_pos;
field_count=(uint) net_field_length(&pos);
if (!(fields = read_rows(mysql,(MYSQL_FIELD*) 0,
if (!(fields = (*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*) 0,
protocol_41(mysql) ? 7 : 5)))
DBUG_RETURN(NULL);
if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc,field_count,0,
......@@ -1569,7 +1575,7 @@ my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
uint field_count;
ulong length, param_count;
MYSQL_DATA *fields_data;
DBUG_ENTER("cli_read_prepare_result");
DBUG_ENTER("read_prepare_result");
mysql= mysql->last_used_con;
if ((length= net_safe_read(mysql)) == packet_error)
......@@ -1586,7 +1592,7 @@ my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
mysql->server_status|= SERVER_STATUS_IN_TRANS;
mysql->extra_info= net_field_length_ll(&pos);
if (!(fields_data= read_rows(mysql, (MYSQL_FIELD*) 0, 7)))
if (!(fields_data= (*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0,7)))
DBUG_RETURN(1);
if (!(stmt->fields= unpack_fields(fields_data,&stmt->mem_root,
field_count,0,
......@@ -1638,17 +1644,17 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
}
init_alloc_root(&stmt->mem_root,8192,0);
if ((*mysql->read_prepare_result)(mysql, stmt))
if ((*mysql->methods->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))))
(stmt->param_count +
stmt->field_count))))
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate);
stmt->bind= stmt->params + param_count;
stmt->bind= stmt->params + stmt->param_count;
stmt->state= MY_ST_PREPARE;
stmt->mysql= mysql;
......
......@@ -26,4 +26,7 @@ C_MODE_START
extern void lib_connection_phase(NET *net, int phase);
extern void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db);
extern void *create_embedded_thd(int client_flag, char *db);
extern MYSQL_METHODS embedded_methods;
void free_old_query(MYSQL *mysql);
extern my_bool server_inited;
C_MODE_END
......@@ -50,7 +50,7 @@ static bool check_user(THD *thd, enum_server_command command,
char * get_mysql_home(){ return mysql_home;};
char * get_mysql_real_data_home(){ return mysql_real_data_home;};
my_bool STDCALL
static my_bool STDCALL
emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check)
......@@ -94,6 +94,77 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
return result;
}
static MYSQL_DATA * STDCALL
emb_read_rows(MYSQL *mysql, MYSQL_FIELD *mysql_fields __attribute__((unused)),
uint fields __attribute__((unused)))
{
MYSQL_DATA *result= ((THD*)mysql->thd)->data;
if (!result)
return NULL;
*result->prev_ptr= NULL;
((THD*)mysql->thd)->data= NULL;
return result;
}
static MYSQL_FIELD * STDCALL emb_list_fields(MYSQL *mysql)
{
return mysql->fields;
}
static my_bool STDCALL emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
{
THD *thd= (THD*)mysql->thd;
stmt->stmt_id= thd->client_stmt_id;
stmt->param_count= thd->client_param_count;
stmt->field_count= mysql->field_count;
if (stmt->field_count != 0)
{
if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT))
mysql->server_status|= SERVER_STATUS_IN_TRANS;
stmt->fields= mysql->fields;
stmt->mem_root= mysql->field_alloc;
}
return 0;
}
/**************************************************************************
Get column lengths of the current row
If one uses mysql_use_result, res->lengths contains the length information,
else the lengths are calculated from the offset between pointers.
**************************************************************************/
static void STDCALL emb_fetch_lengths(ulong *to, MYSQL_ROW column, uint field_count)
{
MYSQL_ROW end;
for (end=column + field_count; column != end ; column++,to++)
*to= *column ? *(uint *)((*column) - sizeof(uint)) : 0;
}
static my_bool STDCALL emb_mysql_read_query_result(MYSQL *mysql)
{
if (mysql->net.last_errno)
return -1;
if (mysql->field_count)
mysql->status=MYSQL_STATUS_GET_RESULT;
return 0;
}
MYSQL_METHODS embedded_methods=
{
emb_mysql_read_query_result,
emb_advanced_command,
emb_read_rows,
mysql_store_result,
emb_fetch_lengths,
emb_list_fields,
emb_read_prepare_result
};
C_MODE_END
void THD::clear_error()
......@@ -334,6 +405,8 @@ void *create_embedded_thd(int client_flag, char *db)
thd->master_access= ~NO_ACCESS;
thd->net.query_cache_query= 0;
thd->data= 0;
return thd;
}
......@@ -343,35 +416,29 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
{
List_iterator_fast<Item> it(*list);
Item *item;
MYSQL_FIELD *field, *client_field;
MYSQL_FIELD *client_field;
MYSQL *mysql= thd->mysql;
MEM_ROOT *field_alloc;
DBUG_ENTER("send_fields");
field_count= list->elements;
if (!(mysql->result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
sizeof(ulong) * (field_count + 1),
MYF(MY_WME | MY_ZEROFILL))))
field_alloc= &mysql->field_alloc;
if (!(client_field= thd->mysql->fields=
(MYSQL_FIELD *)alloc_root(field_alloc,
sizeof(MYSQL_FIELD) * field_count)))
goto err;
mysql->result->lengths= (ulong *)(mysql->result + 1);
mysql->field_count=field_count;
alloc= &mysql->field_alloc;
field= (MYSQL_FIELD *)alloc_root(alloc, sizeof(MYSQL_FIELD) * field_count);
if (!field)
goto err;
client_field= field;
while ((item= it++))
{
Send_field server_field;
item->make_field(&server_field);
client_field->db= strdup_root(alloc, server_field.db_name);
client_field->table= strdup_root(alloc, server_field.table_name);
client_field->name= strdup_root(alloc, server_field.col_name);
client_field->org_table= strdup_root(alloc, server_field.org_table_name);
client_field->org_name= strdup_root(alloc, server_field.org_col_name);
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->type= server_field.type;
client_field->flags= server_field.flags;
......@@ -392,31 +459,16 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
String tmp(buff, sizeof(buff), default_charset_info), *res;
if (!(res=item->val_str(&tmp)))
client_field->def= strdup_root(alloc, "");
client_field->def= strdup_root(field_alloc, "");
else
client_field->def= strdup_root(alloc, tmp.ptr());
client_field->def= strdup_root(field_alloc, tmp.ptr());
}
else
client_field->def=0;
client_field->max_length= 0;
++client_field;
}
mysql->result->fields = field;
if (!(mysql->result->data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
MYF(MY_WME | MY_ZEROFILL))))
goto err;
init_alloc_root(&mysql->result->data->alloc,8192,0); /* Assume rowlength < 8192 */
mysql->result->data->alloc.min_malloc=sizeof(MYSQL_ROWS);
mysql->result->data->rows=0;
mysql->result->data->fields=field_count;
mysql->result->field_count=field_count;
mysql->result->data->prev_ptr= &mysql->result->data->data;
mysql->result->field_alloc= mysql->field_alloc;
mysql->result->current_field=0;
mysql->result->current_row=0;
thd->mysql->field_count= field_count;
DBUG_RETURN(prepare_for_send(list));
err:
......@@ -457,12 +509,26 @@ send_eof(THD *thd, bool no_flush)
void Protocol_simple::prepare_for_resend()
{
MYSQL_ROWS *cur;
MYSQL_DATA *result= thd->mysql->result->data;
MYSQL_DATA *data= thd->data;
DBUG_ENTER("send_data");
alloc= &result->alloc;
result->rows++;
if (!data)
{
if (!(data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
MYF(MY_WME | MY_ZEROFILL))))
goto err;
alloc= &data->alloc;
init_alloc_root(alloc,8192,0); /* Assume rowlength < 8192 */
alloc->min_malloc=sizeof(MYSQL_ROWS);
data->rows=0;
data->fields=field_count;
data->prev_ptr= &data->data;
thd->data= data;
}
data->rows++;
if (!(cur= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS)+(field_count + 1) * sizeof(char *))))
{
my_error(ER_OUT_OF_RESOURCES,MYF(0));
......@@ -470,11 +536,11 @@ void Protocol_simple::prepare_for_resend()
}
cur->data= (MYSQL_ROW)(((char *)cur) + sizeof(MYSQL_ROWS));
*result->prev_ptr= cur;
result->prev_ptr= &cur->next;
*data->prev_ptr= cur;
data->prev_ptr= &cur->next;
next_field=cur->data;
next_mysql_field= thd->mysql->result->fields;
next_mysql_field= thd->mysql->fields;
err:
DBUG_VOID_RETURN;
}
......
......@@ -24,6 +24,7 @@
#include <sys/stat.h>
#include <signal.h>
#include <time.h>
#include "client_settings.h"
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
......@@ -58,29 +59,11 @@
#define closesocket(A) close(A)
#endif
void free_old_query(MYSQL *mysql);
my_bool STDCALL
emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check);
/* From client.c */
void mysql_read_default_options(struct st_mysql_options *options,
const char *filename,const char *group);
MYSQL * STDCALL
cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,ulong client_flag);
void STDCALL cli_mysql_close(MYSQL *mysql);
#ifdef HAVE_GETPWUID
struct passwd *getpwuid(uid_t);
char* getlogin(void);
#endif
extern char server_inited;
#ifdef __WIN__
static my_bool is_NT(void)
{
......@@ -165,77 +148,6 @@ static inline int mysql_init_charset(MYSQL *mysql)
return 0;
}
/**************************************************************************
Get column lengths of the current row
If one uses mysql_use_result, res->lengths contains the length information,
else the lengths are calculated from the offset between pointers.
**************************************************************************/
static void STDCALL emb_fetch_lengths(ulong *to, MYSQL_ROW column, uint field_count)
{
MYSQL_ROW end;
for (end=column + field_count; column != end ; column++,to++)
*to= *column ? *(uint *)((*column) - sizeof(uint)) : 0;
}
/**************************************************************************
List all fields in a table
If wild is given then only the fields matching wild is returned
Instead of this use query:
show fields in 'table' like "wild"
**************************************************************************/
static MYSQL_RES * STDCALL
emb_list_fields(MYSQL *mysql, const char *table, const char *wild)
{
MYSQL_RES *result;
MYSQL_DATA *query;
char buff[257],*end;
DBUG_ENTER("mysql_list_fields");
DBUG_PRINT("enter",("table: '%s' wild: '%s'",table,wild ? wild : ""));
LINT_INIT(query);
end=strmake(strmake(buff, table,128)+1,wild ? wild : "",128);
if (simple_command(mysql,COM_FIELD_LIST,buff,(ulong) (end-buff),1))
DBUG_RETURN(NULL);
result= mysql->result;
if (!result)
return 0;
result->methods= mysql->methods;
result->eof=1;
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()
** before calling mysql_real_connect !
*/
static my_bool STDCALL emb_mysql_read_query_result(MYSQL *mysql);
static MYSQL_RES * STDCALL emb_mysql_store_result(MYSQL *mysql);
static MYSQL_RES * STDCALL emb_mysql_use_result(MYSQL *mysql);
static MYSQL_METHODS embedded_methods=
{
emb_mysql_read_query_result,
emb_advanced_command,
emb_mysql_store_result,
emb_mysql_use_result,
emb_fetch_lengths,
emb_list_fields
};
MYSQL * STDCALL
mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
......@@ -383,58 +295,3 @@ void STDCALL mysql_close(MYSQL *mysql)
DBUG_VOID_RETURN;
}
static my_bool STDCALL emb_mysql_read_query_result(MYSQL *mysql)
{
if (mysql->net.last_errno)
return -1;
if (mysql->field_count)
{
mysql->status=MYSQL_STATUS_GET_RESULT;
mysql->affected_rows= mysql->result->row_count= mysql->result->data->rows;
mysql->result->data_cursor= mysql->result->data->data;
}
return 0;
}
/**************************************************************************
** Alloc result struct for buffered results. All rows are read to buffer.
** mysql_data_seek may be used.
**************************************************************************/
static MYSQL_RES * STDCALL emb_mysql_store_result(MYSQL *mysql)
{
MYSQL_RES *result= mysql->result;
if (!result)
return 0;
result->methods= mysql->methods;
mysql->result= NULL;
*result->data->prev_ptr= 0;
result->eof= 1;
result->lengths= (ulong*)(result + 1);
mysql->affected_rows= result->row_count= result->data->rows;
result->data_cursor= result->data->data;
mysql->status=MYSQL_STATUS_READY; /* server is ready */
return result;
}
/**************************************************************************
** Alloc struct for use with unbuffered reads. Data is fetched by domand
** when calling to mysql_fetch_row.
** mysql_data_seek is a noop.
**
** No other queries may be specified with the same MYSQL handle.
** There shouldn't be much processing per row because mysql server shouldn't
** have to wait for the client (and will not wait more than 30 sec/packet).
**************************************************************************/
static MYSQL_RES * STDCALL emb_mysql_use_result(MYSQL *mysql)
{
DBUG_ENTER("mysql_use_result");
if (mysql->options.separate_thread)
DBUG_RETURN(0);
DBUG_RETURN(emb_mysql_store_result(mysql));
}
......@@ -1139,7 +1139,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
/* Read all rows (fields or data) from server */
MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
uint fields)
{
uint field;
......@@ -1150,7 +1150,7 @@ MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
MYSQL_DATA *result;
MYSQL_ROWS **prev_ptr,*cur;
NET *net = &mysql->net;
DBUG_ENTER("read_rows");
DBUG_ENTER("cli_read_rows");
if ((pkt_len= net_safe_read(mysql)) == packet_error)
DBUG_RETURN(0);
......@@ -1397,14 +1397,13 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
*/
static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql);
static MYSQL_RES * STDCALL cli_mysql_store_result(MYSQL *mysql);
static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql);
static MYSQL_METHODS client_methods=
{
cli_mysql_read_query_result,
cli_advanced_command,
cli_mysql_store_result,
cli_read_rows,
cli_mysql_use_result,
cli_fetch_lengths,
cli_list_fields,
......@@ -2265,7 +2264,8 @@ get_info:
mysql->extra_info= net_field_length_ll(&pos); /* Maybe number of rec */
if (!(fields=read_rows(mysql,(MYSQL_FIELD*)0,protocol_41(mysql) ? 7 : 5)))
if (!(fields=(*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0,
protocol_41(mysql) ? 7 : 5)))
DBUG_RETURN(1);
if (!(mysql->fields=unpack_fields(fields,&mysql->field_alloc,
(uint) field_count,0,
......@@ -2327,7 +2327,7 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong length)
mysql_data_seek may be used.
**************************************************************************/
static MYSQL_RES * STDCALL cli_mysql_store_result(MYSQL *mysql)
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)
{
MYSQL_RES *result;
DBUG_ENTER("mysql_store_result");
......@@ -2356,7 +2356,8 @@ static MYSQL_RES * STDCALL cli_mysql_store_result(MYSQL *mysql)
result->methods= mysql->methods;
result->eof=1; /* Marker for buffered */
result->lengths=(ulong*) (result+1);
if (!(result->data=read_rows(mysql,mysql->fields,mysql->field_count)))
if (!(result->data=
(*mysql->methods->read_rows)(mysql,mysql->fields,mysql->field_count)))
{
my_free((gptr) result,MYF(0));
DBUG_RETURN(0);
......
......@@ -419,6 +419,9 @@ class THD :public ilink
public:
#ifdef EMBEDDED_LIBRARY
struct st_mysql *mysql;
struct st_mysql_data *data;
unsigned long client_stmt_id;
unsigned long client_param_count;
#endif
NET net; // client connection descriptor
LEX lex; // parse tree descriptor
......
......@@ -156,13 +156,14 @@ static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
return (my_net_write(net, buff, sizeof(buff)) || net_flush(net));
}
#else
static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
static bool send_prep_stmt(PREP_STMT *stmt, uint columns __attribute__((unused)))
{
MYSQL_STMT *client_stmt= stmt->thd->client_stmt;
THD *thd= stmt->thd;
client_stmt->stmt_id= stmt->stmt_id;
client_stmt->field_count= columns;
client_stmt->param_count= stmt->param_count;
thd->client_stmt_id= stmt->stmt_id;
thd->client_param_count= stmt->param_count;
return 0;
}
#endif /*!EMBEDDED_LIBRAYR*/
......
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