mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
SCRUM
prepared statements in embedded library. some fixes after testing
This commit is contained in:
@ -557,10 +557,13 @@ typedef struct st_mysql_methods
|
|||||||
MYSQL_RES * (STDCALL *use_result)(MYSQL *mysql);
|
MYSQL_RES * (STDCALL *use_result)(MYSQL *mysql);
|
||||||
void (STDCALL *fetch_lengths)(unsigned long *to,
|
void (STDCALL *fetch_lengths)(unsigned long *to,
|
||||||
MYSQL_ROW column, unsigned int field_count);
|
MYSQL_ROW column, unsigned int field_count);
|
||||||
|
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
|
||||||
MYSQL_FIELD * (STDCALL *list_fields)(MYSQL *mysql);
|
MYSQL_FIELD * (STDCALL *list_fields)(MYSQL *mysql);
|
||||||
my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
|
my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
|
||||||
int (STDCALL *stmt_execute)(MYSQL_STMT *stmt);
|
int (STDCALL *stmt_execute)(MYSQL_STMT *stmt);
|
||||||
MYSQL_DATA *(STDCALL *read_binary_rows)(MYSQL_STMT *stmt);
|
MYSQL_DATA *(STDCALL *read_binary_rows)(MYSQL_STMT *stmt);
|
||||||
|
int (STDCALL *unbuffered_fetch)(MYSQL *mysql, char **row);
|
||||||
|
#endif
|
||||||
|
|
||||||
} MYSQL_METHODS;
|
} MYSQL_METHODS;
|
||||||
|
|
||||||
|
@ -56,3 +56,4 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
|
|||||||
uint fields);
|
uint fields);
|
||||||
int STDCALL cli_stmt_execute(MYSQL_STMT *stmt);
|
int STDCALL cli_stmt_execute(MYSQL_STMT *stmt);
|
||||||
MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt);
|
MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt);
|
||||||
|
int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row);
|
||||||
|
@ -2965,6 +2965,14 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row)
|
||||||
|
{
|
||||||
|
if (packet_error == net_safe_read(mysql))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
*row= (mysql->net.read_pos[0] == 254) ? NULL : (mysql->net.read_pos+1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Fetch and return row data to bound buffers, if any
|
Fetch and return row data to bound buffers, if any
|
||||||
@ -2994,20 +3002,20 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
|
|||||||
}
|
}
|
||||||
else /* un-buffered */
|
else /* un-buffered */
|
||||||
{
|
{
|
||||||
if (packet_error == net_safe_read(mysql))
|
if((*mysql->methods->unbuffered_fetch)(mysql, ( char **)&row))
|
||||||
{
|
{
|
||||||
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
|
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
|
||||||
mysql->net.sqlstate);
|
mysql->net.sqlstate);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
if (mysql->net.read_pos[0] == 254)
|
if (!row)
|
||||||
{
|
{
|
||||||
mysql->status= MYSQL_STATUS_READY;
|
mysql->status= MYSQL_STATUS_READY;
|
||||||
stmt->current_row= 0;
|
stmt->current_row= 0;
|
||||||
goto no_data;
|
goto no_data;
|
||||||
}
|
}
|
||||||
row= mysql->net.read_pos+1;
|
}
|
||||||
}
|
|
||||||
stmt->current_row= row;
|
stmt->current_row= row;
|
||||||
DBUG_RETURN(stmt_fetch_row(stmt, row));
|
DBUG_RETURN(stmt_fetch_row(stmt, row));
|
||||||
|
|
||||||
|
@ -195,6 +195,26 @@ MYSQL_DATA *emb_read_binary_rows(MYSQL_STMT *stmt)
|
|||||||
return emb_read_rows(stmt->mysql, 0, 0);
|
return emb_read_rows(stmt->mysql, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int STDCALL emb_unbuffered_fetch(MYSQL *mysql, char **row)
|
||||||
|
{
|
||||||
|
MYSQL_DATA *data= ((THD*)mysql->thd)->data;
|
||||||
|
if (!data || !data->data)
|
||||||
|
{
|
||||||
|
*row= NULL;
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
free_rows(data);
|
||||||
|
((THD*)mysql->thd)->data= NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*row= (char *)data->data->data;
|
||||||
|
data->data= data->data->next;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
MYSQL_METHODS embedded_methods=
|
MYSQL_METHODS embedded_methods=
|
||||||
{
|
{
|
||||||
emb_mysql_read_query_result,
|
emb_mysql_read_query_result,
|
||||||
@ -205,7 +225,8 @@ MYSQL_METHODS embedded_methods=
|
|||||||
emb_list_fields,
|
emb_list_fields,
|
||||||
emb_read_prepare_result,
|
emb_read_prepare_result,
|
||||||
emb_stmt_execute,
|
emb_stmt_execute,
|
||||||
emb_read_binary_rows
|
emb_read_binary_rows,
|
||||||
|
emb_unbuffered_fetch
|
||||||
};
|
};
|
||||||
|
|
||||||
C_MODE_END
|
C_MODE_END
|
||||||
@ -561,9 +582,8 @@ bool Protocol_prep::write()
|
|||||||
|
|
||||||
*data->prev_ptr= cur;
|
*data->prev_ptr= cur;
|
||||||
data->prev_ptr= &cur->next;
|
data->prev_ptr= &cur->next;
|
||||||
next_field=cur->data;
|
cur->next= 0;
|
||||||
next_mysql_field= thd->mysql->fields;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1405,11 +1405,14 @@ static MYSQL_METHODS client_methods=
|
|||||||
cli_advanced_command,
|
cli_advanced_command,
|
||||||
cli_read_rows,
|
cli_read_rows,
|
||||||
cli_mysql_use_result,
|
cli_mysql_use_result,
|
||||||
cli_fetch_lengths,
|
cli_fetch_lengths
|
||||||
cli_list_fields,
|
#ifndef MYSQL_SERVER
|
||||||
|
,cli_list_fields,
|
||||||
cli_read_prepare_result,
|
cli_read_prepare_result,
|
||||||
cli_stmt_execute,
|
cli_stmt_execute,
|
||||||
cli_read_binary_rows
|
cli_read_binary_rows,
|
||||||
|
cli_unbuffered_fetch
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
MYSQL * STDCALL
|
MYSQL * STDCALL
|
||||||
|
@ -32,8 +32,3 @@
|
|||||||
#undef HAVE_SMEM
|
#undef HAVE_SMEM
|
||||||
#undef _CUSTOMCONFIG_
|
#undef _CUSTOMCONFIG_
|
||||||
|
|
||||||
#define cli_list_fields NULL
|
|
||||||
#define cli_read_prepare_result NULL
|
|
||||||
#define cli_stmt_execute NULL
|
|
||||||
#define cli_read_binary_rows NULL
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user