annotate modules/postgresql/postgresql.c @ 5581:56144c8593a8

Mechanically change INT to FIXNUM in our sources. src/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT (where it refers to non-bignum Lisp integers) to FIXNUM in our sources. Done for the following functions, enums, and macros: Lisp_Type_Int_Even, Lisp_Type_Int_Odd, INT_GCBITS, INT_VALBITS, make_int(), INTP(), XINT(), CHECK_INT(), XREALINT(), INT_PLUS(), INT_MINUS(), EMACS_INT_MAX (to MOST_POSITIVE_FIXNUM), EMACS_INT_MIN (to MOST_NEGATIVE_FIXNUM), NUMBER_FITS_IN_AN_EMACS_INT() to NUMBER_FITS_IN_A_FIXNUM(), XFLOATINT, XCHAR_OR_INT, INT_OR_FLOAT. The EMACS_INT typedef was not changed, it does not describe non-bignum Lisp integers. Script that did the change available in http://mid.gmane.org/20067.17650.181273.12014@parhasard.net . modules/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers. See the src/ChangeLog entry for more details. man/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> * internals/internals.texi (How Lisp Objects Are Represented in C): * internals/internals.texi (Integers and Characters): Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 09 Oct 2011 09:51:57 +0100
parents 8bda66cd0414
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1 /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
2 postgresql.c -- Emacs Lisp binding to libpq.so
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
3 Copyright (C) 2000 Electrotechnical Laboratory, JAPAN.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
4 Licensed to the Free Software Foundation.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
5
3820
6ef4efc5cfe0 [xemacs-hg @ 2007-02-08 21:26:03 by adrian]
adrian
parents: 3024
diff changeset
6 Author: SL Baur <steve@xemacs.org>
6ef4efc5cfe0 [xemacs-hg @ 2007-02-08 21:26:03 by adrian]
adrian
parents: 3024
diff changeset
7 Maintainer: SL Baur <steve@xemacs.org>
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
8
5425
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
9 This file is part of XEmacs.
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
10
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
11 XEmacs is free software: you can redistribute it and/or modify it
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
12 under the terms of the GNU General Public License as published by the
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
13 Free Software Foundation, either version 3 of the License, or (at your
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
14 option) any later version.
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
15
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
16 XEmacs is distributed in the hope that it will be useful, but WITHOUT
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
19 for more details.
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
20
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
21 You should have received a copy of the GNU General Public License
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
22 along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
8bda66cd0414 Convert misc remaining files with GPLv2 or later to GPLv3 or later
Mats Lidell <matsl@xemacs.org>
parents: 5142
diff changeset
23
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
24 Please send patches to this file to me first before submitting them to
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
25 xemacs-patches.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
26
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
27
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
28 KNOWN PROBLEMS (Last update 15-March-2000)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
29 + None.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
30
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
31 Implementation notes:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
32 0. Supported PostgreSQL versions
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
33 This code was developed against libpq-6.5.3 and libpq-7.0-beta1. Earlier
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
34 versions may work. V7 support is more complete than V6.5 support.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
35 1. Mule
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
36 Non-ASCII databases have been tested on both 6.5 and 7.0.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
37 2. Asynchronous Operation
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
38 Starting with libpq-7.0, an asynchronous interface is offered. This
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
39 binding supports the asynchronous calls to a limited extent. Since the
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
40 XEmacs 21.2 core does not support a sensible interface to add managed but
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
41 unreadable (by XEmacs) file descriptors to the main select code, polling
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
42 is required to drive the asynchronous calls. XtAppAddInput would work
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
43 fine, but we want to be able to use the database when running strictly in
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
44 tty mode.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
45 3. Completeness
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
46 Various calls have been deliberately not exported to Lisp. The
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
47 unexported calls are either left-over backwards compatibility code that
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
48 aren't needed, calls that cannot be implemented sensibly, or calls that
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
49 cannot be implemented safely. A list of all global functions in libpq
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
50 but not exported to Lisp is below.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
51 4. Policy
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
52 This interface tries very hard to not set any policy towards how database
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
53 code in Emacs Lisp will be written.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
54 5. Documentation
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
55 For full lisp programming documentation, see the XEmacs Lisp Reference
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
56 Manual. For PostgreSQL documentation, see the PostgreSQL distribution.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
57
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
58 TODO (in rough order of priority):
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
59 1. Asynchronous notifies need to be implemented to the extent they can be.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
60 2. The large object interface needs work with Emacs buffers in addition
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
61 to files. Need two functions buffer->large_object, and large_object->
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
62 buffer.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
63 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
64
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
65 /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
66 Unimplemented functions: [TODO]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
67 PQsetNoticeProcessor
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
68
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
69 Implemented, but undocumented functions: [TODO]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
70 PQgetline (copy in/out)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
71 PQputline (copy in/out)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
72 PQgetlineAsync (copy in/out Asynch.)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
73 PQputnbytes (copy in/out Asynch.)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
74 PQendcopy (copy in/out)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
75
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
76 Unsupported functions:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
77 PQsetdbLogin -- This function is deprecated, has a subset of the
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
78 functionality of PQconnectdb, and is better done in Lisp.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
79 PQsetdb -- Same as for PQsetdbLogin
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
80 PQsocket -- Abstraction error, file descriptors should not be leaked
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
81 into Lisp code
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
82 PQprint -- print to a file descriptor, deprecated, better done in Lisp
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
83 PQdisplayTuples -- deprecated
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
84 PQprintTuples -- really, really deprecated
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
85 PQmblen -- Returns the length in bytes of multibyte character encoded
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
86 string.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
87 PQtrace -- controls debug print tracing to a tty.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
88 PQuntrace -- Ditto. I don't see any way to do this sensibly.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
89 PQoidStatus -- deprecated and nearly identical to PQoidValue
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
90 PQfn -- "Fast path" interface
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
91 lo_open (large object) [*]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
92 lo_close (large object) [*]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
93 lo_read (large object) [*]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
94 lo_write (large object) [*]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
95 lo_lseek (large object) [*]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
96 lo_creat (large object) [*]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
97 lo_tell (large object) [*]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
98 lo_unlink (large object) [*]
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
99 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
100
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
101 #include <config.h>
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
102
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
103 /* This must be portable with XEmacs 21.1 so long as it is the official
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
104 released version of XEmacs and provides the basis of InfoDock. The
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
105 interface to lcrecord handling has changed with 21.2, so unfortunately
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
106 we will need a few snippets of backwards compatibility code.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
107 */
5120
d1247f3cc363 latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
108 #if (EMACS_MAJOR_VERSION == 21) && (EMACS_MINOR_VERSION <= 1)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
109 #define RUNNING_XEMACS_21_1 1
5120
d1247f3cc363 latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
110 #elif (EMACS_MAJOR_VERSION == 21) && (EMACS_MINOR_VERSION <= 4)
d1247f3cc363 latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
111 #define RUNNING_XEMACS_21_4 1
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
112 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
113
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
114 /* #define POSTGRES_LO_IMPORT_IS_VOID 1 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
115
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
116 #include "lisp.h"
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
117
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
118 #include "buffer.h"
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
119 #include "postgresql.h"
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
120 #include "process.h"
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1204
diff changeset
121 #ifdef HAVE_SHLIB
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1204
diff changeset
122 # include "emodules.h"
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1204
diff changeset
123 #endif
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
124 #include "sysdep.h"
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
125 #include "sysfile.h"
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
126
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
127 #ifdef RUNNING_XEMACS_21_1 /* handle interface changes */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
128 #define PG_OS_CODING FORMAT_FILENAME
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
129 #define TO_EXTERNAL_FORMAT(a,from,b,to,c) GET_C_STRING_EXT_DATA_ALLOCA(from,FORMAT_FILENAME,to)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
130 #else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
131 #ifdef MULE
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
132 #define PG_OS_CODING get_coding_system_for_text_file (Vpg_coding_system, 1)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
133 #else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
134 #define PG_OS_CODING Qnative
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
135 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
136 Lisp_Object Vpg_coding_system;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
137 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
138
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
139 #define CHECK_LIVE_CONNECTION(P) \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
140 do \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
141 { \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
142 if (!P || (PQstatus (P) != CONNECTION_OK)) \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
143 { \
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
144 Lisp_Object err; \
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
145 \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
146 if (P) \
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
147 err = build_extstring (PQerrorMessage (P), PG_OS_CODING); \
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
148 else \
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
149 err = build_msg_string ("Bad value"); \
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
150 signal_error (Qprocess_error, "Dead connection", err); \
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
151 } \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
152 } \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
153 while (0)
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
154
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
155 #define PUKE_IF_NULL(p) \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
156 do \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
157 { \
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
158 if (!p) signal_error (Qinvalid_argument, "Bad value", Qunbound); \
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
159 } \
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
160 while (0)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
161
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
162 #define SIGNAL_ERROR(p, reason) \
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
163 do \
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
164 { \
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
165 signal_error (Qprocess_error, reason, \
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
166 build_extstring (PQerrorMessage (p), PG_OS_CODING)); \
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
167 } \
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
168 while (0)
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
169
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
170 static Lisp_Object VXPGHOST;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
171 static Lisp_Object VXPGUSER;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
172 static Lisp_Object VXPGOPTIONS;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
173 static Lisp_Object VXPGPORT;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
174 static Lisp_Object VXPGTTY; /* This needs to be blanked! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
175 static Lisp_Object VXPGDATABASE;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
176 static Lisp_Object VXPGREALM;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
177 #ifdef MULE
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
178 static Lisp_Object VXPGCLIENTENCODING;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
179 #endif /* MULE */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
180
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
181 /* Other variables:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
182 PGAUTHTYPE -- not used after PostgreSQL 6.5
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
183 PGGEQO
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
184 PGCOSTINDEX
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
185 PGCOSTHEAP
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
186 PGTZ
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
187 PGDATESTYLE
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
188 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
189 #ifndef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
190 static Lisp_Object VXPGAUTHTYPE;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
191 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
192 static Lisp_Object VXPGGEQO, VXPGCOSTINDEX, VXPGCOSTHEAP, VXPGTZ, VXPGDATESTYLE;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
193
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
194 static Lisp_Object Qpostgresql;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
195 static Lisp_Object Qpg_connection_ok, Qpg_connection_bad;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
196 static Lisp_Object Qpg_connection_started, Qpg_connection_made;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
197 static Lisp_Object Qpg_connection_awaiting_response, Qpg_connection_auth_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
198 static Lisp_Object Qpg_connection_setenv;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
199
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
200 static Lisp_Object Qpqdb, Qpquser, Qpqpass, Qpqhost, Qpqport, Qpqtty;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
201 static Lisp_Object Qpqoptions, Qpqstatus, Qpqerrormessage, Qpqbackendpid;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
202
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
203 static Lisp_Object Qpgres_empty_query, Qpgres_command_ok, Qpgres_tuples_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
204 static Lisp_Object Qpgres_copy_out, Qpgres_copy_in, Qpgres_bad_response;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
205 static Lisp_Object Qpgres_nonfatal_error, Qpgres_fatal_error;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
206
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
207 static Lisp_Object Qpgres_polling_failed, Qpgres_polling_reading;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
208 static Lisp_Object Qpgres_polling_writing, Qpgres_polling_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
209 static Lisp_Object Qpgres_polling_active;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
210 /****/
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
211
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
212 /* PGconn is an opaque object and we need to be able to store them in
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
213 Lisp code because libpq supports multiple connections.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
214 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
215 Lisp_Object Qpgconnp;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
216
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
217 static Lisp_Object
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
218 make_pgconn (Lisp_PGconn *pgconn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
219 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
220 return wrap_pgconn (pgconn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
221 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
222
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
223 static const struct memory_description pgconn_description [] = {
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
224 { XD_END }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
225 };
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
226
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
227 static Lisp_Object
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
228 #ifdef RUNNING_XEMACS_21_1
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
229 mark_pgconn (Lisp_Object UNUSED (obj),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
230 void (*UNUSED_ARG (markobj)) (Lisp_Object) ATTRIBUTE_UNUSED)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
231 #else
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
232 mark_pgconn (Lisp_Object UNUSED (obj))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
233 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
234 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
235 return Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
236 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
237
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
238 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
239 print_pgconn (Lisp_Object obj, Lisp_Object printcharfun,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
240 int UNUSED (escapeflag))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
241 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
242 char buf[256];
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
243 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
244 ConnStatusType cst;
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 3820
diff changeset
245 const char *host="", *db="", *user="", *port="";
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
246
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
247 P = (XPGCONN (obj))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
248
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
249 if (!P) /* this may happen since we allow PQfinish() to be called */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
250 strcpy (buf, "#<PGconn DEAD>"); /* evil! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
251 else if ((cst = PQstatus (P)) == CONNECTION_OK)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
252 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
253 if (!(host = PQhost (P)))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
254 host = "";
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
255 port = PQport (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
256 db = PQdb (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
257 if (!(user = PQuser (P)))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
258 user = "";
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
259 sprintf (buf, "#<PGconn %s:%s %s/%s>", /* evil! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
260 !strlen (host) ? "localhost" : host,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
261 port,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
262 user,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
263 db);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
264 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
265 else if (cst == CONNECTION_BAD)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
266 strcpy (buf, "#<PGconn BAD>"); /* evil! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
267 else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
268 strcpy (buf, "#<PGconn connecting>"); /* evil! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
269
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
270 if (print_readably)
5142
f965e31a35f0 reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents: 5141
diff changeset
271 printing_unreadable_object_fmt ("%s", buf);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
272 else
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
273 write_cistring (printcharfun, buf);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
274 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
275
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
276 static Lisp_PGconn *
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
277 allocate_pgconn (void)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
278 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
279 #ifdef RUNNING_XEMACS_21_1
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 2720
diff changeset
280 Lisp_PGconn *pgconn = ALLOC_LCRECORD_TYPE (Lisp_PGconn,
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
281 lrecord_pgconn);
5120
d1247f3cc363 latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
282 #elif defined (RUNNING_XEMACS_21_4)
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 2720
diff changeset
283 Lisp_PGconn *pgconn = ALLOC_LCRECORD_TYPE (Lisp_PGconn,
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
284 &lrecord_pgconn);
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
285 #else
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
286 Lisp_PGconn *pgconn = XPGCONN (ALLOC_NORMAL_LISP_OBJECT (pgconn));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
287 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
288 pgconn->pgconn = (PGconn *)NULL;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
289 return pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
290 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
291
5125
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
292 #ifdef RUNNING_XEMACS_21_4
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
293
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
294 static void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
295 finalize_pgconn (void *header, int for_disksave)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
296 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
297 Lisp_PGconn *pgconn = (Lisp_PGconn *)header;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
298
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
299 if (for_disksave)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
300 invalid_operation ("Can't dump an emacs containing PGconn objects",
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
301 make_pgconn (pgconn));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
302
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
303 if (pgconn->pgconn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
304 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
305 PQfinish (pgconn->pgconn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
306 pgconn->pgconn = (PGconn *)NULL;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
307 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
308 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
309
5125
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
310 #else /* not RUNNING_XEMACS_21_4 */
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
311
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
312 static void
5141
0dcd22290039 fix issues with finalizers in number.c, postgresql, ldap
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
313 finalize_pgconn (Lisp_Object obj)
5125
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
314 {
5141
0dcd22290039 fix issues with finalizers in number.c, postgresql, ldap
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
315 Lisp_PGconn *pgconn = XPGCONN (obj);
5125
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
316
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
317 if (pgconn->pgconn)
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
318 {
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
319 PQfinish (pgconn->pgconn);
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
320 pgconn->pgconn = (PGconn *)NULL;
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
321 }
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
322 }
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
323
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
324 #endif /* (not) RUNNING_XEMACS_21_4 */
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
325
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
326 #ifdef RUNNING_XEMACS_21_1
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
327 DEFINE_LRECORD_IMPLEMENTATION ("pgconn", pgconn,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
328 mark_pgconn, print_pgconn, finalize_pgconn,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
329 NULL, NULL,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
330 Lisp_PGconn);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3024
diff changeset
331 #elif defined (RUNNING_XEMACS_21_4)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
332 DEFINE_LRECORD_IMPLEMENTATION ("pgconn", pgconn,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
333 0, /*dumpable-flag*/
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
334 mark_pgconn, print_pgconn, finalize_pgconn,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
335 NULL, NULL,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
336 pgconn_description,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
337 Lisp_PGconn);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3024
diff changeset
338 #else
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
339 DEFINE_NODUMP_LISP_OBJECT ("pgconn", pgconn,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
340 mark_pgconn, print_pgconn,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
341 finalize_pgconn,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
342 NULL, NULL,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
343 pgconn_description,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
344 Lisp_PGconn);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
345 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
346 /****/
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
347
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
348 /* PGresult is an opaque object and we need to be able to store them in
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
349 Lisp code.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
350 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
351 Lisp_Object Qpgresultp;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
352
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
353 static Lisp_Object
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
354 make_pgresult (Lisp_PGresult *pgresult)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
355 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
356 return wrap_pgresult (pgresult);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
357 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
358
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
359 static const struct memory_description pgresult_description [] = {
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
360 { XD_END }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
361 };
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
362
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
363
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
364 static Lisp_Object
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
365 #ifdef RUNNING_XEMACS_21_1
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
366 mark_pgresult (Lisp_Object UNUSED (obj),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
367 void (*UNUSED_ARG (markobj)) (Lisp_Object) ATTRIBUTE_UNUSED)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
368 #else
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
369 mark_pgresult (Lisp_Object UNUSED (obj))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
370 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
371 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
372 return Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
373 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
374
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
375 #define RESULT_TUPLES_FMT "#<PGresult %s[%d] - %s>"
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
376 #define RESULT_CMD_TUPLES_FMT "#<PGresult %s[%s] - %s>"
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
377 #define RESULT_DEFAULT_FMT "#<PGresult %s - %s>"
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
378 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
379 print_pgresult (Lisp_Object obj, Lisp_Object printcharfun,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
380 int UNUSED (escapeflag))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
381 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
382 char buf[1024];
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
383 PGresult *res;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
384
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
385 res = (XPGRESULT (obj))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
386
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
387 if (res)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
388 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
389 switch (PQresultStatus (res))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
390 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
391 case PGRES_TUPLES_OK:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
392 /* Add number of tuples of result to output */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
393 sprintf (buf, RESULT_TUPLES_FMT, /* evil! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
394 PQresStatus (PQresultStatus (res)),
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
395 PQntuples (res),
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
396 PQcmdStatus (res));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
397 break;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
398 case PGRES_COMMAND_OK:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
399 /* Add number of tuples affected by output-less command */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
400 if (!strlen (PQcmdTuples (res))) goto notuples;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
401 sprintf (buf, RESULT_CMD_TUPLES_FMT, /* evil! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
402 PQresStatus (PQresultStatus (res)),
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
403 PQcmdTuples (res),
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
404 PQcmdStatus (res));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
405 break;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
406 default:
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
407 notuples:
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
408 /* No counts to print */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
409 sprintf (buf, RESULT_DEFAULT_FMT, /* evil! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
410 PQresStatus (PQresultStatus (res)),
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
411 PQcmdStatus (res));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
412 break;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
413 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
414 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
415 else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
416 strcpy (buf, "#<PGresult DEAD>"); /* evil! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
417
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
418 if (print_readably)
5142
f965e31a35f0 reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents: 5141
diff changeset
419 printing_unreadable_object_fmt ("%s", buf);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
420 else
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
421 write_cistring (printcharfun, buf);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
422 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
423
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
424 #undef RESULT_TUPLES_FMT
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
425 #undef RESULT_CMD_TUPLES_FMT
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
426 #undef RESULT_DEFAULT_FMT
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
427
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
428 static Lisp_PGresult *
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
429 allocate_pgresult (void)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
430 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
431 #ifdef RUNNING_XEMACS_21_1
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 2720
diff changeset
432 Lisp_PGresult *pgresult = ALLOC_LCRECORD_TYPE (Lisp_PGresult,
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
433 lrecord_pgresult);
5120
d1247f3cc363 latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
434 #elif defined (RUNNING_XEMACS_21_4)
3024
b7f26b2f78bd [xemacs-hg @ 2005-10-25 08:32:40 by ben]
ben
parents: 2720
diff changeset
435 Lisp_PGresult *pgresult = ALLOC_LCRECORD_TYPE (Lisp_PGresult,
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
436 &lrecord_pgresult);
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
437 #else
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
438 Lisp_PGresult *pgresult = XPGRESULT (ALLOC_NORMAL_LISP_OBJECT (pgresult));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
439 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
440 pgresult->pgresult = (PGresult *)NULL;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
441 return pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
442 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
443
5125
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
444 #ifdef RUNNING_XEMACS_21_4
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
445
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
446 static void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
447 finalize_pgresult (void *header, int for_disksave)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
448 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
449 Lisp_PGresult *pgresult = (Lisp_PGresult *)header;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
450
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
451 if (for_disksave)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
452 invalid_operation ("Can't dump an emacs containing PGresult objects",
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
453 make_pgresult (pgresult));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
454
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
455 if (pgresult->pgresult)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
456 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
457 PQclear (pgresult->pgresult);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
458 pgresult->pgresult = (PGresult *)NULL;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
459 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
460 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
461
5125
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
462 #else /* not RUNNING_XEMACS_21_4 */
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
463
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
464 static void
5141
0dcd22290039 fix issues with finalizers in number.c, postgresql, ldap
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
465 finalize_pgresult (Lisp_Object obj)
5125
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
466 {
5141
0dcd22290039 fix issues with finalizers in number.c, postgresql, ldap
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
467 Lisp_PGresult *pgresult = XPGRESULT (obj);
5125
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
468
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
469 if (pgresult->pgresult)
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
470 {
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
471 PQclear (pgresult->pgresult);
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
472 pgresult->pgresult = (PGresult *)NULL;
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
473 }
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
474 }
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
475
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
476 #endif /* (not) RUNNING_XEMACS_21_4 */
Ben Wing <ben@xemacs.org>
parents: 5120 4981
diff changeset
477
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
478 #ifdef RUNNING_XEMACS_21_1
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
479 DEFINE_LRECORD_IMPLEMENTATION ("pgresult", pgresult,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
480 mark_pgresult, print_pgresult, finalize_pgresult,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
481 NULL, NULL,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
482 Lisp_PGresult);
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
483 #elif defined (RUNNING_XEMACS_21_4)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
484 DEFINE_LRECORD_IMPLEMENTATION ("pgresult", pgresult,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
485 0, /*dumpable-flag*/
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
486 mark_pgresult, print_pgresult, finalize_pgresult,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
487 NULL, NULL,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
488 pgresult_description,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
489 Lisp_PGresult);
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
490 #else
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
491 DEFINE_NODUMP_LISP_OBJECT ("pgresult", pgresult,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
492 mark_pgresult, print_pgresult, finalize_pgresult,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
493 NULL, NULL,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
494 pgresult_description,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
495 Lisp_PGresult);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
496 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
497
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
498 /***********************/
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
499
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
500 /* notices */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
501 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1706
diff changeset
502 xemacs_notice_processor (void *UNUSED (arg), const char *msg)
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
503 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
504 warn_when_safe (Qpostgresql, Qnotice, "%s", msg);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
505 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
506
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
507 /* There are four ways (as of PostgreSQL v7) to connect to a database.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
508 Two of them, PQsetdb and PQsetdbLogin, are deprecated. Both of those
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
509 routines take a number of positional parameters and are better done in Lisp.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
510 Note that PQconnectStart does not exist prior to v7.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
511 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
512
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
513 /* ###autoload */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
514 DEFUN ("pq-conn-defaults", Fpq_conn_defaults, 0, 0, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
515 Return a connection default structure.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
516 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
517 ())
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
518 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
519 /* This function can GC */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
520 PQconninfoOption *pcio;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
521 Lisp_Object temp, temp1;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
522 int i;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
523
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
524 pcio = PQconndefaults();
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
525 if (!pcio) return Qnil; /* can never happen in libpq-7.0 */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
526 temp =
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
527 list1 (nconc2 (list4 (build_extstring (pcio[0].keyword, PG_OS_CODING),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
528 build_extstring (pcio[0].envvar, PG_OS_CODING),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
529 build_extstring (pcio[0].compiled, PG_OS_CODING),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
530 build_extstring (pcio[0].val, PG_OS_CODING)),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
531 list3 (build_extstring (pcio[0].label, PG_OS_CODING),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
532 build_extstring (pcio[0].dispchar, PG_OS_CODING),
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
533 make_fixnum (pcio[0].dispsize))));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
534
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
535 for (i = 1; pcio[i].keyword; i++)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
536 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
537 temp1 =
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
538 list1 (nconc2 (list4 (build_extstring (pcio[i].keyword, PG_OS_CODING),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
539 build_extstring (pcio[i].envvar, PG_OS_CODING),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
540 build_extstring (pcio[i].compiled, PG_OS_CODING),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
541 build_extstring (pcio[i].val, PG_OS_CODING)),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
542 list3 (build_extstring (pcio[i].label, PG_OS_CODING),
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
543 build_extstring (pcio[i].dispchar, PG_OS_CODING),
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
544 make_fixnum (pcio[i].dispsize))));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
545 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
546 Lisp_Object args[2];
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
547 args[0] = temp;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
548 args[1] = temp1;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
549 /* Fappend GCPROs its arguments */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
550 temp = Fappend (2, args);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
551 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
552 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
553
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
554 return temp;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
555 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
556
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
557 /* PQconnectdb Makes a new connection to a backend.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
558 PGconn *PQconnectdb(const char *conninfo)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
559 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
560
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
561 #ifdef HAVE_POSTGRESQLV7
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
562 #define USED_IF_V7(x) x
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
563 #else
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
564 #define USED_IF_V7(x) UNUSED (x)
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
565 #endif
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
566
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
567 static Lisp_Object
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
568 postgresql_connect (Lisp_Object conninfo, int USED_IF_V7 (async))
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
569 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
570 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
571 Lisp_PGconn *lisp_pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
572
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
573 CHECK_STRING (conninfo);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
574
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
575 P = (
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
576 #ifdef HAVE_POSTGRESQLV7
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
577 async ? PQconnectStart :
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
578 #endif
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
579 PQconnectdb)
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
580 (LISP_STRING_TO_EXTERNAL (conninfo, PG_OS_CODING));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
581 if (P && (PQstatus (P) == CONNECTION_OK))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
582 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
583 (void) PQsetNoticeProcessor (P, xemacs_notice_processor, NULL);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
584 lisp_pgconn = allocate_pgconn ();
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
585 lisp_pgconn->pgconn = P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
586 return make_pgconn (lisp_pgconn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
587 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
588 else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
589 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
590 /* Connection failed. Destroy the connection and signal an error. */
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
591
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
592 Lisp_Object errmsg;
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
593 if (P)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
594 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
595 errmsg = build_extstring (PQerrorMessage (P), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
596 PQfinish (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
597 }
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
598 else
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
599 errmsg = build_msg_string ("Out of Memory?");
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
600 signal_error (Qprocess_error, "Connecting to PostGreSQL backend",
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
601 errmsg);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
602 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
603 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
604
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
605 /* ###autoload */
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
606 DEFUN ("pq-connectdb", Fpq_connectdb, 1, 1, 0, /*
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
607 Make a new connection to a PostgreSQL backend.
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
608 */
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
609 (conninfo))
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
610 {
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
611 return postgresql_connect (conninfo, 0);
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
612 }
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
613
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
614 /* PQconnectStart Makes a new asynchronous connection to a backend.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
615 PGconn *PQconnectStart(const char *conninfo)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
616 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
617
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
618 #ifdef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
619 /* ###autoload */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
620 DEFUN ("pq-connect-start", Fpq_connect_start, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
621 Make a new asynchronous connection to a PostgreSQL backend.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
622 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
623 (conninfo))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
624 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
625 return postgresql_connect (conninfo, 1);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
626 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
627
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
628 DEFUN ("pq-connect-poll", Fpq_connect_poll, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
629 Poll an asynchronous connection for completion
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
630 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
631 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
632 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
633 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
634 PostgresPollingStatusType polling_status;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
635
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
636 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
637
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
638 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
639 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
640
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
641 polling_status = PQconnectPoll (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
642 switch (polling_status)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
643 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
644 case PGRES_POLLING_FAILED:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
645 /* Something Bad has happened */
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
646 SIGNAL_ERROR (P, "Polling asynchronous connection");
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
647 case PGRES_POLLING_OK:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
648 return Qpgres_polling_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
649 case PGRES_POLLING_READING:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
650 return Qpgres_polling_reading;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
651 case PGRES_POLLING_WRITING:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
652 return Qpgres_polling_writing;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
653 case PGRES_POLLING_ACTIVE:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
654 return Qpgres_polling_active;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
655 default:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
656 /* they've added a new field we don't know about */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
657 signal_ferror (Qprocess_error, "Help! Unknown status code %08x from backend!", polling_status);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
658 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
659 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
660
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
661 #ifdef MULE
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
662 DEFUN ("pq-client-encoding", Fpq_client_encoding, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
663 Return client coding system.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
664 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
665 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
666 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
667 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
668
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
669 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
670 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
671 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
672
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
673 return make_fixnum (PQclientEncoding (P));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
674 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
675
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
676 DEFUN ("pq-set-client-encoding", Fpq_set_client_encoding, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
677 Set client coding system.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
678 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
679 (conn, encoding))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
680 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
681 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
682 int rc;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
683 char *c_encoding;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
684
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
685 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
686 CHECK_STRING (encoding);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
687
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
688 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
689 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
690
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
691 TO_EXTERNAL_FORMAT (LISP_STRING, encoding,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
692 C_STRING_ALLOCA, c_encoding, Qnative);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
693
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
694 if ((rc = PQsetClientEncoding (P, c_encoding)) < 0)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
695 signal_error (Qinvalid_argument, "bad encoding", Qunbound);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
696 else
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
697 return make_fixnum (rc);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
698 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
699
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
700 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
701 #endif /* HAVE_POSTGRESQLV7 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
702
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
703 /* PQfinish Close the connection to the backend. Also frees memory
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
704 used by the PGconn object.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
705 void PQfinish(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
706 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
707 DEFUN ("pq-finish", Fpq_finish, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
708 Close the connection to the backend.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
709 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
710 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
711 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
712 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
713
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
714 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
715 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
716 PUKE_IF_NULL (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
717
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
718 PQfinish (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
719 /* #### PQfinish deallocates the PGconn structure, so we now have a
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
720 dangling pointer. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
721 /* Genocided all @'s ... */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
722 (XPGCONN (conn))->pgconn = (PGconn *)NULL; /* You feel DEAD inside */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
723 return Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
724 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
725
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
726 DEFUN ("pq-clear", Fpq_clear, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
727 Forcibly erase a PGresult object.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
728 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
729 (res))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
730 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
731 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
732
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
733 CHECK_PGRESULT (res);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
734 R = (XPGRESULT (res))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
735 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
736
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
737 PQclear (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
738 /* Genocided all @'s ... */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
739 (XPGRESULT (res))->pgresult = (PGresult *)NULL; /* You feel DEAD inside */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
740
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
741 return Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
742 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
743
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
744 DEFUN ("pq-is-busy", Fpq_is_busy, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
745 Return t if PQgetResult would block waiting for input.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
746 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
747 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
748 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
749 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
750
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
751 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
752 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
753 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
754
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
755 return PQisBusy (P) ? Qt : Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
756 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
757
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
758 DEFUN ("pq-consume-input", Fpq_consume_input, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
759 Consume any available input from the backend.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
760 Returns nil if something bad happened.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
761 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
762 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
763 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
764 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
765
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
766 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
767 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
768 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
769
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
770 return PQconsumeInput (P) ? Qt : Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
771 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
772
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
773 /* PQreset Reset the communication port with the backend.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
774 void PQreset(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
775 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
776 DEFUN ("pq-reset", Fpq_reset, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
777 Reset the connection to the backend.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
778 This function will close the connection to the backend and attempt to
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
779 reestablish a new connection to the same postmaster, using all the same
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
780 parameters previously used. This may be useful for error recovery if a
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
781 working connection is lost.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
782 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
783 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
784 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
785 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
786
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
787 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
788 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
789 PUKE_IF_NULL (P);/* we can resurrect a BAD connection, but not a dead one. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
790
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
791 PQreset (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
792
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
793 return Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
794 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
795
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
796 #ifdef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
797 DEFUN ("pq-reset-start", Fpq_reset_start, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
798 Reset connection to the backend asynchronously.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
799 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
800 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
801 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
802 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
803
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
804 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
805 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
806 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
807
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
808 if (PQresetStart (P)) return Qt;
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
809 SIGNAL_ERROR (P, "Resetting connection");
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
810 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
811
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
812 DEFUN ("pq-reset-poll", Fpq_reset_poll, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
813 Poll an asynchronous reset for completion.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
814 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
815 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
816 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
817 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
818 PostgresPollingStatusType polling_status;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
819
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
820 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
821
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
822 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
823 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
824
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
825 polling_status = PQresetPoll (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
826 switch (polling_status)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
827 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
828 case PGRES_POLLING_FAILED:
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
829 SIGNAL_ERROR (P, "Polling asynchronous reset");
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
830 case PGRES_POLLING_OK:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
831 return Qpgres_polling_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
832 case PGRES_POLLING_READING:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
833 return Qpgres_polling_reading;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
834 case PGRES_POLLING_WRITING:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
835 return Qpgres_polling_writing;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
836 case PGRES_POLLING_ACTIVE:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
837 return Qpgres_polling_active;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
838 default:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
839 /* they've added a new field we don't know about */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
840 signal_ferror (Qprocess_error, "Help! Unknown status code %08x from backend!", polling_status);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
841 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
842 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
843 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
844
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
845 DEFUN ("pq-request-cancel", Fpq_request_cancel, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
846 Attempt to request cancellation of the current operation.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
847
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
848 The return value is t if the cancel request was successfully
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
849 dispatched, nil if not (in which case conn->errorMessage is set).
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
850 Note: successful dispatch is no guarantee that there will be any effect at
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
851 the backend. The application must read the operation result as usual.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
852 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
853 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
854 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
855 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
856
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
857 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
858 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
859 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
860
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
861 return PQrequestCancel (P) ? Qt : Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
862 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
863
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
864 /* accessor function for the PGconn object */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
865 DEFUN ("pq-pgconn", Fpq_pgconn, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
866 Accessor function for the PGconn object.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
867 Currently recognized symbols for the field:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
868 pq::db Database name
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
869 pq::user Database user name
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
870 pq::pass Database user's password
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
871 pq::host Hostname of PostgreSQL backend connected to
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
872 pq::port TCP port number of connection
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
873 pq::tty Debugging TTY (not used in Emacs)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
874 pq::options Additional backend options
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
875 pq::status Connection status (either OK or BAD)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
876 pq::error-message Last error message from the backend
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
877 pq::backend-pid Process ID of backend process
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
878 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
879 (conn, field))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
880 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
881 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
882
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
883 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
884 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
885 PUKE_IF_NULL (P); /* BAD connections still have state to query */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
886
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
887 if (EQ(field, Qpqdb))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
888 /* PQdb Returns the database name of the connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
889 char *PQdb(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
890 */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
891 return build_extstring (PQdb(P), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
892 else if (EQ (field, Qpquser))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
893 /* PQuser Returns the user name of the connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
894 char *PQuser(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
895 */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
896 return build_extstring (PQuser(P), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
897 else if (EQ (field, Qpqpass))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
898 /* PQpass Returns the password of the connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
899 char *PQpass(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
900 */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
901 return build_extstring (PQpass(P), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
902 else if (EQ (field, Qpqhost))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
903 /* PQhost Returns the server host name of the connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
904 char *PQhost(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
905 */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
906 return build_extstring (PQhost(P), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
907 else if (EQ (field, Qpqport))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
908 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
909 char *p;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
910 /* PQport Returns the port of the connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
911 char *PQport(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
912 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
913 if ((p = PQport(P)))
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
914 return make_fixnum(atoi(p));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
915 else
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
916 return make_fixnum(-1);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
917 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
918 else if (EQ (field, Qpqtty))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
919 /* PQtty Returns the debug tty of the connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
920 char *PQtty(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
921 */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
922 return build_extstring (PQtty(P), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
923 else if (EQ (field, Qpqoptions))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
924 /* PQoptions Returns the backend options used in the connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
925 char *PQoptions(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
926 */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
927 return build_extstring (PQoptions(P), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
928 else if (EQ (field, Qpqstatus))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
929 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
930 ConnStatusType cst;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
931 /* PQstatus Returns the status of the connection. The status can be
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
932 CONNECTION_OK or CONNECTION_BAD.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
933 ConnStatusType PQstatus(PGconn *conn)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
934 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
935 switch ((cst = PQstatus (P)))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
936 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
937 case CONNECTION_OK: return Qpg_connection_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
938 case CONNECTION_BAD: return Qpg_connection_bad;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
939 #ifdef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
940 case CONNECTION_STARTED: return Qpg_connection_started;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
941 case CONNECTION_MADE: return Qpg_connection_made;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
942 case CONNECTION_AWAITING_RESPONSE: return Qpg_connection_awaiting_response;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
943 case CONNECTION_AUTH_OK: return Qpg_connection_auth_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
944 case CONNECTION_SETENV: return Qpg_connection_setenv;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
945 #endif /* HAVE_POSTGRESQLV7 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
946 default:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
947 /* they've added a new field we don't know about */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
948 signal_ferror (Qprocess_error, "Help! Unknown connection status code %08x from backend!", cst);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
949 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
950 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
951 else if (EQ (field, Qpqerrormessage))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
952 /* PQerrorMessage Returns the error message most recently generated
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
953 by an operation on the connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
954 char *PQerrorMessage(PGconn* conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
955 */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
956 return build_extstring (PQerrorMessage(P), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
957 else if (EQ (field, Qpqbackendpid))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
958 /* PQbackendPID Returns the process ID of the backend server handling
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
959 this connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
960 int PQbackendPID(PGconn *conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
961 */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
962 return make_fixnum (PQbackendPID(P));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
963 else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
964 signal_error (Qinvalid_argument, "bad PGconn accessor", Qunbound);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
965 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
966
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
967 /* Query functions */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
968 DEFUN ("pq-exec", Fpq_exec, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
969 Submit a query to Postgres and wait for the result.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
970 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
971 (conn, query))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
972 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
973 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
974 Lisp_PGresult *lisp_pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
975 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
976 char *c_query;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
977
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
978 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
979 CHECK_STRING (query);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
980
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
981 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
982 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
983
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
984 TO_EXTERNAL_FORMAT (LISP_STRING, query,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
985 C_STRING_ALLOCA, c_query, Qnative);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
986
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
987 R = PQexec (P, c_query);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
988 {
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 3820
diff changeset
989 const Ascbyte *tag;
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 3820
diff changeset
990 char buf[BLCKSZ];
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
991
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
992 if (!R) out_of_memory ("query: out of memory", Qunbound);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
993 else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
994 switch (PQresultStatus (R))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
995 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
996 case PGRES_BAD_RESPONSE:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
997 tag = "bad response [%s]";
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
998 goto err;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
999 case PGRES_NONFATAL_ERROR:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1000 tag = "non-fatal error [%s]";
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1001 goto err;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1002 case PGRES_FATAL_ERROR:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1003 tag = "fatal error [%s]";
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1004 err:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1005 strncpy (buf, PQresultErrorMessage (R), sizeof (buf));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1006 buf [sizeof (buf) - 1] = '\0';
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1007 PQclear (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1008 signal_ferror (Qprocess_error, tag, buf);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1009 /*NOTREACHED*/
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1010 default:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1011 break;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1012 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1013 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1014
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1015 lisp_pgresult = allocate_pgresult ();
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1016 lisp_pgresult->pgresult = R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1017
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1018 return make_pgresult (lisp_pgresult);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1019 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1020
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1021 DEFUN ("pq-send-query", Fpq_send_query, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1022 Submit a query to Postgres and don't wait for the result.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1023 Returns: t if successfully submitted
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1024 nil if error (conn->errorMessage is set)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1025 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1026 (conn, query))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1027 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1028 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1029 char *c_query;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1030
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1031 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1032 CHECK_STRING (query);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1033
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1034 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1035 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1036
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1037 TO_EXTERNAL_FORMAT (LISP_STRING, query,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1038 C_STRING_ALLOCA, c_query, Qnative);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1039
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1040 if (PQsendQuery (P, c_query)) return Qt;
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
1041 else SIGNAL_ERROR (P, "Sending asynchronous query");
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1042 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1043
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1044 DEFUN ("pq-get-result", Fpq_get_result, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1045 Retrieve an asynchronous result from a query.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1046 NIL is returned when no more query work remains.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1047 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1048 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1049 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1050 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1051 Lisp_PGresult *lisp_pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1052 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1053
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1054 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1055
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1056 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1057 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1058
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1059 R = PQgetResult (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1060 if (!R) return Qnil; /* not an error, there's no more data to get */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1061
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1062 {
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 3820
diff changeset
1063 const Ascbyte *tag;
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 3820
diff changeset
1064 char buf[BLCKSZ];
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1065
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1066 switch (PQresultStatus (R))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1067 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1068 case PGRES_BAD_RESPONSE:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1069 tag = "bad response [%s]";
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1070 goto err;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1071 case PGRES_NONFATAL_ERROR:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1072 tag = "non-fatal error [%s]";
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1073 goto err;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1074 case PGRES_FATAL_ERROR:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1075 tag = "fatal error [%s]";
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1076 err:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1077 strncpy (buf, PQresultErrorMessage (R), sizeof (buf));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1078 buf[sizeof (buf) - 1] = '\0';
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1079 PQclear (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1080 signal_ferror (Qprocess_error, tag, buf);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1081 /*NOTREACHED*/
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1082 default:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1083 break;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1084 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1085 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1086
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1087 lisp_pgresult = allocate_pgresult();
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1088 lisp_pgresult->pgresult = R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1089
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1090 return make_pgresult (lisp_pgresult);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1091 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1092
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1093 DEFUN ("pq-result-status", Fpq_result_status, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1094 Return result status of the query.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1095 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1096 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1097 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1098 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1099 ExecStatusType est;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1100
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1101 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1102 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1103 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1104
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1105 switch ((est = PQresultStatus (R))) {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1106 case PGRES_EMPTY_QUERY: return Qpgres_empty_query;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1107 case PGRES_COMMAND_OK: return Qpgres_command_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1108 case PGRES_TUPLES_OK: return Qpgres_tuples_ok;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1109 case PGRES_COPY_OUT: return Qpgres_copy_out;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1110 case PGRES_COPY_IN: return Qpgres_copy_in;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1111 case PGRES_BAD_RESPONSE: return Qpgres_bad_response;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1112 case PGRES_NONFATAL_ERROR: return Qpgres_nonfatal_error;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1113 case PGRES_FATAL_ERROR: return Qpgres_fatal_error;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1114 default:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1115 /* they've added a new field we don't know about */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
1116 signal_ferror (Qprocess_error,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
1117 "Help! Unknown exec status code %08x from backend!",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
1118 est);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1119 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1120 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1121
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1122 DEFUN ("pq-res-status", Fpq_res_status, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1123 Return stringified result status of the query.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1124 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1125 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1126 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1127 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1128
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1129 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1130 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1131 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1132
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1133 return build_extstring (PQresStatus (PQresultStatus (R)), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1134 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1135
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1136 /* Sundry PGresult accessor functions */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1137 DEFUN ("pq-result-error-message", Fpq_result_error_message, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1138 Return last message associated with the query.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1139 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1140 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1141 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1142 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1143
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1144 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1145 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1146 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1147
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1148 return build_extstring (PQresultErrorMessage (R), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1149 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1150
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1151 DEFUN ("pq-ntuples", Fpq_ntuples, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1152 Return the number of tuples (instances) in the query result.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1153 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1154 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1155 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1156 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1157
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1158 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1159 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1160 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1161
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1162 return make_fixnum (PQntuples (R));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1163 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1164
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1165 DEFUN ("pq-nfields", Fpq_nfields, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1166 Return the number of fields (attributes) in each tuple of the query result.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1167 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1168 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1169 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1170 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1171
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1172 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1173 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1174 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1175
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1176 return make_fixnum (PQnfields (R));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1177 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1178
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1179 DEFUN ("pq-binary-tuples", Fpq_binary_tuples, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1180 Return t if the query result contains binary data, nil otherwise.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1181 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1182 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1183 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1184 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1185
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1186 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1187 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1188 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1189
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1190 return (PQbinaryTuples (R)) ? Qt : Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1191 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1192
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1193 DEFUN ("pq-fname", Fpq_fname, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1194 Return the field (attribute) name associated with the given field index.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1195 Field indices start at 0.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1196 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1197 (result, field_index))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1198 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1199 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1200
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1201 CHECK_PGRESULT (result);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1202 CHECK_FIXNUM (field_index);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1203 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1204 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1205
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1206 return build_extstring (PQfname (R, XFIXNUM (field_index)), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1207 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1208
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1209 DEFUN ("pq-fnumber", Fpq_fnumber, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1210 Return the number of fields (attributes) in each tuple of the query result.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1211 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1212 (result, field_name))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1213 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1214 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1215 char *c_field_name;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1216
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1217 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1218 CHECK_STRING (field_name);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1219 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1220 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1221
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1222 TO_EXTERNAL_FORMAT (LISP_STRING, field_name,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1223 C_STRING_ALLOCA, c_field_name, Qnative);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1224
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1225 return make_fixnum (PQfnumber (R, c_field_name));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1226 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1227
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1228 DEFUN ("pq-ftype", Fpq_ftype, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1229 Return the field type associated with the given field index.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1230 The integer returned is the internal coding of the type. Field indices
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1231 start at 0.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1232 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1233 (result, field_num))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1234 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1235 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1236
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1237 CHECK_PGRESULT (result);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1238 CHECK_FIXNUM (field_num);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1239 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1240 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1241
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1242 return make_fixnum (PQftype (R, XFIXNUM (field_num)));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1243 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1244
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1245 DEFUN ("pq-fsize", Fpq_fsize, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1246 Return the field size in bytes associated with the given field index.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1247 Field indices start at 0.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1248 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1249 (result, field_index))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1250 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1251 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1252
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1253 CHECK_PGRESULT (result);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1254 CHECK_FIXNUM (field_index);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1255 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1256 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1257
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1258 return make_fixnum (PQftype (R, XFIXNUM (field_index)));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1259 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1260
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1261 DEFUN ("pq-fmod", Fpq_fmod, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1262 Return the type modifier associated with a field.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1263 Field indices start at 0.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1264 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1265 (result, field_index))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1266 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1267 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1268
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1269 CHECK_PGRESULT (result);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1270 CHECK_FIXNUM (field_index);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1271 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1272 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1273
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1274 return make_fixnum (PQfmod (R, XFIXNUM (field_index)));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1275 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1276
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1277 DEFUN ("pq-get-value", Fpq_get_value, 3, 3, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1278 Return a single field (attribute) value of one tuple of a PGresult.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1279 Tuple and field indices start at 0.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1280 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1281 (result, tup_num, field_num))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1282 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1283 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1284
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1285 CHECK_PGRESULT (result);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1286 CHECK_FIXNUM (tup_num);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1287 CHECK_FIXNUM (field_num);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1288 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1289 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1290
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1291 return build_extstring (PQgetvalue (R, XFIXNUM (tup_num), XFIXNUM (field_num)),
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1292 PG_OS_CODING);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1293 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1294
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1295 DEFUN ("pq-get-length", Fpq_get_length, 3, 3, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1296 Returns the length of a field value in bytes.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1297 If result is binary, i.e. a result of a binary portal, then the
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1298 length returned does NOT include the size field of the varlena. (The
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1299 data returned by PQgetvalue doesn't either.)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1300 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1301 (result, tup_num, field_num))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1302 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1303 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1304
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1305 CHECK_PGRESULT (result);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1306 CHECK_FIXNUM (tup_num);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1307 CHECK_FIXNUM (field_num);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1308 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1309 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1310
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1311 return make_fixnum (PQgetlength (R, XFIXNUM (tup_num), XFIXNUM (field_num)));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1312 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1313
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1314 DEFUN ("pq-get-is-null", Fpq_get_is_null, 3, 3, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1315 Returns the null status of a field value.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1316 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1317 (result, tup_num, field_num))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1318 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1319 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1320
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1321 CHECK_PGRESULT (result);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1322 CHECK_FIXNUM (tup_num);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1323 CHECK_FIXNUM (field_num);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1324 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1325 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1326
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1327 return PQgetisnull (R, XFIXNUM (tup_num), XFIXNUM (field_num)) ? Qt : Qnil;
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1328 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1329
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1330 DEFUN ("pq-cmd-status", Fpq_cmd_status, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1331 Returns the command status string from the SQL command that generated the result.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1332 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1333 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1334 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1335 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1336
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1337 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1338 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1339 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1340
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1341 return build_extstring (PQcmdStatus (R), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1342 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1343
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1344 DEFUN ("pq-cmd-tuples", Fpq_cmd_tuples, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1345 Returns the number of rows affected by the SQL command.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1346 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1347 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1348 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1349 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1350
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1351 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1352 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1353 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1354
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1355 return build_extstring (PQcmdTuples (R), PG_OS_CODING);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1356 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1357
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1358 DEFUN ("pq-oid-value", Fpq_oid_value, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1359 Returns the object id of the tuple inserted.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1360 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1361 (result))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1362 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1363 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1364
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1365 CHECK_PGRESULT (result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1366 R = (XPGRESULT (result))->pgresult;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1367 PUKE_IF_NULL (R);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1368
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1369 #ifdef HAVE_POSTGRESQLV7
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1370 return make_fixnum (PQoidValue (R));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1371 #else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1372 /* Use the old interface */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1373 return make_fixnum (atoi (PQoidStatus (R)));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1374 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1375 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1376
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1377 #ifdef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1378 DEFUN ("pq-set-nonblocking", Fpq_set_nonblocking, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1379 Sets the PGconn's database connection non-blocking if the arg is TRUE
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1380 or makes it non-blocking if the arg is FALSE, this will not protect
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1381 you from PQexec(), you'll only be safe when using the non-blocking API.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1382
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1383 Needs to be called only on a connected database connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1384 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1385 (conn, arg))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1386 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1387 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1388
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1389 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1390 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1391 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1392
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1393 return make_fixnum (PQsetnonblocking (P, !NILP (arg)));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1394 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1395
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1396 DEFUN ("pq-is-nonblocking", Fpq_is_nonblocking, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1397 Return the blocking status of the database connection.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1398 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1399 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1400 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1401 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1402
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1403 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1404 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1405 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1406
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1407 return PQisnonblocking (P) ? Qt : Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1408 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1409
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1410 DEFUN ("pq-flush", Fpq_flush, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1411 Force the write buffer to be written (or at least try).
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1412 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1413 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1414 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1415 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1416
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1417 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1418 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1419 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1420
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1421 return make_fixnum (PQflush (P));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1422 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1423 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1424
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1425 DEFUN ("pq-notifies", Fpq_notifies, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1426 Return the latest async notification that has not yet been handled.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1427 If there has been a notification, then a list of two elements will be returned.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1428 The first element contains the relation name being notified, the second
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1429 element contains the backend process ID number. nil is returned if there
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1430 aren't any notifications to process.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1431 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1432 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1433 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1434 /* This function cannot GC */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1435 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1436 PGnotify *PGN;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1437
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1438 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1439 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1440 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1441
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1442 PGN = PQnotifies (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1443 if (!PGN)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1444 return Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1445 else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1446 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1447 Lisp_Object temp;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1448
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1449 temp = list2 (build_extstring (PGN->relname, PG_OS_CODING), make_fixnum (PGN->be_pid));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1450 free ((void *)PGN);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1451 return temp;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1452 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1453 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1454
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1455 #if defined (HAVE_POSTGRESQLV7) && defined(MULE)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1456 /* ###autoload */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1457 DEFUN ("pq-env-2-encoding", Fpq_env_2_encoding, 0, 0, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1458 Get encoding id from environment variable PGCLIENTENCODING.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1459 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1460 ())
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1461 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1462 return make_fixnum (PQenv2encoding ());
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1463 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1464 #endif /* MULE */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1465
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1466 DEFUN ("pq-lo-import", Fpq_lo_import, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1467 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1468 (conn, filename))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1469 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1470 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1471 char *c_filename;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1472
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1473 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1474 CHECK_STRING (filename);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1475
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1476 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1477 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1478
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
1479 LISP_PATHNAME_CONVERT_OUT (filename, c_filename);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1480
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1481 return make_fixnum ((int)lo_import (P, c_filename));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1482 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1483
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1484 DEFUN ("pq-lo-export", Fpq_lo_export, 3, 3, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1485 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1486 (conn, oid, filename))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1487 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1488 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1489 char *c_filename;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1490
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1491 CHECK_PGCONN (conn);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1492 CHECK_FIXNUM (oid);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1493 CHECK_STRING (filename);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1494
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1495 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1496 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1497
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
1498 LISP_PATHNAME_CONVERT_OUT (filename, c_filename);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1499
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1500 return make_fixnum ((int)lo_export (P, XFIXNUM (oid), c_filename));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1501 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1502
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1503 DEFUN ("pq-make-empty-pgresult", Fpq_make_empty_pgresult, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1504 Make an empty PGresult object with the given status.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1505 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1506 (conn, status))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1507 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1508 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1509 Lisp_PGresult *lpgr;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1510 PGresult *R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1511 ExecStatusType est;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1512
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1513 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1514 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1515 CHECK_LIVE_CONNECTION (P); /* needed here? */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1516
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1517 if (EQ (status, Qpgres_empty_query)) est = PGRES_EMPTY_QUERY;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1518 else if (EQ (status, Qpgres_command_ok)) est = PGRES_COMMAND_OK;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1519 else if (EQ (status, Qpgres_tuples_ok)) est = PGRES_TUPLES_OK;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1520 else if (EQ (status, Qpgres_copy_out)) est = PGRES_COPY_OUT;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1521 else if (EQ (status, Qpgres_copy_in)) est = PGRES_COPY_IN;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1522 else if (EQ (status, Qpgres_bad_response)) est = PGRES_BAD_RESPONSE;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1523 else if (EQ (status, Qpgres_nonfatal_error)) est = PGRES_NONFATAL_ERROR;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1524 else if (EQ (status, Qpgres_fatal_error)) est = PGRES_FATAL_ERROR;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1525 else invalid_constant ("bad status symbol", status);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1526
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1527 R = PQmakeEmptyPGresult (P, est);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1528 if (!R) out_of_memory (0, Qunbound);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1529
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1530 lpgr = allocate_pgresult ();
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1531 lpgr->pgresult = R;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1532
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1533 return make_pgresult (lpgr);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1534 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1535
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1536 DEFUN ("pq-get-line", Fpq_get_line, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1537 Retrieve a line from server in copy in operation.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1538 The return value is a dotted pair where the cons cell is an integer code:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1539 -1: Copying is complete
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1540 0: A record is complete
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1541 1: A record is incomplete, it will be continued in the next `pq-get-line'
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1542 operation.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1543 and the cdr cell is returned string data.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1544
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1545 The copy operation is complete when the value `\.' (backslash dot) is
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1546 returned.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1547 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1548 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1549 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1550 char buffer[BLCKSZ]; /* size of a Postgres disk block */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1551 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1552 int ret;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1553
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1554 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1555 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1556 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1557
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1558 ret = PQgetline (P, buffer, sizeof (buffer));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1559
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1560 return Fcons (make_fixnum (ret), build_extstring (buffer, PG_OS_CODING));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1561 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1562
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1563 DEFUN ("pq-put-line", Fpq_put_line, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1564 Send a line to the server in copy out operation.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1565
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1566 Returns t if the operation succeeded, nil otherwise.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1567 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1568 (conn, string))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1569 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1570 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1571 char *c_string;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1572
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1573 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1574 CHECK_STRING (string);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1575
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1576 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1577 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1578 TO_EXTERNAL_FORMAT (LISP_STRING, string,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1579 C_STRING_ALLOCA, c_string, Qnative);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1580
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1581 return !PQputline (P, c_string) ? Qt : Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1582 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1583
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1584 DEFUN ("pq-get-line-async", Fpq_get_line_async, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1585 Get a line from the server in copy in operation asynchronously.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1586
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1587 This routine is for applications that want to do "COPY <rel> to stdout"
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1588 asynchronously, that is without blocking. Having issued the COPY command
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1589 and gotten a PGRES_COPY_OUT response, the app should call PQconsumeInput
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1590 and this routine until the end-of-data signal is detected. Unlike
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1591 PQgetline, this routine takes responsibility for detecting end-of-data.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1592
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1593 On each call, PQgetlineAsync will return data if a complete newline-
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1594 terminated data line is available in libpq's input buffer, or if the
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1595 incoming data line is too long to fit in the buffer offered by the caller.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1596 Otherwise, no data is returned until the rest of the line arrives.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1597
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1598 If -1 is returned, the end-of-data signal has been recognized (and removed
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1599 from libpq's input buffer). The caller *must* next call PQendcopy and
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1600 then return to normal processing.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1601
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1602 RETURNS:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1603 -1 if the end-of-copy-data marker has been recognized
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1604 0 if no data is available
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1605 >0 the number of bytes returned.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1606 The data returned will not extend beyond a newline character. If possible
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1607 a whole line will be returned at one time. But if the buffer offered by
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1608 the caller is too small to hold a line sent by the backend, then a partial
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1609 data line will be returned. This can be detected by testing whether the
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1610 last returned byte is '\n' or not.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1611 The returned string is *not* null-terminated.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1612 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1613 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1614 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1615 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1616 char buffer[BLCKSZ];
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1617 int ret;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1618
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1619 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1620
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1621 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1622 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1623
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1624 ret = PQgetlineAsync (P, buffer, sizeof (buffer));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1625
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1626 if (ret == -1) return Qt; /* done! */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1627 else if (!ret) return Qnil; /* no data yet */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1628 else return Fcons (make_fixnum (ret),
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1629 make_extstring ((Extbyte *) buffer, ret, PG_OS_CODING));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1630 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1631
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1632 DEFUN ("pq-put-nbytes", Fpq_put_nbytes, 2, 2, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1633 Asynchronous copy out.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1634 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1635 (conn, data))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1636 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1637 /* NULs are not allowed. I don't think this matters at this time. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1638 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1639 char *c_data;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1640
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1641 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1642 CHECK_STRING (data);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1643
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1644 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1645 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1646 TO_EXTERNAL_FORMAT (LISP_STRING, data,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1647 C_STRING_ALLOCA, c_data, Qnative);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1648
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1649 return !PQputnbytes (P, c_data, strlen (c_data)) ? Qt : Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1650 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1651
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1652 DEFUN ("pq-end-copy", Fpq_end_copy, 1, 1, 0, /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1653 End a copying operation.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1654 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1655 (conn))
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1656 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1657 PGconn *P;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1658
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1659 CHECK_PGCONN (conn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1660 P = (XPGCONN (conn))->pgconn;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1661 CHECK_LIVE_CONNECTION (P);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1662
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1663 return PQendcopy (P) ? Qt : Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1664 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1665
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1666 void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1667 syms_of_postgresql(void)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1668 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1669 #ifndef RUNNING_XEMACS_21_1
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
1670 INIT_LISP_OBJECT (pgconn);
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 3820
diff changeset
1671 INIT_LISP_OBJECT (pgresult);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1672 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1673 DEFSYMBOL (Qpostgresql);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1674
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1675 /* opaque exported types */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1676 DEFSYMBOL (Qpgconnp);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1677 DEFSYMBOL (Qpgresultp);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1678
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1679 /* connection status types */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1680 defsymbol (&Qpg_connection_ok, "pg::connection-ok");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1681 defsymbol (&Qpg_connection_bad, "pg::connection-bad");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1682 defsymbol (&Qpg_connection_started, "pg::connection-started");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1683 defsymbol (&Qpg_connection_made, "pg::connection-made");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1684 defsymbol (&Qpg_connection_awaiting_response, "pg::connection-awaiting-response");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1685 defsymbol (&Qpg_connection_auth_ok, "pg::connection-auth-ok");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1686 defsymbol (&Qpg_connection_setenv, "pg::connection-setenv");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1687
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1688 /* Fields of PGconn */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1689 defsymbol (&Qpqdb, "pq::db");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1690 defsymbol (&Qpquser, "pq::user");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1691 defsymbol (&Qpqpass, "pq::pass");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1692 defsymbol (&Qpqhost, "pq::host");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1693 defsymbol (&Qpqport, "pq::port");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1694 defsymbol (&Qpqtty, "pq::tty");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1695 defsymbol (&Qpqoptions, "pq::options");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1696 defsymbol (&Qpqstatus, "pq::status");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1697 defsymbol (&Qpqerrormessage, "pq::error-message");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1698 defsymbol (&Qpqbackendpid, "pq::backend-pid");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1699
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1700 /* Query status results */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1701 defsymbol (&Qpgres_empty_query, "pgres::empty-query");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1702 defsymbol (&Qpgres_command_ok, "pgres::command-ok");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1703 defsymbol (&Qpgres_tuples_ok, "pgres::tuples-ok");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1704 defsymbol (&Qpgres_copy_out, "pgres::copy-out");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1705 defsymbol (&Qpgres_copy_in, "pgres::copy-in");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1706 defsymbol (&Qpgres_bad_response, "pgres::bad-response");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1707 defsymbol (&Qpgres_nonfatal_error, "pgres::nonfatal-error");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1708 defsymbol (&Qpgres_fatal_error, "pgres::fatal-error");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1709
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1710 /* Poll status results */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1711 defsymbol (&Qpgres_polling_failed, "pgres::polling-failed");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1712 defsymbol (&Qpgres_polling_reading, "pgres::polling-reading");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1713 defsymbol (&Qpgres_polling_writing, "pgres::polling-writing");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1714 defsymbol (&Qpgres_polling_ok, "pgres::polling-ok");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1715 defsymbol (&Qpgres_polling_active, "pgres::polling-active");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1716
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1717 #ifdef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1718 DEFSUBR (Fpq_connect_start);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1719 DEFSUBR (Fpq_connect_poll);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1720 #ifdef MULE
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1721 DEFSUBR (Fpq_client_encoding);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1722 DEFSUBR (Fpq_set_client_encoding);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1723 #endif /* MULE */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1724 #endif /* HAVE_POSTGRESQLV7 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1725 DEFSUBR (Fpq_conn_defaults);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1726 DEFSUBR (Fpq_connectdb);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1727 DEFSUBR (Fpq_finish);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1728 DEFSUBR (Fpq_clear);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1729 DEFSUBR (Fpq_is_busy);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1730 DEFSUBR (Fpq_consume_input);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1731
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1732 DEFSUBR (Fpq_reset);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1733 #ifdef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1734 DEFSUBR (Fpq_reset_start);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1735 DEFSUBR (Fpq_reset_poll);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1736 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1737 DEFSUBR (Fpq_request_cancel);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1738 DEFSUBR (Fpq_pgconn);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1739
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1740 DEFSUBR (Fpq_exec);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1741 DEFSUBR (Fpq_send_query);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1742 DEFSUBR (Fpq_get_result);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1743 DEFSUBR (Fpq_result_status);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1744 DEFSUBR (Fpq_res_status);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1745 DEFSUBR (Fpq_result_error_message);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1746 DEFSUBR (Fpq_ntuples);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1747 DEFSUBR (Fpq_nfields);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1748 DEFSUBR (Fpq_binary_tuples);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1749 DEFSUBR (Fpq_fname);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1750 DEFSUBR (Fpq_fnumber);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1751 DEFSUBR (Fpq_ftype);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1752 DEFSUBR (Fpq_fsize);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1753 DEFSUBR (Fpq_fmod);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1754 /***/
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1755 DEFSUBR (Fpq_get_value);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1756 DEFSUBR (Fpq_get_length);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1757 DEFSUBR (Fpq_get_is_null);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1758 DEFSUBR (Fpq_cmd_status);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1759 DEFSUBR (Fpq_cmd_tuples);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1760 DEFSUBR (Fpq_oid_value);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1761
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1762 #ifdef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1763 DEFSUBR (Fpq_set_nonblocking);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1764 DEFSUBR (Fpq_is_nonblocking);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1765 DEFSUBR (Fpq_flush);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1766 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1767 DEFSUBR (Fpq_notifies);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1768
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1769 #if defined (HAVE_POSTGRESQLV7) && defined(MULE)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1770 DEFSUBR (Fpq_env_2_encoding);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1771 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1772
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1773 DEFSUBR (Fpq_lo_import);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1774 DEFSUBR (Fpq_lo_export);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1775
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1776 DEFSUBR (Fpq_make_empty_pgresult);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1777
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1778 /* copy in/out functions */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1779 DEFSUBR (Fpq_get_line);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1780 DEFSUBR (Fpq_put_line);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1781 DEFSUBR (Fpq_get_line_async);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1782 DEFSUBR (Fpq_put_nbytes);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1783 DEFSUBR (Fpq_end_copy);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1784 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1785
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1786 void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1787 vars_of_postgresql(void)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1788 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1789 Fprovide (Qpostgresql);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1790 #ifdef HAVE_POSTGRESQLV7
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1791 Fprovide (intern ("postgresqlv7"));
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1792 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1793 #ifndef RUNNING_XEMACS_21_1
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1794 Vpg_coding_system = Qnative;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1795 DEFVAR_LISP ("pg-coding-system", &Vpg_coding_system /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1796 Default Postgres client coding system.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1797 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1798 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1799
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1800 DEFVAR_LISP ("pg:host", &VXPGHOST /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1801 Default PostgreSQL server name.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1802 If not set, the server running on the local host is used. The
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1803 initial value is set from the PGHOST environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1804 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1805
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1806 DEFVAR_LISP ("pg:user", &VXPGUSER /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1807 Default PostgreSQL user name.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1808 This value is used when connecting to a database for authentication.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1809 The initial value is set from the PGUSER environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1810 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1811
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1812 DEFVAR_LISP ("pg:options", &VXPGOPTIONS /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1813 Default PostgreSQL user name.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1814 This value is used when connecting to a database for authentication.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1815 The initial value is set from the PGUSER environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1816 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1817
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1818 DEFVAR_LISP ("pg:port", &VXPGPORT /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1819 Default port to connect to PostgreSQL backend.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1820 This value is used when connecting to a database.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1821 The initial value is set from the PGPORT environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1822 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1823
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1824 DEFVAR_LISP ("pg:tty", &VXPGTTY /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1825 Default debugging TTY.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1826 There is no useful setting of this variable in the XEmacs Lisp API.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1827 The initial value is set from the PGTTY environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1828 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1829
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1830 DEFVAR_LISP ("pg:database", &VXPGDATABASE /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1831 Default database to connect to.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1832 The initial value is set from the PGDATABASE environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1833 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1834
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1835 DEFVAR_LISP ("pg:realm", &VXPGREALM /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1836 Default kerberos realm to use for authentication.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1837 The initial value is set from the PGREALM environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1838 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1839
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1840 #ifdef MULE
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1841 /* It's not clear whether this is any use. My intent is to
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1842 autodetect the coding system from the database. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1843 DEFVAR_LISP ("pg:client-encoding", &VXPGCLIENTENCODING /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1844 Default client encoding to use.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1845 The initial value is set from the PGCLIENTENCODING environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1846 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1847 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1848
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1849 #if !defined(HAVE_POSTGRESQLV7)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1850 DEFVAR_LISP ("pg:authtype", &VXPGAUTHTYPE /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1851 Default authentication to use.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1852 The initial value is set from the PGAUTHTYPE environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1853
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1854 WARNING: This variable has gone away in versions of PostgreSQL newer
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1855 than 6.5.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1856 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1857 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1858
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1859 DEFVAR_LISP ("pg:geqo", &VXPGGEQO /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1860 Genetic Query Optimizer options.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1861 The initial value is set from the PGGEQO environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1862 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1863
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1864 DEFVAR_LISP ("pg:cost-index", &VXPGCOSTINDEX /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1865 Default cost index options.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1866 The initial value is set from the PGCOSTINDEX environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1867 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1868
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1869 DEFVAR_LISP ("pg:cost-heap", &VXPGCOSTHEAP /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1870 Default cost heap options.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1871 The initial value is set from the PGCOSTHEAP environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1872 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1873
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1874 DEFVAR_LISP ("pg:tz", &VXPGTZ /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1875 Default timezone to use.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1876 The initial value is set from the PGTZ environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1877 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1878
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1879 DEFVAR_LISP ("pg:date-style", &VXPGDATESTYLE /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1880 Default date style to use.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1881 The initial value is set from the PGDATESTYLE environment variable.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1882 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1883
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1884 #ifdef HAVE_SHLIB
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1885 /* If we are building this as a module, we need the initializing function to
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1886 run at module load time. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1887 init_postgresql_from_environment ();
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1888 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1889 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1890
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1891 /* These initializations should not be done at dump-time. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1892 void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1893 init_postgresql_from_environment (void)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1894 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1895 Ibyte *p;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1896
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1897 #define FROB(envvar, var) \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1898 if ((p = egetenv (envvar))) \
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1899 var = build_istring (p); \
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1900 else \
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1901 var = Qnil
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1902
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1903 if (initialized)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1904 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1905 FROB ("PGHOST", VXPGHOST);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1906 FROB ("PGUSER", VXPGUSER);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1907 FROB ("PGOPTIONS", VXPGOPTIONS);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1908
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1909 if ((p = egetenv ("PGPORT")))
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5425
diff changeset
1910 VXPGPORT = make_fixnum (atoi ((char *) p));
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1911 else
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1912 VXPGPORT = Qnil;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1913
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1914 FROB ("PGTTY", VXPGTTY);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1915 FROB ("PGDATABASE", VXPGDATABASE);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1916 FROB ("PGREALM", VXPGREALM);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1917 #ifdef MULE
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1918 /* It's not clear whether this is any use. My intent is to
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1919 autodetect the coding system from the database. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1920 FROB ("PGCLIENTENCODING", VXPGCLIENTENCODING);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1921 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1922
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1923 #if !defined(HAVE_POSTGRESQLV7)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1924 FROB ("PGAUTHTYPE", VXPGAUTHTYPE);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1925 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1926
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1927 FROB ("PGGEQO", VXPGGEQO);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1928 FROB ("PGCOSTINDEX", VXPGCOSTINDEX);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1929 FROB ("PGCOSTHEAP", VXPGCOSTHEAP);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1930 FROB ("PGTZ", VXPGTZ);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1931 FROB ("PGDATESTYLE", VXPGDATESTYLE);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1932 #undef FROB
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1933 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1934 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1935
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1936 #ifdef HAVE_SHLIB
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
1937 EXTERN_C void unload_postgresql (void);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1938 void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1939 unload_postgresql (void)
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1940 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1941 #ifndef RUNNING_XEMACS_21_1
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1942 /* Remove defined types */
5120
d1247f3cc363 latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1943 UNDEF_LISP_OBJECT (pgconn);
d1247f3cc363 latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents: 5118
diff changeset
1944 UNDEF_LISP_OBJECT (pgresult);
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1945 #endif
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1946
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1947 /* Remove staticpro'ing of symbols */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1948 unstaticpro_nodump (&Qpostgresql);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1949 unstaticpro_nodump (&Qpgconnp);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1950 unstaticpro_nodump (&Qpgresultp);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1951 unstaticpro_nodump (&Qpg_connection_ok);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1952 unstaticpro_nodump (&Qpg_connection_bad);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1953 unstaticpro_nodump (&Qpg_connection_started);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1954 unstaticpro_nodump (&Qpg_connection_made);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1955 unstaticpro_nodump (&Qpg_connection_awaiting_response);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1956 unstaticpro_nodump (&Qpg_connection_auth_ok);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1957 unstaticpro_nodump (&Qpg_connection_setenv);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1958 unstaticpro_nodump (&Qpqdb);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1959 unstaticpro_nodump (&Qpquser);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1960 unstaticpro_nodump (&Qpqpass);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1961 unstaticpro_nodump (&Qpqhost);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1962 unstaticpro_nodump (&Qpqport);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1963 unstaticpro_nodump (&Qpqtty);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1964 unstaticpro_nodump (&Qpqoptions);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1965 unstaticpro_nodump (&Qpqstatus);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1966 unstaticpro_nodump (&Qpqerrormessage);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1967 unstaticpro_nodump (&Qpqbackendpid);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1968 unstaticpro_nodump (&Qpgres_empty_query);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1969 unstaticpro_nodump (&Qpgres_command_ok);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1970 unstaticpro_nodump (&Qpgres_tuples_ok);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1971 unstaticpro_nodump (&Qpgres_copy_out);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1972 unstaticpro_nodump (&Qpgres_copy_in);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1973 unstaticpro_nodump (&Qpgres_bad_response);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1974 unstaticpro_nodump (&Qpgres_nonfatal_error);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1975 unstaticpro_nodump (&Qpgres_fatal_error);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1976 unstaticpro_nodump (&Qpgres_polling_failed);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1977 unstaticpro_nodump (&Qpgres_polling_reading);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1978 unstaticpro_nodump (&Qpgres_polling_writing);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1979 unstaticpro_nodump (&Qpgres_polling_ok);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1980 unstaticpro_nodump (&Qpgres_polling_active);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1981 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1982 #endif /* HAVE_SHLIB */