HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/mysql-postgres/pgloader-3.6.2/src/parsers/command-archive.lisp
;;;
;;; LOAD ARCHIVE ...
;;;

(in-package #:pgloader.parser)

(defrule archive-command (or load-csv-file
			     load-dbf-file
			     load-fixed-cols-file))

(defrule another-archive-command (and kw-and archive-command)
  (:lambda (source)
    (bind (((_ col) source)) col)))

(defrule archive-command-list (and archive-command (* another-archive-command))
  (:lambda (source)
    (destructuring-bind (col1 cols) source
      (cons :commands (list* col1 cols)))))

(defrule archive-source (and kw-load kw-archive kw-from filename-or-http-uri)
  (:lambda (src)
    (bind (((_ _ _ source) src)) source)))

(defrule load-archive-clauses (and archive-source
                                   (? target)
                                   (? before-load)
                                   archive-command-list
                                   (? finally))
  (:lambda (command)
    (bind (((source target before commands finally) command)
           ((&key before commands finally)
            (alexandria:alist-plist (remove-if #'null
                                               (list before commands finally)))))
      (list source target
            :before before
            :commands commands
            :finally finally))))

(defrule load-archive load-archive-clauses
  (:lambda (archive)
    (destructuring-bind (source pg-db-conn &key before commands finally) archive
      (when (and (or before finally) (null pg-db-conn))
        (error "When using a BEFORE LOAD DO or a FINALLY block, you must provide an archive level target database connection."))
      `(lambda ()
         (let* (,@(pgsql-connection-bindings pg-db-conn nil)
                (archive-file
                 , (destructuring-bind (kind url) source
                     (ecase kind
                       (:http     `(with-stats-collection
                                       ("download" :section :pre)
                                       (pgloader.archive:http-fetch-file ,url)))
                       (:filename url))))
                  (*fd-path-root*
                   (with-stats-collection ("extract" :section :pre)
                       (pgloader.archive:expand-archive archive-file))))
           (progn
             ,(sql-code-block pg-db-conn :pre before "before load")

             ;; import from files block
             ,@(loop for command in commands
                  collect `(funcall ,command))

             ,(sql-code-block pg-db-conn :post finally "finally")))))))