summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
authorunknown <venu@myvenu.com>2003-01-30 00:38:11 -0800
committerunknown <venu@myvenu.com>2003-01-30 00:38:11 -0800
commit7d0d2d4f85f921f567ebf46d75b9aab32b5f486e (patch)
treeb44894af687099c5f4b6788966f6f5eab2fafbd3 /libmysql
parenta8abb0471ea4792fc002b817f130501e63e9507b (diff)
downloadmariadb-git-7d0d2d4f85f921f567ebf46d75b9aab32b5f486e.tar.gz
Fix 'n' concurrent prepared executions
sql/sql_prepare.cc: Fix 'n' concurrent executions libmysql/errmsg.c: Fix the missing semicolon for errors libmysql/libmysql.c: Fix the result meta info for non-SELECT statements
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/errmsg.c6
-rw-r--r--libmysql/libmysql.c40
2 files changed, 38 insertions, 8 deletions
diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c
index 2eecb5c2afd..ea11a7b6120 100644
--- a/libmysql/errmsg.c
+++ b/libmysql/errmsg.c
@@ -59,7 +59,7 @@ const char *client_errors[]=
"No parameters exists in the statement",
"Invalid parameter number",
"Can't send long data for non string or binary data types (parameter: %d)",
- "Using un supported parameter type: %d (parameter: %d)"
+ "Using un supported buffer type: %d (parameter: %d)",
"Shared memory (%lu)",
"Can't open shared memory. Request event don't create (%lu)",
"Can't open shared memory. Answer event don't create (%lu)",
@@ -114,7 +114,7 @@ const char *client_errors[]=
"No parameters exists in the statement",
"Invalid parameter number",
"Can't send long data for non string or binary data types (parameter: %d)",
- "Using un supported parameter type: %d (parameter: %d)"
+ "Using un supported buffer type: %d (parameter: %d)",
"Shared memory (%lu)",
"Can't open shared memory. Request event don't create (%lu)",
"Can't open shared memory. Answer event don't create (%lu)",
@@ -167,7 +167,7 @@ const char *client_errors[]=
"No parameters exists in the statement",
"Invalid parameter number",
"Can't send long data for non string or binary data types (parameter: %d)",
- "Using un supported parameter type: %d (parameter: %d)"
+ "Using un supported buffer type: %d (parameter: %d)",
"Shared memory (%lu)",
"Can't open shared memory. Request event don't create (%lu)",
"Can't open shared memory. Answer event don't create (%lu)",
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 5825c055305..08011c376fb 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -3925,6 +3925,28 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
DBUG_RETURN(stmt);
}
+/*
+ Get the execute query meta information for non-select
+ statements (on demand).
+*/
+
+unsigned int alloc_stmt_fields(MYSQL_STMT *stmt)
+{
+ MYSQL_FIELD *fields;
+
+ if (!stmt->mysql->field_count)
+ return 0;
+ stmt->field_count= stmt->mysql->field_count;
+ fields= stmt->mysql->fields;
+
+ if (!(stmt->fields= (MYSQL_FIELD *) alloc_root(&stmt->mem_root,
+ sizeof(fields))) ||
+ !(stmt->bind= (MYSQL_BIND *) alloc_root(&stmt->mem_root,
+ sizeof(MYSQL_BIND ) * stmt->field_count)))
+ return 0;
+ memcpy((char *)stmt->fields, (char *)fields, sizeof(fields));
+ return stmt->field_count;
+}
/*
Returns prepared meta information in the form of resultset
@@ -3938,8 +3960,10 @@ mysql_prepare_result(MYSQL_STMT *stmt)
DBUG_ENTER("mysql_prepare_result");
if (!stmt->field_count || !stmt->fields)
- DBUG_RETURN(0);
-
+ {
+ if (!alloc_stmt_fields(stmt))
+ DBUG_RETURN(0);
+ }
if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result)+
sizeof(ulong)*stmt->field_count,
MYF(MY_WME | MY_ZEROFILL))))
@@ -4436,7 +4460,7 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
default:
sprintf(stmt->last_error,
ER(stmt->last_errno= CR_UNSUPPORTED_PARAM_TYPE),
- param->buffer_type, param->param_number);
+ param->buffer_type, count);
DBUG_RETURN(1);
}
}
@@ -4984,6 +5008,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
{
MYSQL_BIND *param, *end;
ulong bind_count;
+ uint param_count= 0;
DBUG_ENTER("mysql_bind_result");
DBUG_ASSERT(stmt != 0);
@@ -4999,7 +5024,10 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
DBUG_RETURN(1);
}
#endif
- bind_count= stmt->field_count;
+ if (!(bind_count= stmt->field_count) &&
+ !(bind_count= alloc_stmt_fields(stmt)))
+ DBUG_RETURN(0);
+
memcpy((char*) stmt->bind, (char*) bind,
sizeof(MYSQL_BIND)*bind_count);
@@ -5015,6 +5043,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
if (!param->length)
param->length= &param->buffer_length;
+ param->param_number= param_count++;
/* Setup data copy functions for the different supported types */
switch (param->buffer_type) {
case MYSQL_TYPE_TINY:
@@ -5066,7 +5095,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
default:
sprintf(stmt->last_error,
ER(stmt->last_errno= CR_UNSUPPORTED_PARAM_TYPE),
- param->buffer_type, param->param_number);
+ param->buffer_type, param_count);
DBUG_RETURN(1);
}
}
@@ -5303,6 +5332,7 @@ static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
free_root(&stmt->mem_root, MYF(0));
if (!skip_list)
stmt->mysql->stmts= list_delete(stmt->mysql->stmts, &stmt->list);
+ stmt->mysql->status= MYSQL_STATUS_READY;
my_free((gptr) stmt, MYF(MY_WME));
DBUG_RETURN(error);
}