Skip to content

Commit

Permalink
Fixes issues with file:// handling, duckdb FROM queries
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshaw committed Nov 14, 2023
1 parent 4bd9140 commit 56018f4
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 49 deletions.
8 changes: 1 addition & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ fi
TAGS="${TAGS[@]}"
LDFLAGS="${LDFLAGS[@]}"

log() {
cat - | while read -r message; do
echo "$1$message"
done
}

echo "APP: $NAME/${VER} ($PLATFORM/$ARCH)"
if [ "$STATIC" = "1" ]; then
echo "STATIC: yes"
Expand Down Expand Up @@ -197,7 +191,7 @@ fi
-tags="$TAGS" \
-trimpath \
$OUTPUT
) 2>&1 | log ' '
)

if [[ "$INSTALL" == "1" || "$BUILDONLY" == "1" ]]; then
exit
Expand Down
1 change: 1 addition & 0 deletions drivers/qtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var queryMap = map[string]bool{
"EXEC": true, // execute a stored procedure that returns rows (not postgres)
"TABLE": true, // shortcut for select * from <table> (postgresql)
"CALL": true,
"FROM": true,
}

// execMap is the map of SQL prefixes to execute.
Expand Down
4 changes: 2 additions & 2 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ func buildAliases(v DriverInfo) string {
aliases[i] = v.Driver
}
}
headerTypes := dburl.HeaderTypes()
if slices.Contains(headerTypes, name) {
fileTypes := dburl.FileTypes()
if slices.Contains(fileTypes, name) {
aliases = append(aliases, `file`)
}
if len(aliases) > 0 {
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ require (
github.com/ClickHouse/clickhouse-go/v2 v2.15.0
github.com/IBM/nzgo/v12 v12.0.8
github.com/MichaelS11/go-cql-driver v0.1.1
github.com/SAP/go-hdb v1.5.9
github.com/SAP/go-hdb v1.5.10
github.com/VoltDB/voltdb-client-go v1.0.15
github.com/alecthomas/chroma/v2 v2.10.1
github.com/alecthomas/chroma/v2 v2.11.1
github.com/alecthomas/kingpin/v2 v2.3.2
github.com/alexbrainman/odbc v0.0.0-20230814102256-1421b829acc9
github.com/aliyun/aliyun-tablestore-go-sql-driver v0.0.0-20220418015234-4d337cb3eed9
Expand Down Expand Up @@ -51,7 +51,7 @@ require (
github.com/trinodb/trino-go-client v0.313.0
github.com/uber/athenadriver v1.1.14
github.com/vertica/vertica-sql-go v1.3.3
github.com/xo/dburl v0.17.1
github.com/xo/dburl v0.18.2
github.com/xo/tblfmt v0.10.3
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e
github.com/yookoala/realpath v1.0.0
Expand Down Expand Up @@ -93,11 +93,11 @@ require (
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/apache/thrift v0.19.0 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/aws/aws-sdk-go v1.47.9 // indirect
github.com/aws/aws-sdk-go v1.47.10 // indirect
github.com/aws/aws-sdk-go-v2 v1.22.2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.15.2 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.13.5 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.13.6 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.2 // indirect
Expand Down Expand Up @@ -289,7 +289,7 @@ require (
modernc.org/fileutil v1.2.0 // indirect
modernc.org/golex v1.1.0 // indirect
modernc.org/internal v1.1.0 // indirect
modernc.org/libc v1.34.0 // indirect
modernc.org/libc v1.34.3 // indirect
modernc.org/lldb v1.0.8 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
Expand Down
32 changes: 16 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ github.com/Microsoft/hcsshim v0.11.0/go.mod h1:OEthFdQv/AD2RAdzR6Mm1N1KPCztGKDur
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/SAP/go-hdb v1.5.9 h1:MIxXeAjTKjHcI8Jx3SFCeSqZJs3GkEAmbpMKQ1taJhg=
github.com/SAP/go-hdb v1.5.9/go.mod h1:8EPKVjBtWiCYg6RuPWTYB2WL8mjakokIl202h2JeqXs=
github.com/SAP/go-hdb v1.5.10 h1:xK6feDCBxpT0UTYc8z4amGJMVsFfNFIbOfEj53grhPc=
github.com/SAP/go-hdb v1.5.10/go.mod h1:Vcp8cnLTb3oVRdm3tulcrs6ain/g2gSvuTZ1t4EDQFU=
github.com/VoltDB/voltdb-client-go v1.0.15 h1:G7rZxKiemYkaYZLoLamhRnAOGyq5wlyqPefCAAflB/0=
github.com/VoltDB/voltdb-client-go v1.0.15/go.mod h1:mMhb5zwkT46Ef3NvkFqt+kX0j+ltQ2Sdqj9+ICq+Yto=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
github.com/alecthomas/chroma/v2 v2.10.1 h1:AfhjDEtgRLWxCmwUg3MW/0kgmQ6A/7CtY8o3dvkYEdw=
github.com/alecthomas/chroma/v2 v2.10.1/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
github.com/alecthomas/chroma/v2 v2.11.1 h1:m9uUtgcdAwgfFNxuqj7AIG75jD2YmL61BBIJWtdzJPs=
github.com/alecthomas/chroma/v2 v2.11.1/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
github.com/alecthomas/kingpin/v2 v2.3.2 h1:H0aULhgmSzN8xQ3nX1uxtdlTHYoPLu5AhHxWrKI6ocU=
github.com/alecthomas/kingpin/v2 v2.3.2/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
Expand Down Expand Up @@ -281,26 +281,26 @@ github.com/apache/thrift v0.19.0/go.mod h1:SUALL216IiaOw2Oy+5Vs9lboJ/t9g40C+G07D
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/aws/aws-sdk-go v1.37.32/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.47.9 h1:rarTsos0mA16q+huicGx0e560aYRtOucV5z2Mw23JRY=
github.com/aws/aws-sdk-go v1.47.9/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.47.10 h1:cvufN7WkD1nlOgpRopsmxKQlFp5X1MfyAw4r7BBORQc=
github.com/aws/aws-sdk-go v1.47.10/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go-v2 v1.22.2 h1:lV0U8fnhAnPz8YcdmZVV60+tr6CakHzqA6P8T46ExJI=
github.com/aws/aws-sdk-go-v2 v1.22.2/go.mod h1:Kd0OJtkW3Q0M0lUWGszapWjEvrXDzRW+D21JNsroB+c=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.0 h1:hHgLiIrTRtddC0AKcJr5s7i/hLgcpTt+q/FKxf1Zayk=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.0/go.mod h1:w4I/v3NOWgD+qvs1NPEwhd++1h3XPHFaVxasfY6HlYQ=
github.com/aws/aws-sdk-go-v2/config v1.23.0 h1:kqzEfGGDIrRJpfJckgwuZfFTbU9NB1jZnRcaO9MpOqE=
github.com/aws/aws-sdk-go-v2/config v1.23.0/go.mod h1:p7wbxKXXjS1GGQOss7VXOazVMFF9bjUGq85/4wR/fSw=
github.com/aws/aws-sdk-go-v2/config v1.24.0 h1:4LEk29JO3w+y9dEo/5Tq5QTP7uIEw+KQrKiHOs4xlu4=
github.com/aws/aws-sdk-go-v2/config v1.24.0/go.mod h1:11nNDAuK86kOUHeuEQo8f3CkcV5xuUxvPwFjTZE/PnQ=
github.com/aws/aws-sdk-go-v2/credentials v1.15.2 h1:rKH7khRMxPdD0u3dHecd0Q7NOVw3EUe7AqdkUOkiOGI=
github.com/aws/aws-sdk-go-v2/credentials v1.15.2/go.mod h1:tXM8wmaeAhfC7nZoCxb0FzM/aRaB1m1WQ7x0qlBLq80=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.3 h1:G5KawTAkyHH6WyKQCdHiW4h3PmAXNJpOgwKg3H7sDRE=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.3/go.mod h1:hugKmSFnZB+HgNI1sYGT14BUPZkO6alC/e0AWu+0IAQ=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.13.5 h1:P/xwilRdRLLg1PzfviDq0Zjb74weOoDCrh8J5lRCQAY=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.13.5/go.mod h1:9cLHf2IwX6Jyw0KjLVbXly/g6DmzExgUzB1w/AQPGQE=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.13.6 h1:IpQbitxCZeC64C1ALz9QZu6AHHWundnU2evQ9xbp5k8=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.13.6/go.mod h1:27jIVQK+al9s0yTo3pkMdahRinbscqSC6zNGfNWXPZc=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.2 h1:AaQsr5vvGR7rmeSWBtTCcw16tT9r51mWijuCQhzLnq8=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.2/go.mod h1:o1IiRn7CWocIFTXJjGKJDOwxv1ibL53NpcvcqGWyRBA=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.2 h1:UZx8SXZ0YtzRiALzYAWcjb9Y9hZUR7MBKaBQ5ouOjPs=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.2/go.mod h1:ipuRpcSaklmxR6C39G187TpBAO132gUfleTGccUPs8c=
github.com/aws/aws-sdk-go-v2/internal/ini v1.6.0 h1:hwZB07/beLiCopuRKF0t+dEHmP39iN4YtDh3X5d3hrg=
github.com/aws/aws-sdk-go-v2/internal/ini v1.6.0/go.mod h1:rdAuXeHWhI/zkpYcO5n8WCpaIgY9MUxFyBsuqq3kjyA=
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.0 h1:usgqiJtamuGIBj+OvYmMq89+Z1hIKkMJToz1WpoeNUY=
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.0/go.mod h1:6fQQgfuGmw8Al/3M2IgIllycxV7ZW7WCdVSqfBeUiCY=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.2 h1:pyVrNAf7Hwz0u39dLKN5t+n0+K/3rMYKuiOoIum3AsU=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.2/go.mod h1:mydrfOb9uiOYCxuCPR8YHQNQyGQwUQ7gPMZGBKbH8NY=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0 h1:CJxo7ZBbaIzmXfV3hjcx36n9V87gJsIUPJflwqEHl3Q=
Expand Down Expand Up @@ -989,8 +989,8 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
github.com/xo/dburl v0.17.1 h1:n8jpWqYwe8TJQ1n8OvJuKDP9GxnPS+52T/xQtjADTIM=
github.com/xo/dburl v0.17.1/go.mod h1:B7/G9FGungw6ighV8xJNwWYQPMfn3gsi2sn5SE8Bzco=
github.com/xo/dburl v0.18.2 h1:9xqcVf+JEV7bcUa1OjCsoax06roohYFdye6xkvBKo50=
github.com/xo/dburl v0.18.2/go.mod h1:B7/G9FGungw6ighV8xJNwWYQPMfn3gsi2sn5SE8Bzco=
github.com/xo/tblfmt v0.0.0-20190609041254-28c54ec42ce8/go.mod h1:3U5kKQdIhwACye7ml3acccHmjGExY9WmUGU7rnDWgv0=
github.com/xo/tblfmt v0.10.3 h1:Fb2Le5wvzBjOwA/KFRpP5bZo+iR9cZnzSAN3tULoUPI=
github.com/xo/tblfmt v0.10.3/go.mod h1:W6oqhxtqDOEMkrS2GPO0zmcww7ozM2E6BRv3kNfXd24=
Expand Down Expand Up @@ -1708,8 +1708,8 @@ modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/internal v1.0.8/go.mod h1:km71QBJPWkc1+LUldg2U9TJsKT6Q2QKHIykdEeCy/jw=
modernc.org/internal v1.1.0 h1:hYRxTXjPPzzqxXaFyC9UALxi0+v1jgwZAktvZwwgnTE=
modernc.org/internal v1.1.0/go.mod h1:IFhfxUE81NbN8Riy+oHylA3PIYgAvIQ5eMufNzg7/QU=
modernc.org/libc v1.34.0 h1:akq7OQDN7YSoBvTdmaIv3p8RtzAqreMSQxF9u0KHaM4=
modernc.org/libc v1.34.0/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE=
modernc.org/libc v1.34.3 h1:ag+3JIGF0o009YKhKjkqAG3N36X6ctUv2V85hGM45WA=
modernc.org/libc v1.34.3/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE=
modernc.org/lldb v1.0.8 h1:gM0Lpmgtw0h/ylWQSxABvzJ++TZKhf1Q/uPAGBAM6aU=
modernc.org/lldb v1.0.8/go.mod h1:ybOcsZ/RNZo3q8fiGadQFRnD+1Jc+RWGcTPdeilCnUk=
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
Expand Down
27 changes: 9 additions & 18 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,14 @@ func (h *Handler) Prompt(prompt string) string {
buf = append(buf, '%')
case 'S': // short driver name
if connected {
buf = append(buf, dburl.ShortAlias(h.u.Scheme)+":"...)
s := dburl.ShortAlias(h.u.Scheme)
if s == "" {
s = dburl.ShortAlias(h.u.Driver)
}
if s == "" {
s = text.UnknownShortAlias
}
buf = append(buf, s+":"...)
} else {
buf = append(buf, text.NotConnected...)
}
Expand Down Expand Up @@ -717,23 +724,7 @@ func (h *Handler) Open(ctx context.Context, params ...string) error {
urlstr := params[0]
// parse dsn
u, err := dburl.Parse(urlstr)
switch {
case err == dburl.ErrInvalidDatabaseScheme:
fi, err := os.Stat(urlstr)
switch {
case err != nil:
return err
case fi.IsDir():
return h.Open(ctx, "postgres+unix:"+urlstr)
case fi.Mode()&os.ModeSocket != 0:
return h.Open(ctx, "mysql+unix:"+urlstr)
}
// it is a file, so attempt to open it with detected scheme
if scheme, err := dburl.SchemeType(urlstr); err == nil {
return h.Open(ctx, scheme+":"+urlstr)
}
return text.ErrUnknownFileType
case err != nil:
if err != nil {
return err
}
h.u = u
Expand Down
1 change: 1 addition & 0 deletions text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var (
InvalidOption = `invalid option %q`
NotificationReceived = `Asynchronous notification %q %sreceived from server process with PID %d.`
NotificationPayload = `with payload %q `
UnknownShortAlias = `(unk)`
)

func init() {
Expand Down

0 comments on commit 56018f4

Please sign in to comment.