2 -- insert with DEFAULT in the target_list
4 create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing');
5 insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT);
6 ERROR: null value in column "col2" violates not-null constraint
7 insert into inserttest (col2, col3) values (3, DEFAULT);
8 insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT);
9 insert into inserttest values (DEFAULT, 5, 'test');
10 insert into inserttest values (DEFAULT, 7);
11 select * from inserttest;
13 ------+------+---------
21 -- insert with similar expression / target_list values (all fail)
23 insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT);
24 ERROR: INSERT has more target columns than expressions
25 LINE 1: insert into inserttest (col1, col2, col3) values (DEFAULT, D...
27 insert into inserttest (col1, col2, col3) values (1, 2);
28 ERROR: INSERT has more target columns than expressions
29 LINE 1: insert into inserttest (col1, col2, col3) values (1, 2);
31 insert into inserttest (col1) values (1, 2);
32 ERROR: INSERT has more expressions than target columns
33 LINE 1: insert into inserttest (col1) values (1, 2);
35 insert into inserttest (col1) values (DEFAULT, DEFAULT);
36 ERROR: INSERT has more expressions than target columns
37 LINE 1: insert into inserttest (col1) values (DEFAULT, DEFAULT);
39 select * from inserttest;
41 ------+------+---------
51 insert into inserttest values(10, 20, '40'), (-1, 2, DEFAULT),
52 ((select 2), (select i from (values(3)) as foo (i)), 'values are fun!');
53 select * from inserttest;
55 ------+------+-----------------
62 2 | 3 | values are fun!
65 drop table inserttest;