Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
9f3996cd
Commit
9f3996cd
authored
21 years ago
by
hf@deer.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SCRUM:
#977 Prepared statements in embedded library
parent
f434b329
No related merge requests found
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
18 deletions
+31
-18
include/mysql.h
include/mysql.h
+1
-0
libmysql/client_settings.h
libmysql/client_settings.h
+1
-0
libmysql/libmysql.c
libmysql/libmysql.c
+11
-13
libmysqld/libmysqld.c
libmysqld/libmysqld.c
+5
-1
sql-common/client.c
sql-common/client.c
+2
-1
sql/client_settings.h
sql/client_settings.h
+1
-0
sql/sql_prepare.cc
sql/sql_prepare.cc
+10
-3
No files found.
include/mysql.h
View file @
9f3996cd
...
...
@@ -556,6 +556,7 @@ typedef struct st_mysql_methods
MYSQL_ROW
column
,
uint
field_count
);
MYSQL_RES
*
(
STDCALL
*
list_fields
)(
MYSQL
*
mysql
,
const
char
*
table
,
const
char
*
wild
);
my_bool
(
STDCALL
*
read_prepare_result
)(
MYSQL
*
mysql
,
MYSQL_STMT
*
stmt
);
}
MYSQL_METHODS
;
MYSQL_STMT
*
STDCALL
mysql_prepare
(
MYSQL
*
mysql
,
const
char
*
query
,
...
...
This diff is collapsed.
Click to expand it.
libmysql/client_settings.h
View file @
9f3996cd
...
...
@@ -42,4 +42,5 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename);
#endif
MYSQL_RES
*
STDCALL
cli_list_fields
(
MYSQL
*
mysql
,
const
char
*
table
,
const
char
*
wild
);
my_bool
cli_read_prepare_result
(
MYSQL
*
mysql
,
MYSQL_STMT
*
stmt
);
This diff is collapsed.
Click to expand it.
libmysql/libmysql.c
View file @
9f3996cd
...
...
@@ -1556,13 +1556,13 @@ static my_bool my_realloc_str(NET *net, ulong length)
1 error
*/
static
my_bool
read_prepare_result
(
MYSQL
*
mysql
,
MYSQL_STMT
*
stmt
)
my_bool
STDCALL
cli_
read_prepare_result
(
MYSQL
*
mysql
,
MYSQL_STMT
*
stmt
)
{
uchar
*
pos
;
uint
field_count
;
ulong
length
,
param_count
;
MYSQL_DATA
*
fields_data
;
DBUG_ENTER
(
"read_prepare_result"
);
DBUG_ENTER
(
"
cli_
read_prepare_result"
);
mysql
=
mysql
->
last_used_con
;
if
((
length
=
net_safe_read
(
mysql
))
==
packet_error
)
...
...
@@ -1586,18 +1586,8 @@ static my_bool read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
mysql
->
server_capabilities
)))
DBUG_RETURN
(
1
);
}
if
(
!
(
stmt
->
params
=
(
MYSQL_BIND
*
)
alloc_root
(
&
stmt
->
mem_root
,
sizeof
(
MYSQL_BIND
)
*
(
param_count
+
field_count
))))
{
set_stmt_error
(
stmt
,
CR_OUT_OF_MEMORY
,
unknown_sqlstate
);
DBUG_RETURN
(
0
);
}
stmt
->
bind
=
(
stmt
->
params
+
param_count
);
stmt
->
field_count
=
(
uint
)
field_count
;
stmt
->
param_count
=
(
ulong
)
param_count
;
mysql
->
status
=
MYSQL_STATUS_READY
;
DBUG_RETURN
(
0
);
}
...
...
@@ -1641,14 +1631,22 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length)
}
init_alloc_root
(
&
stmt
->
mem_root
,
8192
,
0
);
if
(
read_prepare_result
(
mysql
,
stmt
))
if
(
(
*
mysql
->
read_prepare_result
)
(
mysql
,
stmt
))
{
stmt_close
(
stmt
,
1
);
DBUG_RETURN
(
0
);
}
if
(
!
(
stmt
->
params
=
(
MYSQL_BIND
*
)
alloc_root
(
&
stmt
->
mem_root
,
sizeof
(
MYSQL_BIND
)
*
(
param_count
+
field_count
))))
set_stmt_error
(
stmt
,
CR_OUT_OF_MEMORY
,
unknown_sqlstate
);
stmt
->
bind
=
stmt
->
params
+
param_count
;
stmt
->
state
=
MY_ST_PREPARE
;
stmt
->
mysql
=
mysql
;
mysql
->
stmts
=
list_add
(
mysql
->
stmts
,
&
stmt
->
list
);
mysql
->
status
=
MYSQL_STATUS_READY
;
stmt
->
list
.
data
=
stmt
;
DBUG_PRINT
(
"info"
,
(
"Parameter count: %ld"
,
stmt
->
param_count
));
DBUG_RETURN
(
stmt
);
...
...
This diff is collapsed.
Click to expand it.
libmysqld/libmysqld.c
View file @
9f3996cd
...
...
@@ -211,7 +211,11 @@ emb_list_fields(MYSQL *mysql, const char *table, const char *wild)
DBUG_RETURN
(
result
);
}
my_bool
STDCALL
emb_read_prepare_result
(
MYSQL
*
mysql
,
MYSQL_STMT
*
stmt
)
{
stmt
->
fields
=
mysql
->
result
->
fields
;
stmt
->
alloc
;
}
/*
** Note that the mysql argument must be initialized with mysql_init()
...
...
This diff is collapsed.
Click to expand it.
sql-common/client.c
View file @
9f3996cd
...
...
@@ -1407,7 +1407,8 @@ static MYSQL_METHODS client_methods=
cli_mysql_store_result
,
cli_mysql_use_result
,
cli_fetch_lengths
,
cli_list_fields
cli_list_fields
,
cli_read_prepare_result
};
MYSQL
*
STDCALL
...
...
This diff is collapsed.
Click to expand it.
sql/client_settings.h
View file @
9f3996cd
...
...
@@ -33,4 +33,5 @@
#undef _CUSTOMCONFIG_
#define cli_list_fields NULL
#define cli_read_prepare_result NULL
This diff is collapsed.
Click to expand it.
sql/sql_prepare.cc
View file @
9f3996cd
...
...
@@ -142,6 +142,7 @@ void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used)
Send prepared stmt info to client after prepare
*/
#ifndef EMBEDDED_LIBRARY
static
bool
send_prep_stmt
(
PREP_STMT
*
stmt
,
uint
columns
)
{
NET
*
net
=&
stmt
->
thd
->
net
;
...
...
@@ -150,14 +151,20 @@ static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
int4store
(
buff
+
1
,
stmt
->
stmt_id
);
int2store
(
buff
+
5
,
columns
);
int2store
(
buff
+
7
,
stmt
->
param_count
);
#ifndef EMBEDDED_LIBRARY
/* This should be fixed to work with prepared statements
*/
return
(
my_net_write
(
net
,
buff
,
sizeof
(
buff
))
||
net_flush
(
net
));
}
#else
return
true
;
#endif
static
bool
send_prep_stmt
(
PREP_STMT
*
stmt
,
uint
columns
)
{
MYSQL_STMT
*
client_stmt
=
stmt
->
thd
->
client_stmt
;
client_stmt
->
stmt_id
=
stmt
->
stmt_id
;
client_stmt
->
field_count
=
columns
;
client_stmt
->
param_count
=
stmt
->
param_count
;
}
#endif
/*!EMBEDDED_LIBRAYR*/
/*
Send information about all item parameters
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment