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
8902b739
Commit
8902b739
authored
Apr 17, 2003
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Plain Diff
Merge sinisa@bk-internal.mysql.com:/home/bk/mysql-4.1
into sinisa.nasamreza.org:/mnt/work/mysql-4.1
parents
1224daae
5ca806f7
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
329 additions
and
80 deletions
+329
-80
Docs/internals.texi
Docs/internals.texi
+2
-1
VC++Files/client/mysqlclient.dsp
VC++Files/client/mysqlclient.dsp
+0
-4
VC++Files/libmysql/libmysql.dsp
VC++Files/libmysql/libmysql.dsp
+4
-8
VC++Files/strings/strings.dsp
VC++Files/strings/strings.dsp
+0
-4
include/mysql.h
include/mysql.h
+6
-6
libmysql/libmysql.c
libmysql/libmysql.c
+98
-12
scripts/make_win_src_distribution.sh
scripts/make_win_src_distribution.sh
+3
-4
sql/item.cc
sql/item.cc
+71
-0
sql/item.h
sql/item.h
+8
-5
sql/item_strfunc.cc
sql/item_strfunc.cc
+1
-1
sql/sql_analyse.cc
sql/sql_analyse.cc
+0
-1
sql/sql_class.h
sql/sql_class.h
+3
-0
sql/sql_prepare.cc
sql/sql_prepare.cc
+118
-27
sql/sql_string.cc
sql/sql_string.cc
+13
-6
sql/sql_string.h
sql/sql_string.h
+1
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
No files found.
Docs/internals.texi
View file @
8902b739
...
@@ -2393,10 +2393,11 @@ can only start with 255 if it's an error packet.
...
@@ -2393,10 +2393,11 @@ can only start with 255 if it's an error packet.
@section 4.1 prepared statement init packet
@section 4.1 prepared statement init packet
This is the return packet when one sends a query with the COM
_
PREPARE
This is the return packet when one sends a query with the COM
_
PREPARE
command.
command
(packet length is always '9')
.
@multitable @columnfractions .10 .90
@multitable @columnfractions .10 .90
@item Size @tab Comment
@item Size @tab Comment
@item 1 @tab 0 ; Marker for OK packet
@item 4 @tab Statement handler id
@item 4 @tab Statement handler id
@item 2 @tab Number of columns in result set
@item 2 @tab Number of columns in result set
@item 2 @tab Number of parameters in query
@item 2 @tab Number of parameters in query
...
...
VC++Files/client/mysqlclient.dsp
View file @
8902b739
...
@@ -144,10 +144,6 @@ SOURCE="..\strings\ctype-latin1.c"
...
@@ -144,10 +144,6 @@ SOURCE="..\strings\ctype-latin1.c"
# End Source File
# End Source File
# Begin Source File
# Begin Source File
SOURCE="..\strings\ctype-latin1_de.c"
# End Source File
# Begin Source File
SOURCE="..\strings\ctype-mb.c"
SOURCE="..\strings\ctype-mb.c"
# End Source File
# End Source File
# Begin Source File
# Begin Source File
...
...
VC++Files/libmysql/libmysql.dsp
View file @
8902b739
...
@@ -58,8 +58,8 @@ LINK32=link.exe
...
@@ -58,8 +58,8 @@ LINK32=link.exe
# SUBTRACT LINK32 /pdb:none
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
# Begin Special Build Tool
SOURCE="$(InputPath)"
SOURCE="$(InputPath)"
PostBuild_Desc=
Copy .lib file
PostBuild_Desc=
Move DLL export lib
PostBuild_Cmds=xcopy
release\libmysql.lib ..\lib_release\
PostBuild_Cmds=xcopy
release\libmysql.lib ..\lib_release /y
# End Special Build Tool
# End Special Build Tool
!ELSEIF "$(CFG)" == "libmysql - Win32 Debug"
!ELSEIF "$(CFG)" == "libmysql - Win32 Debug"
...
@@ -91,8 +91,8 @@ LINK32=link.exe
...
@@ -91,8 +91,8 @@ LINK32=link.exe
# SUBTRACT LINK32 /pdb:none
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
# Begin Special Build Tool
SOURCE="$(InputPath)"
SOURCE="$(InputPath)"
PostBuild_Desc=
Copy .lib file
PostBuild_Desc=
Move DLL export lib
PostBuild_Cmds=xcopy
..\lib_debug\libmysql.dll C:\winnt\system32\ xcopy debug\libmysql.lib ..\lib_debug\
PostBuild_Cmds=xcopy
..\lib_debug\libmysql.dll C:\winnt\system32\ /y xcopy debug\libmysql.lib ..\lib_debug\ /y
# End Special Build Tool
# End Special Build Tool
!ENDIF
!ENDIF
...
@@ -155,10 +155,6 @@ SOURCE="..\strings\ctype-latin1.c"
...
@@ -155,10 +155,6 @@ SOURCE="..\strings\ctype-latin1.c"
# End Source File
# End Source File
# Begin Source File
# Begin Source File
SOURCE="..\strings\ctype-latin1_de.c"
# End Source File
# Begin Source File
SOURCE="..\strings\ctype-mb.c"
SOURCE="..\strings\ctype-mb.c"
# End Source File
# End Source File
# Begin Source File
# Begin Source File
...
...
VC++Files/strings/strings.dsp
View file @
8902b739
...
@@ -140,10 +140,6 @@ SOURCE=".\ctype-latin1.c"
...
@@ -140,10 +140,6 @@ SOURCE=".\ctype-latin1.c"
# End Source File
# End Source File
# Begin Source File
# Begin Source File
SOURCE=".\ctype-latin1_de.c"
# End Source File
# Begin Source File
SOURCE=".\ctype-mb.c"
SOURCE=".\ctype-mb.c"
# End Source File
# End Source File
# Begin Source File
# Begin Source File
...
...
include/mysql.h
View file @
8902b739
...
@@ -566,14 +566,14 @@ my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
...
@@ -566,14 +566,14 @@ my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
int
STDCALL
mysql_stmt_store_result
(
MYSQL_STMT
*
stmt
);
int
STDCALL
mysql_stmt_store_result
(
MYSQL_STMT
*
stmt
);
my_bool
STDCALL
mysql_more_results
(
MYSQL
*
mysql
);
my_bool
STDCALL
mysql_more_results
(
MYSQL
*
mysql
);
my_bool
STDCALL
mysql_next_result
(
MYSQL
*
mysql
);
my_bool
STDCALL
mysql_next_result
(
MYSQL
*
mysql
);
MYSQL_ROW_OFFSET
STDCALL
mysql_stmt_row_seek
(
MYSQL_STMT
*
stmt
,
MYSQL_ROW_OFFSET
offset
);
MYSQL_ROW_OFFSET
STDCALL
mysql_stmt_row_tell
(
MYSQL_STMT
*
stmt
);
void
STDCALL
mysql_stmt_data_seek
(
MYSQL_STMT
*
stmt
,
my_ulonglong
offset
);
my_ulonglong
STDCALL
mysql_stmt_num_rows
(
MYSQL_STMT
*
stmt
);
/* status return codes */
/* new status messages */
#define MYSQL_SUCCESS 0
#define MYSQL_STATUS_ERROR 1
#define MYSQL_NO_DATA 100
#define MYSQL_NO_DATA 100
#define MYSQL_NEED_DATA 99
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
...
...
libmysql/libmysql.c
View file @
8902b739
...
@@ -3925,9 +3925,9 @@ static my_bool read_prepare_result(MYSQL_STMT *stmt)
...
@@ -3925,9 +3925,9 @@ static my_bool read_prepare_result(MYSQL_STMT *stmt)
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
pos
=
(
uchar
*
)
mysql
->
net
.
read_pos
;
pos
=
(
uchar
*
)
mysql
->
net
.
read_pos
;
stmt
->
stmt_id
=
uint4korr
(
pos
);
pos
+=
4
;
stmt
->
stmt_id
=
uint4korr
(
pos
+
1
);
pos
+=
5
;
field_count
=
uint2korr
(
pos
);
pos
+=
2
;
field_count
=
uint2korr
(
pos
);
pos
+=
2
;
param_count
=
uint2korr
(
pos
);
pos
+=
2
;
param_count
=
uint2korr
(
pos
);
pos
+=
2
;
if
(
field_count
!=
0
)
if
(
field_count
!=
0
)
{
{
...
@@ -5418,9 +5418,84 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
...
@@ -5418,9 +5418,84 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
DBUG_RETURN
(
0
);
/* Data buffered, must be fetched with mysql_fetch() */
DBUG_RETURN
(
0
);
/* Data buffered, must be fetched with mysql_fetch() */
}
}
/*
Seek to desired row in the statement result set
*/
MYSQL_ROW_OFFSET
STDCALL
mysql_stmt_row_seek
(
MYSQL_STMT
*
stmt
,
MYSQL_ROW_OFFSET
row
)
{
MYSQL_RES
*
result
;
DBUG_ENTER
(
"mysql_stmt_row_seek"
);
if
((
result
=
stmt
->
result
))
{
MYSQL_ROW_OFFSET
return_value
=
result
->
data_cursor
;
result
->
current_row
=
0
;
result
->
data_cursor
=
row
;
DBUG_RETURN
(
return_value
);
}
DBUG_PRINT
(
"exit"
,
(
"stmt doesn't contain any resultset"
));
DBUG_RETURN
(
0
);
}
/*
Return the current statement row cursor position
*/
MYSQL_ROW_OFFSET
STDCALL
mysql_stmt_row_tell
(
MYSQL_STMT
*
stmt
)
{
DBUG_ENTER
(
"mysql_stmt_row_tell"
);
if
(
stmt
->
result
)
DBUG_RETURN
(
stmt
->
result
->
data_cursor
);
DBUG_PRINT
(
"exit"
,
(
"stmt doesn't contain any resultset"
));
DBUG_RETURN
(
0
);
}
/*
Move the stmt result set data cursor to specified row
*/
void
STDCALL
mysql_stmt_data_seek
(
MYSQL_STMT
*
stmt
,
my_ulonglong
row
)
{
MYSQL_RES
*
result
;
DBUG_ENTER
(
"mysql_stmt_data_seek"
);
DBUG_PRINT
(
"enter"
,(
"row id to seek: %ld"
,(
long
)
row
));
if
((
result
=
stmt
->
result
))
{
MYSQL_ROWS
*
tmp
=
0
;
if
(
result
->
data
)
for
(
tmp
=
result
->
data
->
data
;
row
--
&&
tmp
;
tmp
=
tmp
->
next
)
;
result
->
current_row
=
0
;
result
->
data_cursor
=
tmp
;
}
else
DBUG_PRINT
(
"exit"
,
(
"stmt doesn't contain any resultset"
));
}
/*
Return total rows the current statement result set
*/
my_ulonglong
STDCALL
mysql_stmt_num_rows
(
MYSQL_STMT
*
stmt
)
{
DBUG_ENTER
(
"mysql_stmt_num_rows"
);
if
(
stmt
->
result
)
DBUG_RETURN
(
stmt
->
result
->
row_count
);
DBUG_PRINT
(
"exit"
,
(
"stmt doesn't contain any resultset"
));
DBUG_RETURN
(
0
);
}
/********************************************************************
/********************************************************************
Misc function implementations
statement error handling and close
*********************************************************************/
*********************************************************************/
/*
/*
...
@@ -5505,6 +5580,10 @@ const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt)
...
@@ -5505,6 +5580,10 @@ const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt)
DBUG_RETURN
(
stmt
->
last_error
);
DBUG_RETURN
(
stmt
->
last_error
);
}
}
/********************************************************************
Transactional APIs
*********************************************************************/
/*
/*
Commit the current transaction
Commit the current transaction
*/
*/
...
@@ -5542,7 +5621,7 @@ my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode)
...
@@ -5542,7 +5621,7 @@ my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode)
/********************************************************************
/********************************************************************
Multi query execution
related implementation
s
Multi query execution
+ SPs API
s
*********************************************************************/
*********************************************************************/
/*
/*
...
@@ -5552,9 +5631,14 @@ my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode)
...
@@ -5552,9 +5631,14 @@ my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode)
my_bool
STDCALL
mysql_more_results
(
MYSQL
*
mysql
)
my_bool
STDCALL
mysql_more_results
(
MYSQL
*
mysql
)
{
{
if
(
mysql
->
last_used_con
->
server_status
&
SERVER_MORE_RESULTS_EXISTS
)
my_bool
result
;
return
1
;
DBUG_ENTER
(
"mysql_more_results"
);
return
0
;
result
=
(
mysql
->
last_used_con
->
server_status
&
SERVER_MORE_RESULTS_EXISTS
)
?
1
:
0
;
DBUG_PRINT
(
"exit"
,(
"More results exists ? %d"
,
result
));
DBUG_RETURN
(
result
);
}
}
/*
/*
...
@@ -5563,12 +5647,14 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql)
...
@@ -5563,12 +5647,14 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql)
my_bool
STDCALL
mysql_next_result
(
MYSQL
*
mysql
)
my_bool
STDCALL
mysql_next_result
(
MYSQL
*
mysql
)
{
{
DBUG_ENTER
(
"mysql_next_result"
);
mysql
->
net
.
last_error
[
0
]
=
0
;
mysql
->
net
.
last_error
[
0
]
=
0
;
mysql
->
net
.
last_errno
=
0
;
mysql
->
net
.
last_errno
=
0
;
mysql
->
affected_rows
=
~
(
my_ulonglong
)
0
;
mysql
->
affected_rows
=
~
(
my_ulonglong
)
0
;
if
(
mysql
->
last_used_con
->
server_status
&
SERVER_MORE_RESULTS_EXISTS
)
if
(
mysql
->
last_used_con
->
server_status
&
SERVER_MORE_RESULTS_EXISTS
)
return
mysql_read_query_result
(
mysql
);
DBUG_RETURN
(
mysql_read_query_result
(
mysql
));
return
0
;
DBUG_RETURN
(
0
);
}
}
scripts/make_win_src_distribution.sh
View file @
8902b739
...
@@ -145,8 +145,7 @@ rm -r -f "$BASE/share/Makefile.am"
...
@@ -145,8 +145,7 @@ rm -r -f "$BASE/share/Makefile.am"
if
[
-d
$BASE
/SCCS
]
if
[
-d
$BASE
/SCCS
]
then
then
find
$BASE
/
-name
SCCS
-print
| xargs
rm
-r
-f
find
$BASE
/
-type
d
-name
SCCS
-printf
"
\"
%p
\"
"
| xargs
rm
-r
-f
rm
-r
-f
"
$BASE
/InstallShield/Script Files/SCCS"
fi
fi
mkdir
$BASE
/Docs
$BASE
/extra
$BASE
/include
mkdir
$BASE
/Docs
$BASE
/extra
$BASE
/include
...
@@ -161,8 +160,8 @@ copy_dir_files() {
...
@@ -161,8 +160,8 @@ copy_dir_files() {
for
arg
do
for
arg
do
print_debug
"Copying files from directory '
$arg
'"
print_debug
"Copying files from directory '
$arg
'"
cd
$SOURCE
/
$arg
/
cd
$SOURCE
/
$arg
/
for
i
in
*
.c
*
.h
*
.ih
*
.i
*
.ic
*
.asm
\
for
i
in
*
.c
*
.h
*
.ih
*
.i
*
.ic
*
.asm
*
.def
\
README INSTALL
*
LICENSE
README INSTALL
*
LICENSE
do
do
if
[
-f
$i
]
if
[
-f
$i
]
then
then
...
...
sql/item.cc
View file @
8902b739
...
@@ -542,6 +542,77 @@ String *Item_param::val_str(String* str)
...
@@ -542,6 +542,77 @@ String *Item_param::val_str(String* str)
return
(
String
*
)
&
str_value
;
return
(
String
*
)
&
str_value
;
}
}
}
}
/*
Return Param item values in string format, for generating the dynamic
query used in update/binary logs
*/
String
*
Item_param
::
query_val_str
(
String
*
str
)
{
switch
(
item_result_type
)
{
case
INT_RESULT
:
case
REAL_RESULT
:
return
val_str
(
str
);
break
;
default:
str
->
set
(
"'"
,
1
,
default_charset
());
if
(
!
item_is_time
)
{
str
->
append
(
str_value
);
const
char
*
from
=
str
->
ptr
();
uint32
length
=
1
;
// Escape misc cases
char
*
to
=
(
char
*
)
from
,
*
end
=
(
char
*
)
to
+
str
->
length
();
for
(
to
++
;
to
!=
end
;
length
++
,
to
++
)
{
switch
(
*
to
)
{
case
'\''
:
case
'"'
:
case
'\r'
:
case
'\n'
:
case
'\\'
:
// TODO: Add remaining ..
str
->
replace
(
length
,
0
,
"
\\
"
,
1
);
to
++
;
end
++
;
length
++
;
break
;
default:
break
;
}
}
}
else
{
char
buff
[
25
];
switch
(
ltime
.
time_type
)
{
case
TIMESTAMP_NONE
:
break
;
case
TIMESTAMP_DATE
:
sprintf
(
buff
,
"%04d-%02d-%02d"
,
ltime
.
year
,
ltime
.
month
,
ltime
.
day
);
str
->
append
(
buff
,
10
);
break
;
case
TIMESTAMP_FULL
:
sprintf
(
buff
,
"%04d-%02d-%02d %02d:%02d:%02d"
,
ltime
.
year
,
ltime
.
month
,
ltime
.
day
,
ltime
.
hour
,
ltime
.
minute
,
ltime
.
second
);
str
->
append
(
buff
,
19
);
break
;
case
TIMESTAMP_TIME
:
{
sprintf
(
buff
,
"%02d:%02d:%02d"
,
ltime
.
hour
,
ltime
.
minute
,
ltime
.
second
);
str
->
append
(
buff
,
8
);
break
;
}
}
}
str
->
append
(
"'"
);
}
return
str
;
}
/* End of Item_param related */
/* End of Item_param related */
...
...
sql/item.h
View file @
8902b739
...
@@ -239,15 +239,17 @@ public:
...
@@ -239,15 +239,17 @@ public:
enum
Type
item_type
;
enum
Type
item_type
;
enum
enum_field_types
buffer_type
;
enum
enum_field_types
buffer_type
;
bool
item_is_time
;
bool
item_is_time
;
my_bool
long_data_supplied
;
bool
long_data_supplied
;
uint
pos_in_query
;
Item_param
(
char
*
name_par
=
0
)
Item_param
::
Item_param
(
uint
position
)
{
{
name
=
name_par
?
name_par
:
(
char
*
)
"?"
;
name
=
(
char
*
)
"?"
;
long_data_supplied
=
false
;
pos_in_query
=
position
;
item_type
=
STRING_ITEM
;
item_type
=
STRING_ITEM
;
item_result_type
=
STRING_RESULT
;
item_result_type
=
STRING_RESULT
;
item_is_time
=
false
;
item_is_time
=
false
;
long_data_supplied
=
false
;
}
}
enum
Type
type
()
const
{
return
item_type
;
}
enum
Type
type
()
const
{
return
item_type
;
}
double
val
();
double
val
();
...
@@ -268,8 +270,9 @@ public:
...
@@ -268,8 +270,9 @@ public:
void
(
*
setup_param_func
)(
Item_param
*
param
,
uchar
**
pos
);
void
(
*
setup_param_func
)(
Item_param
*
param
,
uchar
**
pos
);
enum
Item_result
result_type
()
const
enum
Item_result
result_type
()
const
{
return
item_result_type
;
}
{
return
item_result_type
;
}
String
*
query_val_str
(
String
*
str
);
enum_field_types
field_type
()
const
{
return
MYSQL_TYPE_STRING
;
}
enum_field_types
field_type
()
const
{
return
MYSQL_TYPE_STRING
;
}
Item
*
new_item
()
{
return
new
Item_param
(
name
);
}
Item
*
new_item
()
{
return
new
Item_param
(
pos_in_query
);
}
};
};
class
Item_int
:
public
Item
class
Item_int
:
public
Item
...
...
sql/item_strfunc.cc
View file @
8902b739
...
@@ -2920,7 +2920,7 @@ ret:
...
@@ -2920,7 +2920,7 @@ ret:
}
}
#ifdef HAVE_COMPRESS
#ifdef HAVE_COMPRESS
#include
<zlib.h>
#include
"../zlib/zlib.h"
String
*
Item_func_compress
::
val_str
(
String
*
str
)
String
*
Item_func_compress
::
val_str
(
String
*
str
)
{
{
...
...
sql/sql_analyse.cc
View file @
8902b739
...
@@ -283,7 +283,6 @@ void field_str::add()
...
@@ -283,7 +283,6 @@ void field_str::add()
char
buff
[
MAX_FIELD_WIDTH
],
*
ptr
;
char
buff
[
MAX_FIELD_WIDTH
],
*
ptr
;
String
s
(
buff
,
sizeof
(
buff
),
&
my_charset_bin
),
*
res
;
String
s
(
buff
,
sizeof
(
buff
),
&
my_charset_bin
),
*
res
;
ulong
length
;
ulong
length
;
TREE_ELEMENT
*
element
;
if
(
!
(
res
=
item
->
val_str
(
&
s
)))
if
(
!
(
res
=
item
->
val_str
(
&
s
)))
{
{
...
...
sql/sql_class.h
View file @
8902b739
...
@@ -321,11 +321,14 @@ typedef struct st_prep_stmt
...
@@ -321,11 +321,14 @@ typedef struct st_prep_stmt
Item_param
**
param
;
Item_param
**
param
;
Item
*
free_list
;
Item
*
free_list
;
MEM_ROOT
mem_root
;
MEM_ROOT
mem_root
;
String
*
query
;
ulong
stmt_id
;
ulong
stmt_id
;
uint
param_count
;
uint
param_count
;
uint
last_errno
;
uint
last_errno
;
char
last_error
[
MYSQL_ERRMSG_SIZE
];
char
last_error
[
MYSQL_ERRMSG_SIZE
];
bool
error_in_prepare
,
long_data_used
;
bool
error_in_prepare
,
long_data_used
;
bool
log_full_query
;
bool
(
*
setup_params
)(
st_prep_stmt
*
stmt
,
uchar
*
pos
,
uchar
*
read_pos
);
}
PREP_STMT
;
}
PREP_STMT
;
...
...
sql/sql_prepare.cc
View file @
8902b739
...
@@ -74,7 +74,10 @@ Long data handling:
...
@@ -74,7 +74,10 @@ Long data handling:
#define IS_PARAM_NULL(pos, param_no) pos[param_no/8] & (1 << param_no & 7)
#define IS_PARAM_NULL(pos, param_no) pos[param_no/8] & (1 << param_no & 7)
#define STMT_QUERY_LOG_LENGTH 8192
extern
int
yyparse
(
void
*
thd
);
extern
int
yyparse
(
void
*
thd
);
static
String
null_string
(
"NULL"
,
4
,
default_charset_info
);
/*
/*
Find prepared statement in thd
Find prepared statement in thd
...
@@ -129,6 +132,8 @@ int compare_prep_stmt(void *not_used, PREP_STMT *stmt, ulong *key)
...
@@ -129,6 +132,8 @@ int compare_prep_stmt(void *not_used, PREP_STMT *stmt, ulong *key)
void
free_prep_stmt
(
PREP_STMT
*
stmt
,
TREE_FREE
mode
,
void
*
not_used
)
void
free_prep_stmt
(
PREP_STMT
*
stmt
,
TREE_FREE
mode
,
void
*
not_used
)
{
{
my_free
((
char
*
)
stmt
->
param
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
((
char
*
)
stmt
->
param
,
MYF
(
MY_ALLOW_ZERO_PTR
));
if
(
stmt
->
query
)
stmt
->
query
->
free
();
free_items
(
stmt
->
free_list
);
free_items
(
stmt
->
free_list
);
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
free_root
(
&
stmt
->
mem_root
,
MYF
(
0
));
}
}
...
@@ -140,10 +145,11 @@ void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used)
...
@@ -140,10 +145,11 @@ void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used)
static
bool
send_prep_stmt
(
PREP_STMT
*
stmt
,
uint
columns
)
static
bool
send_prep_stmt
(
PREP_STMT
*
stmt
,
uint
columns
)
{
{
NET
*
net
=&
stmt
->
thd
->
net
;
NET
*
net
=&
stmt
->
thd
->
net
;
char
buff
[
8
];
char
buff
[
9
];
int4store
(
buff
,
stmt
->
stmt_id
);
buff
[
0
]
=
0
;
int2store
(
buff
+
4
,
columns
);
int4store
(
buff
+
1
,
stmt
->
stmt_id
);
int2store
(
buff
+
6
,
stmt
->
param_count
);
int2store
(
buff
+
5
,
columns
);
int2store
(
buff
+
7
,
stmt
->
param_count
);
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
/* This should be fixed to work with prepared statements
/* This should be fixed to work with prepared statements
*/
*/
...
@@ -374,8 +380,8 @@ static void setup_param_functions(Item_param *param, uchar param_type)
...
@@ -374,8 +380,8 @@ static void setup_param_functions(Item_param *param, uchar param_type)
param
->
setup_param_func
=
setup_param_date
;
param
->
setup_param_func
=
setup_param_date
;
param
->
item_result_type
=
STRING_RESULT
;
param
->
item_result_type
=
STRING_RESULT
;
break
;
break
;
case
FIELD
_TYPE_DATETIME
:
case
MYSQL
_TYPE_DATETIME
:
case
FIELD
_TYPE_TIMESTAMP
:
case
MYSQL
_TYPE_TIMESTAMP
:
param
->
setup_param_func
=
setup_param_datetime
;
param
->
setup_param_func
=
setup_param_datetime
;
param
->
item_result_type
=
STRING_RESULT
;
param
->
item_result_type
=
STRING_RESULT
;
break
;
break
;
...
@@ -386,10 +392,82 @@ static void setup_param_functions(Item_param *param, uchar param_type)
...
@@ -386,10 +392,82 @@ static void setup_param_functions(Item_param *param, uchar param_type)
}
}
/*
/*
Update the parameter markers by reading
the data
Update the parameter markers by reading
data from client packet
from client ..
and if binary/update log is set, generate the valid query.
*/
*/
static
bool
insert_params_withlog
(
PREP_STMT
*
stmt
,
uchar
*
pos
,
uchar
*
read_pos
)
{
THD
*
thd
=
stmt
->
thd
;
List
<
Item
>
&
params
=
thd
->
lex
.
param_list
;
List_iterator
<
Item
>
param_iterator
(
params
);
Item_param
*
param
;
DBUG_ENTER
(
"insert_params_withlog"
);
String
str
,
*
res
,
*
query
=
new
String
(
stmt
->
query
->
alloced_length
());
query
->
copy
(
*
stmt
->
query
);
ulong
param_no
=
0
;
uint32
length
=
0
;
while
((
param
=
(
Item_param
*
)
param_iterator
++
))
{
if
(
param
->
long_data_supplied
)
res
=
param
->
query_val_str
(
&
str
);
else
{
if
(
IS_PARAM_NULL
(
pos
,
param_no
))
{
param
->
maybe_null
=
param
->
null_value
=
1
;
res
=
&
null_string
;
}
else
{
param
->
maybe_null
=
param
->
null_value
=
0
;
param
->
setup_param_func
(
param
,
&
read_pos
);
res
=
param
->
query_val_str
(
&
str
);
}
}
if
(
query
->
replace
(
param
->
pos_in_query
+
length
,
1
,
*
res
))
DBUG_RETURN
(
1
);
length
+=
res
->
length
()
-
1
;
param_no
++
;
}
if
(
alloc_query
(
stmt
->
thd
,
(
char
*
)
query
->
ptr
(),
query
->
length
()
+
1
))
DBUG_RETURN
(
1
);
query
->
free
();
DBUG_RETURN
(
0
);
}
static
bool
insert_params
(
PREP_STMT
*
stmt
,
uchar
*
pos
,
uchar
*
read_pos
)
{
THD
*
thd
=
stmt
->
thd
;
List
<
Item
>
&
params
=
thd
->
lex
.
param_list
;
List_iterator
<
Item
>
param_iterator
(
params
);
Item_param
*
param
;
DBUG_ENTER
(
"insert_params"
);
ulong
param_no
=
0
;
while
((
param
=
(
Item_param
*
)
param_iterator
++
))
{
if
(
!
param
->
long_data_supplied
)
{
if
(
IS_PARAM_NULL
(
pos
,
param_no
))
param
->
maybe_null
=
param
->
null_value
=
1
;
else
{
param
->
maybe_null
=
param
->
null_value
=
0
;
param
->
setup_param_func
(
param
,
&
read_pos
);
}
}
param_no
++
;
}
DBUG_RETURN
(
0
);
}
static
bool
setup_params_data
(
PREP_STMT
*
stmt
)
static
bool
setup_params_data
(
PREP_STMT
*
stmt
)
{
{
THD
*
thd
=
stmt
->
thd
;
THD
*
thd
=
stmt
->
thd
;
...
@@ -418,21 +496,7 @@ static bool setup_params_data(PREP_STMT *stmt)
...
@@ -418,21 +496,7 @@ static bool setup_params_data(PREP_STMT *stmt)
}
}
param_iterator
.
rewind
();
param_iterator
.
rewind
();
}
}
ulong
param_no
=
0
;
stmt
->
setup_params
(
stmt
,
pos
,
read_pos
);
while
((
param
=
(
Item_param
*
)
param_iterator
++
))
{
if
(
!
param
->
long_data_supplied
)
{
if
(
IS_PARAM_NULL
(
pos
,
param_no
))
param
->
maybe_null
=
param
->
null_value
=
1
;
else
{
param
->
maybe_null
=
param
->
null_value
=
0
;
param
->
setup_param_func
(
param
,
&
read_pos
);
}
}
param_no
++
;
}
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
@@ -707,21 +771,42 @@ static bool parse_prepare_query(PREP_STMT *stmt,
...
@@ -707,21 +771,42 @@ static bool parse_prepare_query(PREP_STMT *stmt,
static
bool
init_param_items
(
PREP_STMT
*
stmt
)
static
bool
init_param_items
(
PREP_STMT
*
stmt
)
{
{
List
<
Item
>
&
params
=
stmt
->
thd
->
lex
.
param_list
;
THD
*
thd
=
stmt
->
thd
;
List
<
Item
>
&
params
=
thd
->
lex
.
param_list
;
Item_param
**
to
;
Item_param
**
to
;
uint32
length
=
thd
->
query_length
;
stmt
->
lex
=
stmt
->
thd
->
lex
;
stmt
->
lex
=
thd
->
lex
;
if
(
mysql_bin_log
.
is_open
()
||
mysql_update_log
.
is_open
())
{
stmt
->
log_full_query
=
1
;
stmt
->
setup_params
=
insert_params_withlog
;
}
else
stmt
->
setup_params
=
insert_params
;
// not fully qualified query
if
(
!
stmt
->
param_count
)
if
(
!
stmt
->
param_count
)
stmt
->
param
=
(
Item_param
**
)
0
;
stmt
->
param
=
(
Item_param
**
)
0
;
else
else
{
{
if
(
!
(
stmt
->
param
=
to
=
(
Item_param
**
)
if
(
!
(
stmt
->
param
=
to
=
(
Item_param
**
)
my_malloc
(
sizeof
(
Item_param
*
)
*
(
stmt
->
param_count
+
1
),
my_malloc
(
sizeof
(
Item_param
*
)
*
(
stmt
->
param_count
+
1
),
MYF
(
MY_WME
))))
MYF
(
MY_WME
))))
return
1
;
return
1
;
if
(
stmt
->
log_full_query
)
{
length
=
thd
->
query_length
+
(
stmt
->
param_count
*
2
)
+
1
;
if
(
length
<
STMT_QUERY_LOG_LENGTH
)
length
=
STMT_QUERY_LOG_LENGTH
;
}
List_iterator
<
Item
>
param_iterator
(
params
);
List_iterator
<
Item
>
param_iterator
(
params
);
while
((
*
(
to
++
)
=
(
Item_param
*
)
param_iterator
++
));
while
((
*
(
to
++
)
=
(
Item_param
*
)
param_iterator
++
));
}
}
stmt
->
query
=
new
String
(
length
);
stmt
->
query
->
copy
(
thd
->
query
,
thd
->
query_length
,
default_charset_info
);
return
0
;
return
0
;
}
}
...
@@ -741,6 +826,12 @@ static void init_stmt_execute(PREP_STMT *stmt)
...
@@ -741,6 +826,12 @@ static void init_stmt_execute(PREP_STMT *stmt)
*/
*/
for
(;
tables
;
tables
=
tables
->
next
)
for
(;
tables
;
tables
=
tables
->
next
)
tables
->
table
=
0
;
//safety - nasty init
tables
->
table
=
0
;
//safety - nasty init
if
(
!
(
stmt
->
log_full_query
&&
stmt
->
param_count
))
{
thd
->
query
=
stmt
->
query
->
c_ptr
();
thd
->
query_length
=
stmt
->
query
->
length
();
}
}
}
/*
/*
...
...
sql/sql_string.cc
View file @
8902b739
...
@@ -508,14 +508,20 @@ skipp:
...
@@ -508,14 +508,20 @@ skipp:
bool
String
::
replace
(
uint32
offset
,
uint32
arg_length
,
const
String
&
to
)
bool
String
::
replace
(
uint32
offset
,
uint32
arg_length
,
const
String
&
to
)
{
{
long
diff
=
(
long
)
to
.
length
()
-
(
long
)
arg_length
;
return
replace
(
offset
,
arg_length
,
to
.
ptr
(),
to
.
length
());
}
bool
String
::
replace
(
uint32
offset
,
uint32
arg_length
,
const
char
*
to
,
uint32
length
)
{
long
diff
=
(
long
)
length
-
(
long
)
arg_length
;
if
(
offset
+
arg_length
<=
str_length
)
if
(
offset
+
arg_length
<=
str_length
)
{
{
if
(
diff
<
0
)
if
(
diff
<
0
)
{
{
if
(
to
.
length
()
)
if
(
length
)
memcpy
(
Ptr
+
offset
,
to
.
ptr
(),
to
.
length
()
);
memcpy
(
Ptr
+
offset
,
to
,
length
);
bmove
(
Ptr
+
offset
+
to
.
length
()
,
Ptr
+
offset
+
arg_length
,
bmove
(
Ptr
+
offset
+
length
,
Ptr
+
offset
+
arg_length
,
str_length
-
offset
-
arg_length
);
str_length
-
offset
-
arg_length
);
}
}
else
else
...
@@ -527,14 +533,15 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
...
@@ -527,14 +533,15 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
bmove_upp
(
Ptr
+
str_length
+
diff
,
Ptr
+
str_length
,
bmove_upp
(
Ptr
+
str_length
+
diff
,
Ptr
+
str_length
,
str_length
-
offset
-
arg_length
);
str_length
-
offset
-
arg_length
);
}
}
if
(
to
.
length
()
)
if
(
length
)
memcpy
(
Ptr
+
offset
,
to
.
ptr
(),
to
.
length
()
);
memcpy
(
Ptr
+
offset
,
to
,
length
);
}
}
str_length
+=
(
uint32
)
diff
;
str_length
+=
(
uint32
)
diff
;
}
}
return
FALSE
;
return
FALSE
;
}
}
// added by Holyfoot for "geometry" needs
// added by Holyfoot for "geometry" needs
int
String
::
reserve
(
uint32
space_needed
,
uint32
grow_by
)
int
String
::
reserve
(
uint32
space_needed
,
uint32
grow_by
)
{
{
...
...
sql/sql_string.h
View file @
8902b739
...
@@ -186,6 +186,7 @@ public:
...
@@ -186,6 +186,7 @@ public:
int
strstr
(
const
String
&
search
,
uint32
offset
=
0
);
// Returns offset to substring or -1
int
strstr
(
const
String
&
search
,
uint32
offset
=
0
);
// Returns offset to substring or -1
int
strstr_case
(
const
String
&
s
,
uint32
offset
=
0
);
int
strstr_case
(
const
String
&
s
,
uint32
offset
=
0
);
int
strrstr
(
const
String
&
search
,
uint32
offset
=
0
);
// Returns offset to substring or -1
int
strrstr
(
const
String
&
search
,
uint32
offset
=
0
);
// Returns offset to substring or -1
bool
replace
(
uint32
offset
,
uint32
arg_length
,
const
char
*
to
,
uint32
length
);
bool
replace
(
uint32
offset
,
uint32
arg_length
,
const
String
&
to
);
bool
replace
(
uint32
offset
,
uint32
arg_length
,
const
String
&
to
);
inline
bool
append
(
char
chr
)
inline
bool
append
(
char
chr
)
{
{
...
...
sql/sql_yacc.yy
View file @
8902b739
...
@@ -3950,7 +3950,7 @@ param_marker:
...
@@ -3950,7 +3950,7 @@ param_marker:
LEX *lex=Lex;
LEX *lex=Lex;
if (YYTHD->prepare_command)
if (YYTHD->prepare_command)
{
{
lex->param_list.push_back($$=new Item_param());
lex->param_list.push_back($$=new Item_param(
(uint)(lex->tok_start-(uchar *)YYTHD->query)
));
lex->param_count++;
lex->param_count++;
}
}
else
else
...
...
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