mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 18:36:12 +02:00
Implement ALTER SCHEMA and ALTER TABLE for SQLite.
It turns out we forgot to add support for internal catalog munging clauses to SQLite support. The catalogs being normalized means there's no extra work here other than allowing the parser to accept those clauses and then pass them over to our generic `copy-database' method implementation. It is to be noted that SQLite has no support for schemas as per the standard and PostgreSQL, so that when we inspect the database schema we create a nil entry here. It's then not possible to ALTER SCHEMA nil RENAME TO 'target'; unfortunately, but it's easy enough to SET search_path to 'target' anyway, as shown in the modified test case. Fix #552.
This commit is contained in:
parent
65cdc48c1e
commit
3b4af49e22
@ -74,6 +74,8 @@ load database
|
||||
(defrule load-sqlite-optional-clauses (* (or sqlite-options
|
||||
gucs
|
||||
casts
|
||||
alter-table
|
||||
alter-schema
|
||||
including-like
|
||||
excluding-like
|
||||
before-load
|
||||
@ -96,6 +98,7 @@ load database
|
||||
(defun lisp-code-for-loading-from-sqlite (sqlite-db-conn pg-db-conn
|
||||
&key
|
||||
gucs casts before after options
|
||||
alter-table alter-schema
|
||||
((:including incl))
|
||||
((:excluding excl)))
|
||||
`(lambda ()
|
||||
@ -113,6 +116,8 @@ load database
|
||||
,(sql-code-block pg-db-conn :pre before "before load")
|
||||
|
||||
(pgloader.sqlite:copy-database source
|
||||
:alter-table ',alter-table
|
||||
:alter-schema ',alter-schema
|
||||
:set-table-oids t
|
||||
:including ',incl
|
||||
:excluding ',excl
|
||||
@ -125,7 +130,9 @@ load database
|
||||
(destructuring-bind (sqlite-uri
|
||||
pg-db-uri
|
||||
&key
|
||||
gucs casts before after options including excluding)
|
||||
gucs casts before after options
|
||||
alter-table alter-schema
|
||||
including excluding)
|
||||
source
|
||||
(cond (*dry-run*
|
||||
(lisp-code-for-sqlite-dry-run sqlite-uri pg-db-uri))
|
||||
@ -136,6 +143,8 @@ load database
|
||||
:before before
|
||||
:after after
|
||||
:options options
|
||||
:alter-table alter-table
|
||||
:alter-schema alter-schema
|
||||
:including including
|
||||
:excluding excluding))))))
|
||||
|
||||
|
||||
@ -8,4 +8,11 @@ load database
|
||||
concurrency = 2,
|
||||
include drop, create tables, create indexes, reset sequences, foreign keys
|
||||
|
||||
set work_mem to '16MB', maintenance_work_mem to '512 MB';
|
||||
-- alter table names matching ~/./ set schema 'chinook'
|
||||
alter table names matching 'Employee' rename to 'staff'
|
||||
|
||||
set work_mem to '16MB', maintenance_work_mem to '512 MB',
|
||||
search_path to 'chinook'
|
||||
|
||||
before load do
|
||||
$$ create schema if not exists chinook; $$;
|
||||
Loading…
x
Reference in New Issue
Block a user