| 1 | #include "catch.hpp" | 
|---|
| 2 | #include "test_helpers.hpp" | 
|---|
| 3 |  | 
|---|
| 4 | using namespace duckdb; | 
|---|
| 5 | using namespace std; | 
|---|
| 6 |  | 
|---|
| 7 | TEST_CASE( "Test NULL versions", "[transactions]") { | 
|---|
| 8 | unique_ptr<QueryResult> result; | 
|---|
| 9 | DuckDB db(nullptr); | 
|---|
| 10 | Connection con(db), con2(db); | 
|---|
| 11 | con.EnableQueryVerification(); | 
|---|
| 12 |  | 
|---|
| 13 | REQUIRE_NO_FAIL(con.Query( "CREATE TABLE integers(i INTEGER, j INTEGER)")); | 
|---|
| 14 | REQUIRE_NO_FAIL(con.Query( "INSERT INTO integers VALUES (NULL, 3)")); | 
|---|
| 15 |  | 
|---|
| 16 | result = con.Query( "SELECT * FROM integers"); | 
|---|
| 17 | REQUIRE(CHECK_COLUMN(result, 0, {Value()})); | 
|---|
| 18 |  | 
|---|
| 19 | // begin a transaction in con2 | 
|---|
| 20 | REQUIRE_NO_FAIL(con2.Query( "BEGIN TRANSACTION")); | 
|---|
| 21 | // update the row in con1 | 
|---|
| 22 | REQUIRE_NO_FAIL(con.Query( "UPDATE integers SET i=1,j=1")); | 
|---|
| 23 |  | 
|---|
| 24 | // con1 should see the value "1" | 
|---|
| 25 | result = con.Query( "SELECT * FROM integers"); | 
|---|
| 26 | REQUIRE(CHECK_COLUMN(result, 0, {1})); | 
|---|
| 27 | REQUIRE(CHECK_COLUMN(result, 1, {1})); | 
|---|
| 28 |  | 
|---|
| 29 | // con2 should see the value "NULL" | 
|---|
| 30 | result = con2.Query( "SELECT * FROM integers"); | 
|---|
| 31 | REQUIRE(CHECK_COLUMN(result, 0, {Value()})); | 
|---|
| 32 | REQUIRE(CHECK_COLUMN(result, 1, {3})); | 
|---|
| 33 |  | 
|---|
| 34 | // after a rollback con2 should see the value "1" as well | 
|---|
| 35 | REQUIRE_NO_FAIL(con2.Query( "ROLLBACK")); | 
|---|
| 36 |  | 
|---|
| 37 | result = con.Query( "SELECT * FROM integers"); | 
|---|
| 38 | REQUIRE(CHECK_COLUMN(result, 0, {1})); | 
|---|
| 39 | REQUIRE(CHECK_COLUMN(result, 1, {1})); | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|