123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- # Copyright Materialize, Inc. and contributors. All rights reserved.
- #
- # Use of this software is governed by the Business Source License
- # included in the LICENSE file at the root of this repository.
- #
- # As of the Change Date specified in that file, in accordance with
- # the Business Source License, use of this software will be governed
- # by the Apache License, Version 2.0.
- # Test INSERT INTO...SELECT. This must be a testdrive test to avoid symbiosis
- # in sqllogictest.
- > CREATE TABLE t (i INT, f REAL, t TEXT);
- > INSERT INTO t VALUES (1, 2, 'a'), (3, 4, 'b');
- > SELECT * FROM t ORDER BY i
- 1 2 a
- 3 4 b
- > CREATE TABLE u (i INT, f REAL, t TEXT);
- > INSERT INTO u VALUES (5, 6, 'c');
- > INSERT INTO t SELECT * FROM u;
- # Assignment casts are valid
- > CREATE TABLE bigger (i INT8, f FLOAT, t TEXT);
- > INSERT INTO bigger VALUES (7, 8, 'd');
- > INSERT INTO t SELECT * FROM bigger;
- # Obliquely go through SELECT * FROM ( VALUES ... )
- > INSERT INTO t SELECT * FROM (
- VALUES (9.1::numeric, 10, 'e')
- );
- > SELECT * FROM t ORDER BY i
- 1 2 a
- 3 4 b
- 5 6 c
- 7 8 d
- 9 10 e
- # Multiple connections
- > CREATE TABLE c (a int);
- > INSERT INTO c VALUES (1);
- > CREATE TABLE s (a int);
- $ postgres-connect name=writer url=postgres://materialize:materialize@${testdrive.materialize-sql-addr}
- # In-flight txns don't affect updates/deletes, and vice versa
- $ postgres-execute connection=writer
- BEGIN;
- INSERT INTO s VALUES (2);
- > INSERT INTO c SELECT * FROM s;
- > SELECT a FROM c
- 1
- $ postgres-execute connection=writer
- INSERT INTO s VALUES (3);
- COMMIT;
- > INSERT INTO c SELECT * FROM s;
- > SELECT a FROM c
- 1
- 2
- 3
- > BEGIN;
- > SELECT a FROM c
- 1
- 2
- 3
- $ postgres-execute connection=writer
- INSERT INTO c SELECT * FROM s;
- > SELECT a FROM c
- 1
- 2
- 3
- > COMMIT;
- # Every value from s should be duplicated in c
- > SELECT a FROM s
- 2
- 3
- > SELECT a FROM c;
- 1
- 2
- 2
- 3
- 3
|