From 830651227fc5f6f94adf9dc0f038b43e7e01feef Mon Sep 17 00:00:00 2001 From: Arjun Lall Date: Thu, 5 Dec 2024 23:08:44 -0800 Subject: [PATCH] Add show search_path support --- scripts/install.sh | 2 +- src/main.go | 2 +- src/query_handler.go | 8 ++++++++ src/query_handler_test.go | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 27d8969..86d7a98 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -VERSION="0.19.0" +VERSION="0.19.1" # Detect OS and architecture OS=$(uname -s | tr '[:upper:]' '[:lower:]') diff --git a/src/main.go b/src/main.go index af4690e..262d707 100644 --- a/src/main.go +++ b/src/main.go @@ -6,7 +6,7 @@ import ( "time" ) -const VERSION = "0.19.0" +const VERSION = "0.19.1" func main() { config := LoadConfig() diff --git a/src/query_handler.go b/src/query_handler.go index 4f4f608..f30abbc 100644 --- a/src/query_handler.go +++ b/src/query_handler.go @@ -396,6 +396,14 @@ func (queryHandler *QueryHandler) remapQuery(query string) (string, error) { return FALLBACK_SQL_QUERY, nil } + if statementNode != nil && statementNode.GetVariableShowStmt() != nil { + variableShowStmt := statementNode.GetVariableShowStmt() + if variableShowStmt.Name == "search_path" { + return `SELECT CONCAT('"$user", ', value) AS search_path FROM duckdb_settings() WHERE name = 'search_path';`, nil + } + return FALLBACK_SQL_QUERY, nil + } + LogDebug(queryHandler.config, "Query tree:", queryTree) return "", errors.New("Unsupported query type") } diff --git a/src/query_handler_test.go b/src/query_handler_test.go index 3653fe3..0013c3f 100644 --- a/src/query_handler_test.go +++ b/src/query_handler_test.go @@ -371,6 +371,11 @@ func TestHandleQuery(t *testing.T) { "description": {"objoid"}, "values": {}, }, + // SHOW + "SHOW search_path": { + "description": {"search_path"}, + "values": {`"$user", public`}, + }, } for query, responses := range responsesByQuery {