X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-postgresql%2Fpostgresql-api.lisp;h=b006bf655a733f89f12dd06d1f8965c3ad01655e;hp=6f4908f0e32e99dd672a2f0415f3f8140fc0a174;hb=eb52183ddb786552d5abf6fdfaaca657e0c56ea0;hpb=4e884e357b399c1cf84e82ba3f95406f073811e4 diff --git a/db-postgresql/postgresql-api.lisp b/db-postgresql/postgresql-api.lisp index 6f4908f..b006bf6 100644 --- a/db-postgresql/postgresql-api.lisp +++ b/db-postgresql/postgresql-api.lisp @@ -105,6 +105,41 @@ :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))