16 Oct 2006 Kevin Rosenberg <kevin@rosenberg.net>
+ * Version 3.7.5
* 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
: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))
(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))))))