Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when use q and Q #525

Open
endo64 opened this issue Apr 17, 2024 · 1 comment
Open

Crash when use q and Q #525

endo64 opened this issue Apr 17, 2024 · 1 comment

Comments

@endo64
Copy link

endo64 commented Apr 17, 2024

sqlcmd crashes when use both q and Q command line arguments at the same time.
Version v1.6.0 on Windows 10 (x64)

PS C:\Users\myuser> sqlcmd -S myserver -E -d mydb -q "SELECT 1" -Q "SELECT 2"

-----------
          1

(1 row affected)
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0x16b027b]

goroutine 1 [running]:
github.com/microsoft/go-sqlcmd/pkg/sqlcmd.(*Sqlcmd).scanNext(0xf7edbc?)
        D:/a/1/s/pkg/sqlcmd/sqlcmd.go:114 +0x1b
github.com/microsoft/go-sqlcmd/pkg/sqlcmd.(*Batch).Next(0xc0000b2200)
        D:/a/1/s/pkg/sqlcmd/batch.go:81 +0x6a
github.com/microsoft/go-sqlcmd/pkg/sqlcmd.(*Sqlcmd).Run(0xc0000b8000, 0x90?, 0x0)
        D:/a/1/s/pkg/sqlcmd/sqlcmd.go:142 +0x27c
github.com/microsoft/go-sqlcmd/cmd/sqlcmd.run(0xc00040e028, 0x22430c0)
        D:/a/1/s/cmd/sqlcmd/sqlcmd.go:822 +0xcb3
github.com/microsoft/go-sqlcmd/cmd/sqlcmd.Execute.func2(0xc000028600?, {0xc0000a2000?, 0x9?, 0x10?})
        D:/a/1/s/cmd/sqlcmd/sqlcmd.go:249 +0x425
github.com/spf13/cobra.(*Command).execute(0xc000028600, {0xc000415e00, 0x9, 0x10})
        C:/Users/VssAdministrator/go/pkg/mod/github.com/spf13/[email protected]/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0xc000028600)
        C:/Users/VssAdministrator/go/pkg/mod/github.com/spf13/[email protected]/command.go:1044 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
        C:/Users/VssAdministrator/go/pkg/mod/github.com/spf13/[email protected]/command.go:968
github.com/microsoft/go-sqlcmd/cmd/sqlcmd.Execute({0x1c1cda8, 0x6})
        D:/a/1/s/cmd/sqlcmd/sqlcmd.go:273 +0x1a5
main.main()
        D:/a/1/s/cmd/modern/main.go:52 +0x21f
@shueybubbles
Copy link
Collaborator

those switches are mutually exclusive. I agree sqlcmd shouldn't crash but it's not a supported parameter combination.
EG the ODBC sqlcmd ignores the q:

sqlcmd -Q "select 1" -q "select 100"

-----------
          1

(1 rows affected)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants