r9309: fix recording reversion
[clsql.git] / base / basic-sql.lisp
index df5d93b840c27ae9218718668b9bc5e0b5294806..a7d32cfba64a92d3278750975fae24c2f92929cb 100644 (file)
@@ -1,8 +1,18 @@
 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; *************************************************************************
-;;;;  $Id: $
+;;;;
+;;;; $Id$
+;;;;
+;;;; Base SQL functions
+;;;;
+;;;; This file is part of CLSQL.
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+;;;; *************************************************************************
 
-(in-package #:clsql-base-sys)
+(in-package #:clsql-base)
 
 ;;; Query
 
@@ -20,16 +30,17 @@ one result per row. Returns a list of lists of values of the result of
 that expression and a list of field names selected in sql-exp."))
 
 (defmethod query ((query-expression string) &key (database *default-database*)
-                  (result-types nil) (flatp nil))
+                  (result-types :auto) (flatp nil) (field-names t))
   (record-sql-command query-expression database)
-  (let* ((res (database-query query-expression database result-types))
-         (res (if (and flatp (= (length
-                                 (slot-value query-expression 'selections))
-                                1))
-                  (mapcar #'car res)
-                  res)))
-    (record-sql-result res database)
-    res))
+  (multiple-value-bind (rows names) (database-query query-expression database result-types
+                                                    field-names)
+    (let ((result (if (and flatp (= 1 (length (car rows))))
+                      (mapcar #'car rows)
+                    rows)))
+      (record-sql-result result database)
+      (if field-names
+         (values result names)
+       result))))
 
 ;;; Execute
 
@@ -49,4 +60,21 @@ pair."))
     (record-sql-result res database))
   (values))
 
+;;; Large objects support
+
+(defun create-large-object (&key (database *default-database*))
+  "Creates a new large object in the database and returns the object identifier"
+  (database-create-large-object database))
+
+(defun write-large-object (object-id data &key (database *default-database*))
+  "Writes data to the large object"
+  (database-write-large-object object-id data database))
+
+(defun read-large-object (object-id &key (database *default-database*))
+  "Reads the large object content"
+  (database-read-large-object object-id database))
+
+(defun delete-large-object (object-id &key (database *default-database*))
+  "Deletes the large object in the database"
+  (database-delete-large-object object-id database))