parent
f434b329f5
commit
9f3996cde9
@ -556,6 +556,7 @@ typedef struct st_mysql_methods
|
|||||||
MYSQL_ROW column, uint field_count);
|
MYSQL_ROW column, uint field_count);
|
||||||
MYSQL_RES * (STDCALL *list_fields)(MYSQL *mysql, const char *table,
|
MYSQL_RES * (STDCALL *list_fields)(MYSQL *mysql, const char *table,
|
||||||
const char *wild);
|
const char *wild);
|
||||||
|
my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
|
||||||
} MYSQL_METHODS;
|
} MYSQL_METHODS;
|
||||||
|
|
||||||
MYSQL_STMT * STDCALL mysql_prepare(MYSQL * mysql, const char *query,
|
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
|
#endif
|
||||||
|
|
||||||
MYSQL_RES * STDCALL cli_list_fields(MYSQL *mysql, const char *table, const char *wild);
|
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);
|
||||||
|
|
||||||
|
@ -1556,13 +1556,13 @@ static my_bool my_realloc_str(NET *net, ulong length)
|
|||||||
1 error
|
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;
|
uchar *pos;
|
||||||
uint field_count;
|
uint field_count;
|
||||||
ulong length, param_count;
|
ulong length, param_count;
|
||||||
MYSQL_DATA *fields_data;
|
MYSQL_DATA *fields_data;
|
||||||
DBUG_ENTER("read_prepare_result");
|
DBUG_ENTER("cli_read_prepare_result");
|
||||||
|
|
||||||
mysql= mysql->last_used_con;
|
mysql= mysql->last_used_con;
|
||||||
if ((length= net_safe_read(mysql)) == packet_error)
|
if ((length= net_safe_read(mysql)) == packet_error)
|
||||||
@ -1586,18 +1586,8 @@ static my_bool read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
|
|||||||
mysql->server_capabilities)))
|
mysql->server_capabilities)))
|
||||||
DBUG_RETURN(1);
|
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->field_count= (uint) field_count;
|
||||||
stmt->param_count= (ulong) param_count;
|
stmt->param_count= (ulong) param_count;
|
||||||
mysql->status= MYSQL_STATUS_READY;
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1641,14 +1631,22 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
init_alloc_root(&stmt->mem_root,8192,0);
|
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);
|
stmt_close(stmt, 1);
|
||||||
DBUG_RETURN(0);
|
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->state= MY_ST_PREPARE;
|
||||||
stmt->mysql= mysql;
|
stmt->mysql= mysql;
|
||||||
mysql->stmts= list_add(mysql->stmts, &stmt->list);
|
mysql->stmts= list_add(mysql->stmts, &stmt->list);
|
||||||
|
mysql->status= MYSQL_STATUS_READY;
|
||||||
stmt->list.data= stmt;
|
stmt->list.data= stmt;
|
||||||
DBUG_PRINT("info", ("Parameter count: %ld", stmt->param_count));
|
DBUG_PRINT("info", ("Parameter count: %ld", stmt->param_count));
|
||||||
DBUG_RETURN(stmt);
|
DBUG_RETURN(stmt);
|
||||||
|
@ -211,7 +211,11 @@ emb_list_fields(MYSQL *mysql, const char *table, const char *wild)
|
|||||||
DBUG_RETURN(result);
|
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()
|
** 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_store_result,
|
||||||
cli_mysql_use_result,
|
cli_mysql_use_result,
|
||||||
cli_fetch_lengths,
|
cli_fetch_lengths,
|
||||||
cli_list_fields
|
cli_list_fields,
|
||||||
|
cli_read_prepare_result
|
||||||
};
|
};
|
||||||
|
|
||||||
MYSQL * STDCALL
|
MYSQL * STDCALL
|
||||||
|
@ -33,4 +33,5 @@
|
|||||||
#undef _CUSTOMCONFIG_
|
#undef _CUSTOMCONFIG_
|
||||||
|
|
||||||
#define cli_list_fields NULL
|
#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
|
Send prepared stmt info to client after prepare
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef EMBEDDED_LIBRARY
|
||||||
static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
|
static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
|
||||||
{
|
{
|
||||||
NET *net=&stmt->thd->net;
|
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);
|
int4store(buff+1, stmt->stmt_id);
|
||||||
int2store(buff+5, columns);
|
int2store(buff+5, columns);
|
||||||
int2store(buff+7, stmt->param_count);
|
int2store(buff+7, stmt->param_count);
|
||||||
#ifndef EMBEDDED_LIBRARY
|
|
||||||
/* This should be fixed to work with prepared statements
|
/* This should be fixed to work with prepared statements
|
||||||
*/
|
*/
|
||||||
return (my_net_write(net, buff, sizeof(buff)) || net_flush(net));
|
return (my_net_write(net, buff, sizeof(buff)) || net_flush(net));
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
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
|
Send information about all item parameters
|
||||||
|
Loading…
x
Reference in New Issue
Block a user