From fc6e46a000589bffc1a1b69cb3fe13bcbaade59b Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Fri, 28 May 2004 19:03:58 +0000 Subject: [PATCH 1/1] r9508: condition fixes --- ChangeLog | 4 + db-mysql/mysql-sql.lisp | 2 +- db-oracle/oracle-sql.lisp | 6 +- doc/clsql.xml | 2 +- doc/{ref_clsql.xml => ref-clsql.xml} | 406 +++++---------------------- 5 files changed, 73 insertions(+), 347 deletions(-) rename doc/{ref_clsql.xml => ref-clsql.xml} (84%) diff --git a/ChangeLog b/ChangeLog index f347578..f682d2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,10 @@ * doc/appendix.xml: Add Oracle backend information * db-oracle/oracle-objects.lisp: Add database-get-type-specifier for universal-time. Convert BIGINT CLSQL type to CHAR SQL type + * db-mysql/mysql-sql.lisp: Fix condition name to sql-connection-error + * doc/ref-clsql.xml: Renamed from ref_clsql.xml. Change the documentation + for map-query to reflect changed in arguments to be CommonSQL compatible. + Updated old clsql conditions to new CommonSQL compatible conditions. 25 May 2004 Kevin Rosenberg * sql/oodml.lisp: (string n) now produces a CHAR field. Add new VARCHAR diff --git a/db-mysql/mysql-sql.lisp b/db-mysql/mysql-sql.lisp index f85ffac..513c9ed 100644 --- a/db-mysql/mysql-sql.lisp +++ b/db-mysql/mysql-sql.lisp @@ -117,7 +117,7 @@ db-native 0 socket-native 0)) (progn (setq error-occurred t) - (error 'sql-connect-error + (error 'sql-connection-error :database-type database-type :connection-spec connection-spec :error-id (mysql-errno mysql-ptr) diff --git a/db-oracle/oracle-sql.lisp b/db-oracle/oracle-sql.lisp index 119a669..222e030 100644 --- a/db-oracle/oracle-sql.lisp +++ b/db-oracle/oracle-sql.lisp @@ -397,11 +397,7 @@ the length of that format.") (#.SQLT-INT (ecase (cd-sizeof cd) (4 - (uffi:deref-array b '(:array :int) irow)) - (8 - (deref-oci-int64 b irow)) - (16 - (deref-oci-int128 b irow)))) + (uffi:deref-array b '(:array :int) irow)))) (#.SQLT-DATE (deref-oci-string b irow (cd-sizeof cd)))))))) (when (and (eq :string (cd-result-type cd)) diff --git a/doc/clsql.xml b/doc/clsql.xml index 3b2ecc9..561316f 100644 --- a/doc/clsql.xml +++ b/doc/clsql.xml @@ -12,7 +12,7 @@ - + diff --git a/doc/ref_clsql.xml b/doc/ref-clsql.xml similarity index 84% rename from doc/ref_clsql.xml rename to doc/ref-clsql.xml index c24b2ce..fc99b08 100644 --- a/doc/ref_clsql.xml +++ b/doc/ref-clsql.xml @@ -9,15 +9,14 @@ <symbol>CLSQL</symbol> This part gives a reference to the symbols exported from the - package CLSQL-SYS, which are also re-exported - from the package CLSQL. These symbols constitute + CLSQL package. These symbols constitute the normal user-interface of &clsql;. Currently, the symbols of the &commonsql;-API are not documented here. - + - CLSQL-CONDITION + SQL-CONDITION the super-type of all &clsql;-specific conditions @@ -27,7 +26,7 @@ Class Precedence List - clsql-condition + sql-condition condition t @@ -42,9 +41,9 @@ initialization arguments nor any accessors. - + - CLSQL-ERROR + SQL-ERROR the super-type of all &clsql;-specific errors @@ -54,10 +53,10 @@ Class Precedence List - clsql-error + sql-error error serious-condition - clsql-condition + sql-condition condition t @@ -73,40 +72,9 @@ initialization arguments nor any accessors. - + - CLSQL-SIMPLE-ERROR - Unspecific simple - &clsql; errors - Condition Type - - - Class Precedence List - - - clsql-simple-error - simple-condition - clsql-error - error - serious-condition - clsql-condition - condition - t - - - - - Description - This condition is used in all instances of errors, where - there exists no &clsql;-specific - condition that is more specific. The valid initialization - arguments and accessors are the same as for - simple-condition. - - - - - CLSQL-WARNING + SQL-WARNING the super-type of all &clsql;-specific warnings @@ -116,9 +84,9 @@ Class Precedence List - clsql-warning + sql-warning warning - clsql-condition + sql-condition condition t @@ -134,54 +102,20 @@ initialization arguments nor any accessors. - - - CLSQL-SIMPLE-WARNING - Unspecific simple - &clsql; warnings - Condition Type - - - Class Precedence List - - - clsql-simple-warning - simple-condition - clsql-warning - warning - clsql-condition - condition - t - - - - - Description - This condition is used in all instances of warnings, - where there exists no - &clsql;-specific condition that is - more specific. The valid initialization arguments and - accessors are the same as for - simple-condition. - - - + - CLSQL-INVALID-SPEC-ERROR + CLSQL-USER-ERROR condition representing errors because of invalid - connection specifications + parameters from the library user. Condition Type Class Precedence List - clsql-invalid-spec-error - clsql-error - error - serious-condition - clsql-condition + sql-error + sql-condition condition t @@ -190,36 +124,14 @@ Description This condition represents errors that occur because the - user supplies an invalid connection specification to either - database-name-from-spec or - connect. The following initialization - arguments and accessors exist: - - Initarg - Accessor - Description - - :connection-spec - clsql-invalid-spec-error-connection-spec - The invalid connection specification used. - - - :database-type - clsql-invalid-spec-error-database-type - The Database type used in the attempt. - - - :template - clsql-invalid-spec-error-template - An argument describing the template that a valid - connection specification must match for this database type. - - + user supplies invalid data to &clsql;. This includes errors such as + an invalid format connection specification or an error in the syntax + for the LOOP macro extensions. - + - CLSQL-CONNECT-ERROR + SQL-CONNECTION-ERROR condition representing errors during connection Condition Type @@ -228,11 +140,10 @@ Class Precedence List - clsql-connect-error - clsql-error - error - serious-condition - clsql-condition + sql-connection-error + sql-database-error + sql-error + sql-condition condition t @@ -249,34 +160,34 @@ Description :database-type - clsql-connect-error-database-type + sql-connection-error-database-type Database type for the connection attempt :connection-spec - clsql-connect-error-connection-spec + sql-connection-error-connection-spec The connection specification used in the connection attempt. :errno - clsql-connect-error-errno + sql-connection-error-errno The numeric or symbolic error specification returned by the database back-end. The values and semantics of this are interface specific. :error - clsql-connect-error-error + sql-connection-error-error A string describing the problem that occurred, possibly one returned by the database back-end. - + - CLSQL-SQL-ERROR + SQL-DATABASE-ERROR condition representing errors during query or command execution Condition Type @@ -285,11 +196,11 @@ Class Precedence List - clsql-sql-error - clsql-error + sql-database-error + sql-error error serious-condition - clsql-condition + sql-condition condition t @@ -308,217 +219,31 @@ Description :database - clsql-sql-error-database + sql-database-error-database The database object that was involved in the incident. :expression - clsql-sql-error-expression + sql-database-error-expression The SQL expression whose execution caused the error. :errno - clsql-sql-error-errno + sql-database-error-errno The numeric or symbolic error specification returned by the database back-end. The values and semantics of this are interface specific. :error - clsql-sql-error-error + sql-database-error-error A string describing the problem that occurred, possibly one returned by the database back-end. - - - CLSQL-EXISTS-CONDITION - condition indicating situations arising because of - existing connections - Condition Type - - - Class Precedence List - - - clsql-exists-condition - clsql-condition - condition - t - - - - - Description - This condition is the super-type of all conditions which - represents problems that occur during calls to - connect, if a connection to the - database exists already. Depending on the value of - if-exists to the call of - connect, either a warning, an error or - no condition at all is signalled. If a warning or error is - signalled, either - clsql-exists-warning or - clsql-exists-error is signalled, - which are subtypes of - clsql-exists-condition and - clsql-warning or - clsql-error. - clsql-exists-condition is never - signalled itself. - - The following initialization arguments and accessors exist: - - Initarg - Accessor - Description - - :old-db - clsql-exists-condition-old-db - The database object that represents the existing - connection. This slot is always filled. - - - :new-db - clsql-exists-condition-new-db - The database object that will be used and returned by - this call to connect, if execution continues normally. - This can be either nil, indicating that - a new database object is to be created on continuation, - or a database object representing the newly created - continuation, or the same database object as - old-db, indicating that the existing - database object will be reused. This slot is always - filled and defaults to nil. - - - - - - - CLSQL-EXISTS-WARNING - condition representing warnings arising because of - existing connections - Condition Type - - - Class Precedence List - - - clsql-exists-warning - clsql-exists-condition - clsql-warning - warning - clsql-condition - condition - t - - - - - Description - This condition is a subtype of - clsql-exists-condition, and is - signalled during calls to connect when - there is an existing connection, and - if-exists is either - :warn-new or :warn-old. - In the former case, new-db will be the - newly created database object, in the latter case it will be - the existing old database object. - - The initialization arguments and accessors are the same as - for clsql-exists-condition. - - - - - CLSQL-EXISTS-ERROR - condition representing errors arising because of - existing connections - Condition Type - - - Class Precedence List - - - clsql-exists-error - clsql-exists-condition - clsql-error - error - serious-condition - clsql-condition - condition - t - - - - - Description - This condition is a subtype of - clsql-exists-condition, and is - signalled during calls to connect when - there is an existing connection, and - if-exists is :error. - In this case, new-db will be - nil, indicating that the database object to - be returned by connect depends on user - action in continuing from this correctable error. - - The initialization arguments and accessors are the same as - for clsql-exists-condition. - - - - - CLSQL-CLOSED-ERROR - condition representing errors because the database - has already been closed - Condition Type - - - Class Precedence List - - - clsql-closed-error - clsql-error - error - serious-condition - clsql-condition - condition - t - - - - - Description - This condition represents errors that occur because the - user invokes an operation on the given database object, - although the database is invalid because - disconnect has already been called on - this database object. - Functions which signal this error when called with a - closed database will usually provide a - continue restart, that will just return nil - from the function. - - The following initialization arguments and accessors exist: - - Initarg - Accessor - Description - - :database - clsql-closed-error-database - The database object that was involved in the - incident. - - - - @@ -1467,7 +1192,7 @@ signalled. If during the connection attempt an error is detected (e.g. because of permission problems, network trouble or any other cause), an error of type - clsql-connect-error is + sql-connection-error is signalled. If a connection to the database specified by connection-spec exists already, @@ -2029,7 +1754,7 @@ Error: While trying to access database localhost/test2/root sql-expression in the database specified. If the execution succeeds it will return t, otherwise an - error of type clsql-sql-error will + error of type sql-database-error will be signalled. @@ -2055,7 +1780,7 @@ Error: While trying to access database localhost/test2/root >> #<unused-arg> >> #<unavailable-arg> >> #<unavailable-arg>) ->> Source: (ERROR 'CLSQL-SQL-ERROR :DATABASE DATABASE :EXPRESSION ...) +>> Source: (ERROR 'SQL-DATABASE-ERROR :DATABASE DATABASE :EXPRESSION ...) >> 0] 0 (execute-command "drop table eventlog") @@ -2075,7 +1800,7 @@ Error: While trying to access database localhost/test2/root Exceptional Situations If the execution of the SQL statement leads to any errors, an error of type - clsql-sql-error is signalled. + sql-database-error is signalled. See Also @@ -2191,7 +1916,7 @@ Error: While trying to access database localhost/test2/root database specified. If the execution succeeds it will return the result set returned by the database, otherwise an error of type - clsql-sql-error will + sql-database-error will be signalled. @@ -2234,7 +1959,7 @@ Error: While trying to access database localhost/test2/root Exceptional Situations If the execution of the SQL query leads to any errors, an error of type - clsql-sql-error is signalled. + sql-database-error is signalled. See Also @@ -2274,10 +1999,9 @@ Error: While trying to access database localhost/test2/root function A function designator. - function must take as many - arguments as are attributes in the result set returned - by executing the SQL - query-expression. + function takes a single argument which + is the atom value for a query single with a single column + or is a list of values for a multi-column query. @@ -2286,8 +2010,7 @@ Error: While trying to access database localhost/test2/root An sql expression that represents an SQL query which is expected to return a (possibly empty) - result set, where each tuple has as many attributes as - function takes arguments. + result set. @@ -2324,7 +2047,7 @@ Error: While trying to access database localhost/test2/root Description Applies function to the - attributes of successive tuples in the result set returned + successive tuples in the result set returned by executing the SQL query-expression. If the output-type-spec is @@ -2357,25 +2080,28 @@ Error: While trying to access database localhost/test2/root Examples -(map-query 'list #'(lambda (salary name) - (declare (ignorable name)) - (read-from-string salary)) +(map-query 'list #'(lambda (tuple) + (multiple-value-bind (salary name) tuple + (declare (ignorable name)) + (read-from-string salary))) "select salary,name from simple where salary > 8000") => (10000.0 8000.5) (map-query '(vector double-float) - #'(lambda (salary name) - (declare (ignorable name)) - (let ((*read-default-float-format* 'double-float)) - (coerce (read-from-string salary) 'double-float)) - "select salary,name from simple where salary > 8000")) + #'(lambda (tuple) + (multiple-value-bind (salary name) tuple + (declare (ignorable name)) + (let ((*read-default-float-format* 'double-float)) + (coerce (read-from-string salary) 'double-float)) + "select salary,name from simple where salary > 8000"))) => #(10000.0d0 8000.5d0) (type-of *) => (SIMPLE-ARRAY DOUBLE-FLOAT (2)) (let (list) - (values (map-query nil #'(lambda (salary name) - (push (cons name (read-from-string salary)) list)) + (values (map-query nil #'(lambda (tuple) + (multiple-value-bind (salary name) tuple + (push (cons name (read-from-string salary)) list)) "select salary,name from simple where salary > 8000") list)) => NIL @@ -2395,7 +2121,7 @@ Error: While trying to access database localhost/test2/root Exceptional Situations If the execution of the SQL query leads to any errors, an error of type - clsql-sql-error is signalled. + sql-database-error is signalled. An error of type type-error must be signaled if the output-type-spec is not a recognizable subtype of list, not a @@ -2529,7 +2255,7 @@ Error: While trying to access database localhost/test2/root Exceptional Situations If the execution of the SQL query leads to any errors, an error of type - clsql-sql-error is signalled. + sql-database-error is signalled. If the number of variable names in args and the number of attributes in the tuples in the result set don't match up, an error is @@ -2666,7 +2392,7 @@ Error: While trying to access database localhost/test2/root Exceptional Situations If the execution of the SQL query leads to any errors, an error of type - clsql-sql-error is signalled. + sql-database-error is signalled. Otherwise, any of the exceptional situations of loop applies. -- 2.34.1