Skip to content

Conversation

@tbg
Copy link
Member

@tbg tbg commented Jul 25, 2015

  • 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

Copy link
Collaborator

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?

Copy link
Member Author

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.

@petermattis
Copy link
Collaborator

LGTM

@tbg tbg force-pushed the sql_literals branch 3 times, most recently from f440628 to 0c9245c Compare July 26, 2015 13:43
tbg added 2 commits July 26, 2015 11:39
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 Jul 26, 2015
parse literals more like Postgres
@tbg tbg merged commit cdd21fd into cockroachdb:master Jul 26, 2015
@tbg tbg removed the PTAL label Jul 26, 2015
@tbg tbg deleted the sql_literals branch July 26, 2015 15:55
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