File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed
Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 99
1010extern " C" {
1111#include " postgres.h"
12+ #include " access/xact.h"
1213#include " utils/guc.h"
1314#include " utils/guc_tables.h"
1415#include " miscadmin.h" // DataDir
@@ -272,8 +273,12 @@ DuckAssignTimezone_Cpp(const char *tz) {
272273 return ;
273274 }
274275
275- // update duckdb tz
276- auto connection = pgduckdb::DuckDBManager::GetConnection (false );
276+ // Update timezone in DuckDB too.
277+ // This uses GetConnectionUnsafe because GetConnection requires a
278+ // transaction context to be active in Postgres to be able to call
279+ // RefreshConnectionState, and GUCs can be changed outside of transaction
280+ // blocks (for instance by being reverted due to SET LOCAL or by SIGHUP)
281+ auto connection = pgduckdb::DuckDBManager::GetConnectionUnsafe ();
277282 pgduckdb::DuckDBQueryOrThrow (*connection, " SET TimeZone =" + duckdb::KeywordHelper::WriteQuoted (tz));
278283 elog (DEBUG2, " [PGDuckDB] Set DuckDB option: 'TimeZone'=%s" , tz);
279284}
Original file line number Diff line number Diff line change 1+ -- Initialize duckdb in this session
2+ SELECT * FROM duckdb.query($$ SELECT 1 $$);
3+ 1
4+ ---
5+ 1
6+ (1 row)
7+
8+ -- Have the timezone change be rolled back at the end transaction
9+ BEGIN;
10+ SET TimeZone TO 'UTC';
11+ ROLLBACK;
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ test: issue_789
2929test: issue_796
3030test: issue_802
3131test: issue_813
32+ test: issue_975
3233test: json_functions_duckdb
3334test: materialized_view
3435test: non_superuser
Original file line number Diff line number Diff line change 1+ -- Initialize duckdb in this session
2+ SELECT * FROM duckdb .query ($$ SELECT 1 $$);
3+ -- Have the timezone change be rolled back at the end transaction
4+ BEGIN ;
5+ SET TimeZone TO ' UTC' ;
6+ ROLLBACK ;
You can’t perform that action at this time.
0 commit comments