Skip to content

Commit 8e2e651

Browse files
authored
feat: set/show enhancement (#226)
1 parent c4dbe70 commit 8e2e651

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

datafusion-postgres/src/hooks/set_show.rs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,15 @@ where
170170

171171
client::set_statement_timeout(client, timeout);
172172
return Some(Ok(Response::Execution(Tag::new("SET"))));
173-
} else if matches!(var.as_str(), "datestyle" | "bytea_output" | "intervalstyle")
174-
&& !values.is_empty()
173+
} else if matches!(
174+
var.as_str(),
175+
"datestyle"
176+
| "bytea_output"
177+
| "intervalstyle"
178+
| "application_name"
179+
| "extra_float_digits"
180+
| "search_path"
181+
) && !values.is_empty()
175182
{
176183
// postgres configuration variables
177184
let value = values[0].clone();
@@ -190,6 +197,13 @@ where
190197
let tz = value.to_string();
191198
let tz = tz.trim_matches('"').trim_matches('\'');
192199
client::set_timezone(client, Some(tz));
200+
// execution options for timezone
201+
session_context
202+
.state()
203+
.config_mut()
204+
.options_mut()
205+
.execution
206+
.time_zone = tz.to_string();
193207
return Some(Ok(Response::Execution(Tag::new("SET"))));
194208
}
195209
_ => {}
@@ -249,7 +263,13 @@ where
249263
Some(mock_show_response("TimeZone", timezone).map(Response::Query))
250264
}
251265
["server_version"] => {
252-
Some(mock_show_response("server_version", "15.0 (DataFusion)").map(Response::Query))
266+
let version = format!(
267+
"datafusion {} on {} {}",
268+
session_context.state().version(),
269+
env!("CARGO_PKG_NAME"),
270+
env!("CARGO_PKG_VERSION")
271+
);
272+
Some(mock_show_response("server_version", &version).map(Response::Query))
253273
}
254274
["transaction_isolation"] => Some(
255275
mock_show_response("transaction_isolation", "read uncommitted").map(Response::Query),
@@ -259,10 +279,6 @@ where
259279
let value = catalogs.join(", ");
260280
Some(mock_show_response("Catalogs", &value).map(Response::Query))
261281
}
262-
["search_path"] => {
263-
let default_schema = "public";
264-
Some(mock_show_response("search_path", default_schema).map(Response::Query))
265-
}
266282
["statement_timeout"] => {
267283
let timeout = client::get_statement_timeout(client);
268284
let timeout_str = match timeout {
@@ -274,7 +290,12 @@ where
274290
["transaction", "isolation", "level"] => {
275291
Some(mock_show_response("transaction_isolation", "read_committed").map(Response::Query))
276292
}
277-
["bytea_output"] | ["datestyle"] | ["intervalstyle"] => {
293+
["bytea_output"]
294+
| ["datestyle"]
295+
| ["intervalstyle"]
296+
| ["application_name"]
297+
| ["extra_float_digits"]
298+
| ["search_path"] => {
278299
let val = client
279300
.metadata()
280301
.get(&variables[0])

0 commit comments

Comments
 (0)