summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2004-04-30 01:02:29 +0400
committerunknown <konstantin@mysql.com>2004-04-30 01:02:29 +0400
commite73e26f3812a77551a58faf5b022ade1245b1409 (patch)
treef7bebcd7a35a5e9629f8b55f24abc75c628205c6
parent242fe78d2b79d40862f8f979921831883e3ac1e4 (diff)
downloadmariadb-git-e73e26f3812a77551a58faf5b022ade1245b1409.tar.gz
Implementation of mysql_stmt_attr_get and mysql_stmt_attr_set
requested by Monty for Bug#1647 (No way to determine what size blob/clob is being returned into bound buffer) include/mysql.h: Implementation of mysql_stmt_attr_get and mysql_stmt_attr_set requested by Monty for Bug#1647. libmysql/libmysql.c: Implementation of mysql_stmt_attr_get and mysql_stmt_attr_set requested by Monty for Bug#1647. libmysql/libmysql.def: Windows .defs added for new API calls
-rw-r--r--include/mysql.h23
-rw-r--r--libmysql/libmysql.c50
-rw-r--r--libmysql/libmysql.def2
3 files changed, 75 insertions, 0 deletions
diff --git a/include/mysql.h b/include/mysql.h
index 852d633facf..077c66235a7 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -589,8 +589,25 @@ typedef struct st_mysql_stmt
my_bool bind_result_done; /* output buffers were supplied */
/* mysql_stmt_close() had to cancel this result */
my_bool unbuffered_fetch_cancelled;
+ /*
+ Is set to true if we need to calculate field->max_length for
+ metadata fields when doing mysql_stmt_store_result.
+ */
+ my_bool update_max_length;
} MYSQL_STMT;
+enum enum_stmt_attr_type
+{
+ /*
+ When doing mysql_stmt_store_result calculate max_length attribute
+ of statement metadata. This is to be consistent with the old API,
+ where this was done automatically.
+ In the new API we do that only by request because it slows down
+ mysql_stmt_store_result sufficiently.
+ */
+ STMT_ATTR_UPDATE_MAX_LENGTH
+};
+
typedef struct st_mysql_methods
{
@@ -648,6 +665,12 @@ int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
unsigned long offset);
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
+my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
+ enum enum_stmt_attr_type attr_type,
+ const void *attr);
+my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
+ enum enum_stmt_attr_type attr_type,
+ void *attr);
my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 4447ece308e..eb5048bbb61 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -2514,6 +2514,56 @@ stmt_read_row_no_data(MYSQL_STMT *stmt __attribute__((unused)),
return MYSQL_NO_DATA;
}
+
+/*
+ Get/set statement attributes
+
+ SYNOPSIS
+ mysql_stmt_attr_get()
+ mysql_stmt_attr_set()
+
+ attr_type statemenet attribute
+ value casted to const void * pointer to value.
+
+ RETURN VALUE
+ 0 success
+ !0 wrong attribute type
+*/
+
+my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
+ enum enum_stmt_attr_type attr_type,
+ const void *value)
+{
+ switch (attr_type) {
+ case STMT_ATTR_UPDATE_MAX_LENGTH:
+ /*
+ Do we need a flags variable for all attributes or a bool for each
+ attribute?
+ */
+ stmt->update_max_length= value ? *(const my_bool*) value : 0;
+ break;
+ default:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
+ enum enum_stmt_attr_type attr_type,
+ void *value)
+{
+ switch (attr_type) {
+ case STMT_ATTR_UPDATE_MAX_LENGTH:
+ *(unsigned long *) value= stmt->update_max_length;
+ break;
+ default:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
/*
Execute the prepared query
*/
diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def
index 4f6347776e0..1790b0fa888 100644
--- a/libmysql/libmysql.def
+++ b/libmysql/libmysql.def
@@ -127,3 +127,5 @@ EXPORTS
mysql_stmt_prepare
mysql_stmt_init
mysql_stmt_insert_id
+ mysql_stmt_attr_get
+ mysql_stmt_attr_set