Skip to content

Commit

Permalink
Fix #222: use PQexec instead of PQsendQuery for postgres_execute
Browse files Browse the repository at this point in the history
  • Loading branch information
Mytherin committed Sep 3, 2024
1 parent b6dda6c commit 6a75ae4
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/postgres_execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void PGExecuteFunction(ClientContext &context, TableFunctionInput &data_p
return;
}
auto &transaction = Transaction::Get(context, data.pg_catalog).Cast<PostgresTransaction>();
transaction.ExecuteQueries(data.query);
transaction.Query(data.query);
data.finished = true;
}

Expand Down
54 changes: 54 additions & 0 deletions test/sql/storage/postgres_execute_transaction.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# name: test/sql/storage/postgres_execute_transaction.test
# description: Test interactions of postgres_execute and transactions
# group: [storage]

require postgres_scanner

require-env POSTGRES_TEST_DATABASE_AVAILABLE

statement ok
PRAGMA enable_verification

statement ok
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES)

statement ok
CREATE OR REPLACE TABLE s.postgres_execute_attempt(i INTEGER);

statement ok
BEGIN

query I
CALL postgres_query('s', 'SELECT 42')
----
42

statement ok
CALL postgres_execute('s', 'INSERT INTO postgres_execute_attempt VALUES (42)')

statement ok
ROLLBACK

query I
FROM s.postgres_execute_attempt
----

statement ok
BEGIN

query I
CALL postgres_query('s', 'SELECT 42')
----
42

statement ok
CALL postgres_execute('s', 'INSERT INTO postgres_execute_attempt VALUES (42); INSERT INTO postgres_execute_attempt VALUES (84)')

statement ok
COMMIT

query I
FROM s.postgres_execute_attempt
----
42
84

0 comments on commit 6a75ae4

Please sign in to comment.