1 | #include "catch.hpp" |
2 | #include "test_helpers.hpp" |
3 | |
4 | using namespace duckdb; |
5 | using namespace std; |
6 | |
7 | TEST_CASE("Test explain" , "[explain]" ) { |
8 | unique_ptr<QueryResult> result; |
9 | DuckDB db(nullptr); |
10 | Connection con(db); |
11 | con.EnableQueryVerification(); |
12 | con.EnableProfiling(); |
13 | |
14 | REQUIRE_NO_FAIL(con.Query("CREATE TABLE integers(i INTEGER, j INTEGER)" )); |
15 | REQUIRE_NO_FAIL(con.Query("INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3), (NULL, NULL)" )); |
16 | |
17 | REQUIRE_NO_FAIL(con.Query("EXPLAIN SELECT * FROM integers" )); |
18 | REQUIRE_NO_FAIL(con.Query("EXPLAIN select sum(i), j, sum(i), j from integers group by j having j < 10;" )); |
19 | REQUIRE_NO_FAIL(con.Query("EXPLAIN update integers set i=i+1;" )); |
20 | REQUIRE_NO_FAIL(con.Query("EXPLAIN delete from integers where i=1;" )); |
21 | |
22 | // explaining prepared statements works now as well |
23 | REQUIRE_NO_FAIL(con.Query("EXPLAIN SELECT * FROM integers WHERE i=?" , 1)); |
24 | } |
25 | |