r11228: * db-postgresql/postgresql-{package,api,sql}.lisp: Apply
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 16 Oct 2006 19:07:38 +0000 (19:07 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 16 Oct 2006 19:07:38 +0000 (19:07 +0000)
        changes from Andew Golding to use a more-specific error code
        from PostgreSQL than the generic fatal error code of the result set.

ChangeLog
db-postgresql/postgresql-api.lisp
db-postgresql/postgresql-package.lisp
db-postgresql/postgresql-sql.lisp
debian/changelog

index 685df98b829af32bc92d0d65ce46aeab7211c33b..1ea677010f682ff3b42af4f45a8c42e102040b38 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 16 Oct 2006  Kevin Rosenberg <kevin@rosenberg.net>
 16 Oct 2006  Kevin Rosenberg <kevin@rosenberg.net>
+       * Version 3.7.5
        * doc/intro.xml: Update supported platforms.
        * doc/intro.xml: Update supported platforms.
+       * db-postgresql/postgresql-{package,api,sql}.lisp: Apply
+       changes from Andew Golding to use a more-specific error code
+       from PostgreSQL than the generic fatal error code of the result set.
 
 03 Oct 2006  Kevin Rosenberg <kevin@rosenberg.net>
        * sql/syntax.lisp: Commit patch from Marcus Pearce to improve
 
 03 Oct 2006  Kevin Rosenberg <kevin@rosenberg.net>
        * sql/syntax.lisp: Commit patch from Marcus Pearce to improve
index 6f4908f0e32e99dd672a2f0415f3f8140fc0a174..b006bf655a733f89f12dd06d1f8965c3ad01655e 100644 (file)
   :module "postgresql"
   :returning pgsql-exec-status-type)
 
   :module "postgresql"
   :returning pgsql-exec-status-type)
 
+; From postgres_ext.h
+
+; #define PG_DIAG_SEVERITY                'S'
+; #define PG_DIAG_SQLSTATE                'C'
+; #define PG_DIAG_MESSAGE_PRIMARY 'M'
+; #define PG_DIAG_MESSAGE_DETAIL  'D'
+; #define PG_DIAG_MESSAGE_HINT    'H'
+; #define PG_DIAG_STATEMENT_POSITION 'P'
+; #define PG_DIAG_INTERNAL_POSITION 'p'
+; #define PG_DIAG_INTERNAL_QUERY  'q'
+; #define PG_DIAG_CONTEXT                 'W'
+; #define PG_DIAG_SOURCE_FILE             'F'
+; #define PG_DIAG_SOURCE_LINE             'L'
+; #define PG_DIAG_SOURCE_FUNCTION 'R'
+(defconstant +PG-DIAG-SEVERITY+ (char-code #\S))
+(defconstant +PG-DIAG-SQLSTATE+ (char-code #\C))
+(defconstant +PG-DIAG-MESSAGE-PRIMARY+ (char-code #\M))
+(defconstant +PG-DIAG-MESSAGE-DETAIL+ (char-code #\D))
+(defconstant +PG-DIAG-MESSAGE-HINT+ (char-code #\H))
+(defconstant +PG-DIAG-STATEMENT-POSITION+ (char-code #\P))
+(defconstant +PG-DIAG-INTERNAL-POSITION+ (char-code #\p))
+(defconstant +PG-DIAG-INTERNAL-QUERY+ (char-code #\q))
+(defconstant +PG-DIAG-CONTEXT+ (char-code #\W))
+(defconstant +PG-DIAG-SOURCE-FILE+ (char-code #\F))
+(defconstant +PG-DIAG-SOURCE-LINE+ (char-code #\L))
+(defconstant +PG-DIAG-SOURCE-FUNCTION+ (char-code #\R))
+
+; PQresultErrorField can return diagnostic information about an error
+(declaim (inline PQresultErrorField))
+(uffi:def-function ("PQresultErrorField" PQresultErrorField)
+    ((res pgsql-result)
+     (field-code :int))
+  :module "postgresql"
+  :returning (* char))
+
 (declaim (inline PQresultErrorMessage))
 (uffi:def-function ("PQresultErrorMessage" PQresultErrorMessage)
   ((res pgsql-result))
 (declaim (inline PQresultErrorMessage))
 (uffi:def-function ("PQresultErrorMessage" PQresultErrorMessage)
   ((res pgsql-result))
index 32ea77db7c68e8a46f2ea84b72725f9957e84f55..080eaf96ad5ca6a568bf3f0e1bd57905355f731d 100644 (file)
      #:pgsql-ftype#int8
      #:pgsql-ftype#float4
      #:pgsql-ftype#float8
      #:pgsql-ftype#int8
      #:pgsql-ftype#float4
      #:pgsql-ftype#float8
+
+     ;; Used by PQresultErrorField to get the sql error code
+     #:+PG-DIAG-SQLSTATE+
+
      
      ;; Functions
      #:PQsetdbLogin
      
      ;; Functions
      #:PQsetdbLogin
@@ -53,6 +57,7 @@
      #:PQerrorMessage
      #:PQexec
      #:PQresultStatus
      #:PQerrorMessage
      #:PQexec
      #:PQresultStatus
+     #:PQresultErrorField ; used to grab the SQLSTATE code from an error
      #:PQresultErrorMessage
      #:PQntuples
      #:PQnfields
      #:PQresultErrorMessage
      #:PQntuples
      #:PQnfields
index d5a13f29befdbbc5eb86c7a5737e2a98e41f9954..2d74fc1179e160d765645b66597038a2344080d9 100644 (file)
                (error 'sql-database-data-error
                       :database database
                       :expression sql-expression
                (error 'sql-database-data-error
                       :database database
                       :expression sql-expression
-                      :error-id (PQresultStatus result)
+                      :error-id (uffi:convert-from-foreign-string (PQresultErrorField result +PG-DIAG-SQLSTATE+))
                       :message (tidy-error-message
                                (PQresultErrorMessage result)))))
           (PQclear result))))))
                       :message (tidy-error-message
                                (PQresultErrorMessage result)))))
           (PQclear result))))))
index 6b59a0a58be4e64b65931fae93165f2cf86cbb9a..f519bf45d1d5e0e0999e03d655f8b89c869d153c 100644 (file)
@@ -1,3 +1,9 @@
+cl-sql (3.7.5-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Mon, 16 Oct 2006 13:05:53 -0600
+
 cl-sql (3.7.4-1) unstable; urgency=low
 
   * New upstream
 cl-sql (3.7.4-1) unstable; urgency=low
 
   * New upstream