Support String Constants with Escapes in SQL files.

pgloader has to parse external SQL files because of the driver we use,
Postmodern, only know how to deal with sending one query at a time. So
SQL parsing we do, and split the queries, and send them one after the
other to the server.

PostgreSQL allows String Constants with C-style Escapes to be used in
some situations, and the SQL parsing done in pgloader failed to support
that.

  http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE

This fixes #284.
This commit is contained in:
Dimitri Fontaine 2015-08-31 20:34:22 +02:00
parent 72fdf112ff
commit 62f0b7fc56

View File

@ -160,6 +160,15 @@ Another test case for the classic quotes:
(otherwise (cond ((member (parser-state state) '(:eat :eqt))
(write-char char (parser-stream state)))
;; see
;; http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE
;; we re-inject whatever we read in the \x
;; syntax into the stream and let PostgreSQL
;; be the judge of what it means.
((member (parser-state state) '(:esc))
(write-char char (parser-stream state))
(setf (parser-state state) :eqt))
((member (parser-state state) '(:tag))
;; only letters are allowed in tags
(if (alpha-char-p char)