Skip to content
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
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ add_library(
postgres_connection.cpp
postgres_copy_from.cpp
postgres_copy_to.cpp
postgres_execute.cpp
postgres_extension.cpp
postgres_filter_pushdown.cpp
postgres_hstore.cpp
Expand Down
78 changes: 0 additions & 78 deletions src/postgres_execute.cpp

This file was deleted.

12 changes: 12 additions & 0 deletions src/postgres_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,16 @@ PostgresQueryFunction::PostgresQueryFunction()
projection_pushdown = true;
global_initialization = TableFunctionInitialization::INITIALIZE_ON_SCHEDULE;
}

PostgresExecuteFunction::PostgresExecuteFunction()
: TableFunction("postgres_execute", {LogicalType::VARCHAR, LogicalType::VARCHAR}, nullptr, PGQueryBind) {
named_parameters["use_transaction"] = LogicalType::BOOLEAN;
named_parameters["params"] = LogicalType::ANY;
PostgresScanFunction scan_function;
init_global = scan_function.init_global;
init_local = scan_function.init_local;
function = scan_function.function;
projection_pushdown = true;
global_initialization = TableFunctionInitialization::INITIALIZE_ON_SCHEDULE;
}
} // namespace duckdb
5 changes: 4 additions & 1 deletion src/postgres_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,10 @@ static void PostgresScan(ClientContext &context, TableFunctionInput &data, DataC
auto &gstate = data.global_state->Cast<PostgresGlobalState>();

if (gstate.collection) {
gstate.collection->Scan(gstate.scan_state, output);
bool scan_happened = gstate.collection->Scan(gstate.scan_state, output);
if (!scan_happened) {
output.SetChildCardinality(0);
}
return;
}
auto &local_state = data.local_state->Cast<PostgresLocalState>();
Expand Down
2 changes: 1 addition & 1 deletion test/sql/storage/attach_rollback_throws.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ s 1
statement error
CALL postgres_execute('s', 'SELECT pg_terminate_backend(pg_backend_pid())')
----
pg_terminate_backend
terminating connection due to administrator command

# connection must have been discarded, as it cannot pass the health check on returning it to the pool
query II
Expand Down
2 changes: 1 addition & 1 deletion test/sql/storage/postgres_execute_transaction.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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)')
CALL postgres_execute('s', 'INSERT INTO postgres_execute_attempt VALUES (42), (84)')

statement ok
COMMIT
Expand Down
9 changes: 3 additions & 6 deletions test/sql/storage/postgres_execute_use_transaction.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES)
statement error
CALL postgres_execute('s', 'VACUUM')
----
Invalid Error: Failed to execute query "BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
VACUUM": ERROR: VACUUM cannot run inside a transaction block
Invalid Error: Failed to execute query "VACUUM": ERROR: VACUUM cannot run inside a transaction block

statement error
CALL postgres_execute('s', 'VACUUM', use_transaction=true)
----
Invalid Error: Failed to execute query "BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
VACUUM": ERROR: VACUUM cannot run inside a transaction block
Invalid Error: Failed to execute query "VACUUM": ERROR: VACUUM cannot run inside a transaction block

statement error
CALL postgres_execute('s', 'VACUUM', use_transaction=true)
----
Invalid Error: Failed to execute query "BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
VACUUM": ERROR: VACUUM cannot run inside a transaction block
Invalid Error: Failed to execute query "VACUUM": ERROR: VACUUM cannot run inside a transaction block

statement ok
CALL postgres_execute('s', 'VACUUM', use_transaction=false)
Expand Down
Loading