+;; Prepared statements
+
+(defgeneric database-prepare (stmt types database result-types field-names)
+ (:method (stmt types (database t) result-types field-names)
+ (declare (ignore stmt types result-types field-names))
+ (signal-no-database-error database))
+ (:method (stmt types (database database) result-types field-names)
+ (declare (ignore stmt types result-types field-names))
+ (error 'sql-database-error
+ :message
+ (format nil "DATABASE-PREPARE not implemented for ~S" database)))
+ (:documentation "Prepare a statement for later execution."))
+
+(defgeneric database-bind-parameter (prepared-stmt position value)
+ (:method ((pstmt t) position value)
+ (declare (ignore position value))
+ (error 'sql-database-error
+ :message
+ (format nil "database-bind-paremeter not implemented for ~S" pstmt)))
+ (:documentation "Bind a parameter for a prepared statement."))
+
+(defgeneric database-run-prepared (prepared-stmt)
+ (:method ((pstmt t))
+ (error 'sql-database-error
+ :message (format nil "database-run-prepared not specialized for ~S" pstmt)))
+ (:documentation "Execute a prepared statement."))
+
+(defgeneric database-free-prepared (prepared-stmt)
+ (:method ((pstmt t))
+ ;; nothing to do by default
+ nil)
+ (:documentation "Free the resources of a prepared statement."))
+
+(defgeneric database-acquire-from-conn-pool (database)
+ (:documentation "Acquire a database connection from the pool. This
+is a chance to test the connection for validity before returning it to
+the user. If this function returns NIL or throws an error that
+database connection is considered bad and we make a new one.
+
+Database objects have a chance to specialize, otherwise the default
+method uses the database-underlying-type and tries to do something
+appropriate."))
+
+(defgeneric database-release-to-conn-pool (database)
+ (:documentation "Chance for the database to cleanup before it is
+ returned to the connection pool."))