diff --git a/src/pgsql/pgsql-create-schema.lisp b/src/pgsql/pgsql-create-schema.lisp index 29fedc4..dd490ac 100644 --- a/src/pgsql/pgsql-create-schema.lisp +++ b/src/pgsql/pgsql-create-schema.lisp @@ -167,10 +167,14 @@ (schema (table-list catalog-or-table)) (table (list catalog-or-table))))) (sql - (format nil "TRUNCATE ~{~a~^,~};" target-list))) - (pgsql-execute sql) - ;; return how many tables we just TRUNCATEd - (length target-list))) + (when target-list + (format nil "TRUNCATE ~{~a~^,~};" target-list)))) + (if target-list + (progn + (pgsql-execute sql) + ;; return how many tables we just TRUNCATEd + (length target-list)) + 0))) (defun disable-triggers (table-name) "Disable triggers on TABLE-NAME. Needs to be called with a PostgreSQL diff --git a/test/mysql/db789.load b/test/mysql/db789.load new file mode 100644 index 0000000..ba456d9 --- /dev/null +++ b/test/mysql/db789.load @@ -0,0 +1,17 @@ +LOAD DATABASE + FROM mysql://root@localhost/db789 + INTO postgres:///pgloader + + WITH data only, truncate, create no tables + + MATERIALIZE VIEWS proceed + + INCLUDING ONLY TABLE NAMES MATCHING 'proceed' + + BEFORE LOAD DO + $$ drop schema if exists matview cascade; $$, + $$ drop schema if exists db789 cascade; $$, + $$ create schema db789; $$, + $$ create table db789.refrain (id char(1) primary key); $$, + $$ create table db789.proceed (id char(1) primary key); $$; + diff --git a/test/mysql/db789.sql b/test/mysql/db789.sql new file mode 100644 index 0000000..dfbff07 --- /dev/null +++ b/test/mysql/db789.sql @@ -0,0 +1,8 @@ +drop database if exists db789; +create database db789; +use db789; + +create table refrain (id char(1) primary key); +insert into refrain values ('a'), ('b'), ('c'), ('d'); + +create view proceed as select * from refrain where id > 'b';