Skip to content

Conversation

@ljwun
Copy link

@ljwun ljwun commented Dec 2, 2025

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Remove tab character (\t) from sqliteSeparator.

sqlite/ddlmod.go

Lines 58 to 79 in 7818dfd

if sc := string(c); separatorRegexp.MatchString(sc) {
if c == next {
buf += sc // Skip escaped quote
idx++
} else if quote > 0 {
quote = 0
} else {
quote = c
}
} else if quote == 0 {
if c == '(' {
bracketLevel++
} else if c == ')' {
bracketLevel--
} else if bracketLevel == 0 {
if c == ',' {
result.fields = append(result.fields, strings.TrimSpace(buf))
buf = ""
continue
}
}
}

When a tab character (\t) is present between the identifier and its type, separatorRegexp.MatchString(sc) can match and the code toggles the quote state incorrectly. The incorrect quote state causes the parser to ignore commas and therefore fail to split fields properly.

User Case Description

When parsing DDL that uses a tab character (\t) as whitespace between an identifier and its type, the parser can misinterpret the column list and return the wrong number of columns.

Reproduction DDL:

CREATE TABLE `test-e` (`field1`\ttext NOT NULL,`field2`\tinteger NOT NULL)

Expected result should have two columns:

  • field1
  • field2

Only one column is actually returned (the parser fails to split the column definitions correctly):

  • field1

Copy link
Contributor

@Shion1305 Shion1305 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Successfully merging this pull request may close these issues.

2 participants