Skip to content

Commit

Permalink
Implement AFTER CREATE SCHEMA DO for more sources.
Browse files Browse the repository at this point in the history
It was only implemented for Postgres sources even though the implementation
is generic enough to be shared. It's only a matter of instructing our parser
about the new facility, which this patch does.

Fixes #1062.
  • Loading branch information
dimitri committed Feb 11, 2020
1 parent 8a13c02 commit 2fef253
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
9 changes: 7 additions & 2 deletions src/parsers/command-dbf.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
gucs
casts
before-load
after-schema
after-load))
(:lambda (clauses-list)
(alexandria:alist-plist clauses-list)))
Expand Down Expand Up @@ -93,7 +94,8 @@
&key
target-table-name
encoding
gucs casts before after options
gucs casts options
before after-schema after
&allow-other-keys)
`(lambda ()
(let* ((*default-cast-rules* ',*db3-default-cast-rules*)
Expand All @@ -116,6 +118,7 @@

(copy-database source
,@(remove-batch-control-option options)
:after-schema ',after-schema
:on-error-stop on-error-stop
:create-indexes nil
:foreign-keys nil
Expand All @@ -126,7 +129,8 @@
(defrule load-dbf-file load-dbf-command
(:lambda (command)
(bind (((source encoding pg-db-uri table-name
&key options gucs casts before after) command))
&key options gucs casts before after-schema after)
command))
(cond (*dry-run*
(lisp-code-for-dbf-dry-run source pg-db-uri))
(t
Expand All @@ -136,5 +140,6 @@
:gucs gucs
:casts casts
:before before
:after-schema after-schema
:after after
:options options))))))
10 changes: 7 additions & 3 deletions src/parsers/command-ixf.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
(defrule load-ixf-optional-clauses (* (or ixf-options
gucs
before-load
after-schema
after-load))
(:lambda (clauses-list)
(alexandria:alist-plist clauses-list)))
Expand All @@ -76,8 +77,8 @@

(defun lisp-code-for-loading-from-ixf (ixf-db-conn pg-db-conn
&key
target-table-name
gucs before after options
target-table-name gucs options
before after-schema after
&allow-other-keys)
`(lambda ()
(let* (,@(pgsql-connection-bindings pg-db-conn gucs)
Expand All @@ -101,6 +102,7 @@
options
:extras '(:timezone))
:on-error-stop on-error-stop
:after-schema ',after-schema
:foreign-keys nil
:reset-sequences nil)

Expand All @@ -109,13 +111,15 @@
(defrule load-ixf-file load-ixf-command
(:lambda (command)
(bind (((source pg-db-uri table-name
&key options gucs before after) command))
&key options gucs before after-schema after)
command))
(cond (*dry-run*
(lisp-code-for-csv-dry-run pg-db-uri))
(t
(lisp-code-for-loading-from-ixf source pg-db-uri
:target-table-name table-name
:gucs gucs
:before before
:after-schema after-schema
:after after
:options options))))))
7 changes: 5 additions & 2 deletions src/parsers/command-mssql.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
materialize-views
distribute-commands
before-load
after-schema
after-load
including-like-in-schema
excluding-like-in-schema))
Expand Down Expand Up @@ -142,7 +143,7 @@
(defun lisp-code-for-loading-from-mssql (ms-db-conn pg-db-conn
&key
gucs mssql-gucs
casts before after
casts before after after-schema
options distribute views
alter-schema alter-table
including excluding
Expand Down Expand Up @@ -171,6 +172,7 @@
:excluding ',excluding
:alter-schema ',alter-schema
:alter-table ',alter-table
:after-schema ',after-schema
:materialize-views ',views
:distribute ',distribute
:set-table-oids t
Expand All @@ -183,7 +185,7 @@
(:lambda (source)
(bind (((ms-db-uri pg-db-uri
&key
gucs mssql-gucs casts views before after
gucs mssql-gucs casts views before after-schema after
alter-schema alter-table distribute
including excluding options)
source))
Expand All @@ -196,6 +198,7 @@
:casts casts
:views views
:before before
:after-schema after-schema
:after after
:alter-schema alter-schema
:alter-table alter-table
Expand Down
13 changes: 9 additions & 4 deletions src/parsers/command-mysql.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
excluding-matching
decoding-tables-as
before-load
after-schema
after-load
distribute-commands))
(:lambda (clauses-list)
Expand Down Expand Up @@ -164,8 +165,10 @@
(defun lisp-code-for-loading-from-mysql (my-db-conn pg-db-conn
&key
gucs mysql-gucs
casts views before after options
alter-table alter-schema distribute
casts options views
before after after-schema
alter-table alter-schema
distribute
((:including incl))
((:excluding excl))
((:decoding decoding-as))
Expand All @@ -192,6 +195,7 @@
:materialize-views ',views
:alter-table ',alter-table
:alter-schema ',alter-schema
:after-schema ',after-schema
:distribute ',distribute
:set-table-oids t
:on-error-stop on-error-stop
Expand All @@ -204,8 +208,8 @@
(destructuring-bind (my-db-uri
pg-db-uri
&key
gucs mysql-gucs casts views before after options
alter-table alter-schema distribute
gucs mysql-gucs casts views before after after-schema
options alter-table alter-schema distribute
including excluding decoding)
source
(cond (*dry-run*
Expand All @@ -218,6 +222,7 @@
:views views
:before before
:after after
:after-schema after-schema
:options options
:alter-table alter-table
:alter-schema alter-schema
Expand Down
7 changes: 5 additions & 2 deletions src/parsers/command-sqlite.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ load database

(defun lisp-code-for-loading-from-sqlite (sqlite-db-conn pg-db-conn
&key
gucs casts before after options
gucs casts options
before after-schema after
alter-table alter-schema
((:including incl))
((:excluding excl))
Expand All @@ -116,6 +117,7 @@ load database
(copy-database source
:alter-table ',alter-table
:alter-schema ',alter-schema
:after-schema ',after-schema
:set-table-oids t
:including ',incl
:excluding ',excl
Expand All @@ -129,7 +131,7 @@ load database
(destructuring-bind (sqlite-uri
pg-db-uri
&key
gucs casts before after options
gucs casts before after after-schema options
alter-table alter-schema
including excluding)
source
Expand All @@ -140,6 +142,7 @@ load database
:gucs gucs
:casts casts
:before before
:after-schema after-schema
:after after
:options options
:alter-table alter-table
Expand Down

0 comments on commit 2fef253

Please sign in to comment.