(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/db/dbi#connection::t
    (make-struct-type
     'std/db/dbi#connection::t
     '#f
     '4
     'connection
     '()
     ':init!
     '(e txn-begin txn-commit txn-abort)))
  (define std/db/dbi#connection?
    (make-struct-predicate std/db/dbi#connection::t))
  (define std/db/dbi#make-connection
    (lambda _$args1096_
      (apply make-struct-instance std/db/dbi#connection::t _$args1096_)))
  (define std/db/dbi#connection-e
    (make-struct-field-accessor std/db/dbi#connection::t '0))
  (define std/db/dbi#connection-txn-begin
    (make-struct-field-accessor std/db/dbi#connection::t '1))
  (define std/db/dbi#connection-txn-commit
    (make-struct-field-accessor std/db/dbi#connection::t '2))
  (define std/db/dbi#connection-txn-abort
    (make-struct-field-accessor std/db/dbi#connection::t '3))
  (define std/db/dbi#connection-e-set!
    (make-struct-field-mutator std/db/dbi#connection::t '0))
  (define std/db/dbi#connection-txn-begin-set!
    (make-struct-field-mutator std/db/dbi#connection::t '1))
  (define std/db/dbi#connection-txn-commit-set!
    (make-struct-field-mutator std/db/dbi#connection::t '2))
  (define std/db/dbi#connection-txn-abort-set!
    (make-struct-field-mutator std/db/dbi#connection::t '3))
  (define std/db/dbi#statement::t
    (make-struct-type 'std/db/dbi#statement::t '#f '1 'statement '() '#f '(e)))
  (define std/db/dbi#statement?
    (make-struct-predicate std/db/dbi#statement::t))
  (define std/db/dbi#make-statement
    (lambda _$args1093_
      (apply make-struct-instance std/db/dbi#statement::t _$args1093_)))
  (define std/db/dbi#statement-e
    (make-struct-field-accessor std/db/dbi#statement::t '0))
  (define std/db/dbi#statement-e-set!
    (make-struct-field-mutator std/db/dbi#statement::t '0))
  (define std/db/dbi#connection:::init!
    (lambda (_self1090_ _e1091_)
      (if (let ((__tmp4753
                 (let () (declare (not safe)) (##vector-length _self1090_))))
            (declare (not safe))
            (##fx< '1 __tmp4753))
          (let () (declare (not safe)) (##vector-set! _self1090_ '1 _e1091_))
          (error '"struct-instance-init!: too many arguments for struct"
                 _self1090_))))
  (bind-method!
   std/db/dbi#connection::t
   ':init!
   std/db/dbi#connection:::init!
   '#f)
  (define std/db/dbi#sql-error::t
    (make-struct-type
     'std/db/dbi#sql-error::t
     error::t
     '0
     'sql-error
     '()
     '#f
     '()))
  (define std/db/dbi#sql-error?
    (make-struct-predicate std/db/dbi#sql-error::t))
  (define std/db/dbi#make-sql-error
    (lambda _$args965_
      (apply make-struct-instance std/db/dbi#sql-error::t _$args965_)))
  (define std/db/dbi#raise-sql-error
    (lambda (_where961_ _what962_ . _irritants963_)
      (raise (make-struct-instance
              std/db/dbi#sql-error::t
              _what962_
              _irritants963_
              _where961_))))
  (define std/db/dbi#sql-connect
    (lambda (_connect956_ . _args957_)
      (let ((_conn959_ (apply _connect956_ _args957_)))
        (make-will _conn959_ std/db/dbi#sql-close)
        _conn959_)))
  (define std/db/dbi#sql-close
    (lambda (_conn906_)
      (let* ((_conn907916_ _conn906_)
             (_E909920_ (lambda () (error '"No clause matching" _conn907916_)))
             (_K910933_
              (lambda (_txn-abort923_ _txn-commit924_ _txn-begin925_ _e926_)
                (if _e926_
                    (with-unwind-protect
                     (lambda ()
                       (if _txn-begin925_
                           (with-exception-catcher
                            void
                            (lambda ()
                              (let ((__method4734
                                     (method-ref _txn-begin925_ 'finalize)))
                                (if __method4734
                                    (__method4734 _txn-begin925_)
                                    (error '"Missing method"
                                           _txn-begin925_
                                           'finalize)))))
                           '#!void)
                       (if _txn-commit924_
                           (with-exception-catcher
                            void
                            (lambda ()
                              (let ((__method4735
                                     (method-ref _txn-commit924_ 'finalize)))
                                (if __method4735
                                    (__method4735 _txn-commit924_)
                                    (error '"Missing method"
                                           _txn-commit924_
                                           'finalize)))))
                           '#!void)
                       (if _txn-abort923_
                           (with-exception-catcher
                            void
                            (lambda ()
                              (let ((__method4736
                                     (method-ref _txn-abort923_ 'finalize)))
                                (if __method4736
                                    (__method4736 _txn-abort923_)
                                    (error '"Missing method"
                                           _txn-abort923_
                                           'finalize)))))
                           '#!void)
                       (let ((__method4737 (method-ref _conn906_ 'close)))
                         (if __method4737
                             (__method4737 _conn906_)
                             (error '"Missing method" _conn906_ 'close))))
                     (lambda ()
                       (##structure-set!
                        _conn906_
                        '#f
                        '1
                        std/db/dbi#connection::t
                        '#f)
                       (##structure-set!
                        _conn906_
                        '#f
                        '2
                        std/db/dbi#connection::t
                        '#f)
                       (##structure-set!
                        _conn906_
                        '#f
                        '3
                        std/db/dbi#connection::t
                        '#f)
                       (##structure-set!
                        _conn906_
                        '#f
                        '4
                        std/db/dbi#connection::t
                        '#f)))
                    '#!void))))
        (if (let ()
              (declare (not safe))
              (##structure-instance-of?
               _conn907916_
               'std/db/dbi#connection::t))
            (let* ((_e911936_
                    (let ()
                      (declare (not safe))
                      (##vector-ref _conn907916_ '1)))
                   (_e939_ _e911936_)
                   (_e912941_
                    (let ()
                      (declare (not safe))
                      (##vector-ref _conn907916_ '2)))
                   (_txn-begin944_ _e912941_)
                   (_e913946_
                    (let ()
                      (declare (not safe))
                      (##vector-ref _conn907916_ '3)))
                   (_txn-commit949_ _e913946_)
                   (_e914951_
                    (let ()
                      (declare (not safe))
                      (##vector-ref _conn907916_ '4)))
                   (_txn-abort954_ _e914951_))
              (_K910933_ _txn-abort954_ _txn-commit949_ _txn-begin944_ _e939_))
            (_E909920_)))))
  (define std/db/dbi#connection::destroy std/db/dbi#sql-close)
  (bind-method!
   std/db/dbi#connection::t
   'destroy
   std/db/dbi#connection::destroy
   '#f)
  (define std/db/dbi#sql-txn-do
    (lambda (_conn752_ _sql753_ _getf754_ _setf755_)
      (let* ((_conn756762_ _conn752_)
             (_E758766_ (lambda () (error '"No clause matching" _conn756762_)))
             (_K759776_
              (lambda (_e769_)
                (if (not _e769_)
                    (error '"Invalid operation; connection closed" _conn752_)
                    (let ((_$e771_ (_getf754_ _conn752_)))
                      (if _$e771_
                          (std/db/dbi#sql-exec _$e771_)
                          (let ((_stmt774_
                                 (let ((__method4738
                                        (method-ref _conn752_ 'prepare)))
                                   (if __method4738
                                       (__method4738 _conn752_ _sql753_)
                                       (error '"Missing method"
                                              _conn752_
                                              'prepare)))))
                            (_setf755_ _conn752_ _stmt774_)
                            (std/db/dbi#sql-exec _stmt774_))))))))
        (if (let ()
              (declare (not safe))
              (##structure-instance-of?
               _conn756762_
               'std/db/dbi#connection::t))
            (let* ((_e760779_
                    (let ()
                      (declare (not safe))
                      (##vector-ref _conn756762_ '1)))
                   (_e782_ _e760779_))
              (_K759776_ _e782_))
            (_E758766_)))))
  (define std/db/dbi#sql-txn-begin
    (lambda (_conn750_)
      (std/db/dbi#sql-txn-do
       _conn750_
       '"BEGIN TRANSACTION"
       std/db/dbi#connection-txn-begin
       std/db/dbi#connection-txn-begin-set!)))
  (define std/db/dbi#sql-txn-commit
    (lambda (_conn748_)
      (std/db/dbi#sql-txn-do
       _conn748_
       '"COMMIT"
       std/db/dbi#connection-txn-commit
       std/db/dbi#connection-txn-commit-set!)))
  (define std/db/dbi#sql-txn-abort
    (lambda (_conn746_)
      (std/db/dbi#sql-txn-do
       _conn746_
       '"ROLLBACK"
       std/db/dbi#connection-txn-abort
       std/db/dbi#connection-txn-abort-set!)))
  (define std/db/dbi#sql-prepare
    (lambda (_conn741_ _text742_)
      (if (##structure-ref _conn741_ '1 std/db/dbi#connection::t '#f)
          (let ((_stmt744_
                 (let ((__method4739 (method-ref _conn741_ 'prepare)))
                   (if __method4739
                       (__method4739 _conn741_ _text742_)
                       (error '"Missing method" _conn741_ 'prepare)))))
            (make-will _stmt744_ std/db/dbi#sql-finalize)
            _stmt744_)
          (error '"Invalid operation; connection closed" _conn741_))))
  (define std/db/dbi#sql-finalize
    (lambda (_stmt737_)
      (if (##structure-ref _stmt737_ '1 std/db/dbi#statement::t '#f)
          (with-unwind-protect
           (lambda ()
             (let ((__method4740 (method-ref _stmt737_ 'finalize)))
               (if __method4740
                   (__method4740 _stmt737_)
                   (error '"Missing method" _stmt737_ 'finalize))))
           (lambda ()
             (##structure-set! _stmt737_ '#f '1 std/db/dbi#statement::t '#f)))
          '#!void)))
  (define std/db/dbi#statement::destroy std/db/dbi#sql-finalize)
  (bind-method!
   std/db/dbi#statement::t
   'destroy
   std/db/dbi#statement::destroy
   '#f)
  (define std/db/dbi#sql-bind
    (lambda (_stmt612_ . _args613_)
      (if (##structure-ref _stmt612_ '1 std/db/dbi#statement::t '#f)
          (apply call-method _stmt612_ 'bind _args613_)
          (error '"Invalid operation; statement finalized" _stmt612_))))
  (define std/db/dbi#sql-clear
    (lambda (_stmt610_)
      (if (##structure-ref _stmt610_ '1 std/db/dbi#statement::t '#f)
          (let ((__method4741 (method-ref _stmt610_ 'clear)))
            (if __method4741
                (__method4741 _stmt610_)
                (error '"Missing method" _stmt610_ 'clear)))
          (error '"Invalid operation; statement finalized" _stmt610_))))
  (define std/db/dbi#sql-reset
    (lambda (_stmt608_)
      (if (##structure-ref _stmt608_ '1 std/db/dbi#statement::t '#f)
          (let ((__method4742 (method-ref _stmt608_ 'reset)))
            (if __method4742
                (__method4742 _stmt608_)
                (error '"Missing method" _stmt608_ 'reset)))
          (error '"Invalid operation; statement finalized" _stmt608_))))
  (define std/db/dbi#sql-reset/clear
    (lambda (_stmt606_)
      (if (##structure-ref _stmt606_ '1 std/db/dbi#statement::t '#f)
          (begin
            (let ((__method4743 (method-ref _stmt606_ 'reset)))
              (if __method4743
                  (__method4743 _stmt606_)
                  (error '"Missing method" _stmt606_ 'reset)))
            (let ((__method4744 (method-ref _stmt606_ 'clear)))
              (if __method4744
                  (__method4744 _stmt606_)
                  (error '"Missing method" _stmt606_ 'clear))))
          (error '"Invalid operation; statement finalized" _stmt606_))))
  (define std/db/dbi#sql-eval-e
    (lambda (_eval-e597_ _conn598_ _sql599_ _args600_)
      (let ((_stmt602_ (std/db/dbi#sql-prepare _conn598_ _sql599_)))
        (with-unwind-protect
         (lambda ()
           (if (null? _args600_)
               '#!void
               (apply std/db/dbi#sql-bind _stmt602_ _args600_))
           (_eval-e597_ _stmt602_))
         (lambda () (std/db/dbi#sql-finalize _stmt602_))))))
  (define std/db/dbi#sql-eval
    (lambda (_conn593_ _sql594_ . _args595_)
      (std/db/dbi#sql-eval-e
       std/db/dbi#sql-exec
       _conn593_
       _sql594_
       _args595_)))
  (define std/db/dbi#sql-eval-query
    (lambda (_conn589_ _sql590_ . _args591_)
      (std/db/dbi#sql-eval-e
       std/db/dbi#sql-query
       _conn589_
       _sql590_
       _args591_)))
  (define std/db/dbi#sql-exec
    (lambda (_stmt587_)
      (if (##structure-ref _stmt587_ '1 std/db/dbi#statement::t '#f)
          (begin
            (let ((__method4745 (method-ref _stmt587_ 'exec)))
              (if __method4745
                  (__method4745 _stmt587_)
                  (error '"Missing method" _stmt587_ 'exec)))
            (let ((__method4746 (method-ref _stmt587_ 'reset)))
              (if __method4746
                  (__method4746 _stmt587_)
                  (error '"Missing method" _stmt587_ 'reset)))
            '#!void)
          (error '"Invalid operation; statement finalized" _stmt587_))))
  (define std/db/dbi#sql-query
    (lambda (_stmt533_)
      (let ((_iterable556_ (std/db/dbi#in-sql-query _stmt533_))
            (_iter-do558_
             (lambda (_val535_)
               (let* ((_val537542_ _val535_)
                      (_E539546_
                       (lambda () (error '"No clause matching" _val537542_)))
                      (_K540551_ (lambda (_row549_) _row549_))
                      (_row554_ _val537542_))
                 (_K540551_ _row554_)))))
        (if (pair? _iterable556_)
            (map _iter-do558_ _iterable556_)
            (if (null? _iterable556_)
                '()
                (let* ((_it561_ (std/iter#iter _iterable556_))
                       (_next!564_
                        (let ()
                          (declare (not safe))
                          (##unchecked-structure-ref
                           _it561_
                           '2
                           std/iter#iterator::t
                           '#f))))
                  (declare (not safe))
                  (let _lp569_ ((_rval572_ '()))
                    (let ((_val575_ (_next!564_ _it561_)))
                      (if (eq? std/iter#iter-end _val575_)
                          (begin
                            (let ((_$e577_ (##unchecked-structure-ref
                                            _it561_
                                            '3
                                            std/iter#iterator::t
                                            '#f)))
                              (if _$e577_
                                  ((lambda (_g579581_) (_g579581_ _it561_))
                                   _$e577_)
                                  '#!void))
                            (reverse _rval572_))
                          (let ((_xval584_ (_iter-do558_ _val575_)))
                            (_lp569_ (cons _xval584_ _rval572_))))))))))))
  (define std/db/dbi#:iter::statement
    (lambda (_stmt531_) (std/db/dbi#in-sql-query _stmt531_)))
  (std/generic/dispatch#generic-bind!
   std/iter#:iter::t
   (cons (std/generic/dispatch#type-linearize-class std/db/dbi#statement::t)
         '())
   std/db/dbi#:iter::statement)
  (define std/db/dbi#in-sql-query
    (lambda (_stmt407_)
      (letrec ((_next409_
                (lambda (_it438_)
                  (let* ((_it439445_ _it438_)
                         (_E441449_
                          (lambda () (error '"No clause matching" _it439445_)))
                         (_K442456_
                          (lambda (_stmt452_)
                            (let ((_r454_ (let ((__method4747
                                                 (method-ref
                                                  _stmt452_
                                                  'query-fetch)))
                                            (if __method4747
                                                (__method4747 _stmt452_)
                                                (error '"Missing method"
                                                       _stmt452_
                                                       'query-fetch)))))
                              (if (std/iter#iter-end? _r454_)
                                  std/iter#iter-end
                                  (let ((__method4748
                                         (method-ref _stmt452_ 'query-row)))
                                    (if __method4748
                                        (__method4748 _stmt452_)
                                        (error '"Missing method"
                                               _stmt452_
                                               'query-row))))))))
                    (if (let ()
                          (declare (not safe))
                          (##structure-direct-instance-of?
                           _it439445_
                           'std/iter#iterator::t))
                        (let* ((_e443459_
                                (let ()
                                  (declare (not safe))
                                  (##vector-ref _it439445_ '1)))
                               (_stmt462_ _e443459_))
                          (_K442456_ _stmt462_))
                        (_E441449_)))))
               (_fini410_
                (lambda (_it414_)
                  (let* ((_it415421_ _it414_)
                         (_E417425_
                          (lambda () (error '"No clause matching" _it415421_)))
                         (_K418430_
                          (lambda (_stmt428_)
                            (if _stmt428_
                                (begin
                                  (let ((__method4749
                                         (method-ref _stmt428_ 'query-fini)))
                                    (if __method4749
                                        (__method4749 _stmt428_)
                                        (error '"Missing method"
                                               _stmt428_
                                               'query-fini)))
                                  (##direct-structure-set!
                                   _it414_
                                   '#f
                                   '1
                                   std/iter#iterator::t
                                   '#f))
                                '#!void))))
                    (if (let ()
                          (declare (not safe))
                          (##structure-direct-instance-of?
                           _it415421_
                           'std/iter#iterator::t))
                        (let* ((_e419433_
                                (let ()
                                  (declare (not safe))
                                  (##vector-ref _it415421_ '1)))
                               (_stmt436_ _e419433_))
                          (_K418430_ _stmt436_))
                        (_E417425_))))))
        (if (##structure-ref _stmt407_ '1 std/db/dbi#statement::t '#f)
            (let ((_it412_ (let ((__obj4750
                                  (make-object std/iter#iterator::t '3)))
                             (if (let ((__tmp4754
                                        (let ()
                                          (declare (not safe))
                                          (##vector-length __obj4750))))
                                   (declare (not safe))
                                   (##fx< '3 __tmp4754))
                                 (begin
                                   (let ()
                                     (declare (not safe))
                                     (##vector-set! __obj4750 '1 _stmt407_))
                                   (let ()
                                     (declare (not safe))
                                     (##vector-set! __obj4750 '2 _next409_))
                                   (let ()
                                     (declare (not safe))
                                     (##vector-set! __obj4750 '3 _fini410_)))
                                 (error '"struct-instance-init!: too many arguments for struct"
                                        __obj4750))
                             __obj4750)))
              (make-will _it412_ _fini410_)
              (let ((__method4751 (method-ref _stmt407_ 'query-start)))
                (if __method4751
                    (__method4751 _stmt407_)
                    (error '"Missing method" _stmt407_ 'query-start)))
              _it412_)
            (error '"Invalid operation; statement finalized" _stmt407_)))))
  (define std/db/dbi#sql-columns
    (lambda (_stmt405_)
      (if (##structure-ref _stmt405_ '1 std/db/dbi#statement::t '#f)
          (let ((__method4752 (method-ref _stmt405_ 'columns)))
            (if __method4752
                (__method4752 _stmt405_)
                (error '"Missing method" _stmt405_ 'columns)))
          (error '"Invalid operation; statement finalized" _stmt405_)))))
