Commit e701333b authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi
Browse files

INSERT ... VALUES(DEFAULT)

parent b71b26d1
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -34456,13 +34456,13 @@ provide an interactive user interfaces to the database.
@example
    INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name [(col_name,...)]
        VALUES (expression,...),(...),...
        VALUES ((expression | DEFAULT),...),(...),...
or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name [(col_name,...)]
        SELECT ...
or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name
        SET col_name=expression, col_name=expression, ...
        SET col_name=(expression | DEFAULT), ...
@end example
@@ -34492,6 +34492,11 @@ example, if you specify a column list that doesn't name all the columns in
the table, unnamed columns are set to their default values.  Default value
assignment is described in @ref{CREATE TABLE, , @code{CREATE TABLE}}.
You can also use the keyword @code{DEFAULT} to set a column to it's
defaults value. (New in MySQL 4.0.3).  This makes it easier to write
insert statements as you don't have to use a field-name list just because
you don't want to set a value for a few columns.
MySQL always has a default value for all fields. This is something
that is imposed on MySQL to be able to work with both transactional
and not transactional tables.
@@ -50010,6 +50015,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@node News-4.0.3, News-4.0.2, News-4.0.x, News-4.0.x
@appendixsubsec Changes in release 4.0.3
@itemize @bullet
@item
Allow @code{DEFAULT} with @code{INSERT} statement.
@item
The startup parameters @code{myisam_max_extra_sort_file_size} and
@code{myisam_max_extra_sort_file_size} are now given in bytes, not megabytes.
@item
+26 −0
Original line number Diff line number Diff line
@@ -19,3 +19,29 @@ insert into t1 values (0,"mysql a");
insert into t1 values (0,"r1manic");
insert into t1 values (0,"r1man");
drop table t1;
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello");
insert into t1 values (default,default,default), (default,default,default), (4,0,"a"),(default,default,default);
select a,t>0,c from t1;
a	t>0	c
1	1	hello
2	1	hello
4	0	a
5	1	hello
truncate table t1;
insert into t1 set a=default,t=default,c=default;
insert into t1 set a=default,t=default,c=default;
insert into t1 set a=4,t=0,c="a";
insert into t1 set a=default,t=default,c=default;
select a,t>0,c from t1;
a	t>0	c
1	1	hello
2	1	hello
4	0	a
5	1	hello
drop table t1;
drop database if exists foo;
create database foo;
use foo;
create table t1 (c int);
insert into foo.t1 set foo.t1.c = '1';
drop database foo;

mysql-test/r/insert_set.result

deleted100644 → 0
+0 −6
Original line number Diff line number Diff line
drop database if exists foo;
create database foo;
use foo;
create table b (c int);
insert into foo.b set foo.b.c = '1';
drop database foo;
+26 −0
Original line number Diff line number Diff line
@@ -22,3 +22,29 @@ insert into t1 values (0,"mysql a");
insert into t1 values (0,"r1manic");
insert into t1 values (0,"r1man");
drop table t1;

#
# Test insert syntax
#

create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello");
insert into t1 values (default,default,default), (default,default,default), (4,0,"a"),(default,default,default);
select a,t>0,c from t1;
truncate table t1;
insert into t1 set a=default,t=default,c=default;
insert into t1 set a=default,t=default,c=default;
insert into t1 set a=4,t=0,c="a";
insert into t1 set a=default,t=default,c=default;
select a,t>0,c from t1;
drop table t1;

#
# Test of mysqld crash with fully qualified column names
#

drop database if exists foo;
create database foo;
use foo;
create table t1 (c int);
insert into foo.t1 set foo.t1.c = '1';
drop database foo;

mysql-test/t/insert_set.test

deleted100644 → 0
+0 −10
Original line number Diff line number Diff line
#
# Test of mysqld crash with fully qualified column names
#

drop database if exists foo;
create database foo;
use foo;
create table b (c int);
insert into foo.b set foo.b.c = '1';
drop database foo;
Loading