SQLLogicTest - Multiple Connections
For tests whose purpose is to verify that the transactional management or versioning of data works correctly, it is generally necessary to use multiple connections. For example, if we want to verify that the creation of tables is correctly transactional, we might want to start a transaction and create a table in con1, then fire a query in con2 that checks that the table is not accessible yet until committed.
We can use multiple connections in the sqllogictests using connection labels. The connection label can be optionally appended to any statement or query. All queries with the same connection label will be executed in the same connection. A test that would verify the above property would look as follows:
statement ok con1
BEGIN TRANSACTION
statement ok con1
CREATE TABLE integers(i INTEGER);
statement error con2
SELECT * FROM integers;
Concurrent Connections
Using connection modifiers on the statement and queries will result in testing of multiple connections, but all the queries will still be run sequentially on a single thread. If we want to run code from multiple connections concurrently over multiple threads, we can use the concurrentloop construct. The queries in concurrentloop will be run concurrently on separate threads at the same time.
concurrentloop i 0 10
statement ok
CREATE TEMP TABLE t2 AS (SELECT 1);
statement ok
INSERT INTO t2 VALUES (42);
statement ok
DELETE FROM t2
endloop
Does this implementation support concurrent connections?
In the documentation for DuckDB here https://duckdb.org/dev/sqllogictest/multiple_connections.html
It states the following:
SQLLogicTest - Multiple Connections For tests whose purpose is to verify that the transactional management or versioning of data works correctly, it is generally necessary to use multiple connections. For example, if we want to verify that the creation of tables is correctly transactional, we might want to start a transaction and create a table in con1, then fire a query in con2 that checks that the table is not accessible yet until committed.
We can use multiple connections in the sqllogictests using connection labels. The connection label can be optionally appended to any statement or query. All queries with the same connection label will be executed in the same connection. A test that would verify the above property would look as follows:
statement ok con1 BEGIN TRANSACTION
statement ok con1 CREATE TABLE integers(i INTEGER);
statement error con2 SELECT * FROM integers; Concurrent Connections Using connection modifiers on the statement and queries will result in testing of multiple connections, but all the queries will still be run sequentially on a single thread. If we want to run code from multiple connections concurrently over multiple threads, we can use the concurrentloop construct. The queries in concurrentloop will be run concurrently on separate threads at the same time.
concurrentloop i 0 10
statement ok CREATE TEMP TABLE t2 AS (SELECT 1);
statement ok INSERT INTO t2 VALUES (42);
statement ok DELETE FROM t2
endloop
Does this implementation support concurrent connections?