parse literals more like Postgres by tbg · Pull Request #1807 · cockroachdb/cockroach (original) (raw)
- rewrote SQL escaping. It'll output an escaped string when it has to, or when
a single-quote or backslash appears (the former could be written as '', but
this is more awkward to implement; the latter needs escaping only in an
escaped string, which would require an extra pass through the string prior
to beginning the encoding - not worth it). - no escaping of "; Postgres doesn't do it
- dissect and update all the test cases affected by this and add some new ones.
found via go-fuzz, ping @dvyukov.
data0: "INSERT INTO O VALUES ('\0\n\n')"
data1: "INSERT INTO O VALUES ('\0\n\n')"
panic: not equal
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you append the strMod byte above where the opening ' is appended?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. Remnants from earlier code where I hoped not to have to iterate twice.
with this change
- rewrote SQL escaping. It'll output an escaped string when it has to, or when a single-quote or backslash appears (the former could be written as '', but this is more awkward to implement; the latter needs escaping only in an escaped string, which would require an extra pass through the string prior to beginning the encoding - not worth it).
- no escaping of "; Postgres doesn't do it
- dissect and update all the test cases affected by this and add some new ones.
found via go-fuzz, ping @dvyukov.
tbg added a commit that referenced this pull request
parse literals more like Postgres
tbg deleted the sql_literals branch