Commit 83e8881a authored by unknown's avatar unknown

SCRUM

prepared statements in embedded library.
some fixes after testing


include/mysql.h:
  virtual method added
libmysql/client_settings.h:
  declaration added
libmysql/libmysql.c:
  implementation added
  mysql_fetch changed to work in both libraries
libmysqld/lib_sql.cc:
  implementation added
sql-common/client.c:
  added items in methods table
sql/client_settings.h:
  decided to remove such defines - i placed single #ifdef in client.c
parent 4c638048
......@@ -557,10 +557,13 @@ typedef struct st_mysql_methods
MYSQL_RES * (STDCALL *use_result)(MYSQL *mysql);
void (STDCALL *fetch_lengths)(unsigned long *to,
MYSQL_ROW column, unsigned int field_count);
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
MYSQL_FIELD * (STDCALL *list_fields)(MYSQL *mysql);
my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
int (STDCALL *stmt_execute)(MYSQL_STMT *stmt);
MYSQL_DATA *(STDCALL *read_binary_rows)(MYSQL_STMT *stmt);
int (STDCALL *unbuffered_fetch)(MYSQL *mysql, char **row);
#endif
} MYSQL_METHODS;
......
......@@ -56,3 +56,4 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
uint fields);
int STDCALL cli_stmt_execute(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;
}
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
......@@ -2994,20 +3002,20 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
}
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,
mysql->net.sqlstate);
DBUG_RETURN(1);
}
if (mysql->net.read_pos[0] == 254)
if (!row)
{
mysql->status= MYSQL_STATUS_READY;
stmt->current_row= 0;
goto no_data;
}
row= mysql->net.read_pos+1;
}
stmt->current_row= 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);
}
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=
{
emb_mysql_read_query_result,
......@@ -205,7 +225,8 @@ MYSQL_METHODS embedded_methods=
emb_list_fields,
emb_read_prepare_result,
emb_stmt_execute,
emb_read_binary_rows
emb_read_binary_rows,
emb_unbuffered_fetch
};
C_MODE_END
......@@ -561,8 +582,7 @@ bool Protocol_prep::write()
*data->prev_ptr= cur;
data->prev_ptr= &cur->next;
next_field=cur->data;
next_mysql_field= thd->mysql->fields;
cur->next= 0;
return false;
}
......
......@@ -1405,11 +1405,14 @@ static MYSQL_METHODS client_methods=
cli_advanced_command,
cli_read_rows,
cli_mysql_use_result,
cli_fetch_lengths,
cli_list_fields,
cli_fetch_lengths
#ifndef MYSQL_SERVER
,cli_list_fields,
cli_read_prepare_result,
cli_stmt_execute,
cli_read_binary_rows
cli_read_binary_rows,
cli_unbuffered_fetch
#endif
};
MYSQL * STDCALL
......
......@@ -32,8 +32,3 @@
#undef HAVE_SMEM
#undef _CUSTOMCONFIG_
#define cli_list_fields NULL
#define cli_read_prepare_result NULL
#define cli_stmt_execute NULL
#define cli_read_binary_rows NULL
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