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
0fa62b69
Commit
0fa62b69
authored
Oct 05, 2004
by
monty@mishka.local
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in strict mode (A state was not properly cleared on successful insert/update's)
parent
be4ca46f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
37 deletions
+82
-37
mysql-test/mysql-test-run.sh
mysql-test/mysql-test-run.sh
+13
-13
mysql-test/r/strict.result
mysql-test/r/strict.result
+47
-11
mysql-test/t/strict.test
mysql-test/t/strict.test
+20
-10
sql/set_var.cc
sql/set_var.cc
+0
-3
sql/sql_insert.cc
sql/sql_insert.cc
+1
-0
sql/sql_update.cc
sql/sql_update.cc
+1
-0
No files found.
mysql-test/mysql-test-run.sh
View file @
0fa62b69
...
...
@@ -1184,17 +1184,19 @@ stop_master ()
mysql_stop
()
{
$ECHO
"Ending Tests"
$ECHO
"Shutting-down MySQL daemon"
$ECHO
""
stop_master
$ECHO
"Master shutdown finished"
stop_slave
stop_slave 1
stop_slave 2
$ECHO
"Slave shutdown finished"
return
1
if
[
"
$MASTER_RUNNING
"
=
1
]
then
$ECHO
"Ending Tests"
$ECHO
"Shutting-down MySQL daemon"
$ECHO
""
stop_master
$ECHO
"Master shutdown finished"
stop_slave
stop_slave 1
stop_slave 2
$ECHO
"Slave shutdown finished"
fi
return
1
}
mysql_restart
()
...
...
@@ -1383,8 +1385,6 @@ run_testcase ()
then
mysql_restart
fi
$ECHO
"Resuming Tests"
$ECHO
""
fi
fi
fi
...
...
mysql-test/r/strict.result
View file @
0fa62b69
...
...
@@ -26,14 +26,20 @@ ERROR 22007: Incorrect date value: '59' for column 'col1' at row 1
set @@sql_mode='STRICT_ALL_TABLES';
INSERT INTO t1 VALUES('2004-01-03'),('2004-0-31');
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_IN_DATE';
INSERT INTO t1 VALUES('2004-0-3
1
');
ERROR 22007: Incorrect date value: '2004-0-3
1
' for column 'col1' at row 1
INSERT INTO t1 VALUES('2004-0-3
0
');
ERROR 22007: Incorrect date value: '2004-0-3
0
' for column 'col1' at row 1
INSERT INTO t1 VALUES('2004-01-04'),('2004-0-31'),('2004-01-05');
ERROR 22007: Incorrect date value: '2004-0-31' for column 'col1' at row 2
INSERT INTO t1 VALUES('0000-00-00');
INSERT IGNORE INTO t1 VALUES('2004-0-29');
Warnings:
Warning 1265 Data truncated for column 'col1' at row 1
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_DATE';
INSERT INTO t1 VALUES('0000-00-00');
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
INSERT IGNORE INTO t1 VALUES('0000-00-00');
Warnings:
Warning 1265 Data truncated for column 'col1' at row 1
INSERT INTO t1 VALUES ('2004-0-30');
INSERT INTO t1 VALUES ('2004-2-30');
ERROR 22007: Incorrect date value: '2004-2-30' for column 'col1' at row 1
...
...
@@ -54,6 +60,8 @@ col1
2004-00-31
2004-01-04
0000-00-00
0000-00-00
0000-00-00
2004-00-30
2004-02-30
2004-02-29
...
...
@@ -188,6 +196,13 @@ col1
DROP TABLE t1;
CREATE TABLE t1(col1 TINYINT, col2 TINYINT UNSIGNED);
INSERT INTO t1 VALUES(-128,0),(0,0),(127,255),('-128','0'),('0','0'),('127','255'),(-128.0,0.0),(0.0,0.0),(127.0,255.0);
SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 2;
MOD(col1,0)
NULL
NULL
Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
INSERT INTO t1 (col1) VALUES(-129);
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(128);
...
...
@@ -210,14 +225,30 @@ INSERT INTO t1 (col2) VALUES(-1.0);
ERROR 22003: Out of range value adjusted for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(256.0);
ERROR 22003: Out of range value adjusted for column 'col2' at row 1
SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 1;
MOD(col1,0)
NULL
Warnings:
Error 1365 Division by 0
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
UPDATE t1 SET col2=col2 + 50 WHERE col2 > 0;
ERROR 22003: Out of range value adjusted for column 'col2' at row 3
UPDATE t1 SET col1=col1 / 0 WHERE col1 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM t1;
ERROR 22012: Division by 0
set @@sql_mode='ERROR_FOR_DIVISION_BY_ZERO';
INSERT INTO t1 values (1/0,1/0);
Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
set @@sql_mode='ansi,traditional';
SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 2;
MOD(col1,0)
NULL
NULL
Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES ('a59b');
...
...
@@ -231,6 +262,9 @@ INSERT IGNORE INTO t1 values (1/0,1/0);
Warnings:
Error 1365 Division by 0
Error 1365 Division by 0
set @@sql_mode='ansi';
INSERT INTO t1 values (1/0,1/0);
set @@sql_mode='ansi,traditional';
INSERT IGNORE INTO t1 VALUES('-129','-1'),('128','256');
Warnings:
Warning 1264 Out of range value adjusted for column 'col1' at row 1
...
...
@@ -255,8 +289,10 @@ col1 col2
-128 0
0 NULL
127 255
NULL NULL
2 NULL
NULL NULL
NULL NULL
-128 0
127 255
-128 0
...
...
@@ -294,7 +330,7 @@ UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
ERROR 22003: Out of range value adjusted for column 'col2' at row 3
UPDATE t1 SET col1 = col1 / 0 WHERE col1 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM t1
;
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0
;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1
...
...
@@ -378,7 +414,7 @@ UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
ERROR 22003: Out of range value adjusted for column 'col2' at row 3
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM t1
;
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0
;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR HY000: Incorrect integer value: '' for column 'col1' at row 1
...
...
@@ -462,7 +498,7 @@ UPDATE t1 SET col2 =col2 + 50 WHERE col2 > 0;
ERROR 22003: Out of range value adjusted for column 'col2' at row 3
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM t1
;
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0
;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
...
...
@@ -541,7 +577,7 @@ INSERT INTO t1 (col2) VALUES(18446744073709551616.0);
ERROR 22003: Out of range value adjusted for column 'col2' at row 1
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM t1
;
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0
;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR 22003: Out of range value adjusted for column 'col1' at row 1
...
...
@@ -621,7 +657,7 @@ UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;
ERROR 22003: Out of range value adjusted for column 'col1' at row 6
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM t1
;
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0
;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR 01000: Data truncated for column 'col1' at row 1
...
...
@@ -692,7 +728,7 @@ UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0;
ERROR 22003: Out of range value adjusted for column 'col1' at row 2
UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM t1
;
UPDATE t1 SET col2= MOD(col2,0) WHERE col2 > 0
;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR 01000: Data truncated for column 'col1' at row 1
...
...
@@ -742,7 +778,7 @@ UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0;
ERROR 22003: Out of range value adjusted for column 'col1' at row 2
UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0;
ERROR 22012: Division by 0
SELECT MOD(col1,0) FROM t1
;
UPDATE t1 SET col2= MOD(col2,0) WHERE col2 > 0
;
ERROR 22012: Division by 0
INSERT INTO t1 (col1) VALUES ('');
ERROR 01000: Data truncated for column 'col1' at row 1
...
...
mysql-test/t/strict.test
View file @
0fa62b69
...
...
@@ -38,13 +38,15 @@ set @@sql_mode='STRICT_ALL_TABLES';
INSERT
INTO
t1
VALUES
(
'2004-01-03'
),(
'2004-0-31'
);
set
@@
sql_mode
=
'STRICT_ALL_TABLES,NO_ZERO_IN_DATE'
;
--
error
1292
INSERT
INTO
t1
VALUES
(
'2004-0-3
1
'
);
INSERT
INTO
t1
VALUES
(
'2004-0-3
0
'
);
--
error
1292
INSERT
INTO
t1
VALUES
(
'2004-01-04'
),(
'2004-0-31'
),(
'2004-01-05'
);
INSERT
INTO
t1
VALUES
(
'0000-00-00'
);
INSERT
IGNORE
INTO
t1
VALUES
(
'2004-0-29'
);
set
@@
sql_mode
=
'STRICT_ALL_TABLES,NO_ZERO_DATE'
;
--
error
1292
INSERT
INTO
t1
VALUES
(
'0000-00-00'
);
INSERT
IGNORE
INTO
t1
VALUES
(
'0000-00-00'
);
INSERT
INTO
t1
VALUES
(
'2004-0-30'
);
--
error
1292
INSERT
INTO
t1
VALUES
(
'2004-2-30'
);
...
...
@@ -165,6 +167,8 @@ DROP TABLE t1;
CREATE
TABLE
t1
(
col1
TINYINT
,
col2
TINYINT
UNSIGNED
);
INSERT
INTO
t1
VALUES
(
-
128
,
0
),(
0
,
0
),(
127
,
255
),(
'-128'
,
'0'
),(
'0'
,
'0'
),(
'127'
,
'255'
),(
-
128.0
,
0.0
),(
0.0
,
0.0
),(
127.0
,
255.0
);
# Test that we restored the mode checking properly after an ok query
SELECT
MOD
(
col1
,
0
)
FROM
t1
WHERE
col1
>
0
LIMIT
2
;
--
error
1264
INSERT
INTO
t1
(
col1
)
VALUES
(
-
129
);
--
error
1264
...
...
@@ -187,14 +191,17 @@ INSERT INTO t1 (col1) VALUES(128.0);
INSERT
INTO
t1
(
col2
)
VALUES
(
-
1.0
);
--
error
1264
INSERT
INTO
t1
(
col2
)
VALUES
(
256.0
);
SELECT
MOD
(
col1
,
0
)
FROM
t1
WHERE
col1
>
0
LIMIT
1
;
--
error
1264
UPDATE
t1
SET
col1
=
col1
-
50
WHERE
col1
<
0
;
--
error
1264
UPDATE
t1
SET
col2
=
col2
+
50
WHERE
col2
>
0
;
--
error
1365
UPDATE
t1
SET
col1
=
col1
/
0
WHERE
col1
>
0
;
--
error
1365
SELECT
MOD
(
col1
,
0
)
FROM
t1
;
set
@@
sql_mode
=
'ERROR_FOR_DIVISION_BY_ZERO'
;
INSERT
INTO
t1
values
(
1
/
0
,
1
/
0
);
set
@@
sql_mode
=
'ansi,traditional'
;
SELECT
MOD
(
col1
,
0
)
FROM
t1
WHERE
col1
>
0
LIMIT
2
;
# Should return SQLSTATE 22018 invalid character value for cast
--
error
1366
INSERT
INTO
t1
(
col1
)
VALUES
(
''
);
...
...
@@ -204,6 +211,9 @@ INSERT INTO t1 (col1) VALUES ('a59b');
INSERT
INTO
t1
(
col1
)
VALUES
(
'1a'
);
INSERT
IGNORE
INTO
t1
(
col1
)
VALUES
(
'2a'
);
INSERT
IGNORE
INTO
t1
values
(
1
/
0
,
1
/
0
);
set
@@
sql_mode
=
'ansi'
;
INSERT
INTO
t1
values
(
1
/
0
,
1
/
0
);
set
@@
sql_mode
=
'ansi,traditional'
;
INSERT
IGNORE
INTO
t1
VALUES
(
'-129'
,
'-1'
),(
'128'
,
'256'
);
INSERT
IGNORE
INTO
t1
VALUES
(
-
129.0
,
-
1.0
),(
128.0
,
256.0
);
UPDATE
IGNORE
t1
SET
col2
=
1
/
NULL
where
col1
=
0
;
...
...
@@ -247,7 +257,7 @@ UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
--
error
1365
UPDATE
t1
SET
col1
=
col1
/
0
WHERE
col1
>
0
;
--
error
1365
SELECT
MOD
(
col1
,
0
)
FROM
t1
;
UPDATE
t1
SET
col1
=
MOD
(
col1
,
0
)
WHERE
col1
>
0
;
--
error
1366
INSERT
INTO
t1
(
col1
)
VALUES
(
''
);
--
error
1366
...
...
@@ -300,7 +310,7 @@ UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
--
error
1365
UPDATE
t1
SET
col1
=
col1
/
0
WHERE
col1
>
0
;
--
error
1365
SELECT
MOD
(
col1
,
0
)
FROM
t1
;
UPDATE
t1
SET
col1
=
MOD
(
col1
,
0
)
WHERE
col1
>
0
;
--
error
1366
INSERT
INTO
t1
(
col1
)
VALUES
(
''
);
--
error
1366
...
...
@@ -353,7 +363,7 @@ UPDATE t1 SET col2 =col2 + 50 WHERE col2 > 0;
--
error
1365
UPDATE
t1
SET
col1
=
col1
/
0
WHERE
col1
>
0
;
--
error
1365
SELECT
MOD
(
col1
,
0
)
FROM
t1
;
UPDATE
t1
SET
col1
=
MOD
(
col1
,
0
)
WHERE
col1
>
0
;
--
error
1264
INSERT
INTO
t1
(
col1
)
VALUES
(
''
);
--
error
1264
...
...
@@ -411,7 +421,7 @@ INSERT INTO t1 (col2) VALUES(18446744073709551616.0);
--
error
1365
UPDATE
t1
SET
col1
=
col1
/
0
WHERE
col1
>
0
;
--
error
1365
SELECT
MOD
(
col1
,
0
)
FROM
t1
;
UPDATE
t1
SET
col1
=
MOD
(
col1
,
0
)
WHERE
col1
>
0
;
--
error
1264
INSERT
INTO
t1
(
col1
)
VALUES
(
''
);
--
error
1264
...
...
@@ -461,7 +471,7 @@ UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;
--
error
1365
UPDATE
t1
SET
col1
=
col1
/
0
WHERE
col1
>
0
;
--
error
1365
SELECT
MOD
(
col1
,
0
)
FROM
t1
;
UPDATE
t1
SET
col1
=
MOD
(
col1
,
0
)
WHERE
col1
>
0
;
--
error
1265
INSERT
INTO
t1
(
col1
)
VALUES
(
''
);
--
error
1265
...
...
@@ -497,7 +507,7 @@ UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0;
--
error
1365
UPDATE
t1
SET
col2
=
col2
/
0
WHERE
col2
>
0
;
--
error
1365
SELECT
MOD
(
col1
,
0
)
FROM
t1
;
UPDATE
t1
SET
col2
=
MOD
(
col2
,
0
)
WHERE
col2
>
0
;
--
error
1265
INSERT
INTO
t1
(
col1
)
VALUES
(
''
);
--
error
1265
...
...
@@ -531,7 +541,7 @@ UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0;
--
error
1365
UPDATE
t1
SET
col2
=
col2
/
0
WHERE
col2
>
0
;
--
error
1365
SELECT
MOD
(
col1
,
0
)
FROM
t1
;
UPDATE
t1
SET
col2
=
MOD
(
col2
,
0
)
WHERE
col2
>
0
;
--
error
1265
INSERT
INTO
t1
(
col1
)
VALUES
(
''
);
--
error
1265
...
...
sql/set_var.cc
View file @
0fa62b69
...
...
@@ -3102,12 +3102,9 @@ ulong fix_sql_mode(ulong sql_mode)
if
(
sql_mode
&
MODE_MYSQL323
)
sql_mode
|=
MODE_NO_FIELD_OPTIONS
;
if
(
sql_mode
&
MODE_TRADITIONAL
)
{
sql_mode
|=
(
MODE_STRICT_TRANS_TABLES
|
MODE_STRICT_ALL_TABLES
|
MODE_NO_ZERO_IN_DATE
|
MODE_NO_ZERO_DATE
|
MODE_ERROR_FOR_DIVISION_BY_ZERO
);
sql_mode
&=
~
MODE_INVALID_DATES
;
}
return
sql_mode
;
}
...
...
sql/sql_insert.cc
View file @
0fa62b69
...
...
@@ -453,6 +453,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
}
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
table
->
insert_values
=
0
;
thd
->
abort_on_warning
=
0
;
DBUG_RETURN
(
0
);
abort:
...
...
sql/sql_update.cc
View file @
0fa62b69
...
...
@@ -457,6 +457,7 @@ int mysql_update(THD *thd,
DBUG_PRINT
(
"info"
,(
"%d records updated"
,
updated
));
}
thd
->
count_cuted_fields
=
CHECK_FIELD_IGNORE
;
/* calc cuted fields */
thd
->
abort_on_warning
=
0
;
free_io_cache
(
table
);
DBUG_RETURN
(
0
);
...
...
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