Skip to content

Commit

Permalink
Add show search_path support
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunlol committed Dec 6, 2024
1 parent 8d74cd0 commit 8306512
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION="0.19.0"
VERSION="0.19.1"

# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

const VERSION = "0.19.0"
const VERSION = "0.19.1"

func main() {
config := LoadConfig()
Expand Down
8 changes: 8 additions & 0 deletions src/query_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
5 changes: 5 additions & 0 deletions src/query_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8306512

Please sign in to comment.