mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-09 15:56:58 +02:00
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:
parent
252abdeaa7
commit
f7d251ed86
@ -14,7 +14,7 @@
|
|||||||
case)))
|
case)))
|
||||||
(ecase case
|
(ecase case
|
||||||
(:downcase (cl-ppcre:regex-replace-all
|
(: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)))))
|
(:quote (format nil "\"~a\"" identifier)))))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
@ -189,7 +189,7 @@
|
|||||||
"Truncate given TABLE-NAME in database DBNAME"
|
"Truncate given TABLE-NAME in database DBNAME"
|
||||||
(pomo:with-connection (get-connection-spec dbname)
|
(pomo:with-connection (get-connection-spec dbname)
|
||||||
(set-session-gucs *pg-settings*)
|
(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
|
(loop :for table-name :in table-name-list
|
||||||
:collect (apply-identifier-case table-name
|
:collect (apply-identifier-case table-name
|
||||||
identifier-case)))))
|
identifier-case)))))
|
||||||
|
@ -9,7 +9,8 @@ LOAD CSV
|
|||||||
iprange ip4r using (ip-range startIpNum endIpNum),
|
iprange ip4r using (ip-range startIpNum endIpNum),
|
||||||
locId
|
locId
|
||||||
)
|
)
|
||||||
WITH fields optionally enclosed by '"',
|
WITH truncate,
|
||||||
|
fields optionally enclosed by '"',
|
||||||
fields escaped by double-quote,
|
fields escaped by double-quote,
|
||||||
fields terminated by ','
|
fields terminated by ','
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ LOAD CSV
|
|||||||
|
|
||||||
BEFORE LOAD DO
|
BEFORE LOAD DO
|
||||||
$$ create extension if not exists ip4r; $$,
|
$$ create extension if not exists ip4r; $$,
|
||||||
$$ drop schema if exists csv; $$,
|
$$ drop schema if exists csv cascade; $$,
|
||||||
$$ create schema csv; $$,
|
$$ create schema csv; $$,
|
||||||
$$ create table if not exists csv.blocks
|
$$ create table if not exists csv.blocks
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user