sql icon indicating copy to clipboard operation
sql copied to clipboard

CreateTableStatement.String panic

Open bradfitz opened this issue 2 months ago • 0 comments

https://go.dev/play/p/2yGiVAG8PtP

func TestCreateTableStringPanic(t *testing.T) {
	p := sql.NewParser(strings.NewReader(`CREATE TABLE Foo (
	SomeID    INTEGER NOT NULL PRIMARY KEY,
	Created         INTEGER NOT NULL DEFAULT 0,
	ExplicitExpiry  INTEGER,
	EffectiveExpiry GENERATED ALWAYS AS (COALESCE(ExplicitExpiry, Created+31*24*60*60)) VIRTUAL
);`))
	st, err := p.ParseStatement()
	if err != nil {
		t.Logf("error: %v", err)
	}
	t.Logf("Got: %s", st.String())
}

=>

=== RUN   TestCreateTableStringPanic
--- FAIL: TestCreateTableStringPanic (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x509f1a]

goroutine 18 [running]:
testing.tRunner.func1.2({0x53bfc0, 0x674ab0})
	/usr/local/go-faketime/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
	/usr/local/go-faketime/src/testing/testing.go:1634 +0x377
panic({0x53bfc0?, 0x674ab0?})
	/usr/local/go-faketime/src/runtime/panic.go:770 +0x132
github.com/rqlite/sql.(*Type).String(0xc00011dd88?)
	/tmp/gopath2235184643/pkg/mod/github.com/rqlite/[email protected]/ast.go:1364 +0x1a
github.com/rqlite/sql.(*ColumnDefinition).String(0xc000120690)
	/tmp/gopath2235184643/pkg/mod/github.com/rqlite/[email protected]/ast.go:726 +0xc5
github.com/rqlite/sql.(*CreateTableStatement).String(0xc000170000)
	/tmp/gopath2235184643/pkg/mod/github.com/rqlite/[email protected]/ast.go:680 +0x1e5
play.TestCreateTableStringPanic(0xc000148680)
	/tmp/sandbox623454917/prog_test.go:21 +0x239
testing.tRunner(0xc000148680, 0x572a10)
	/usr/local/go-faketime/src/testing/testing.go:1689 +0xfb
created by testing.(*T).Run in goroutine 1
	/usr/local/go-faketime/src/testing/testing.go:1742 +0x390

bradfitz avatar Apr 20 '24 03:04 bradfitz