Fix quoting of TRUNCATE command, fix #84.

That patch is not a principaled approach at fixing the problem but
should allow for not messing up with fully qualified table names.

A proper way to do it would be to have a pgsql object name structure
composed of the catalog, the schema and the name as separate entries,
with assorted API to print that object properly. That's for another day
though.
This commit is contained in:
Dimitri Fontaine 2014-06-20 13:10:39 +02:00
parent 252abdeaa7
commit f7d251ed86
2 changed files with 5 additions and 4 deletions

View File

@ -14,7 +14,7 @@
case)))
(ecase case
(:downcase (cl-ppcre:regex-replace-all
"[^a-zA-Z0-9]" (string-downcase identifier) "_"))
"[^a-zA-Z0-9.]" (string-downcase identifier) "_"))
(:quote (format nil "\"~a\"" identifier)))))
;;;
@ -189,7 +189,7 @@
"Truncate given TABLE-NAME in database DBNAME"
(pomo:with-connection (get-connection-spec dbname)
(set-session-gucs *pg-settings*)
(let ((sql (format nil "TRUNCATE ~{~s~^,~};"
(let ((sql (format nil "TRUNCATE ~{~a~^,~};"
(loop :for table-name :in table-name-list
:collect (apply-identifier-case table-name
identifier-case)))))

View File

@ -9,7 +9,8 @@ LOAD CSV
iprange ip4r using (ip-range startIpNum endIpNum),
locId
)
WITH fields optionally enclosed by '"',
WITH truncate,
fields optionally enclosed by '"',
fields escaped by double-quote,
fields terminated by ','
@ -17,7 +18,7 @@ LOAD CSV
BEFORE LOAD DO
$$ create extension if not exists ip4r; $$,
$$ drop schema if exists csv; $$,
$$ drop schema if exists csv cascade; $$,
$$ create schema csv; $$,
$$ create table if not exists csv.blocks
(