Implement AFTER CREATE SCHEMA DO for more sources.

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.
This commit is contained in:
Dimitri Fontaine 2020-02-11 22:20:08 +01:00
parent 8a13c02561
commit 2fef253d28
5 changed files with 33 additions and 13 deletions

View File

@ -59,6 +59,7 @@
gucs
casts
before-load
after-schema
after-load))
(:lambda (clauses-list)
(alexandria:alist-plist clauses-list)))
@ -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*)
@ -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
@ -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
@ -136,5 +140,6 @@
:gucs gucs
:casts casts
:before before
:after-schema after-schema
:after after
:options options))))))

View File

@ -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)))
@ -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)
@ -101,6 +102,7 @@
options
:extras '(:timezone))
:on-error-stop on-error-stop
:after-schema ',after-schema
:foreign-keys nil
:reset-sequences nil)
@ -109,7 +111,8 @@
(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
@ -117,5 +120,6 @@
:target-table-name table-name
:gucs gucs
:before before
:after-schema after-schema
:after after
:options options))))))

View File

@ -87,6 +87,7 @@
materialize-views
distribute-commands
before-load
after-schema
after-load
including-like-in-schema
excluding-like-in-schema))
@ -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
@ -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
@ -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))
@ -196,6 +198,7 @@
:casts casts
:views views
:before before
:after-schema after-schema
:after after
:alter-schema alter-schema
:alter-table alter-table

View File

@ -89,6 +89,7 @@
excluding-matching
decoding-tables-as
before-load
after-schema
after-load
distribute-commands))
(:lambda (clauses-list)
@ -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))
@ -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
@ -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*
@ -218,6 +222,7 @@
:views views
:before before
:after after
:after-schema after-schema
:options options
:alter-table alter-table
:alter-schema alter-schema

View File

@ -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))
@ -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
@ -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
@ -140,6 +142,7 @@ load database
:gucs gucs
:casts casts
:before before
:after-schema after-schema
:after after
:options options
:alter-table alter-table