Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #222: use PQexec instead of PQsendQuery for postgres_execute #258

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading