MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / TestParseError

Function TestParseError

pkg/sql/parser/parse_test.go:2364–2948  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2362}
2363
2364func TestParseError(t *testing.T) {
2365 testData := []struct {
2366 sql string
2367 expected string
2368 }{
2369 {`SELECT2 1`,
2370 `at or near "select2": syntax error
2371DETAIL: source SQL:
2372SELECT2 1
2373^`},
2374 {`SELECT 1 FROM (t)`,
2375 `at or near ")": syntax error
2376DETAIL: source SQL:
2377SELECT 1 FROM (t)
2378 ^
2379HINT: try \h <SOURCE>`},
2380 {`SET TIME ZONE INTERVAL 'foobar'`,
2381 `at or near "EOF": syntax error: could not parse "foobar" as type interval: interval: missing unit at position 0: "foobar"
2382DETAIL: source SQL:
2383SET TIME ZONE INTERVAL 'foobar'
2384 ^`},
2385 {`SELECT INTERVAL 'foo'`,
2386 `at or near "EOF": syntax error: could not parse "foo" as type interval: interval: missing unit at position 0: "foo"
2387DETAIL: source SQL:
2388SELECT INTERVAL 'foo'
2389 ^`},
2390 {`SELECT 1 /* hello`,
2391 `lexical error: unterminated comment
2392DETAIL: source SQL:
2393SELECT 1 /* hello
2394 ^`},
2395 {`SELECT '1`,
2396 `lexical error: unterminated string
2397DETAIL: source SQL:
2398SELECT '1
2399 ^
2400HINT: try \h SELECT`},
2401 {`SELECT * FROM t WHERE k=`,
2402 `at or near "EOF": syntax error
2403DETAIL: source SQL:
2404SELECT * FROM t WHERE k=
2405 ^
2406HINT: try \h SELECT`,
2407 },
2408 {`CREATE TABLE test (
2409 CONSTRAINT foo INDEX (bar)
2410)`,
2411 `at or near "index": syntax error
2412DETAIL: source SQL:
2413CREATE TABLE test (
2414 CONSTRAINT foo INDEX (bar)
2415 ^
2416HINT: try \h CREATE TABLE`},
2417 {`CREATE TABLE test (
2418 foo BIT(0)
2419)`,
2420 `at or near ")": syntax error: length for type bit must be at least 1
2421DETAIL: source SQL:

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.92
FlattenFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…