Comments (10)
I tried many times and finally found the problem.
My config file $HOME/.config/usql/config.yaml
like this:
connections:
xxx: xxxx
init: |
\echo date `date`
Then after deleting the init
fragment, no errors were reported.
from usql.
Oh I totally forgot there's a yaml config too, thanks! @kenshaw PTAL, \echo date
date`` works with a regular .usqlrc
.
from usql.
I'll look in to this shortly. Probably a simple oversight on my part.
from usql.
What's in your $HOME/.usqlrc
? What's usql_static
- how did you build it?
from usql.
The .usqlrc
is an empty file, and the usql_static
was downloaded from https://github.com/xo/usql/releases/download/v0.19.1/usql_static-0.19.1-linux-amd64.tar.bz2
from usql.
Are you sure it's empty? It fails when executing an \echo
command, I wonder how it's being triggered and what are the arguments to it. Can you try running it with -X
? This disables reading any init files.
from usql.
I'm not able to reproduce this error:
ken@ken-desktop:~/Downloads$ mkdir usql
ken@ken-desktop:~/Downloads$ cd usql/
[config.yaml.txt](https://github.com/xo/usql/files/15292979/config.yaml.txt)
ken@ken-desktop:~/Downloads/usql$ mv ../usql_static-0.19.1-linux-amd64.tar.bz2 .
ken@ken-desktop:~/Downloads/usql$ tar -jxvf usql_static-0.19.1-linux-amd64.tar.bz2
usql_static
LICENSE
ken@ken-desktop:~/Downloads/usql$ md5sum usql_static
c110e337bb43dd359c34813bb459366c usql_static
ken@ken-desktop:~/Downloads/usql$ ./usql_static
Type "help" for help.
date Mon May 13 05:18:34 PM WIB 2024
(not connected)=> \q
ken@ken-desktop:~/Downloads/usql$ cat ~/.config/usql/config.yaml
---
init: |
\echo date `date`
ken@ken-desktop:~/Downloads/usql$ ./usql_static -V
usql 0.19.1
ken@ken-desktop:~/Downloads/usql$
Can you please share your exact yaml config file? Note that GitHub doesn't seem to allow uploads of .yaml extensions, for whatever reason. You'll need to rename the file prior to upload.
This is the simple debugging config file that I used:
config.txt
from usql.
Are you perhaps using something like Windows encoding? With \r\n
line endings? I've tried all manner of variations and I can't cause that same block of code to escape under any input that I could come up with. I'm sure my code is bad, but it's going to be difficult to figure out the cause of this without the exact character sequence/input.
Are you able to get \echo
to work in the init:
stanza in a simpler form? For example:
init: '\echo hi'
Which has this output on my system:
$ usql
Type "help" for help.
hi
(not connected)=> \q
from usql.
I repeat it again.
~$ cat .config/usql/config.yaml
connections:
xx: mysql://xxxx
cr: mysql://xxxx
init: |
\echo `date`
~$ ./usql
Type "help" for help.
panic: runtime error: slice bounds out of range [:43] with capacity 32
goroutine 1 [running]:
github.com/xo/usql/stmt.(*Params).Get(0xc000d0f660, 0xc00173ea28)
github.com/xo/usql/stmt/params.go:86 +0x9fb
github.com/xo/usql/metacmd.(*Params).Get(0xc00174ef00, 0x1)
github.com/xo/usql/metacmd/types.go:164 +0x192
github.com/xo/usql/metacmd.(*Params).GetOptional(0xc0007763c0?, 0xa0?)
github.com/xo/usql/metacmd/types.go:189 +0x13
github.com/xo/usql/metacmd.init.0.func15(0xc00174ef00)
github.com/xo/usql/metacmd/cmds.go:428 +0x2c
github.com/xo/usql/handler.(*Handler).Run.Decode.func3({0x6c8a398, 0xc0015fa9c0})
github.com/xo/usql/metacmd/metacmd.go:26 +0xd8
github.com/xo/usql/metacmd.RunnerFunc.Run(0x56b4360?, {0x6c8a398?, 0xc0015fa9c0?})
github.com/xo/usql/metacmd/types.go:82 +0x4d
github.com/xo/usql/handler.(*Handler).Run(0xc0015fa9c0)
github.com/xo/usql/handler/handler.go:282 +0xb30
main.Run({0x6c2d9c0, 0xabad740}, 0xc001277cb0, 0xc000f22bd0, {0xc000f0cd40, 0xd})
github.com/xo/usql/run.go:355 +0xce2
main.New.func3(0xc00012d808?, {0xabad740?, 0x7?, 0x5ed2453?})
github.com/xo/usql/run.go:126 +0x185
github.com/spf13/cobra.(*Command).execute(0xc00012d808, {0xc0000740a0, 0x0, 0x0})
github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc00012d808)
github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:1039
github.com/spf13/cobra.(*Command).ExecuteContext(0xc0000740a0?, {0x6c2d9c0?, 0xabad740?})
github.com/spf13/[email protected]/command.go:1032 +0x47
main.main()
github.com/xo/usql/main.go:40 +0x13c
~$
~$ vim .config/usql/config.yaml
~$ cat .config/usql/config.yaml
connections:
xx: mysql://xxxx
cr: mysql://xxxx
~$
~$ ./usql
Type "help" for help.
(not connected)=> \q
~$
from usql.
Now I found the cause of this problem, because the output of the date
command contains some unicode characters (non-ascii), causing the variable i
calculation in the Params.Get()
method to become longer.
There is my simple fix:
i = start + len([]rune(z)) - 1 // Line-59
Another solution: utf8.RuneCountInString(z)
from usql.
Related Issues (20)
- Feature request: implement the \bind meta-command HOT 6
- Using usql as a library (or subprocess) HOT 9
- Batch insert in \copy to DB destination HOT 1
- How to .usqlpass HOT 6
- Parentheses issue when \copying to postgres from sqlite HOT 2
- connect to clickhouse over http from cmdline HOT 4
- error: sqlserver: TLS Handshake failed: tls: server selected unsupported protocol version 301 HOT 1
- USQL Databricks driver fails when connection with Azure Databricks HOT 6
- Prompt `%/` doesn't reflect the actual database
- [Question] Defined Queries
- Dashes in connections names in config.yaml cause warnings/errors
- Question regarding /gx and /g mode
- Can't send tab character as input
- (new) copying between databases? HOT 1
- terminal graphics support HOT 6
- 0.19.3 on rhel 7.9: Warn DBUS_SESSION_BUS_ADDRESS
- mysql 5.7 converting NULL to uint32 is unsupported HOT 1
- table name tab-completion not working between 0.18.x -> 0.19.x HOT 1
- Support EDITOR with arguments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from usql.