summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2003-09-17 20:48:53 +0500
committerunknown <hf@deer.(none)>2003-09-17 20:48:53 +0500
commit194f6725d42a111e31fbdff2707095abd7cd1b05 (patch)
tree883748d65cbe22427001e2d6bd03ea8386ee3593 /sql
parent11d36fa83101f6490f22da74f1a2b81588683f4b (diff)
downloadmariadb-git-194f6725d42a111e31fbdff2707095abd7cd1b05.tar.gz
SCRUM:
prepared statements in embedded library include/mysql.h: Another 'virtual' method libmysql/client_settings.h: client implementation declared libmysql/libmysql.c: mysql_execute edited to work with embedded implementation libmysqld/lib_sql.cc: one error fixed (we do need parameter's buffer in embedded library) embedded recordset transfer methods implementations added sql-common/client.c: method added to the table sql/client_settings.h: no prepared statements in mimiclient sql/mysql_priv.h: these functions became global sql/protocol.cc: the stub added sql/protocol.h: had to change Protocol's interface for embedded library sql/sql_class.h: i changed this only for embedded case, but i think it's better to do the same for remote server also sql/sql_prepare.cc: parts of code #ifndef-ed
Diffstat (limited to 'sql')
-rw-r--r--sql/client_settings.h1
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/protocol.cc9
-rw-r--r--sql/protocol.h13
-rw-r--r--sql/sql_class.h5
-rw-r--r--sql/sql_prepare.cc24
6 files changed, 48 insertions, 6 deletions
diff --git a/sql/client_settings.h b/sql/client_settings.h
index 266f6807a36..c345021d7f5 100644
--- a/sql/client_settings.h
+++ b/sql/client_settings.h
@@ -35,4 +35,5 @@
#define cli_list_fields NULL
#define cli_read_prepare_result NULL
#define cli_stmt_execute NULL
+#define cli_read_binary_rows NULL
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index d4bacb57a38..9737434fa3a 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -577,6 +577,7 @@ void mysql_stmt_reset(THD *thd, char *packet);
void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length);
int check_insert_fields(THD *thd,TABLE *table,List<Item> &fields,
List<Item> &values, ulong counter);
+void setup_param_functions(Item_param *param, uchar param_type);
/* sql_error.cc */
MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code,
@@ -803,6 +804,7 @@ extern SHOW_COMP_OPTION have_berkeley_db;
extern struct system_variables global_system_variables;
extern struct system_variables max_system_variables;
extern struct rand_struct sql_rand;
+extern String null_string;
/* optional things, have_* variables */
diff --git a/sql/protocol.cc b/sql/protocol.cc
index d1eb3460fc8..edf74aee05e 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -1130,3 +1130,12 @@ bool Protocol_prep::store_time(TIME *tm)
buff[0]=(char) length; // Length is stored first
return packet->append(buff, length+1, PACKET_BUFFET_EXTRA_ALLOC);
}
+
+#ifdef EMBEDDED_LIBRARY
+/* Should be removed when we define the Protocol_cursor's future */
+bool Protocol_cursor::write()
+{
+ return Protocol_simple::write();
+}
+#endif
+
diff --git a/sql/protocol.h b/sql/protocol.h
index f32c135ab3c..8986757922e 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -53,7 +53,11 @@ public:
bool store(const char *from, CHARSET_INFO *cs);
String *storage_packet() { return packet; }
inline void free() { packet->free(); }
+#ifndef EMBEDDED_LIBRARY
bool write();
+#else
+ virtual bool write();
+#endif
inline bool store(uint32 from)
{ return store_long((longlong) from); }
inline bool store(longlong from)
@@ -121,6 +125,9 @@ public:
Protocol_prep(THD *thd) :Protocol(thd) {}
virtual bool prepare_for_send(List<Item> *item_list);
virtual void prepare_for_resend();
+#ifdef EMBEDDED_LIBRARY
+ virtual bool write();
+#endif
virtual bool store_null();
virtual bool store_tiny(longlong from);
virtual bool store_short(longlong from);
@@ -170,3 +177,9 @@ char *net_store_length(char *packet,uint length);
char *net_store_data(char *to,const char *from, uint length);
char *net_store_data(char *to,int32 from);
char *net_store_data(char *to,longlong from);
+
+#ifdef EMBEDDED_LIBRARY
+bool setup_params_data(struct st_prep_stmt *stmt);
+bool setup_params_data_withlog(struct st_prep_stmt *stmt);
+#endif
+
diff --git a/sql/sql_class.h b/sql/sql_class.h
index da6e47e4ac7..da6aab8d266 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -341,7 +341,11 @@ typedef struct st_prep_stmt
char last_error[MYSQL_ERRMSG_SIZE];
bool error_in_prepare, long_data_used;
bool log_full_query;
+#ifndef EMBEDDED_LIBRARY
bool (*setup_params)(st_prep_stmt *stmt, uchar *pos, uchar *read_pos);
+#else
+ bool (*setup_params_data)(st_prep_stmt *stmt);
+#endif
} PREP_STMT;
@@ -425,6 +429,7 @@ public:
struct st_mysql_data *data;
unsigned long client_stmt_id;
unsigned long client_param_count;
+ struct st_mysql_bind *client_params;
#endif
NET net; // client connection descriptor
LEX lex; // parse tree descriptor
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index edbcdce4e43..d16b499815e 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -77,7 +77,7 @@ Long data handling:
#define STMT_QUERY_LOG_LENGTH 8192
extern int yyparse(void *thd);
-static String null_string("NULL", 4, default_charset_info);
+String null_string("NULL", 4, default_charset_info);
/*
Find prepared statement in thd
@@ -353,7 +353,7 @@ static void setup_param_str(Item_param *param, uchar **pos)
*pos+= len;
}
-static void setup_param_functions(Item_param *param, uchar param_type)
+void setup_param_functions(Item_param *param, uchar param_type)
{
switch (param_type) {
case FIELD_TYPE_TINY:
@@ -399,6 +399,7 @@ static void setup_param_functions(Item_param *param, uchar param_type)
}
}
+#ifndef EMBEDDED_LIBRARY
/*
Update the parameter markers by reading data from client packet
and if binary/update log is set, generate the valid query.
@@ -484,11 +485,7 @@ static bool setup_params_data(PREP_STMT *stmt)
Item_param *param;
DBUG_ENTER("setup_params_data");
-#ifndef EMBEDDED_LIBRARY
uchar *pos=(uchar*) thd->net.read_pos+1+MYSQL_STMT_HEADER; //skip header
-#else
- uchar *pos= 0; //just to compile TODO code for embedded case
-#endif
uchar *read_pos= pos+(stmt->param_count+7) / 8; //skip null bits
if (*read_pos++) //types supplied / first execute
@@ -508,6 +505,8 @@ static bool setup_params_data(PREP_STMT *stmt)
DBUG_RETURN(0);
}
+#endif /*!EMBEDDED_LIBRARY*/
+
/*
Validate the following information for INSERT statement:
- field existance
@@ -792,10 +791,18 @@ static bool init_param_items(PREP_STMT *stmt)
if (mysql_bin_log.is_open() || mysql_update_log.is_open())
{
stmt->log_full_query= 1;
+#ifndef EMBEDDED_LIBRARY
stmt->setup_params= insert_params_withlog;
+#else
+ stmt->setup_params_data= setup_params_data_withlog;
+#endif
}
else
+#ifndef EMBEDDED_LIBRARY
stmt->setup_params= insert_params; // not fully qualified query
+#else
+ stmt->setup_params_data= setup_params_data;
+#endif
if (!stmt->param_count)
stmt->param= (Item_param **)0;
@@ -949,8 +956,13 @@ void mysql_stmt_execute(THD *thd, char *packet)
}
init_stmt_execute(stmt);
+#ifndef EMBEDDED_LIBRARY
if (stmt->param_count && setup_params_data(stmt))
DBUG_VOID_RETURN;
+#else
+ if (stmt->param_count && (*stmt->setup_params_data)(stmt))
+ DBUG_VOID_RETURN;
+#endif
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),QUERY_PRIOR);