1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: postgresql.cl
6 ;;;; Purpose: Low-level PostgreSQL interface using UFFI
7 ;;;; Programmers: Kevin M. Rosenberg based on
8 ;;;; Original code by Pierre R. Mai
9 ;;;; Date Started: Feb 2002
11 ;;;; $Id: postgresql-api.cl,v 1.1 2002/03/23 17:10:48 kevin Exp $
13 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
14 ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
16 ;;;; CLSQL users are granted the rights to distribute and use this software
17 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
18 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
19 ;;;; *************************************************************************
21 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
22 (in-package :postgresql)
25 ;;;; This file implements as little of the FFI bindings to the
26 ;;;; PostgreSQL client libraries as we could get away with.
27 ;;;; Especially all the PostgreSQL-specific goodies aren't there, and
28 ;;;; we just use void pointers where we can get away with it, which
29 ;;;; thanks to the design of the PostgreSQL client libraries is pretty
30 ;;;; much everywhere, in contrast to the MySQL client libraries for
37 (uffi:def-foreign-type pgsql-oid :unsigned-int)
39 (uffi:def-enum pgsql-conn-status-type
43 (uffi:def-enum pgsql-exec-status-type
53 (uffi:def-foreign-type pgsql-conn :pointer-void)
54 (uffi:def-foreign-type pgsql-result :pointer-void)
56 ;;(declaim (inline PQsetdbLogin)) ;; causes compile error in LW 4.2.0
57 (uffi:def-function ("PQsetdbLogin" PQsetdbLogin)
65 :returning pgsql-conn)
67 (declaim (inline PQfinish))
68 (uffi:def-function ("PQfinish" PQfinish)
73 (declaim (inline PQstatus))
74 (uffi:def-function ("PQstatus" PQstatus)
77 :returning pgsql-conn-status-type)
79 (declaim (inline PQerrorMessage))
80 (uffi:def-function ("PQerrorMessage" PQerrorMessage)
85 (declaim (inline PQexec))
86 (uffi:def-function ("PQexec" PQexec)
90 :returning pgsql-result)
92 (declaim (inline PQresultStatus))
93 (uffi:def-function ("PQresultStatus" PQresultStatus)
96 :returning pgsql-exec-status-type)
98 (declaim (inline PQresultErrorMessage))
99 (uffi:def-function ("PQresultErrorMessage" PQresultErrorMessage)
104 (declaim (inline PQntuples))
105 (uffi:def-function ("PQntuples" PQntuples)
110 (declaim (inline PQnfields))
111 (uffi:def-function ("PQnfields" PQnfields)
116 (declaim (inline PQfname))
117 (uffi:def-function ("PQfname" PQfname)
123 (declaim (inline PQfnumber))
124 (uffi:def-function ("PQfnumber" PQfnumber)
126 (field-name :cstring))
130 (declaim (inline PQftype))
131 (uffi:def-function ("PQftype" PQftype)
135 :returning pgsql-oid)
137 (declaim (inline PQfsize))
138 (uffi:def-function ("PQfsize" PQfsize)
144 (declaim (inline PQcmdStatus))
145 (uffi:def-function ("PQcmdStatus" PQcmdStatus)
150 (declaim (inline PQoidStatus))
151 (uffi:def-function ("PQoidStatus" PQoidStatus)
156 (declaim (inline PQcmdTuples))
157 (uffi:def-function ("PQcmdTuples" PQcmdTuples)
162 (declaim (inline PQgetvalue))
163 (uffi:def-function ("PQgetvalue" PQgetvalue)
170 (declaim (inline PQgetlength))
171 (uffi:def-function ("PQgetlength" PQgetlength)
178 (declaim (inline PQgetisnull))
179 (uffi:def-function ("PQgetisnull" PQgetisnull)
186 (declaim (inline PQclear))
187 (uffi:def-function ("PQclear" PQclear)