diff --git a/src/pgsql/queries.lisp b/src/pgsql/queries.lisp index 6ccd77e..48d5f5c 100644 --- a/src/pgsql/queries.lisp +++ b/src/pgsql/queries.lisp @@ -324,15 +324,25 @@ select i.relname, (defun sanitize-user-gucs (gucs) "Forbid certain actions such as setting a client_encoding different from utf8." - (append - (list (cons "client_encoding" "utf8")) - (loop :for (name . value) :in gucs - :when (and (string-equal name "client_encoding") - (not (member value '("utf-8" "utf8") :test #'string-equal))) - :do (log-message :warning - "pgloader always talk to PostgreSQL in utf-8, client_encoding has been forced to 'utf8'.") - :else - :collect (cons name value)))) + (let ((gucs + (append + (list (cons "client_encoding" "utf8")) + (loop :for (name . value) :in gucs + :when (and (string-equal name "client_encoding") + (not (member value '("utf-8" "utf8") :test #'string-equal))) + :do (log-message :warning + "pgloader always talk to PostgreSQL in utf-8, client_encoding has been forced to 'utf8'.") + :else + :collect (cons name value))))) + ;; + ;; Now see about the application_name, provide "pgloader" if it's not + ;; been overloaded already. + ;; + (cond ((not (assoc "application_name" gucs :test #'string-equal)) + (append gucs (list (cons "application_name" "pgloader")))) + + (t + gucs)))) (defun list-reserved-keywords (pgconn) "Connect to PostgreSQL DBNAME and fetch reserved keywords." diff --git a/test/csv-hstore.load b/test/csv-hstore.load index be0753c..6660c48 100644 --- a/test/csv-hstore.load +++ b/test/csv-hstore.load @@ -8,7 +8,8 @@ LOAD CSV fields escaped by backslash-quote SET work_mem to '128MB', - standard_conforming_strings to 'on' + standard_conforming_strings to 'on', + application_name to 'my app name' BEFORE LOAD DO $$ create extension if not exists hstore; $$,