Commit 5cdec5d6 authored by unknown's avatar unknown

Merge


mysql-test/r/create.result:
  Auto merged
mysql-test/r/ctype_latin1_de.result:
  Auto merged
mysql-test/r/grant.result:
  Auto merged
mysql-test/r/grant2.result:
  Auto merged
mysql-test/r/limit.result:
  Auto merged
mysql-test/r/order_by.result:
  Auto merged
mysql-test/r/rpl000001.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/strict.result:
  Auto merged
mysql-test/r/type_blob.result:
  Auto merged
mysql-test/r/type_ranges.result:
  Auto merged
mysql-test/r/warnings.result:
  Auto merged
mysql-test/t/ctype_latin1_de.test:
  Auto merged
mysql-test/t/limit.test:
  Auto merged
mysql-test/t/order_by.test:
  Auto merged
mysql-test/t/show_check.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/type_blob.test:
  Auto merged
mysql-test/t/type_ranges.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
mysql-test/t/strict.test:
  SCCS merged
parents 51653cb2 2f19824d
...@@ -267,11 +267,15 @@ drop table t1; ...@@ -267,11 +267,15 @@ drop table t1;
create table t1 (a int not null, b int, primary key (a)); create table t1 (a int not null, b int, primary key (a));
insert into t1 values (1,1); insert into t1 values (1,1);
create table if not exists t1 select 2; create table if not exists t1 select 2;
Warnings:
Warning 1364 Field 'a' doesn't have a default value
select * from t1; select * from t1;
a b a b
1 1 1 1
0 2 0 2
create table if not exists t1 select 3 as 'a',4 as 'b'; create table if not exists t1 select 3 as 'a',4 as 'b';
Warnings:
Warning 1364 Field 'a' doesn't have a default value
create table if not exists t1 select 3 as 'a',3 as 'b'; create table if not exists t1 select 3 as 'a',3 as 'b';
ERROR 23000: Duplicate entry '3' for key 1 ERROR 23000: Duplicate entry '3' for key 1
select * from t1; select * from t1;
......
...@@ -220,12 +220,12 @@ select * from t1 where match a against ("te*" in boolean mode)+0; ...@@ -220,12 +220,12 @@ select * from t1 where match a against ("te*" in boolean mode)+0;
a a
test test
drop table t1; drop table t1;
create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word)); create table t1 (word varchar(255) not null, word2 varchar(255) not null default '', index(word));
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`word` varchar(255) collate latin1_german2_ci NOT NULL, `word` varchar(255) collate latin1_german2_ci NOT NULL,
`word2` varchar(255) collate latin1_german2_ci NOT NULL, `word2` varchar(255) collate latin1_german2_ci NOT NULL default '',
KEY `word` (`word`) KEY `word` (`word`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci
insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae'); insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae');
......
...@@ -758,7 +758,6 @@ SPATIAL KEY(g) ...@@ -758,7 +758,6 @@ SPATIAL KEY(g)
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)')); INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)'));
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
geoobjid INT NOT NULL,
line LINESTRING NOT NULL, line LINESTRING NOT NULL,
kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po', kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
name VARCHAR(32), name VARCHAR(32),
......
...@@ -157,6 +157,10 @@ select 1; ...@@ -157,6 +157,10 @@ select 1;
1 1
1 1
insert into mysql.user (host, user) values ('localhost', 'test11'); insert into mysql.user (host, user) values ('localhost', 'test11');
Warnings:
Warning 1364 Field 'ssl_cipher' doesn't have a default value
Warning 1364 Field 'x509_issuer' doesn't have a default value
Warning 1364 Field 'x509_subject' doesn't have a default value
insert into mysql.db (host, db, user, select_priv) values insert into mysql.db (host, db, user, select_priv) values
('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); ('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y');
alter table mysql.db order by db asc; alter table mysql.db order by db asc;
......
...@@ -261,6 +261,10 @@ GRANT INSERT, UPDATE, DELETE ON `mysql`.* TO 'mysqltest_3'@'localhost' ...@@ -261,6 +261,10 @@ GRANT INSERT, UPDATE, DELETE ON `mysql`.* TO 'mysqltest_3'@'localhost'
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password; select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 'user' ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 'user'
insert into mysql.user set host='%', user='mysqltest_B'; insert into mysql.user set host='%', user='mysqltest_B';
Warnings:
Warning 1364 Field 'ssl_cipher' doesn't have a default value
Warning 1364 Field 'x509_issuer' doesn't have a default value
Warning 1364 Field 'x509_subject' doesn't have a default value
create user mysqltest_A@'%'; create user mysqltest_A@'%';
rename user mysqltest_B@'%' to mysqltest_C@'%'; rename user mysqltest_B@'%' to mysqltest_C@'%';
drop user mysqltest_C@'%'; drop user mysqltest_C@'%';
......
insert into mysql.help_category(help_category_id,name)values(1,'impossible_category_1'); insert into mysql.help_category(help_category_id,name)values(1,'impossible_category_1');
Warnings:
Warning 1364 Field 'url' doesn't have a default value
select @category1_id:= 1; select @category1_id:= 1;
@category1_id:= 1 @category1_id:= 1
1 1
insert into mysql.help_category(help_category_id,name)values(2,'impossible_category_2'); insert into mysql.help_category(help_category_id,name)values(2,'impossible_category_2');
Warnings:
Warning 1364 Field 'url' doesn't have a default value
select @category2_id:= 2; select @category2_id:= 2;
@category2_id:= 2 @category2_id:= 2
2 2
insert into mysql.help_category(help_category_id,name,parent_category_id)values(3,'impossible_category_3',@category2_id); insert into mysql.help_category(help_category_id,name,parent_category_id)values(3,'impossible_category_3',@category2_id);
Warnings:
Warning 1364 Field 'url' doesn't have a default value
select @category3_id:= 3; select @category3_id:= 3;
@category3_id:= 3 @category3_id:= 3
3 3
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(1,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1'); insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(1,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1');
Warnings:
Warning 1364 Field 'url' doesn't have a default value
select @topic1_id:= 1; select @topic1_id:= 1;
@topic1_id:= 1 @topic1_id:= 1
1 1
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(2,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2'); insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(2,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2');
Warnings:
Warning 1364 Field 'url' doesn't have a default value
select @topic2_id:= 2; select @topic2_id:= 2;
@topic2_id:= 2 @topic2_id:= 2
2 2
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(3,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3'); insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(3,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3');
Warnings:
Warning 1364 Field 'url' doesn't have a default value
select @topic3_id:= 3; select @topic3_id:= 3;
@topic3_id:= 3 @topic3_id:= 3
3 3
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(4,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4'); insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(4,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4');
Warnings:
Warning 1364 Field 'url' doesn't have a default value
select @topic4_id:= 4; select @topic4_id:= 4;
@topic4_id:= 4 @topic4_id:= 4
4 4
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(5,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7'); insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(5,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7');
Warnings:
Warning 1364 Field 'url' doesn't have a default value
select @topic5_id:= 5; select @topic5_id:= 5;
@topic5_id:= 5 @topic5_id:= 5
5 5
......
drop table if exists t1; drop table if exists t1;
create table t1 (a int primary key, b int not null); create table t1 (a int not null default 0 primary key, b int not null default 0);
insert into t1 () values (); insert into t1 () values ();
insert into t1 values (1,1),(2,1),(3,1); insert into t1 values (1,1),(2,1),(3,1);
update t1 set a=4 where b=1 limit 1; update t1 set a=4 where b=1 limit 1;
......
...@@ -88,7 +88,7 @@ b ifnull(t2.b,"this is null") ...@@ -88,7 +88,7 @@ b ifnull(t2.b,"this is null")
NULL this is null NULL this is null
NULL this is null NULL this is null
drop table t1; drop table t1;
CREATE TABLE t1 (a varchar(16) NOT NULL, b smallint(6) NOT NULL, c datetime NOT NULL, d smallint(6) NOT NULL); CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default '', c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55"; INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
Warnings: Warnings:
Warning 1265 Data truncated for column 'd' at row 1 Warning 1265 Data truncated for column 'd' at row 1
......
...@@ -257,7 +257,7 @@ favo_tijdschrift varchar(50) NOT NULL default '', ...@@ -257,7 +257,7 @@ favo_tijdschrift varchar(50) NOT NULL default '',
favo_tv varchar(50) NOT NULL default '', favo_tv varchar(50) NOT NULL default '',
favo_eten varchar(50) NOT NULL default '', favo_eten varchar(50) NOT NULL default '',
favo_muziek varchar(30) NOT NULL default '', favo_muziek varchar(30) NOT NULL default '',
info text NOT NULL, info text NOT NULL default '',
ipnr varchar(30) NOT NULL default '', ipnr varchar(30) NOT NULL default '',
PRIMARY KEY (member_id) PRIMARY KEY (member_id)
) ENGINE=MyISAM PACK_KEYS=1; ) ENGINE=MyISAM PACK_KEYS=1;
......
...@@ -61,6 +61,10 @@ create table t1 (n int); ...@@ -61,6 +61,10 @@ create table t1 (n int);
insert into t1 values(3456); insert into t1 values(3456);
insert into mysql.user (Host, User, Password) insert into mysql.user (Host, User, Password)
VALUES ("10.10.10.%", "blafasel2", password("blafasel2")); VALUES ("10.10.10.%", "blafasel2", password("blafasel2"));
Warnings:
Warning 1364 Field 'ssl_cipher' doesn't have a default value
Warning 1364 Field 'x509_issuer' doesn't have a default value
Warning 1364 Field 'x509_subject' doesn't have a default value
select select_priv,user from mysql.user where user = _binary'blafasel2'; select select_priv,user from mysql.user where user = _binary'blafasel2';
select_priv user select_priv user
N blafasel2 N blafasel2
......
use test; use test;
drop table if exists t1; drop table if exists t1;
create table t1 ( create table t1 (
id char(16) not null, id char(16) not null default '',
data int not null data int not null
); );
drop table if exists t2; drop table if exists t2;
...@@ -2164,7 +2164,7 @@ tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer ...@@ -2164,7 +2164,7 @@ tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer
tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`id` char(16) NOT NULL, `id` char(16) NOT NULL default '',
`data` int(11) NOT NULL `data` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
Database Create Database Database Create Database
...@@ -2218,7 +2218,7 @@ tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer ...@@ -2218,7 +2218,7 @@ tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer
tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`id` char(16) NOT NULL, `id` char(16) NOT NULL default '',
`data` int(11) NOT NULL `data` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
Database Create Database Database Create Database
......
...@@ -1029,7 +1029,11 @@ Warnings: ...@@ -1029,7 +1029,11 @@ Warnings:
Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col1' at row 1 Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col1' at row 1
Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col2' at row 1 Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col2' at row 1
INSERT IGNORE INTO t1 (col1) values (3); INSERT IGNORE INTO t1 (col1) values (3);
Warnings:
Warning 1364 Field 'col2' doesn't have a default value
INSERT IGNORE INTO t1 () values (); INSERT IGNORE INTO t1 () values ();
Warnings:
Warning 1364 Field 'col2' doesn't have a default value
SELECT * FROM t1; SELECT * FROM t1;
col1 col2 col1 col2
1 hello 1 hello
...@@ -1038,6 +1042,47 @@ col1 col2 ...@@ -1038,6 +1042,47 @@ col1 col2
3 3
99 99
DROP TABLE t1; DROP TABLE t1;
SET @@sql_mode = 'traditional';
CREATE TABLE t1 (i int not null);
INSERT INTO t1 VALUES ();
ERROR HY000: Field 'i' doesn't have a default value
INSERT INTO t1 VALUES (DEFAULT);
ERROR HY000: Field 'i' doesn't have a default value
INSERT INTO t1 VALUES (DEFAULT(i));
ERROR HY000: Field 'i' doesn't have a default value
ALTER TABLE t1 ADD j int;
INSERT INTO t1 SET j = 1;
ERROR HY000: Field 'i' doesn't have a default value
INSERT INTO t1 SET j = 1, i = DEFAULT;
ERROR HY000: Field 'i' doesn't have a default value
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
ERROR HY000: Field 'i' doesn't have a default value
INSERT INTO t1 VALUES (DEFAULT,1);
ERROR HY000: Field 'i' doesn't have a default value
DROP TABLE t1;
SET @@sql_mode = '';
CREATE TABLE t1 (i int not null);
INSERT INTO t1 VALUES ();
Warnings:
Warning 1364 Field 'i' doesn't have a default value
INSERT INTO t1 VALUES (DEFAULT);
Warnings:
Warning 1364 Field 'i' doesn't have a default value
INSERT INTO t1 VALUES (DEFAULT(i));
ERROR HY000: Field 'i' doesn't have a default value
ALTER TABLE t1 ADD j int;
INSERT INTO t1 SET j = 1;
Warnings:
Warning 1364 Field 'i' doesn't have a default value
INSERT INTO t1 SET j = 1, i = DEFAULT;
Warnings:
Warning 1364 Field 'i' doesn't have a default value
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
ERROR HY000: Field 'i' doesn't have a default value
INSERT INTO t1 VALUES (DEFAULT,1);
Warnings:
Warning 1364 Field 'i' doesn't have a default value
DROP TABLE t1;
set sql_mode='traditional'; set sql_mode='traditional';
create table t1 (charcol char(255), varcharcol varchar(255), create table t1 (charcol char(255), varcharcol varchar(255),
binarycol binary(255), varbinarycol varbinary(255), tinytextcol tinytext, binarycol binary(255), varbinarycol varbinary(255), tinytextcol tinytext,
......
...@@ -502,7 +502,7 @@ select foobar, boggle from t1 where foobar = 'fish' and boggle = 10; ...@@ -502,7 +502,7 @@ select foobar, boggle from t1 where foobar = 'fish' and boggle = 10;
foobar boggle foobar boggle
fish 10 fish 10
drop table t1; drop table t1;
create table t1 (id integer auto_increment unique,imagem LONGBLOB not null); create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default '');
insert into t1 (id) values (1); insert into t1 (id) values (1);
select select
charset(load_file('../../std_data/words.dat')), charset(load_file('../../std_data/words.dat')),
......
...@@ -21,10 +21,10 @@ time_field time, ...@@ -21,10 +21,10 @@ time_field time,
date_time datetime, date_time datetime,
blob_col blob, blob_col blob,
tinyblob_col tinyblob, tinyblob_col tinyblob,
mediumblob_col mediumblob not null, mediumblob_col mediumblob not null default '',
longblob_col longblob not null, longblob_col longblob not null default '',
options enum('one','two','tree') not null, options enum('one','two','tree') not null ,
flags set('one','two','tree') not null, flags set('one','two','tree') not null default '',
PRIMARY KEY (auto), PRIMARY KEY (auto),
KEY (utiny), KEY (utiny),
KEY (tiny), KEY (tiny),
......
...@@ -117,10 +117,12 @@ Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' a ...@@ -117,10 +117,12 @@ Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' a
Warning 1265 Data truncated for column 'b' at row 4 Warning 1265 Data truncated for column 'b' at row 4
insert into t2(b) values('mysqlab'); insert into t2(b) values('mysqlab');
Warnings: Warnings:
Warning 1364 Field 'a' doesn't have a default value
Warning 1265 Data truncated for column 'b' at row 1 Warning 1265 Data truncated for column 'b' at row 1
set sql_warnings=1; set sql_warnings=1;
insert into t2(b) values('mysqlab'); insert into t2(b) values('mysqlab');
Warnings: Warnings:
Warning 1364 Field 'a' doesn't have a default value
Warning 1265 Data truncated for column 'b' at row 1 Warning 1265 Data truncated for column 'b' at row 1
set sql_warnings=0; set sql_warnings=0;
drop table t1, t2; drop table t1, t2;
......
...@@ -66,7 +66,7 @@ drop table t1; ...@@ -66,7 +66,7 @@ drop table t1;
# #
# The below checks both binary and character comparisons. # The below checks both binary and character comparisons.
# #
create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word)); create table t1 (word varchar(255) not null, word2 varchar(255) not null default '', index(word));
show create table t1; show create table t1;
insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae'); insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae');
update t1 set word2=word; update t1 set word2=word;
......
...@@ -8,7 +8,7 @@ SET CHARACTER SET latin1; ...@@ -8,7 +8,7 @@ SET CHARACTER SET latin1;
CREATE TABLE t1 ( CREATE TABLE t1 (
comment CHAR(32) ASCII NOT NULL, comment CHAR(32) ASCII NOT NULL,
koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL default ''
) CHARSET=latin5; ) CHARSET=latin5;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
...@@ -142,13 +142,13 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r' ...@@ -142,13 +142,13 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'
SET CHARACTER SET utf8; SET CHARACTER SET utf8;
SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1; SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1;
ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL default '';
UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8);
SET CHARACTER SET koi8r; SET CHARACTER SET koi8r;
SELECT * FROM t1; SELECT * FROM t1;
ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL default '';
UPDATE t1 SET bin_f=koi8_ru_f; UPDATE t1 SET bin_f=koi8_ru_f;
SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1; SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1;
......
...@@ -120,7 +120,6 @@ INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText(' ...@@ -120,7 +120,6 @@ INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('
drop table t1; drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
geoobjid INT NOT NULL,
line LINESTRING NOT NULL, line LINESTRING NOT NULL,
kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po', kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
name VARCHAR(32), name VARCHAR(32),
......
...@@ -8,13 +8,13 @@ drop table if exists t0,t1,t2; ...@@ -8,13 +8,13 @@ drop table if exists t0,t1,t2;
create table t1 create table t1
( (
/* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */ /* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */
st_a int not null, st_a int not null default 0,
swt1a int not null, swt1a int not null default 0,
swt2a int not null, swt2a int not null default 0,
st_b int not null, st_b int not null default 0,
swt1b int not null, swt1b int not null default 0,
swt2b int not null, swt2b int not null default 0,
/* fields/keys for row retrieval tests */ /* fields/keys for row retrieval tests */
key1 int, key1 int,
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
create table t1 (a int primary key, b int not null); create table t1 (a int not null default 0 primary key, b int not null default 0);
insert into t1 () values (); -- Testing default values insert into t1 () values (); -- Testing default values
insert into t1 values (1,1),(2,1),(3,1); insert into t1 values (1,1),(2,1),(3,1);
update t1 set a=4 where b=1 limit 1; update t1 set a=4 where b=1 limit 1;
......
...@@ -59,7 +59,7 @@ drop table t1; ...@@ -59,7 +59,7 @@ drop table t1;
# #
# Test inserting and updating with NULL # Test inserting and updating with NULL
# #
CREATE TABLE t1 (a varchar(16) NOT NULL, b smallint(6) NOT NULL, c datetime NOT NULL, d smallint(6) NOT NULL); CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default '', c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55"; INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
UPDATE t1 SET d=1/NULL; UPDATE t1 SET d=1/NULL;
UPDATE t1 SET d=NULL; UPDATE t1 SET d=NULL;
......
...@@ -206,7 +206,7 @@ CREATE TABLE t1 ( ...@@ -206,7 +206,7 @@ CREATE TABLE t1 (
favo_tv varchar(50) NOT NULL default '', favo_tv varchar(50) NOT NULL default '',
favo_eten varchar(50) NOT NULL default '', favo_eten varchar(50) NOT NULL default '',
favo_muziek varchar(30) NOT NULL default '', favo_muziek varchar(30) NOT NULL default '',
info text NOT NULL, info text NOT NULL default '',
ipnr varchar(30) NOT NULL default '', ipnr varchar(30) NOT NULL default '',
PRIMARY KEY (member_id) PRIMARY KEY (member_id)
) ENGINE=MyISAM PACK_KEYS=1; ) ENGINE=MyISAM PACK_KEYS=1;
......
...@@ -106,7 +106,7 @@ drop table t1; ...@@ -106,7 +106,7 @@ drop table t1;
# Do a create table that tries to cover all types and options # Do a create table that tries to cover all types and options
# #
create table t1 ( create table t1 (
type_bool bool not null, type_bool bool not null default false,
type_tiny tinyint not null auto_increment primary key, type_tiny tinyint not null auto_increment primary key,
type_short smallint(3), type_short smallint(3),
type_mediumint mediumint, type_mediumint mediumint,
...@@ -117,9 +117,9 @@ empty_char char(0), ...@@ -117,9 +117,9 @@ empty_char char(0),
type_char char(2), type_char char(2),
type_varchar varchar(10), type_varchar varchar(10),
type_timestamp timestamp not null, type_timestamp timestamp not null,
type_date date not null, type_date date not null default '0000-00-00',
type_time time not null, type_time time not null default '00:00:00',
type_datetime datetime not null, type_datetime datetime not null default '0000-00-00 00:00:00',
type_year year, type_year year,
type_enum enum ('red', 'green', 'blue'), type_enum enum ('red', 'green', 'blue'),
type_set enum ('red', 'green', 'blue'), type_set enum ('red', 'green', 'blue'),
......
...@@ -24,7 +24,7 @@ use test; ...@@ -24,7 +24,7 @@ use test;
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
create table t1 ( create table t1 (
id char(16) not null, id char(16) not null default '',
data int not null data int not null
); );
--disable_warnings --disable_warnings
......
...@@ -1049,3 +1049,37 @@ drop table t1; ...@@ -1049,3 +1049,37 @@ drop table t1;
# Restore mode # Restore mode
# #
set sql_mode=@org_mode; set sql_mode=@org_mode;
# Test fields with no default value that are NOT NULL (Bug #5986)
SET @@sql_mode = 'traditional';
CREATE TABLE t1 (i int not null);
--error 1364
INSERT INTO t1 VALUES ();
--error 1364
INSERT INTO t1 VALUES (DEFAULT);
--error 1364
INSERT INTO t1 VALUES (DEFAULT(i));
ALTER TABLE t1 ADD j int;
--error 1364
INSERT INTO t1 SET j = 1;
--error 1364
INSERT INTO t1 SET j = 1, i = DEFAULT;
--error 1364
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
--error 1364
INSERT INTO t1 VALUES (DEFAULT,1);
DROP TABLE t1;
SET @@sql_mode = '';
CREATE TABLE t1 (i int not null);
INSERT INTO t1 VALUES ();
INSERT INTO t1 VALUES (DEFAULT);
# DEFAULT(i) is an error even with the default sql_mode
--error 1364
INSERT INTO t1 VALUES (DEFAULT(i));
ALTER TABLE t1 ADD j int;
INSERT INTO t1 SET j = 1;
INSERT INTO t1 SET j = 1, i = DEFAULT;
--error 1364
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
INSERT INTO t1 VALUES (DEFAULT,1);
DROP TABLE t1;
...@@ -304,7 +304,7 @@ drop table t1; ...@@ -304,7 +304,7 @@ drop table t1;
# Bug when blob is updated # Bug when blob is updated
# #
create table t1 (id integer auto_increment unique,imagem LONGBLOB not null); create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default '');
insert into t1 (id) values (1); insert into t1 (id) values (1);
# We have to clean up the path in the results for safe comparison # We have to clean up the path in the results for safe comparison
--replace_result $MYSQL_TEST_DIR ../.. --replace_result $MYSQL_TEST_DIR ../..
......
...@@ -28,10 +28,10 @@ CREATE TABLE t1 ( ...@@ -28,10 +28,10 @@ CREATE TABLE t1 (
date_time datetime, date_time datetime,
blob_col blob, blob_col blob,
tinyblob_col tinyblob, tinyblob_col tinyblob,
mediumblob_col mediumblob not null, mediumblob_col mediumblob not null default '',
longblob_col longblob not null, longblob_col longblob not null default '',
options enum('one','two','tree') not null, options enum('one','two','tree') not null ,
flags set('one','two','tree') not null, flags set('one','two','tree') not null default '',
PRIMARY KEY (auto), PRIMARY KEY (auto),
KEY (utiny), KEY (utiny),
KEY (tiny), KEY (tiny),
......
...@@ -4220,6 +4220,7 @@ bool Item_default_value::fix_fields(THD *thd, ...@@ -4220,6 +4220,7 @@ bool Item_default_value::fix_fields(THD *thd,
return FALSE; return FALSE;
} }
void Item_default_value::print(String *str) void Item_default_value::print(String *str)
{ {
if (!arg) if (!arg)
...@@ -4232,6 +4233,27 @@ void Item_default_value::print(String *str) ...@@ -4232,6 +4233,27 @@ void Item_default_value::print(String *str)
str->append(')'); str->append(')');
} }
int Item_default_value::save_in_field(Field *field_arg, bool no_conversions)
{
if (!arg)
{
if (field_arg->flags & NO_DEFAULT_VALUE_FLAG)
{
push_warning_printf(field_arg->table->in_use,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD,
ER(ER_NO_DEFAULT_FOR_FIELD),
field_arg->field_name);
return 1;
}
field_arg->set_default();
return 0;
}
return Item_field::save_in_field(field_arg, no_conversions);
}
bool Item_insert_value::eq(const Item *item, bool binary_cmp) const bool Item_insert_value::eq(const Item *item, bool binary_cmp) const
{ {
return item->type() == INSERT_VALUE_ITEM && return item->type() == INSERT_VALUE_ITEM &&
......
...@@ -1502,15 +1502,7 @@ public: ...@@ -1502,15 +1502,7 @@ public:
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
bool fix_fields(THD *, struct st_table_list *, Item **); bool fix_fields(THD *, struct st_table_list *, Item **);
void print(String *str); void print(String *str);
int save_in_field(Field *field_arg, bool no_conversions) int save_in_field(Field *field_arg, bool no_conversions);
{
if (!arg)
{
field_arg->set_default();
return 0;
}
return Item_field::save_in_field(field_arg, no_conversions);
}
table_map used_tables() const { return (table_map)0L; } table_map used_tables() const { return (table_map)0L; }
bool walk(Item_processor processor, byte *args) bool walk(Item_processor processor, byte *args)
......
...@@ -313,7 +313,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, ...@@ -313,7 +313,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
(MODE_STRICT_TRANS_TABLES | (MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES))); MODE_STRICT_ALL_TABLES)));
if (fields.elements && check_that_all_fields_are_given_values(thd, table)) if ((fields.elements || !value_count) &&
check_that_all_fields_are_given_values(thd, table))
{ {
/* thd->net.report_error is now set, which will abort the next loop */ /* thd->net.report_error is now set, which will abort the next loop */
error= 1; error= 1;
...@@ -885,19 +886,20 @@ err: ...@@ -885,19 +886,20 @@ err:
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry) int check_that_all_fields_are_given_values(THD *thd, TABLE *entry)
{ {
if (!thd->abort_on_warning) // No check if not strict mode int err= 0;
return 0;
for (Field **field=entry->field ; *field ; field++) for (Field **field=entry->field ; *field ; field++)
{ {
if ((*field)->query_id != thd->query_id && if ((*field)->query_id != thd->query_id &&
((*field)->flags & NO_DEFAULT_VALUE_FLAG)) ((*field)->flags & NO_DEFAULT_VALUE_FLAG))
{ {
my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), (*field)->field_name); push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
return 1; ER_NO_DEFAULT_FOR_FIELD,
ER(ER_NO_DEFAULT_FOR_FIELD),
(*field)->field_name);
err= 1;
} }
} }
return 0; return thd->abort_on_warning ? err : 0;
} }
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment