mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-09 07:47:00 +02:00
Implement support for MS SQL set parameters.
It is sometimes needed to tweak MS SQL server parameters, such as the textsize parameters which allows fetching the whole set of bytes of a text of binary column (not kidding). Now it's possible to add such a line in the load file: set mssql parameters textsize to '104857600' Fixes #603.
This commit is contained in:
parent
30f359735c
commit
20a85055f4
@ -26,6 +26,7 @@
|
|||||||
#:*prefetch-rows*
|
#:*prefetch-rows*
|
||||||
#:*pg-settings*
|
#:*pg-settings*
|
||||||
#:*mysql-settings*
|
#:*mysql-settings*
|
||||||
|
#:*mssql-settings*
|
||||||
#:*default-tmpdir*
|
#:*default-tmpdir*
|
||||||
#:init-params-from-environment
|
#:init-params-from-environment
|
||||||
#:getenv-default
|
#:getenv-default
|
||||||
@ -142,6 +143,7 @@
|
|||||||
|
|
||||||
(defparameter *pg-settings* nil "An alist of GUC names and values.")
|
(defparameter *pg-settings* nil "An alist of GUC names and values.")
|
||||||
(defparameter *mysql-settings* nil "An alist of GUC names and values.")
|
(defparameter *mysql-settings* nil "An alist of GUC names and values.")
|
||||||
|
(defparameter *mssql-settings* nil "An alist of GUC names and values.")
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Archive processing: downloads and unzip.
|
;;; Archive processing: downloads and unzip.
|
||||||
|
@ -156,3 +156,4 @@
|
|||||||
|
|
||||||
(defrule kw-postgresql (or (~ "pgsql") (~ "postgresql")))
|
(defrule kw-postgresql (or (~ "pgsql") (~ "postgresql")))
|
||||||
(defrule kw-mysql (~ "mysql"))
|
(defrule kw-mysql (~ "mysql"))
|
||||||
|
(defrule kw-mssql (~ "mssql"))
|
||||||
|
@ -65,11 +65,19 @@
|
|||||||
(destructuring-bind (excl1 excls) source
|
(destructuring-bind (excl1 excls) source
|
||||||
(cons :excluding (list* excl1 excls)))))
|
(cons :excluding (list* excl1 excls)))))
|
||||||
|
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; MSSQL SET parameters, because sometimes we need that
|
||||||
|
;;;
|
||||||
|
(defrule mssql-gucs (and kw-set kw-mssql kw-parameters generic-option-list)
|
||||||
|
(:lambda (mygucs) (cons :mssql-gucs (fourth mygucs))))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Allow clauses to appear in any order
|
;;; Allow clauses to appear in any order
|
||||||
;;;
|
;;;
|
||||||
(defrule load-mssql-optional-clauses (* (or mssql-options
|
(defrule load-mssql-optional-clauses (* (or mssql-options
|
||||||
|
mssql-gucs
|
||||||
gucs
|
gucs
|
||||||
casts
|
casts
|
||||||
alter-schema
|
alter-schema
|
||||||
@ -139,7 +147,8 @@
|
|||||||
|
|
||||||
(defun lisp-code-for-loading-from-mssql (ms-db-conn pg-db-conn
|
(defun lisp-code-for-loading-from-mssql (ms-db-conn pg-db-conn
|
||||||
&key
|
&key
|
||||||
gucs casts before after options
|
gucs mssql-gucs
|
||||||
|
casts before after options
|
||||||
alter-schema alter-table
|
alter-schema alter-table
|
||||||
including excluding)
|
including excluding)
|
||||||
`(lambda ()
|
`(lambda ()
|
||||||
@ -149,6 +158,7 @@
|
|||||||
|
|
||||||
(let* ((*default-cast-rules* ',*mssql-default-cast-rules*)
|
(let* ((*default-cast-rules* ',*mssql-default-cast-rules*)
|
||||||
(*cast-rules* ',casts)
|
(*cast-rules* ',casts)
|
||||||
|
(*mssql-settings* ',mssql-gucs)
|
||||||
,@(pgsql-connection-bindings pg-db-conn gucs)
|
,@(pgsql-connection-bindings pg-db-conn gucs)
|
||||||
,@(batch-control-bindings options)
|
,@(batch-control-bindings options)
|
||||||
,@(identifier-case-binding options)
|
,@(identifier-case-binding options)
|
||||||
@ -173,7 +183,8 @@
|
|||||||
(:lambda (source)
|
(:lambda (source)
|
||||||
(bind (((ms-db-uri pg-db-uri
|
(bind (((ms-db-uri pg-db-uri
|
||||||
&key
|
&key
|
||||||
gucs casts before after alter-schema alter-table
|
gucs mssql-gucs casts before after
|
||||||
|
alter-schema alter-table
|
||||||
including excluding options)
|
including excluding options)
|
||||||
source))
|
source))
|
||||||
(cond (*dry-run*
|
(cond (*dry-run*
|
||||||
@ -181,6 +192,7 @@
|
|||||||
(t
|
(t
|
||||||
(lisp-code-for-loading-from-mssql ms-db-uri pg-db-uri
|
(lisp-code-for-loading-from-mssql ms-db-uri pg-db-uri
|
||||||
:gucs gucs
|
:gucs gucs
|
||||||
|
:mssql-gucs mssql-gucs
|
||||||
:casts casts
|
:casts casts
|
||||||
:before before
|
:before before
|
||||||
:after after
|
:after after
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
(db-user msconn)
|
(db-user msconn)
|
||||||
(db-pass msconn)
|
(db-pass msconn)
|
||||||
(db-host msconn)))
|
(db-host msconn)))
|
||||||
|
;; apply mysql-settings, if any
|
||||||
|
(loop :for (name . value) :in *mssql-settings*
|
||||||
|
:for sql := (format nil "set ~a ~a;" name value)
|
||||||
|
:do (query msconn sql))
|
||||||
|
|
||||||
;; return the connection object
|
;; return the connection object
|
||||||
msconn)
|
msconn)
|
||||||
|
|
||||||
@ -40,8 +45,7 @@
|
|||||||
(defun mssql-query (query)
|
(defun mssql-query (query)
|
||||||
"Execute given QUERY within the current *connection*, and set proper
|
"Execute given QUERY within the current *connection*, and set proper
|
||||||
defaults for pgloader."
|
defaults for pgloader."
|
||||||
(log-message :sql "MSSQL: sending query: ~a" query)
|
(query *mssql-db* query))
|
||||||
(mssql:query query :connection (conn-handle *mssql-db*)))
|
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
(*prefetch-rows* . ,*prefetch-rows*)
|
(*prefetch-rows* . ,*prefetch-rows*)
|
||||||
(*pg-settings* . ',*pg-settings*)
|
(*pg-settings* . ',*pg-settings*)
|
||||||
(*mysql-settings* . ',*mysql-settings*)
|
(*mysql-settings* . ',*mysql-settings*)
|
||||||
|
(*mssql-settings* . ',*mssql-settings*)
|
||||||
(*root-dir* . ,*root-dir*)
|
(*root-dir* . ,*root-dir*)
|
||||||
(*fd-path-root* . ,*fd-path-root*)
|
(*fd-path-root* . ,*fd-path-root*)
|
||||||
(*client-min-messages* . ,*client-min-messages*)
|
(*client-min-messages* . ,*client-min-messages*)
|
||||||
|
Loading…
Reference in New Issue
Block a user