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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
e9e64527
Commit
e9e64527
authored
Apr 04, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-5.0
into mysql.com:/home/jimw/my/mysql-5.0-clean
parents
4189e7c8
f3aa7770
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
162 additions
and
94 deletions
+162
-94
client/mysqldump.c
client/mysqldump.c
+60
-55
innobase/row/row0sel.c
innobase/row/row0sel.c
+6
-2
mysql-test/r/strict.result
mysql-test/r/strict.result
+12
-0
mysql-test/t/strict.test
mysql-test/t/strict.test
+15
-0
sql/ha_innodb.cc
sql/ha_innodb.cc
+42
-20
sql/item_timefunc.cc
sql/item_timefunc.cc
+1
-1
sql/sql_base.cc
sql/sql_base.cc
+2
-2
sql/sql_class.h
sql/sql_class.h
+2
-1
sql/sql_error.cc
sql/sql_error.cc
+17
-10
sql/sql_table.cc
sql/sql_table.cc
+5
-3
No files found.
client/mysqldump.c
View file @
e9e64527
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
*/
*/
#define DUMP_VERSION "10.
9
"
#define DUMP_VERSION "10.
10
"
#include <my_global.h>
#include <my_global.h>
#include <my_sys.h>
#include <my_sys.h>
...
@@ -396,7 +396,7 @@ static int dump_all_databases();
...
@@ -396,7 +396,7 @@ static int dump_all_databases();
static
char
*
quote_name
(
const
char
*
name
,
char
*
buff
,
my_bool
force
);
static
char
*
quote_name
(
const
char
*
name
,
char
*
buff
,
my_bool
force
);
static
const
char
*
check_if_ignore_table
(
const
char
*
table_name
);
static
const
char
*
check_if_ignore_table
(
const
char
*
table_name
);
static
char
*
primary_key_fields
(
const
char
*
table_name
);
static
char
*
primary_key_fields
(
const
char
*
table_name
);
static
my_bool
get
ViewS
tructure
(
char
*
table
,
char
*
db
);
static
my_bool
get
_view_s
tructure
(
char
*
table
,
char
*
db
);
static
my_bool
dump_all_views_in_db
(
char
*
database
);
static
my_bool
dump_all_views_in_db
(
char
*
database
);
#include <help_start.h>
#include <help_start.h>
...
@@ -777,16 +777,16 @@ static int get_options(int *argc, char ***argv)
...
@@ -777,16 +777,16 @@ static int get_options(int *argc, char ***argv)
/*
/*
** DBerror -- prints mysql error message and exits the program.
** DB
_
error -- prints mysql error message and exits the program.
*/
*/
static
void
DBerror
(
MYSQL
*
mysql
,
const
char
*
when
)
static
void
DB
_
error
(
MYSQL
*
mysql
,
const
char
*
when
)
{
{
DBUG_ENTER
(
"DBerror"
);
DBUG_ENTER
(
"DB
_
error"
);
my_printf_error
(
0
,
"Got error: %d: %s %s"
,
MYF
(
0
),
my_printf_error
(
0
,
"Got error: %d: %s %s"
,
MYF
(
0
),
mysql_errno
(
mysql
),
mysql_error
(
mysql
),
when
);
mysql_errno
(
mysql
),
mysql_error
(
mysql
),
when
);
safe_exit
(
EX_MYSQLERR
);
safe_exit
(
EX_MYSQLERR
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
/* DBerror */
}
/* DB
_
error */
/*
/*
...
@@ -862,7 +862,7 @@ static int dbConnect(char *host, char *user,char *passwd)
...
@@ -862,7 +862,7 @@ static int dbConnect(char *host, char *user,char *passwd)
NULL
,
opt_mysql_port
,
opt_mysql_unix_port
,
NULL
,
opt_mysql_port
,
opt_mysql_unix_port
,
0
)))
0
)))
{
{
DBerror
(
&
mysql_connection
,
"when trying to connect"
);
DB
_
error
(
&
mysql_connection
,
"when trying to connect"
);
return
1
;
return
1
;
}
}
/*
/*
...
@@ -1093,7 +1093,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
...
@@ -1093,7 +1093,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
number of fields in table, 0 if error
number of fields in table, 0 if error
*/
*/
static
uint
get
TableS
tructure
(
char
*
table
,
char
*
db
)
static
uint
get
_table_s
tructure
(
char
*
table
,
char
*
db
)
{
{
MYSQL_RES
*
tableRes
;
MYSQL_RES
*
tableRes
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
...
@@ -1104,7 +1104,7 @@ static uint getTableStructure(char *table, char *db)
...
@@ -1104,7 +1104,7 @@ static uint getTableStructure(char *table, char *db)
char
name_buff
[
NAME_LEN
+
3
],
table_buff
[
NAME_LEN
*
2
+
3
];
char
name_buff
[
NAME_LEN
+
3
],
table_buff
[
NAME_LEN
*
2
+
3
];
char
table_buff2
[
NAME_LEN
*
2
+
3
];
char
table_buff2
[
NAME_LEN
*
2
+
3
];
FILE
*
sql_file
=
md_result_file
;
FILE
*
sql_file
=
md_result_file
;
DBUG_ENTER
(
"get
TableS
tructure"
);
DBUG_ENTER
(
"get
_table_s
tructure"
);
delayed
=
opt_delayed
?
" DELAYED "
:
""
;
delayed
=
opt_delayed
?
" DELAYED "
:
""
;
...
@@ -1457,7 +1457,7 @@ static uint getTableStructure(char *table, char *db)
...
@@ -1457,7 +1457,7 @@ static uint getTableStructure(char *table, char *db)
my_fclose
(
sql_file
,
MYF
(
MY_WME
));
my_fclose
(
sql_file
,
MYF
(
MY_WME
));
}
}
DBUG_RETURN
(
numFields
);
DBUG_RETURN
(
numFields
);
}
/* get
TableS
tructure */
}
/* get
_table_s
tructure */
static
char
*
add_load_option
(
char
*
ptr
,
const
char
*
object
,
static
char
*
add_load_option
(
char
*
ptr
,
const
char
*
object
,
...
@@ -1523,10 +1523,12 @@ static char *alloc_query_str(ulong size)
...
@@ -1523,10 +1523,12 @@ static char *alloc_query_str(ulong size)
return
query
;
return
query
;
}
}
/*
/*
** dump
T
able saves database contents as a series of INSERT statements.
** dump
_t
able saves database contents as a series of INSERT statements.
*/
*/
static
void
dumpTable
(
uint
numFields
,
char
*
table
)
static
void
dump_table
(
uint
numFields
,
char
*
table
)
{
{
char
query_buf
[
QUERY_LENGTH
],
*
end
,
buff
[
256
],
table_buff
[
NAME_LEN
+
3
];
char
query_buf
[
QUERY_LENGTH
],
*
end
,
buff
[
256
],
table_buff
[
NAME_LEN
+
3
];
char
*
result_table
,
table_buff2
[
NAME_LEN
*
2
+
3
],
*
opt_quoted_table
;
char
*
result_table
,
table_buff2
[
NAME_LEN
*
2
+
3
],
*
opt_quoted_table
;
...
@@ -1592,7 +1594,7 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1592,7 +1594,7 @@ static void dumpTable(uint numFields, char *table)
}
}
if
(
mysql_real_query
(
sock
,
query
,
(
uint
)
(
end
-
query
)))
if
(
mysql_real_query
(
sock
,
query
,
(
uint
)
(
end
-
query
)))
{
{
DBerror
(
sock
,
"when executing 'SELECT INTO OUTFILE'"
);
DB
_
error
(
sock
,
"when executing 'SELECT INTO OUTFILE'"
);
return
;
return
;
}
}
}
}
...
@@ -1639,13 +1641,13 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1639,13 +1641,13 @@ static void dumpTable(uint numFields, char *table)
check_io
(
md_result_file
);
check_io
(
md_result_file
);
}
}
if
(
mysql_query_with_error_report
(
sock
,
0
,
query
))
if
(
mysql_query_with_error_report
(
sock
,
0
,
query
))
DBerror
(
sock
,
"when retrieving data from server"
);
DB
_
error
(
sock
,
"when retrieving data from server"
);
if
(
quick
)
if
(
quick
)
res
=
mysql_use_result
(
sock
);
res
=
mysql_use_result
(
sock
);
else
else
res
=
mysql_store_result
(
sock
);
res
=
mysql_store_result
(
sock
);
if
(
!
res
)
if
(
!
res
)
DBerror
(
sock
,
"when retrieving data from server"
);
DB
_
error
(
sock
,
"when retrieving data from server"
);
if
(
verbose
)
if
(
verbose
)
fprintf
(
stderr
,
"-- Retrieving rows...
\n
"
);
fprintf
(
stderr
,
"-- Retrieving rows...
\n
"
);
if
(
mysql_num_fields
(
res
)
!=
numFields
)
if
(
mysql_num_fields
(
res
)
!=
numFields
)
...
@@ -1946,7 +1948,7 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1946,7 +1948,7 @@ static void dumpTable(uint numFields, char *table)
my_free
(
query
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
query
,
MYF
(
MY_ALLOW_ZERO_PTR
));
safe_exit
(
error
);
safe_exit
(
error
);
return
;
return
;
}
/* dump
T
able */
}
/* dump
_t
able */
static
char
*
getTableName
(
int
reset
)
static
char
*
getTableName
(
int
reset
)
...
@@ -2035,7 +2037,7 @@ static int init_dumping(char *database)
...
@@ -2035,7 +2037,7 @@ static int init_dumping(char *database)
if
(
mysql_select_db
(
sock
,
database
))
if
(
mysql_select_db
(
sock
,
database
))
{
{
DBerror
(
sock
,
"when selecting the database"
);
DB
_
error
(
sock
,
"when selecting the database"
);
return
1
;
/* If --force */
return
1
;
/* If --force */
}
}
if
(
!
path
&&
!
opt_xml
)
if
(
!
path
&&
!
opt_xml
)
...
@@ -2123,14 +2125,14 @@ static int dump_all_tables_in_db(char *database)
...
@@ -2123,14 +2125,14 @@ static int dump_all_tables_in_db(char *database)
dynstr_append
(
&
query
,
" READ /*!32311 LOCAL */,"
);
dynstr_append
(
&
query
,
" READ /*!32311 LOCAL */,"
);
}
}
if
(
numrows
&&
mysql_real_query
(
sock
,
query
.
str
,
query
.
length
-
1
))
if
(
numrows
&&
mysql_real_query
(
sock
,
query
.
str
,
query
.
length
-
1
))
DBerror
(
sock
,
"when using LOCK TABLES"
);
DB
_
error
(
sock
,
"when using LOCK TABLES"
);
/* We shall continue here, if --force was given */
/* We shall continue here, if --force was given */
dynstr_free
(
&
query
);
dynstr_free
(
&
query
);
}
}
if
(
flush_logs
)
if
(
flush_logs
)
{
{
if
(
mysql_refresh
(
sock
,
REFRESH_LOG
))
if
(
mysql_refresh
(
sock
,
REFRESH_LOG
))
DBerror
(
sock
,
"when doing refresh"
);
DB
_
error
(
sock
,
"when doing refresh"
);
/* We shall continue here, if --force was given */
/* We shall continue here, if --force was given */
}
}
while
((
table
=
getTableName
(
0
)))
while
((
table
=
getTableName
(
0
)))
...
@@ -2138,9 +2140,9 @@ static int dump_all_tables_in_db(char *database)
...
@@ -2138,9 +2140,9 @@ static int dump_all_tables_in_db(char *database)
char
*
end
=
strmov
(
afterdot
,
table
);
char
*
end
=
strmov
(
afterdot
,
table
);
if
(
include_table
(
hash_key
,
end
-
hash_key
))
if
(
include_table
(
hash_key
,
end
-
hash_key
))
{
{
numrows
=
get
TableS
tructure
(
table
,
database
);
numrows
=
get
_table_s
tructure
(
table
,
database
);
if
(
!
dFlag
&&
numrows
>
0
)
if
(
!
dFlag
&&
numrows
>
0
)
dump
T
able
(
numrows
,
table
);
dump
_t
able
(
numrows
,
table
);
my_free
(
order_by
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
order_by
,
MYF
(
MY_ALLOW_ZERO_PTR
));
order_by
=
0
;
order_by
=
0
;
}
}
...
@@ -2188,18 +2190,18 @@ static my_bool dump_all_views_in_db(char *database)
...
@@ -2188,18 +2190,18 @@ static my_bool dump_all_views_in_db(char *database)
dynstr_append
(
&
query
,
" READ /*!32311 LOCAL */,"
);
dynstr_append
(
&
query
,
" READ /*!32311 LOCAL */,"
);
}
}
if
(
numrows
&&
mysql_real_query
(
sock
,
query
.
str
,
query
.
length
-
1
))
if
(
numrows
&&
mysql_real_query
(
sock
,
query
.
str
,
query
.
length
-
1
))
DBerror
(
sock
,
"when using LOCK TABLES"
);
DB
_
error
(
sock
,
"when using LOCK TABLES"
);
/* We shall continue here, if --force was given */
/* We shall continue here, if --force was given */
dynstr_free
(
&
query
);
dynstr_free
(
&
query
);
}
}
if
(
flush_logs
)
if
(
flush_logs
)
{
{
if
(
mysql_refresh
(
sock
,
REFRESH_LOG
))
if
(
mysql_refresh
(
sock
,
REFRESH_LOG
))
DBerror
(
sock
,
"when doing refresh"
);
DB
_
error
(
sock
,
"when doing refresh"
);
/* We shall continue here, if --force was given */
/* We shall continue here, if --force was given */
}
}
while
((
table
=
getTableName
(
0
)))
while
((
table
=
getTableName
(
0
)))
get
ViewS
tructure
(
table
,
database
);
get
_view_s
tructure
(
table
,
database
);
if
(
opt_xml
)
if
(
opt_xml
)
{
{
fputs
(
"</database>
\n
"
,
md_result_file
);
fputs
(
"</database>
\n
"
,
md_result_file
);
...
@@ -2226,7 +2228,7 @@ static int get_actual_table_name(const char *old_table_name,
...
@@ -2226,7 +2228,7 @@ static int get_actual_table_name(const char *old_table_name,
int
buf_size
)
int
buf_size
)
{
{
int
retval
;
int
retval
;
MYSQL_RES
*
table
R
es
;
MYSQL_RES
*
table
_r
es
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
char
query
[
50
+
2
*
NAME_LEN
];
char
query
[
50
+
2
*
NAME_LEN
];
char
show_name_buff
[
FN_REFLEN
];
char
show_name_buff
[
FN_REFLEN
];
...
@@ -2242,18 +2244,22 @@ static int get_actual_table_name(const char *old_table_name,
...
@@ -2242,18 +2244,22 @@ static int get_actual_table_name(const char *old_table_name,
safe_exit
(
EX_MYSQLERR
);
safe_exit
(
EX_MYSQLERR
);
}
}
tableRes
=
mysql_store_result
(
sock
);
retval
=
1
;
retval
=
1
;
if
(
tableRes
!=
NULL
)
if
((
table_res
=
mysql_store_result
(
sock
)))
{
{
my_ulonglong
numRows
=
mysql_num_rows
(
tableR
es
);
my_ulonglong
num_rows
=
mysql_num_rows
(
table_r
es
);
if
(
numR
ows
>
0
)
if
(
num_r
ows
>
0
)
{
{
row
=
mysql_fetch_row
(
tableRes
);
/*
Return first row
TODO: Return all matching rows
*/
row
=
mysql_fetch_row
(
table_res
);
strmake
(
new_table_name
,
row
[
0
],
buf_size
-
1
);
strmake
(
new_table_name
,
row
[
0
],
buf_size
-
1
);
retval
=
0
;
retval
=
0
;
}
}
mysql_free_result
(
tableR
es
);
mysql_free_result
(
table_r
es
);
}
}
return
retval
;
return
retval
;
}
}
...
@@ -2278,14 +2284,14 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -2278,14 +2284,14 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
dynstr_append
(
&
query
,
" READ /*!32311 LOCAL */,"
);
dynstr_append
(
&
query
,
" READ /*!32311 LOCAL */,"
);
}
}
if
(
mysql_real_query
(
sock
,
query
.
str
,
query
.
length
-
1
))
if
(
mysql_real_query
(
sock
,
query
.
str
,
query
.
length
-
1
))
DBerror
(
sock
,
"when doing LOCK TABLES"
);
DB
_
error
(
sock
,
"when doing LOCK TABLES"
);
/* We shall countinue here, if --force was given */
/* We shall countinue here, if --force was given */
dynstr_free
(
&
query
);
dynstr_free
(
&
query
);
}
}
if
(
flush_logs
)
if
(
flush_logs
)
{
{
if
(
mysql_refresh
(
sock
,
REFRESH_LOG
))
if
(
mysql_refresh
(
sock
,
REFRESH_LOG
))
DBerror
(
sock
,
"when doing refresh"
);
DB
_
error
(
sock
,
"when doing refresh"
);
/* We shall countinue here, if --force was given */
/* We shall countinue here, if --force was given */
}
}
if
(
opt_xml
)
if
(
opt_xml
)
...
@@ -2295,12 +2301,11 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -2295,12 +2301,11 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
char
new_table_name
[
NAME_LEN
];
char
new_table_name
[
NAME_LEN
];
/* the table name passed on commandline may be wrong case */
/* the table name passed on commandline may be wrong case */
if
(
!
get_actual_table_name
(
table_names
[
i
],
new_table_name
,
sizeof
(
new_table_name
)
))
if
(
!
get_actual_table_name
(
table_names
[
i
],
new_table_name
,
sizeof
(
new_table_name
)))
{
{
numrows
=
get_table_structure
(
new_table_name
,
db
);
numrows
=
getTableStructure
(
new_table_name
,
db
);
dump_table
(
numrows
,
new_table_name
);
dumpTable
(
numrows
,
new_table_name
);
}
}
my_free
(
order_by
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
order_by
,
MYF
(
MY_ALLOW_ZERO_PTR
));
order_by
=
0
;
order_by
=
0
;
...
@@ -2308,7 +2313,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -2308,7 +2313,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
if
(
was_views
)
if
(
was_views
)
{
{
for
(
i
=
0
;
i
<
tables
;
i
++
)
for
(
i
=
0
;
i
<
tables
;
i
++
)
get
ViewS
tructure
(
table_names
[
i
],
db
);
get
_view_s
tructure
(
table_names
[
i
],
db
);
}
}
if
(
opt_xml
)
if
(
opt_xml
)
{
{
...
@@ -2613,7 +2618,7 @@ static char *primary_key_fields(const char *table_name)
...
@@ -2613,7 +2618,7 @@ static char *primary_key_fields(const char *table_name)
Getting VIEW structure
Getting VIEW structure
SYNOPSIS
SYNOPSIS
get
ViewS
tructure()
get
_view_s
tructure()
table view name
table view name
db db name
db db name
...
@@ -2622,9 +2627,9 @@ static char *primary_key_fields(const char *table_name)
...
@@ -2622,9 +2627,9 @@ static char *primary_key_fields(const char *table_name)
1 ERROR
1 ERROR
*/
*/
static
my_bool
get
ViewS
tructure
(
char
*
table
,
char
*
db
)
static
my_bool
get
_view_s
tructure
(
char
*
table
,
char
*
db
)
{
{
MYSQL_RES
*
table
R
es
;
MYSQL_RES
*
table
_r
es
;
MYSQL_ROW
row
;
MYSQL_ROW
row
;
MYSQL_FIELD
*
field
;
MYSQL_FIELD
*
field
;
char
*
result_table
,
*
opt_quoted_table
;
char
*
result_table
,
*
opt_quoted_table
;
...
@@ -2632,7 +2637,7 @@ static my_bool getViewStructure(char *table, char* db)
...
@@ -2632,7 +2637,7 @@ static my_bool getViewStructure(char *table, char* db)
char
table_buff2
[
NAME_LEN
*
2
+
3
];
char
table_buff2
[
NAME_LEN
*
2
+
3
];
char
buff
[
20
+
FN_REFLEN
];
char
buff
[
20
+
FN_REFLEN
];
FILE
*
sql_file
=
md_result_file
;
FILE
*
sql_file
=
md_result_file
;
DBUG_ENTER
(
"get
ViewS
tructure"
);
DBUG_ENTER
(
"get
_view_s
tructure"
);
if
(
tFlag
)
if
(
tFlag
)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
@@ -2667,8 +2672,8 @@ static my_bool getViewStructure(char *table, char* db)
...
@@ -2667,8 +2672,8 @@ static my_bool getViewStructure(char *table, char* db)
}
}
write_header
(
sql_file
,
db
);
write_header
(
sql_file
,
db
);
}
}
table
R
es
=
mysql_store_result
(
sock
);
table
_r
es
=
mysql_store_result
(
sock
);
field
=
mysql_fetch_field_direct
(
table
R
es
,
0
);
field
=
mysql_fetch_field_direct
(
table
_r
es
,
0
);
if
(
strcmp
(
field
->
name
,
"View"
)
!=
0
)
if
(
strcmp
(
field
->
name
,
"View"
)
!=
0
)
{
{
if
(
verbose
)
if
(
verbose
)
...
@@ -2688,10 +2693,10 @@ static my_bool getViewStructure(char *table, char* db)
...
@@ -2688,10 +2693,10 @@ static my_bool getViewStructure(char *table, char* db)
check_io
(
sql_file
);
check_io
(
sql_file
);
}
}
row
=
mysql_fetch_row
(
table
R
es
);
row
=
mysql_fetch_row
(
table
_r
es
);
fprintf
(
sql_file
,
"%s;
\n
"
,
row
[
1
]);
fprintf
(
sql_file
,
"%s;
\n
"
,
row
[
1
]);
check_io
(
sql_file
);
check_io
(
sql_file
);
mysql_free_result
(
table
R
es
);
mysql_free_result
(
table
_r
es
);
if
(
sql_file
!=
md_result_file
)
if
(
sql_file
!=
md_result_file
)
{
{
...
...
innobase/row/row0sel.c
View file @
e9e64527
...
@@ -2145,12 +2145,16 @@ row_sel_convert_mysql_key_to_innobase(
...
@@ -2145,12 +2145,16 @@ row_sel_convert_mysql_key_to_innobase(
}
}
if
(
dtype_get_mysql_type
(
dfield_get_type
(
dfield
))
if
(
dtype_get_mysql_type
(
dfield_get_type
(
dfield
))
==
DATA_MYSQL_TRUE_VARCHAR
)
{
==
DATA_MYSQL_TRUE_VARCHAR
&&
dfield_get_type
(
dfield
)
->
mtype
!=
DATA_INT
)
{
/* In a MySQL key value format, a true VARCHAR is
/* In a MySQL key value format, a true VARCHAR is
always preceded by 2 bytes of a length field.
always preceded by 2 bytes of a length field.
dfield_get_type(dfield)->len returns the maximum
dfield_get_type(dfield)->len returns the maximum
'payload' len in bytes. That does not include the
'payload' len in bytes. That does not include the
2 bytes that tell the actual data length. */
2 bytes that tell the actual data length.
We added the check != DATA_INT to make sure we do
not treat MySQL ENUM or SET as a true VARCHAR! */
data_len
+=
2
;
data_len
+=
2
;
data_field_len
+=
2
;
data_field_len
+=
2
;
...
...
mysql-test/r/strict.result
View file @
e9e64527
...
@@ -1173,4 +1173,16 @@ col1
...
@@ -1173,4 +1173,16 @@ col1
0000-00-00 00:00:00
0000-00-00 00:00:00
NULL
NULL
drop table t1;
drop table t1;
create table t1 (col1 tinyint);
drop procedure if exists t1;
Warnings:
Note 1305 PROCEDURE t1 does not exist
create procedure t1 () begin declare exit handler for sqlexception
select'a'; insert into t1 values (200); end;|
call t1();
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
select * from t1;
col1
drop procedure t1;
drop table t1;
set sql_mode=@org_mode;
set sql_mode=@org_mode;
mysql-test/t/strict.test
View file @
e9e64527
...
@@ -1031,6 +1031,21 @@ insert into t1 select * from t1;
...
@@ -1031,6 +1031,21 @@ insert into t1 select * from t1;
select
*
from
t1
;
select
*
from
t1
;
drop
table
t1
;
drop
table
t1
;
#
# Test of inserting an invalid value via a stored procedure (Bug #5907)
#
create
table
t1
(
col1
tinyint
);
drop
procedure
if
exists
t1
;
delimiter
|
;
create
procedure
t1
()
begin
declare
exit
handler
for
sqlexception
select
'a'
;
insert
into
t1
values
(
200
);
end
;
|
delimiter
;
|
--
error
1264
call
t1
();
select
*
from
t1
;
drop
procedure
t1
;
drop
table
t1
;
#
#
# Restore mode
# Restore mode
#
#
...
...
sql/ha_innodb.cc
View file @
e9e64527
...
@@ -2272,12 +2272,42 @@ ulint
...
@@ -2272,12 +2272,42 @@ ulint
get_innobase_type_from_mysql_type
(
get_innobase_type_from_mysql_type
(
/*==============================*/
/*==============================*/
/* out: DATA_BINARY, DATA_VARCHAR, ... */
/* out: DATA_BINARY, DATA_VARCHAR, ... */
ulint
*
unsigned_flag
,
/* out: DATA_UNSIGNED if an 'unsigned type';
at least ENUM and SET, and unsigned integer
types are 'unsigned types' */
Field
*
field
)
/* in: MySQL field */
Field
*
field
)
/* in: MySQL field */
{
{
/* The following asserts try to check that the MySQL type code fits in
/* The following asserts try to check that the MySQL type code fits in
8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to
8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to
the type */
the type */
DBUG_ASSERT
((
ulint
)
FIELD_TYPE_STRING
<
256
);
DBUG_ASSERT
((
ulint
)
FIELD_TYPE_VAR_STRING
<
256
);
DBUG_ASSERT
((
ulint
)
FIELD_TYPE_DOUBLE
<
256
);
DBUG_ASSERT
((
ulint
)
FIELD_TYPE_FLOAT
<
256
);
DBUG_ASSERT
((
ulint
)
FIELD_TYPE_DECIMAL
<
256
);
if
(
field
->
flags
&
UNSIGNED_FLAG
)
{
*
unsigned_flag
=
DATA_UNSIGNED
;
}
else
{
*
unsigned_flag
=
0
;
}
if
(
field
->
real_type
()
==
FIELD_TYPE_ENUM
||
field
->
real_type
()
==
FIELD_TYPE_SET
)
{
/* MySQL has field->type() a string type for these, but the
data is actually internally stored as an unsigned integer
code! */
*
unsigned_flag
=
DATA_UNSIGNED
;
/* MySQL has its own unsigned
flag set to zero, even though
internally this is an unsigned
integer type */
return
(
DATA_INT
);
}
switch
(
field
->
type
())
{
switch
(
field
->
type
())
{
/* NOTE that we only allow string types in DATA_MYSQL
/* NOTE that we only allow string types in DATA_MYSQL
and DATA_VARMYSQL */
and DATA_VARMYSQL */
...
@@ -2313,8 +2343,6 @@ get_innobase_type_from_mysql_type(
...
@@ -2313,8 +2343,6 @@ get_innobase_type_from_mysql_type(
case
FIELD_TYPE_DATETIME
:
case
FIELD_TYPE_DATETIME
:
case
FIELD_TYPE_YEAR
:
case
FIELD_TYPE_YEAR
:
case
FIELD_TYPE_NEWDATE
:
case
FIELD_TYPE_NEWDATE
:
case
FIELD_TYPE_ENUM
:
case
FIELD_TYPE_SET
:
case
FIELD_TYPE_TIME
:
case
FIELD_TYPE_TIME
:
case
FIELD_TYPE_TIMESTAMP
:
case
FIELD_TYPE_TIMESTAMP
:
return
(
DATA_INT
);
return
(
DATA_INT
);
...
@@ -2686,7 +2714,7 @@ build_template(
...
@@ -2686,7 +2714,7 @@ build_template(
get_field_offset
(
table
,
field
);
get_field_offset
(
table
,
field
);
templ
->
mysql_col_len
=
(
ulint
)
field
->
pack_length
();
templ
->
mysql_col_len
=
(
ulint
)
field
->
pack_length
();
templ
->
type
=
get_innobase_type_from_mysql_type
(
field
)
;
templ
->
type
=
index
->
table
->
cols
[
i
].
type
.
mtype
;
templ
->
mysql_type
=
(
ulint
)
field
->
type
();
templ
->
mysql_type
=
(
ulint
)
field
->
type
();
if
(
templ
->
mysql_type
==
DATA_MYSQL_TRUE_VARCHAR
)
{
if
(
templ
->
mysql_type
==
DATA_MYSQL_TRUE_VARCHAR
)
{
...
@@ -2698,8 +2726,8 @@ build_template(
...
@@ -2698,8 +2726,8 @@ build_template(
index
->
table
->
cols
[
i
].
type
.
prtype
);
index
->
table
->
cols
[
i
].
type
.
prtype
);
templ
->
mbminlen
=
index
->
table
->
cols
[
i
].
type
.
mbminlen
;
templ
->
mbminlen
=
index
->
table
->
cols
[
i
].
type
.
mbminlen
;
templ
->
mbmaxlen
=
index
->
table
->
cols
[
i
].
type
.
mbmaxlen
;
templ
->
mbmaxlen
=
index
->
table
->
cols
[
i
].
type
.
mbmaxlen
;
templ
->
is_unsigned
=
(
ulint
)
(
field
->
flags
&
UNSIGNED_FLAG
);
templ
->
is_unsigned
=
index
->
table
->
cols
[
i
].
type
.
prtype
&
DATA_UNSIGNED
;
if
(
templ
->
type
==
DATA_BLOB
)
{
if
(
templ
->
type
==
DATA_BLOB
)
{
prebuilt
->
templ_contains_blob
=
TRUE
;
prebuilt
->
templ_contains_blob
=
TRUE
;
}
}
...
@@ -2962,7 +2990,6 @@ calc_row_difference(
...
@@ -2962,7 +2990,6 @@ calc_row_difference(
byte
*
buf
;
byte
*
buf
;
upd_field_t
*
ufield
;
upd_field_t
*
ufield
;
ulint
col_type
;
ulint
col_type
;
ulint
is_unsigned
;
ulint
n_changed
=
0
;
ulint
n_changed
=
0
;
dfield_t
dfield
;
dfield_t
dfield
;
uint
i
;
uint
i
;
...
@@ -2998,8 +3025,7 @@ calc_row_difference(
...
@@ -2998,8 +3025,7 @@ calc_row_difference(
field_mysql_type
=
field
->
type
();
field_mysql_type
=
field
->
type
();
col_type
=
get_innobase_type_from_mysql_type
(
field
);
col_type
=
prebuilt
->
table
->
cols
[
i
].
type
.
mtype
;
is_unsigned
=
(
ulint
)
(
field
->
flags
&
UNSIGNED_FLAG
);
switch
(
col_type
)
{
switch
(
col_type
)
{
...
@@ -3072,8 +3098,7 @@ calc_row_difference(
...
@@ -3072,8 +3098,7 @@ calc_row_difference(
}
}
ufield
->
exp
=
NULL
;
ufield
->
exp
=
NULL
;
ufield
->
field_no
=
ufield
->
field_no
=
prebuilt
->
table
->
cols
[
i
].
clust_pos
;
(
prebuilt
->
table
->
cols
+
i
)
->
clust_pos
;
n_changed
++
;
n_changed
++
;
}
}
}
}
...
@@ -3932,19 +3957,14 @@ create_table_def(
...
@@ -3932,19 +3957,14 @@ create_table_def(
for
(
i
=
0
;
i
<
n_cols
;
i
++
)
{
for
(
i
=
0
;
i
<
n_cols
;
i
++
)
{
field
=
form
->
field
[
i
];
field
=
form
->
field
[
i
];
col_type
=
get_innobase_type_from_mysql_type
(
field
);
col_type
=
get_innobase_type_from_mysql_type
(
&
unsigned_type
,
field
);
if
(
field
->
null_ptr
)
{
if
(
field
->
null_ptr
)
{
nulls_allowed
=
0
;
nulls_allowed
=
0
;
}
else
{
}
else
{
nulls_allowed
=
DATA_NOT_NULL
;
nulls_allowed
=
DATA_NOT_NULL
;
}
}
if
(
field
->
flags
&
UNSIGNED_FLAG
)
{
unsigned_type
=
DATA_UNSIGNED
;
}
else
{
unsigned_type
=
0
;
}
if
(
field
->
binary
())
{
if
(
field
->
binary
())
{
binary_type
=
DATA_BINARY_TYPE
;
binary_type
=
DATA_BINARY_TYPE
;
}
else
{
}
else
{
...
@@ -4021,6 +4041,7 @@ create_index(
...
@@ -4021,6 +4041,7 @@ create_index(
ulint
ind_type
;
ulint
ind_type
;
ulint
col_type
;
ulint
col_type
;
ulint
prefix_len
;
ulint
prefix_len
;
ulint
is_unsigned
;
ulint
i
;
ulint
i
;
ulint
j
;
ulint
j
;
...
@@ -4070,7 +4091,8 @@ create_index(
...
@@ -4070,7 +4091,8 @@ create_index(
ut_a
(
j
<
form
->
s
->
fields
);
ut_a
(
j
<
form
->
s
->
fields
);
col_type
=
get_innobase_type_from_mysql_type
(
key_part
->
field
);
col_type
=
get_innobase_type_from_mysql_type
(
&
is_unsigned
,
key_part
->
field
);
if
(
DATA_BLOB
==
col_type
if
(
DATA_BLOB
==
col_type
||
(
key_part
->
length
<
field
->
pack_length
()
||
(
key_part
->
length
<
field
->
pack_length
()
...
...
sql/item_timefunc.cc
View file @
e9e64527
...
@@ -2199,7 +2199,7 @@ String *Item_char_typecast::val_str(String *str)
...
@@ -2199,7 +2199,7 @@ String *Item_char_typecast::val_str(String *str)
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
ER_TRUNCATED_WRONG_VALUE
,
ER_TRUNCATED_WRONG_VALUE
,
ER
(
ER_TRUNCATED_WRONG_VALUE
),
char_type
,
ER
(
ER_TRUNCATED_WRONG_VALUE
),
char_type
,
res
->
c_ptr
());
res
->
c_ptr
_safe
());
res
->
length
((
uint
)
length
);
res
->
length
((
uint
)
length
);
}
}
null_value
=
0
;
null_value
=
0
;
...
...
sql/sql_base.cc
View file @
e9e64527
...
@@ -692,11 +692,11 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table,
...
@@ -692,11 +692,11 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table,
/*
/*
Test that table is unique
Test that table is unique
(It's only exists once in the table list)
SYNOPSIS
SYNOPSIS
unique_table()
unique_table()
table table which should be ch
a
ked
table table which should be ch
ec
ked
table_list list of tables
table_list list of tables
NOTE: to exclude derived tables from check we use following mechanism:
NOTE: to exclude derived tables from check we use following mechanism:
...
...
sql/sql_class.h
View file @
e9e64527
...
@@ -1410,6 +1410,7 @@ class THD :public ilink,
...
@@ -1410,6 +1410,7 @@ class THD :public ilink,
inline
void
send_kill_message
()
const
inline
void
send_kill_message
()
const
{
{
int
err
=
killed_errno
();
int
err
=
killed_errno
();
if
(
err
)
my_message
(
err
,
ER
(
err
),
MYF
(
0
));
my_message
(
err
,
ER
(
err
),
MYF
(
0
));
}
}
/* return TRUE if we will abort query if we make a warning now */
/* return TRUE if we will abort query if we make a warning now */
...
...
sql/sql_error.cc
View file @
e9e64527
...
@@ -116,15 +116,6 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
...
@@ -116,15 +116,6 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
if
(
thd
->
query_id
!=
thd
->
warn_id
)
if
(
thd
->
query_id
!=
thd
->
warn_id
)
mysql_reset_errors
(
thd
,
0
);
mysql_reset_errors
(
thd
,
0
);
thd
->
got_warning
=
1
;
thd
->
got_warning
=
1
;
if
(
thd
->
spcont
&&
thd
->
spcont
->
find_handler
(
code
,
((
int
)
level
>=
(
int
)
MYSQL_ERROR
::
WARN_LEVEL_WARN
&&
thd
->
really_abort_on_warning
())
?
MYSQL_ERROR
::
WARN_LEVEL_ERROR
:
level
))
{
DBUG_RETURN
(
NULL
);
}
/* Abort if we are using strict mode and we are not using IGNORE */
/* Abort if we are using strict mode and we are not using IGNORE */
if
((
int
)
level
>=
(
int
)
MYSQL_ERROR
::
WARN_LEVEL_WARN
&&
if
((
int
)
level
>=
(
int
)
MYSQL_ERROR
::
WARN_LEVEL_WARN
&&
...
@@ -132,14 +123,30 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
...
@@ -132,14 +123,30 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
{
{
/* Avoid my_message() calling push_warning */
/* Avoid my_message() calling push_warning */
bool
no_warnings_for_error
=
thd
->
no_warnings_for_error
;
bool
no_warnings_for_error
=
thd
->
no_warnings_for_error
;
sp_rcontext
*
spcont
=
thd
->
spcont
;
thd
->
no_warnings_for_error
=
1
;
thd
->
no_warnings_for_error
=
1
;
thd
->
spcont
=
0
;
thd
->
killed
=
THD
::
KILL_BAD_DATA
;
thd
->
killed
=
THD
::
KILL_BAD_DATA
;
my_message
(
code
,
msg
,
MYF
(
0
));
my_message
(
code
,
msg
,
MYF
(
0
));
thd
->
spcont
=
spcont
;
thd
->
no_warnings_for_error
=
no_warnings_for_error
;
thd
->
no_warnings_for_error
=
no_warnings_for_error
;
/* Store error in error list (as my_message() didn't do it
in this case
*/
/* Store error in error list (as my_message() didn't do it
)
*/
level
=
MYSQL_ERROR
::
WARN_LEVEL_ERROR
;
level
=
MYSQL_ERROR
::
WARN_LEVEL_ERROR
;
}
}
if
(
thd
->
spcont
&&
thd
->
spcont
->
find_handler
(
code
,
((
int
)
level
>=
(
int
)
MYSQL_ERROR
::
WARN_LEVEL_WARN
&&
thd
->
really_abort_on_warning
())
?
MYSQL_ERROR
::
WARN_LEVEL_ERROR
:
level
))
{
DBUG_RETURN
(
NULL
);
}
if
(
thd
->
warn_list
.
elements
<
thd
->
variables
.
max_error_count
)
if
(
thd
->
warn_list
.
elements
<
thd
->
variables
.
max_error_count
)
{
{
/*
/*
...
...
sql/sql_table.cc
View file @
e9e64527
...
@@ -3740,9 +3740,11 @@ copy_data_between_tables(TABLE *from,TABLE *to,
...
@@ -3740,9 +3740,11 @@ copy_data_between_tables(TABLE *from,TABLE *to,
goto
err
;
goto
err
;
};
};
/* Handler must be told explicitly to retrieve all columns, because
/*
Handler must be told explicitly to retrieve all columns, because
this function does not set field->query_id in the columns to the
this function does not set field->query_id in the columns to the
current query id */
current query id
*/
from
->
file
->
extra
(
HA_EXTRA_RETRIEVE_ALL_COLS
);
from
->
file
->
extra
(
HA_EXTRA_RETRIEVE_ALL_COLS
);
init_read_record
(
&
info
,
thd
,
from
,
(
SQL_SELECT
*
)
0
,
1
,
1
);
init_read_record
(
&
info
,
thd
,
from
,
(
SQL_SELECT
*
)
0
,
1
,
1
);
if
(
ignore
||
if
(
ignore
||
...
...
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