annotate src/postgresql.c @ 826:6728e641994e

[xemacs-hg @ 2002-05-05 11:30:15 by ben] syntax cache, 8-bit-format, lots of code cleanup README.packages: Update info about --package-path. i.c: Create an inheritable event and pass it on to XEmacs, so that ^C can be handled properly. Intercept ^C and signal the event. "Stop Build" in VC++ now works. bytecomp-runtime.el: Doc string changes. compat.el: Some attempts to redo this to make it truly useful and fix the "multiple versions interacting with each other" problem. Not yet done. Currently doesn't work. files.el: Use with-obsolete-variable to avoid warnings in new revert-buffer code. xemacs.mak: Split up CFLAGS into a version without flags specifying the C library. The problem seems to be that minitar depends on zlib, which depends specifically on libc.lib, not on any of the other C libraries. Unless you compile with libc.lib, you get errors -- specifically, no _errno in the other libraries, which must make it something other than an int. (#### But this doesn't seem to obtain in XEmacs, which also uses zlib, and can be linked with any of the C libraries. Maybe zlib is used differently and doesn't need errno, or maybe XEmacs provides an int errno; ... I don't understand. Makefile.in.in: Fix so that packages are around when testing. abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, cmds.c, console-msw.h, console-stream.c, console-x.c, console.c, console.h, data.c, device-msw.c, device.c, device.h, dialog-msw.c, dialog-x.c, dired-msw.c, dired.c, doc.c, doprnt.c, dumper.c, editfns.c, elhash.c, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, events.h, extents.c, extents.h, faces.c, file-coding.c, file-coding.h, fileio.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, frame.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-msw.h, glyphs-x.c, glyphs.c, glyphs.h, gui-msw.c, gui-x.c, gui.h, gutter.h, hash.h, indent.c, insdel.c, intl-win32.c, intl.c, keymap.c, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, marker.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, nas.c, objects-msw.c, objects-x.c, opaque.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, process.h, profile.c, rangetab.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, regex.h, scrollbar-msw.c, search.c, select-x.c, specifier.c, specifier.h, symbols.c, symsinit.h, syntax.c, syntax.h, syswindows.h, tests.c, text.c, text.h, tooltalk.c, ui-byhand.c, ui-gtk.c, unicode.c, win32.c, window.c: Another big Ben patch. -- FUNCTIONALITY CHANGES: add partial support for 8-bit-fixed, 16-bit-fixed, and 32-bit-fixed formats. not quite done yet. (in particular, needs functions to actually convert the buffer.) NOTE: lots of changes to regex.c here. also, many new *_fmt() inline funs that take an Internal_Format argument. redo syntax cache code. make the cache per-buffer; keep the cache valid across calls to functions that use it. also keep it valid across insertions/deletions and extent changes, as much as is possible. eliminate the junky regex-reentrancy code by passing in the relevant lisp info to the regex routines as local vars. add general mechanism in extents code for signalling extent changes. fix numerous problems with the case-table implementation; yoshiki never properly transferred many algorithms from old-style to new-style case tables. redo char tables to support a default argument, so that mapping only occurs over changed args. change many chartab functions to accept Lisp_Object instead of Lisp_Char_Table *. comment out the code in font-lock.c by default, because font-lock.el no longer uses it. we should consider eliminating it entirely. Don't output bell as ^G in console-stream when not a TTY. add -mswindows-termination-handle to interface with i.c, so we can properly kill a build. add more error-checking to buffer/string macros. add some additional buffer_or_string_() funs. -- INTERFACE CHANGES AFFECTING MORE CODE: switch the arguments of write_c_string and friends to be consistent with write_fmt_string, which must have printcharfun first. change BI_* macros to BYTE_* for increased clarity; similarly for bi_* local vars. change VOID_TO_LISP to be a one-argument function. eliminate no-longer-needed CVOID_TO_LISP. -- char/string macro changes: rename MAKE_CHAR() to make_emchar() for slightly less confusion with make_char(). (The former generates an Emchar, the latter a Lisp object. Conceivably we should rename make_char() -> wrap_char() and similarly for make_int(), make_float().) Similar changes for other *CHAR* macros -- we now consistently use names with `emchar' whenever we are working with Emchars. Any remaining name with just `char' always refers to a Lisp object. rename macros with XSTRING_* to string_* except for those that reference actual fields in the Lisp_String object, following conventions used elsewhere. rename set_string_{data,length} macros (the only ones to work with a Lisp_String_* instead of a Lisp_Object) to set_lispstringp_* to make the difference clear. try to be consistent about caps vs. lowercase in macro/inline-fun names for chars and such, which wasn't the case before. we now reserve caps either for XFOO_ macros that reference object fields (e.g. XSTRING_DATA) or for things that have non-function semantics, e.g. directly modifying an arg (BREAKUP_EMCHAR) or evaluating an arg (any arg) more than once. otherwise, use lowercase. here is a summary of most of the macros/inline funs changed by all of the above changes: BYTE_*_P -> byte_*_p XSTRING_BYTE -> string_byte set_string_data/length -> set_lispstringp_data/length XSTRING_CHAR_LENGTH -> string_char_length XSTRING_CHAR -> string_emchar INTBYTE_FIRST_BYTE_P -> intbyte_first_byte_p INTBYTE_LEADING_BYTE_P -> intbyte_leading_byte_p charptr_copy_char -> charptr_copy_emchar LEADING_BYTE_* -> leading_byte_* CHAR_* -> EMCHAR_* *_CHAR_* -> *_EMCHAR_* *_CHAR -> *_EMCHAR CHARSET_BY_ -> charset_by_* BYTE_SHIFT_JIS* -> byte_shift_jis* BYTE_BIG5* -> byte_big5* REP_BYTES_BY_FIRST_BYTE -> rep_bytes_by_first_byte char_to_unicode -> emchar_to_unicode valid_char_p -> valid_emchar_p Change intbyte_strcmp -> qxestrcmp_c (duplicated functionality). -- INTERFACE CHANGES AFFECTING LESS CODE: use DECLARE_INLINE_HEADER in various places. remove '#ifdef emacs' from XEmacs-only files. eliminate CHAR_TABLE_VALUE(), which duplicated the functionality of get_char_table(). add BUFFER_TEXT_LOOP to simplify iterations over buffer text. define typedefs for signed and unsigned types of fixed sizes (INT_32_BIT, UINT_32_BIT, etc.). create ALIGN_FOR_TYPE as a higher-level interface onto ALIGN_SIZE; fix code to use it. add charptr_emchar_len to return the text length of the character pointed to by a ptr; use it in place of charcount_to_bytecount(..., 1). add emchar_len to return the text length of a given character. add types Bytexpos and Charxpos to generalize Bytebpos/Bytecount and Charbpos/Charcount, in code (particularly, the extents code and redisplay code) that works with either kind of index. rename redisplay struct params with names such as `charbpos' to e.g. `charpos' when they are e.g. a Charxpos, not a Charbpos. eliminate xxDEFUN in place of DEFUN; no longer necessary with changes awhile back to doc.c. split up big ugly combined list of EXFUNs in lisp.h on a file-by-file basis, since other prototypes are similarly split. rewrite some "*_UNSAFE" macros as inline funs and eliminate the _UNSAFE suffix. move most string code from lisp.h to text.h; the string code and text.h code is now intertwined in such a fashion that they need to be in the same place and partially interleaved. (you can't create forward references for inline funs) automated/lisp-tests.el, automated/symbol-tests.el, automated/test-harness.el: Fix test harness to output FAIL messages to stderr when in batch mode. Fix up some problems in lisp-tests/symbol-tests that were causing spurious failures.
author ben
date Sun, 05 May 2002 11:33:57 +0000
parents e38acbeb1cae
children 804517e16990
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
2 postgresql.c -- Emacs Lisp binding to libpq.so
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
3 Copyright (C) 2000 Electrotechnical Laboratory, JAPAN.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
4 Licensed to the Free Software Foundation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
5
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
6 Author: SL Baur <steve@beopen.com>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
7 Maintainer: SL Baur <steve@beopen.com>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
8
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
9 Please send patches to this file to me first before submitting them to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
10 xemacs-patches.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
11
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
12
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
13 KNOWN PROBLEMS (Last update 15-March-2000)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
14 + None.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
15
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
16 Implementation notes:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
17 0. Supported PostgreSQL versions
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
18 This code was developed against libpq-6.5.3 and libpq-7.0-beta1. Earlier
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
19 versions may work. V7 support is more complete than V6.5 support.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
20 1. Mule
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
21 Non-ASCII databases have been tested on both 6.5 and 7.0.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
22 2. Asynchronous Operation
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
23 Starting with libpq-7.0, an asynchronous interface is offered. This
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
24 binding supports the asynchronous calls to a limited extent. Since the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
25 XEmacs 21.2 core does not support a sensible interface to add managed but
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
26 unreadable (by XEmacs) file descriptors to the main select code, polling
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
27 is required to drive the asynchronous calls. XtAppAddInput would work
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
28 fine, but we want to be able to use the database when running strictly in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
29 tty mode.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
30 3. Completeness
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
31 Various calls have been deliberately not exported to Lisp. The
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
32 unexported calls are either left-over backwards compatibility code that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
33 aren't needed, calls that cannot be implemented sensibly, or calls that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
34 cannot be implemented safely. A list of all global functions in libpq
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
35 but not exported to Lisp is below.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
36 4. Policy
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
37 This interface tries very hard to not set any policy towards how database
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
38 code in Emacs Lisp will be written.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
39 5. Documentation
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
40 For full lisp programming documentation, see the XEmacs Lisp Reference
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
41 Manual. For PostgreSQL documentation, see the PostgreSQL distribution.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
42
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
43 TODO (in rough order of priority):
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
44 1. Asynchronous notifies need to be implemented to the extent they can be.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
45 2. The large object interface needs work with Emacs buffers in addition
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
46 to files. Need two functions buffer->large_object, and large_object->
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
47 buffer.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
48 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
49
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
50 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
51 Unimplemented functions: [TODO]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
52 PQsetNoticeProcessor
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
53
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
54 Implemented, but undocumented functions: [TODO]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
55 PQgetline (copy in/out)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
56 PQputline (copy in/out)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
57 PQgetlineAsync (copy in/out Asynch.)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
58 PQputnbytes (copy in/out Asynch.)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
59 PQendcopy (copy in/out)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
60
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
61 Unsupported functions:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
62 PQsetdbLogin -- This function is deprecated, has a subset of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
63 functionality of PQconnectdb, and is better done in Lisp.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
64 PQsetdb -- Same as for PQsetdbLogin
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
65 PQsocket -- Abstraction error, file descriptors should not be leaked
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
66 into Lisp code
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
67 PQprint -- print to a file descriptor, deprecated, better done in Lisp
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
68 PQdisplayTuples -- deprecated
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
69 PQprintTuples -- really, really deprecated
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
70 PQmblen -- Returns the length in bytes of multibyte character encoded
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
71 string.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
72 PQtrace -- controls debug print tracing to a tty.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
73 PQuntrace -- Ditto. I don't see any way to do this sensibly.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
74 PQoidStatus -- deprecated and nearly identical to PQoidValue
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
75 PQfn -- "Fast path" interface
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
76 lo_open (large object) [*]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
77 lo_close (large object) [*]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
78 lo_read (large object) [*]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
79 lo_write (large object) [*]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
80 lo_lseek (large object) [*]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
81 lo_creat (large object) [*]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
82 lo_tell (large object) [*]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
83 lo_unlink (large object) [*]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
84 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
85
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
86 #include <config.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
87
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
88 /* This must be portable with XEmacs 21.1 so long as it is the official
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
89 released version of XEmacs and provides the basis of InfoDock. The
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
90 interface to lcrecord handling has changed with 21.2, so unfortunately
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
91 we will need a few snippets of backwards compatibility code.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
92 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
93 #if (EMACS_MAJOR_VERSION == 21) && (EMACS_MINOR_VERSION < 2)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
94 #define RUNNING_XEMACS_21_1 1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
95 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
96
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
97 /* #define POSTGRES_LO_IMPORT_IS_VOID 1 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
98
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
99 #include "lisp.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
100 #include "sysdep.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
101 #include "buffer.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
102 #include "postgresql.h"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
103
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
104 #ifdef RUNNING_XEMACS_21_1 /* handle interface changes */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
105 #define PG_OS_CODING FORMAT_FILENAME
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
106 #define TO_EXTERNAL_FORMAT(a,from,b,to,c) GET_C_STRING_EXT_DATA_ALLOCA(from,FORMAT_FILENAME,to)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
107 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
108 #ifdef MULE
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
109 #define PG_OS_CODING get_coding_system_for_text_file (Vpg_coding_system, 1)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
110 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
111 #define PG_OS_CODING Qnative
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
112 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
113 Lisp_Object Vpg_coding_system;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
114 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
115
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
116 #define CHECK_LIVE_CONNECTION(P) do { \
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
117 if (!P || (PQstatus (P) != CONNECTION_OK)) { \
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
118 char *e = "bad value"; \
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
119 if (P) e = PQerrorMessage (P); \
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
120 signal_ferror (Qprocess_error, "dead connection [%s]", e); \
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
121 } } while (0)
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
122 #define PUKE_IF_NULL(p) do { \
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
123 if (!p) signal_error (Qinvalid_argument, "bad value", Qunbound); \
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
124 } while (0)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
125
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
126 static Lisp_Object VXPGHOST;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
127 static Lisp_Object VXPGUSER;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
128 static Lisp_Object VXPGOPTIONS;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
129 static Lisp_Object VXPGPORT;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
130 static Lisp_Object VXPGTTY; /* This needs to be blanked! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
131 static Lisp_Object VXPGDATABASE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
132 static Lisp_Object VXPGREALM;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
133 #ifdef MULE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
134 static Lisp_Object VXPGCLIENTENCODING;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
135 #endif /* MULE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
136
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
137 /* Other variables:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
138 PGAUTHTYPE -- not used after PostgreSQL 6.5
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
139 PGGEQO
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
140 PGCOSTINDEX
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
141 PGCOSTHEAP
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
142 PGTZ
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
143 PGDATESTYLE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
144 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
145 #ifndef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
146 static Lisp_Object VXPGAUTHTYPE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
147 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
148 static Lisp_Object VXPGGEQO, VXPGCOSTINDEX, VXPGCOSTHEAP, VXPGTZ, VXPGDATESTYLE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
149
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
150 static Lisp_Object Qpostgresql;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
151 static Lisp_Object Qpg_connection_ok, Qpg_connection_bad;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
152 static Lisp_Object Qpg_connection_started, Qpg_connection_made;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
153 static Lisp_Object Qpg_connection_awaiting_response, Qpg_connection_auth_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
154 static Lisp_Object Qpg_connection_setenv;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
155
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
156 static Lisp_Object Qpqdb, Qpquser, Qpqpass, Qpqhost, Qpqport, Qpqtty;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
157 static Lisp_Object Qpqoptions, Qpqstatus, Qpqerrormessage, Qpqbackendpid;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
158
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
159 static Lisp_Object Qpgres_empty_query, Qpgres_command_ok, Qpgres_tuples_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
160 static Lisp_Object Qpgres_copy_out, Qpgres_copy_in, Qpgres_bad_response;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
161 static Lisp_Object Qpgres_nonfatal_error, Qpgres_fatal_error;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
162
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
163 static Lisp_Object Qpgres_polling_failed, Qpgres_polling_reading;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
164 static Lisp_Object Qpgres_polling_writing, Qpgres_polling_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
165 static Lisp_Object Qpgres_polling_active;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
166 /****/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
167
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
168 /* PGconn is an opaque object and we need to be able to store them in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
169 Lisp code because libpq supports multiple connections.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
170 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
171 Lisp_Object Qpgconnp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
172
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
173 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
174 make_pgconn (Lisp_PGconn *pgconn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
175 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
176 return wrap_pgconn (pgconn);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
177 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
178
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
179 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
180 #ifdef RUNNING_XEMACS_21_1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
181 mark_pgconn (Lisp_Object obj, void (*markobj) (Lisp_Object))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
182 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
183 mark_pgconn (Lisp_Object obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
184 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
185 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
186 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
187 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
188
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
189 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
190 print_pgconn (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
191 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
192 char buf[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
193 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
194 ConnStatusType cst;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
195 char *host="", *db="", *user="", *port="";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
196
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
197 P = (XPGCONN (obj))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
198
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
199 if (!P) /* this may happen since we allow PQfinish() to be called */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
200 strcpy (buf, "#<PGconn DEAD>"); /* evil! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
201 else if ((cst = PQstatus (P)) == CONNECTION_OK)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
202 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
203 if (!(host = PQhost (P)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
204 host = "";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
205 port = PQport (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
206 db = PQdb (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
207 if (!(user = PQuser (P)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
208 user = "";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
209 sprintf (buf, "#<PGconn %s:%s %s/%s>", /* evil! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
210 !strlen (host) ? "localhost" : host,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
211 port,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
212 user,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
213 db);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
214 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
215 else if (cst == CONNECTION_BAD)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
216 strcpy (buf, "#<PGconn BAD>"); /* evil! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
217 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
218 strcpy (buf, "#<PGconn connecting>"); /* evil! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
219
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
220 if (print_readably)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
221 printing_unreadable_object ("%s", buf);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
222 else
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
223 write_c_string (printcharfun, buf);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
224 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
225
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
226 static Lisp_PGconn *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
227 allocate_pgconn (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
228 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
229 #ifdef RUNNING_XEMACS_21_1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
230 Lisp_PGconn *pgconn = alloc_lcrecord_type (Lisp_PGconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
231 lrecord_pgconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
232 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
233 Lisp_PGconn *pgconn = alloc_lcrecord_type (Lisp_PGconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
234 &lrecord_pgconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
235 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
236 pgconn->pgconn = (PGconn *)NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
237 return pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
238 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
239
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
240 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
241 finalize_pgconn (void *header, int for_disksave)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
242 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
243 Lisp_PGconn *pgconn = (Lisp_PGconn *)header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
244
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
245 if (for_disksave)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
246 invalid_operation ("Can't dump an emacs containing PGconn objects",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
247 make_pgconn (pgconn));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
248
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
249 if (pgconn->pgconn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
250 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
251 PQfinish (pgconn->pgconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
252 pgconn->pgconn = (PGconn *)NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
253 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
254 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
255
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
256 #ifdef RUNNING_XEMACS_21_1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
257 DEFINE_LRECORD_IMPLEMENTATION ("pgconn", pgconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
258 mark_pgconn, print_pgconn, finalize_pgconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
259 NULL, NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
260 Lisp_PGconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
261 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
262 DEFINE_LRECORD_IMPLEMENTATION ("pgconn", pgconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
263 mark_pgconn, print_pgconn, finalize_pgconn,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
264 NULL, NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
265 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
266 Lisp_PGconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
267 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
268 /****/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
269
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
270 /* PGresult is an opaque object and we need to be able to store them in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
271 Lisp code.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
272 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
273 Lisp_Object Qpgresultp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
274
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
275 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
276 make_pgresult (Lisp_PGresult *pgresult)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
277 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
278 return wrap_pgresult (pgresult);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
279 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
280
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
281 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
282 #ifdef RUNNING_XEMACS_21_1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
283 mark_pgresult (Lisp_Object obj, void (*markobj) (Lisp_Object))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
284 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
285 mark_pgresult (Lisp_Object obj)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
286 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
287 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
288 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
289 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
290
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
291 #define RESULT_TUPLES_FMT "#<PGresult %s[%d] - %s>"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
292 #define RESULT_CMD_TUPLES_FMT "#<PGresult %s[%s] - %s>"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
293 #define RESULT_DEFAULT_FMT "#<PGresult %s - %s>"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
294 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
295 print_pgresult (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
296 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
297 char buf[1024];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
298 PGresult *res;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
299
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
300 res = (XPGRESULT (obj))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
301
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
302 if (res)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
303 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
304 switch (PQresultStatus (res))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
305 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
306 case PGRES_TUPLES_OK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
307 /* Add number of tuples of result to output */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
308 sprintf (buf, RESULT_TUPLES_FMT, /* evil! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
309 PQresStatus (PQresultStatus (res)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
310 PQntuples (res),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
311 PQcmdStatus (res));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
312 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
313 case PGRES_COMMAND_OK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
314 /* Add number of tuples affected by output-less command */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
315 if (!strlen (PQcmdTuples (res))) goto notuples;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
316 sprintf (buf, RESULT_CMD_TUPLES_FMT, /* evil! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
317 PQresStatus (PQresultStatus (res)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
318 PQcmdTuples (res),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
319 PQcmdStatus (res));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
320 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
321 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
322 notuples:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
323 /* No counts to print */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
324 sprintf (buf, RESULT_DEFAULT_FMT, /* evil! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
325 PQresStatus (PQresultStatus (res)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
326 PQcmdStatus (res));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
327 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
328 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
329 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
330 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
331 strcpy (buf, "#<PGresult DEAD>"); /* evil! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
332
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
333 if (print_readably)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
334 printing_unreadable_object ("%s", buf);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
335 else
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
336 write_c_string (printcharfun, buf);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
337 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
338
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
339 #undef RESULT_TUPLES_FMT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
340 #undef RESULT_CMD_TUPLES_FMT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
341 #undef RESULT_DEFAULT_FMT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
342
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
343 static Lisp_PGresult *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
344 allocate_pgresult (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
345 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
346 #ifdef RUNNING_XEMACS_21_1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
347 Lisp_PGresult *pgresult = alloc_lcrecord_type (Lisp_PGresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
348 lrecord_pgresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
349 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
350 Lisp_PGresult *pgresult = alloc_lcrecord_type (Lisp_PGresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
351 &lrecord_pgresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
352 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
353 pgresult->pgresult = (PGresult *)NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
354 return pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
355 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
356
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
357 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
358 finalize_pgresult (void *header, int for_disksave)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
359 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
360 Lisp_PGresult *pgresult = (Lisp_PGresult *)header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
361
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
362 if (for_disksave)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
363 invalid_operation ("Can't dump an emacs containing PGresult objects",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
364 make_pgresult (pgresult));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
365
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
366 if (pgresult->pgresult)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
367 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
368 PQclear (pgresult->pgresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
369 pgresult->pgresult = (PGresult *)NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
370 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
371 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
372
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
373 #ifdef RUNNING_XEMACS_21_1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
374 DEFINE_LRECORD_IMPLEMENTATION ("pgresult", pgresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
375 mark_pgresult, print_pgresult, finalize_pgresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
376 NULL, NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
377 Lisp_PGresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
378 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
379 DEFINE_LRECORD_IMPLEMENTATION ("pgresult", pgresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
380 mark_pgresult, print_pgresult, finalize_pgresult,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
381 NULL, NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
382 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
383 Lisp_PGresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
384 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
385
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
386 /***********************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
387
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
388 /* notices */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
389 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
390 xemacs_notice_processor (void *arg, const char *msg)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
391 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
392 warn_when_safe (Qpostgresql, Qnotice, "%s", msg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
393 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
394
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
395 /* There are four ways (as of PostgreSQL v7) to connect to a database.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
396 Two of them, PQsetdb and PQsetdbLogin, are deprecated. Both of those
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
397 routines take a number of positional parameters and are better done in Lisp.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
398 Note that PQconnectStart does not exist prior to v7.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
399 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
400
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
401 DEFUN ("pq-conn-defaults", Fpq_conn_defaults, 0, 0, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
402 Return a connection default structure.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
403 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
404 ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
405 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
406 /* This function can GC */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
407 PQconninfoOption *pcio;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
408 Lisp_Object temp, temp1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
409 int i;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
410
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
411 pcio = PQconndefaults();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
412 if (!pcio) return Qnil; /* can never happen in libpq-7.0 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
413 temp = list1 (Fcons (build_ext_string (pcio[0].keyword, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
414 Fcons (build_ext_string (pcio[0].envvar, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
415 Fcons (build_ext_string (pcio[0].compiled, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
416 Fcons (build_ext_string (pcio[0].val, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
417 Fcons (build_ext_string (pcio[0].label, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
418 Fcons (build_ext_string (pcio[0].dispchar, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
419 Fcons (make_int (pcio[0].dispsize), Qnil))))))));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
420
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
421 for (i = 1; pcio[i].keyword; i++)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
422 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
423 temp1 = list1 (Fcons (build_ext_string (pcio[i].keyword, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
424 Fcons (build_ext_string (pcio[i].envvar, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
425 Fcons (build_ext_string (pcio[i].compiled, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
426 Fcons (build_ext_string (pcio[i].val, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
427 Fcons (build_ext_string (pcio[i].label, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
428 Fcons (build_ext_string (pcio[i].dispchar, PG_OS_CODING),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
429 Fcons (make_int (pcio[i].dispsize), Qnil))))))));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
430 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
431 Lisp_Object args[2];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
432 args[0] = temp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
433 args[1] = temp1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
434 /* Fappend GCPROs its arguments */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
435 temp = Fappend (2, args);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
436 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
437 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
438
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
439 return temp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
440 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
441
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
442 /* PQconnectdb Makes a new connection to a backend.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
443 PGconn *PQconnectdb(const char *conninfo)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
444 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
445
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
446 DEFUN ("pq-connectdb", Fpq_connectdb, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
447 Make a new connection to a PostgreSQL backend.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
448 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
449 (conninfo))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
450 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
451 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
452 Lisp_PGconn *lisp_pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
453 char *error_message = "Out of Memory?";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
454 char *c_conninfo;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
455
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
456 CHECK_STRING (conninfo);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
457
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
458 TO_EXTERNAL_FORMAT(LISP_STRING, conninfo,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
459 C_STRING_ALLOCA, c_conninfo, Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
460 P = PQconnectdb (c_conninfo);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
461 if (P && (PQstatus (P) == CONNECTION_OK))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
462 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
463 (void)PQsetNoticeProcessor (P, xemacs_notice_processor, NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
464 lisp_pgconn = allocate_pgconn();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
465 lisp_pgconn->pgconn = P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
466 return make_pgconn (lisp_pgconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
467 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
468 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
469 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
470 /* Connection failed. Destroy the connection and signal an error. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
471 char buf[BLCKSZ];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
472 strcpy (buf, error_message);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
473 if (P)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
474 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
475 /* storage for the error message gets erased when call PQfinish */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
476 /* so we must temporarily stash it somewhere */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
477 strncpy (buf, PQerrorMessage (P), sizeof (buf));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
478 buf[sizeof (buf) - 1] = '\0';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
479 PQfinish (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
480 }
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
481 signal_ferror (Qprocess_error, "libpq: %s", buf);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
482 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
483 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
484
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
485 /* PQconnectStart Makes a new asynchronous connection to a backend.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
486 PGconn *PQconnectStart(const char *conninfo)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
487 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
488
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
489 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
490 DEFUN ("pq-connect-start", Fpq_connect_start, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
491 Make a new asynchronous connection to a PostgreSQL backend.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
492 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
493 (conninfo))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
494 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
495 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
496 Lisp_PGconn *lisp_pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
497 char *error_message = "Out of Memory?";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
498 char *c_conninfo;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
499
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
500 CHECK_STRING (conninfo);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
501 TO_EXTERNAL_FORMAT (LISP_STRING, conninfo,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
502 C_STRING_ALLOCA, c_conninfo, Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
503 P = PQconnectStart (c_conninfo);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
504
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
505 if (P && (PQstatus (P) != CONNECTION_BAD))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
506 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
507 (void)PQsetNoticeProcessor (P, xemacs_notice_processor, NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
508 lisp_pgconn = allocate_pgconn();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
509 lisp_pgconn->pgconn = P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
510
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
511 return make_pgconn (lisp_pgconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
512 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
513 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
514 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
515 /* capture the error message before destroying the object */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
516 char buf[BLCKSZ];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
517 strcpy (buf, error_message);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
518 if (P)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
519 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
520 strncpy (buf, PQerrorMessage (P), sizeof (buf));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
521 buf[sizeof (buf) - 1] = '\0';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
522 PQfinish (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
523 }
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
524 signal_ferror (Qprocess_error, "libpq: %s", buf);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
525 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
526 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
527
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
528 DEFUN ("pq-connect-poll", Fpq_connect_poll, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
529 Poll an asynchronous connection for completion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
530 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
531 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
532 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
533 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
534 PostgresPollingStatusType polling_status;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
535
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
536 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
537
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
538 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
539 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
540
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
541 polling_status = PQconnectPoll (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
542 switch (polling_status)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
543 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
544 case PGRES_POLLING_FAILED:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
545 /* Something Bad has happened */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
546 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
547 char *e = PQerrorMessage (P);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
548 signal_ferror (Qprocess_error, "libpq: %s", e);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
549 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
550 case PGRES_POLLING_OK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
551 return Qpgres_polling_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
552 case PGRES_POLLING_READING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
553 return Qpgres_polling_reading;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
554 case PGRES_POLLING_WRITING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
555 return Qpgres_polling_writing;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
556 case PGRES_POLLING_ACTIVE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
557 return Qpgres_polling_active;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
558 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
559 /* they've added a new field we don't know about */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
560 signal_ferror (Qprocess_error, "Help! Unknown status code %08x from backend!", polling_status);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
561 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
562 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
563
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
564 #ifdef MULE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
565 DEFUN ("pq-client-encoding", Fpq_client_encoding, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
566 Return client coding system.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
567 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
568 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
569 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
570 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
571
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
572 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
573 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
574 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
575
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
576 return make_int (PQclientEncoding (P));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
577 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
578
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
579 DEFUN ("pq-set-client-encoding", Fpq_set_client_encoding, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
580 Set client coding system.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
581 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
582 (conn, encoding))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
583 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
584 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
585 int rc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
586 char *c_encoding;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
587
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
588 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
589 CHECK_STRING (encoding);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
590
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
591 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
592 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
593
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
594 TO_EXTERNAL_FORMAT (LISP_STRING, encoding,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
595 C_STRING_ALLOCA, c_encoding, Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
596
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
597 if ((rc = PQsetClientEncoding (P, c_encoding)) < 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
598 signal_error (Qinvalid_argument, "bad encoding", Qunbound);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
599 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
600 return make_int (rc);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
601 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
602
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
603 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
604 #endif /* HAVE_POSTGRESQLV7 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
605
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
606 /* PQfinish Close the connection to the backend. Also frees memory
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
607 used by the PGconn object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
608 void PQfinish(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
609 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
610 DEFUN ("pq-finish", Fpq_finish, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
611 Close the connection to the backend.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
612 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
613 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
614 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
615 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
616
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
617 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
618 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
619 PUKE_IF_NULL (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
620
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
621 PQfinish (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
622 /* #### PQfinish deallocates the PGconn structure, so we now have a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
623 dangling pointer. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
624 /* Genocided all @'s ... */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
625 (XPGCONN (conn))->pgconn = (PGconn *)NULL; /* You feel DEAD inside */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
626 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
627 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
628
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
629 DEFUN ("pq-clear", Fpq_clear, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
630 Forcibly erase a PGresult object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
631 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
632 (res))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
633 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
634 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
635
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
636 CHECK_PGRESULT (res);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
637 R = (XPGRESULT (res))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
638 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
639
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
640 PQclear (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
641 /* Genocided all @'s ... */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
642 (XPGRESULT (res))->pgresult = (PGresult *)NULL; /* You feel DEAD inside */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
643
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
644 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
645 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
646
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
647 DEFUN ("pq-is-busy", Fpq_is_busy, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
648 Return t if PQgetResult would block waiting for input.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
649 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
650 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
651 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
652 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
653
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
654 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
655 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
656 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
657
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
658 return PQisBusy (P) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
659 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
660
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
661 DEFUN ("pq-consume-input", Fpq_consume_input, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
662 Consume any available input from the backend.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
663 Returns nil if something bad happened.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
664 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
665 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
666 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
667 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
668
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
669 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
670 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
671 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
672
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
673 return PQconsumeInput (P) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
674 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
675
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
676 /* PQreset Reset the communication port with the backend.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
677 void PQreset(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
678 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
679 DEFUN ("pq-reset", Fpq_reset, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
680 Reset the connection to the backend.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
681 This function will close the connection to the backend and attempt to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
682 reestablish a new connection to the same postmaster, using all the same
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
683 parameters previously used. This may be useful for error recovery if a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
684 working connection is lost.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
685 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
686 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
687 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
688 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
689
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
690 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
691 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
692 PUKE_IF_NULL (P);/* we can resurrect a BAD connection, but not a dead one. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
693
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
694 PQreset (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
695
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
696 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
697 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
698
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
699 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
700 DEFUN ("pq-reset-start", Fpq_reset_start, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
701 Reset connection to the backend asynchronously.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
702 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
703 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
704 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
705 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
706
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
707 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
708 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
709 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
710
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
711 if (PQresetStart (P)) return Qt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
712 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
713 char *e = PQerrorMessage (P);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
714 signal_ferror (Qprocess_error, "libpq: %s", e);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
715 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
716 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
717
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
718 DEFUN ("pq-reset-poll", Fpq_reset_poll, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
719 Poll an asynchronous reset for completion.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
720 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
721 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
722 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
723 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
724 PostgresPollingStatusType polling_status;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
725
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
726 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
727
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
728 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
729 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
730
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
731 polling_status = PQresetPoll (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
732 switch (polling_status)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
733 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
734 case PGRES_POLLING_FAILED:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
735 /* Something Bad has happened */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
736 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
737 char *e = PQerrorMessage (P);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
738 signal_ferror (Qprocess_error, "libpq: %s", e);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
739 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
740 case PGRES_POLLING_OK:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
741 return Qpgres_polling_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
742 case PGRES_POLLING_READING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
743 return Qpgres_polling_reading;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
744 case PGRES_POLLING_WRITING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
745 return Qpgres_polling_writing;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
746 case PGRES_POLLING_ACTIVE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
747 return Qpgres_polling_active;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
748 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
749 /* they've added a new field we don't know about */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
750 signal_ferror (Qprocess_error, "Help! Unknown status code %08x from backend!", polling_status);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
751 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
752 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
753 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
754
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
755 DEFUN ("pq-request-cancel", Fpq_request_cancel, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
756 Attempt to request cancellation of the current operation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
757
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
758 The return value is t if the cancel request was successfully
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
759 dispatched, nil if not (in which case conn->errorMessage is set).
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
760 Note: successful dispatch is no guarantee that there will be any effect at
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
761 the backend. The application must read the operation result as usual.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
762 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
763 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
764 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
765 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
766
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
767 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
768 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
769 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
770
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
771 return PQrequestCancel (P) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
772 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
773
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
774 /* accessor function for the PGconn object */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
775 DEFUN ("pq-pgconn", Fpq_pgconn, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
776 Accessor function for the PGconn object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
777 Currently recognized symbols for the field:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
778 pq::db Database name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
779 pq::user Database user name
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
780 pq::pass Database user's password
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
781 pq::host Hostname of PostgreSQL backend connected to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
782 pq::port TCP port number of connection
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
783 pq::tty Debugging TTY (not used in Emacs)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
784 pq::options Additional backend options
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
785 pq::status Connection status (either OK or BAD)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
786 pq::error-message Last error message from the backend
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
787 pq::backend-pid Process ID of backend process
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
788 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
789 (conn, field))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
790 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
791 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
792
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
793 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
794 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
795 PUKE_IF_NULL (P); /* BAD connections still have state to query */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
796
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
797 if (EQ(field, Qpqdb))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
798 /* PQdb Returns the database name of the connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
799 char *PQdb(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
800 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
801 return build_ext_string (PQdb(P), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
802 else if (EQ (field, Qpquser))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
803 /* PQuser Returns the user name of the connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
804 char *PQuser(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
805 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
806 return build_ext_string (PQuser(P), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
807 else if (EQ (field, Qpqpass))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
808 /* PQpass Returns the password of the connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
809 char *PQpass(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
810 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
811 return build_ext_string (PQpass(P), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
812 else if (EQ (field, Qpqhost))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
813 /* PQhost Returns the server host name of the connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
814 char *PQhost(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
815 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
816 return build_ext_string (PQhost(P), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
817 else if (EQ (field, Qpqport))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
818 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
819 char *p;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
820 /* PQport Returns the port of the connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
821 char *PQport(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
822 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
823 if ((p = PQport(P)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
824 return make_int(atoi(p));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
825 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
826 return make_int(-1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
827 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
828 else if (EQ (field, Qpqtty))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
829 /* PQtty Returns the debug tty of the connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
830 char *PQtty(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
831 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
832 return build_ext_string (PQtty(P), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
833 else if (EQ (field, Qpqoptions))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
834 /* PQoptions Returns the backend options used in the connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
835 char *PQoptions(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
836 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
837 return build_ext_string (PQoptions(P), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
838 else if (EQ (field, Qpqstatus))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
839 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
840 ConnStatusType cst;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
841 /* PQstatus Returns the status of the connection. The status can be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
842 CONNECTION_OK or CONNECTION_BAD.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
843 ConnStatusType PQstatus(PGconn *conn)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
844 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
845 switch ((cst = PQstatus (P)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
846 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
847 case CONNECTION_OK: return Qpg_connection_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
848 case CONNECTION_BAD: return Qpg_connection_bad;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
849 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
850 case CONNECTION_STARTED: return Qpg_connection_started;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
851 case CONNECTION_MADE: return Qpg_connection_made;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
852 case CONNECTION_AWAITING_RESPONSE: return Qpg_connection_awaiting_response;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
853 case CONNECTION_AUTH_OK: return Qpg_connection_auth_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
854 case CONNECTION_SETENV: return Qpg_connection_setenv;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
855 #endif /* HAVE_POSTGRESQLV7 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
856 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
857 /* they've added a new field we don't know about */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
858 signal_ferror (Qprocess_error, "Help! Unknown connection status code %08x from backend!", cst);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
859 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
860 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
861 else if (EQ (field, Qpqerrormessage))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
862 /* PQerrorMessage Returns the error message most recently generated
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
863 by an operation on the connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
864 char *PQerrorMessage(PGconn* conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
865 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
866 return build_ext_string (PQerrorMessage(P), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
867 else if (EQ (field, Qpqbackendpid))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
868 /* PQbackendPID Returns the process ID of the backend server handling
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
869 this connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
870 int PQbackendPID(PGconn *conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
871 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
872 return make_int (PQbackendPID(P));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
873 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
874 signal_error (Qinvalid_argument, "bad PGconn accessor", Qunbound);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
875 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
876
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
877 /* Query functions */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
878 DEFUN ("pq-exec", Fpq_exec, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
879 Submit a query to Postgres and wait for the result.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
880 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
881 (conn, query))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
882 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
883 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
884 Lisp_PGresult *lisp_pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
885 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
886 char *c_query;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
887
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
888 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
889 CHECK_STRING (query);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
890
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
891 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
892 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
893
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
894 TO_EXTERNAL_FORMAT (LISP_STRING, query,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
895 C_STRING_ALLOCA, c_query, Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
896
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
897 R = PQexec (P, c_query);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
898 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
899 char *tag, buf[BLCKSZ];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
900
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
901 if (!R) out_of_memory ("query: out of memory", Qunbound);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
902 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
903 switch (PQresultStatus (R))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
904 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
905 case PGRES_BAD_RESPONSE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
906 tag = "bad response [%s]";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
907 goto err;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
908 case PGRES_NONFATAL_ERROR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
909 tag = "non-fatal error [%s]";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
910 goto err;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
911 case PGRES_FATAL_ERROR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
912 tag = "fatal error [%s]";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
913 err:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
914 strncpy (buf, PQresultErrorMessage (R), sizeof (buf));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
915 buf [sizeof (buf) - 1] = '\0';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
916 PQclear (R);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
917 signal_ferror (Qprocess_error, tag, buf);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
918 /*NOTREACHED*/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
919 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
920 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
921 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
922 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
923
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
924 lisp_pgresult = allocate_pgresult ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
925 lisp_pgresult->pgresult = R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
926
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
927 return make_pgresult (lisp_pgresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
928 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
929
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
930 DEFUN ("pq-send-query", Fpq_send_query, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
931 Submit a query to Postgres and don't wait for the result.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
932 Returns: t if successfully submitted
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
933 nil if error (conn->errorMessage is set)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
934 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
935 (conn, query))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
936 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
937 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
938 char *c_query;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
939
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
940 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
941 CHECK_STRING (query);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
942
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
943 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
944 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
945
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
946 TO_EXTERNAL_FORMAT (LISP_STRING, query,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
947 C_STRING_ALLOCA, c_query, Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
948
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
949 if (PQsendQuery (P, c_query)) return Qt;
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
950 else signal_ferror (Qprocess_error, "async query: %s", PQerrorMessage (P));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
951 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
952
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
953 DEFUN ("pq-get-result", Fpq_get_result, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
954 Retrieve an asynchronous result from a query.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
955 NIL is returned when no more query work remains.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
956 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
957 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
958 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
959 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
960 Lisp_PGresult *lisp_pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
961 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
962
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
963 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
964
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
965 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
966 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
967
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
968 R = PQgetResult (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
969 if (!R) return Qnil; /* not an error, there's no more data to get */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
970
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
971 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
972 char *tag, buf[BLCKSZ];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
973
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
974 switch (PQresultStatus (R))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
975 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
976 case PGRES_BAD_RESPONSE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
977 tag = "bad response [%s]";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
978 goto err;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
979 case PGRES_NONFATAL_ERROR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
980 tag = "non-fatal error [%s]";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
981 goto err;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
982 case PGRES_FATAL_ERROR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
983 tag = "fatal error [%s]";
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
984 err:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
985 strncpy (buf, PQresultErrorMessage (R), sizeof (buf));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
986 buf[sizeof (buf) - 1] = '\0';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
987 PQclear (R);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
988 signal_ferror (Qprocess_error, tag, buf);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
989 /*NOTREACHED*/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
990 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
991 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
992 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
993 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
994
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
995 lisp_pgresult = allocate_pgresult();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
996 lisp_pgresult->pgresult = R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
997
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
998 return make_pgresult (lisp_pgresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
999 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1000
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1001 DEFUN ("pq-result-status", Fpq_result_status, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1002 Return result status of the query.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1003 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1004 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1005 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1006 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1007 ExecStatusType est;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1008
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1009 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1010 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1011 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1012
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1013 switch ((est = PQresultStatus (R))) {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1014 case PGRES_EMPTY_QUERY: return Qpgres_empty_query;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1015 case PGRES_COMMAND_OK: return Qpgres_command_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1016 case PGRES_TUPLES_OK: return Qpgres_tuples_ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1017 case PGRES_COPY_OUT: return Qpgres_copy_out;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1018 case PGRES_COPY_IN: return Qpgres_copy_in;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1019 case PGRES_BAD_RESPONSE: return Qpgres_bad_response;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1020 case PGRES_NONFATAL_ERROR: return Qpgres_nonfatal_error;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1021 case PGRES_FATAL_ERROR: return Qpgres_fatal_error;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1022 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1023 /* they've added a new field we don't know about */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1024 signal_ferror (Qprocess_error, "Help! Unknown exec status code %08x from backend!", est);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1025 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1026 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1027
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1028 DEFUN ("pq-res-status", Fpq_res_status, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1029 Return stringified result status of the query.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1030 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1031 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1032 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1033 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1034
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1035 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1036 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1037 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1038
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1039 return build_ext_string (PQresStatus (PQresultStatus (R)), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1040 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1041
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1042 /* Sundry PGresult accessor functions */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1043 DEFUN ("pq-result-error-message", Fpq_result_error_message, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1044 Return last message associated with the query.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1045 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1046 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1047 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1048 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1049
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1050 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1051 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1052 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1053
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1054 return build_ext_string (PQresultErrorMessage (R), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1055 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1056
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1057 DEFUN ("pq-ntuples", Fpq_ntuples, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1058 Return the number of tuples (instances) in the query result.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1059 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1060 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1061 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1062 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1063
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1064 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1065 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1066 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1067
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1068 return make_int (PQntuples (R));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1069 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1070
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1071 DEFUN ("pq-nfields", Fpq_nfields, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1072 Return the number of fields (attributes) in each tuple of the query result.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1073 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1074 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1075 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1076 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1077
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1078 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1079 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1080 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1081
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1082 return make_int (PQnfields (R));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1083 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1084
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1085 DEFUN ("pq-binary-tuples", Fpq_binary_tuples, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1086 Return t if the query result contains binary data, nil otherwise.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1087 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1088 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1089 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1090 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1091
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1092 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1093 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1094 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1095
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1096 return (PQbinaryTuples (R)) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1097 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1098
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1099 DEFUN ("pq-fname", Fpq_fname, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1100 Return the field (attribute) name associated with the given field index.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1101 Field indices start at 0.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1102 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1103 (result, field_index))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1104 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1105 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1106
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1107 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1108 CHECK_INT (field_index);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1109 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1110 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1111
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1112 return build_ext_string (PQfname (R, XINT (field_index)), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1113 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1114
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1115 DEFUN ("pq-fnumber", Fpq_fnumber, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1116 Return the number of fields (attributes) in each tuple of the query result.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1117 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1118 (result, field_name))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1119 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1120 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1121 char *c_field_name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1122
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1123 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1124 CHECK_STRING (field_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1125 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1126 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1127
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1128 TO_EXTERNAL_FORMAT (LISP_STRING, field_name,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1129 C_STRING_ALLOCA, c_field_name, Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1130
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1131 return make_int (PQfnumber (R, c_field_name));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1132 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1133
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1134 DEFUN ("pq-ftype", Fpq_ftype, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1135 Return the field type associated with the given field index.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1136 The integer returned is the internal coding of the type. Field indices
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1137 start at 0.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1138 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1139 (result, field_num))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1140 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1141 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1142
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1143 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1144 CHECK_INT (field_num);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1145 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1146 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1147
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1148 return make_int (PQftype (R, XINT (field_num)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1149 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1150
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1151 DEFUN ("pq-fsize", Fpq_fsize, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1152 Return the field size in bytes associated with the given field index.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1153 Field indices start at 0.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1154 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1155 (result, field_index))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1156 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1157 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1158
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1159 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1160 CHECK_INT (field_index);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1161 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1162 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1163
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1164 return make_int (PQftype (R, XINT (field_index)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1165 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1166
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1167 DEFUN ("pq-fmod", Fpq_fmod, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1168 Return the type modifier associated with a field.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1169 Field indices start at 0.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1170 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1171 (result, field_index))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1172 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1173 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1174
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1175 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1176 CHECK_INT (field_index);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1177 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1178 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1179
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1180 return make_int (PQfmod (R, XINT (field_index)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1181 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1182
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1183 DEFUN ("pq-get-value", Fpq_get_value, 3, 3, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1184 Return a single field (attribute) value of one tuple of a PGresult.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1185 Tuple and field indices start at 0.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1186 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1187 (result, tup_num, field_num))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1188 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1189 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1190
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1191 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1192 CHECK_INT (tup_num);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1193 CHECK_INT (field_num);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1194 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1195 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1196
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1197 return build_ext_string (PQgetvalue (R, XINT (tup_num), XINT (field_num)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1198 PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1199 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1200
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1201 DEFUN ("pq-get-length", Fpq_get_length, 3, 3, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1202 Returns the length of a field value in bytes.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1203 If result is binary, i.e. a result of a binary portal, then the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1204 length returned does NOT include the size field of the varlena. (The
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1205 data returned by PQgetvalue doesn't either.)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1206 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1207 (result, tup_num, field_num))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1208 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1209 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1210
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1211 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1212 CHECK_INT (tup_num);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1213 CHECK_INT (field_num);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1214 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1215 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1216
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1217 return make_int (PQgetlength (R, XINT (tup_num), XINT (field_num)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1218 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1219
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1220 DEFUN ("pq-get-is-null", Fpq_get_is_null, 3, 3, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1221 Returns the null status of a field value.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1222 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1223 (result, tup_num, field_num))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1224 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1225 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1226
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1227 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1228 CHECK_INT (tup_num);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1229 CHECK_INT (field_num);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1230 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1231 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1232
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1233 return PQgetisnull (R, XINT (tup_num), XINT (field_num)) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1234 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1235
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1236 DEFUN ("pq-cmd-status", Fpq_cmd_status, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1237 Returns the command status string from the SQL command that generated the result.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1238 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1239 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1240 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1241 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1242
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1243 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1244 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1245 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1246
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1247 return build_ext_string (PQcmdStatus (R), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1248 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1249
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1250 DEFUN ("pq-cmd-tuples", Fpq_cmd_tuples, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1251 Returns the number of rows affected by the SQL command.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1252 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1253 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1254 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1255 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1256
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1257 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1258 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1259 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1260
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1261 return build_ext_string (PQcmdTuples (R), PG_OS_CODING);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1262 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1263
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1264 DEFUN ("pq-oid-value", Fpq_oid_value, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1265 Returns the object id of the tuple inserted.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1266 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1267 (result))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1268 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1269 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1270
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1271 CHECK_PGRESULT (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1272 R = (XPGRESULT (result))->pgresult;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1273 PUKE_IF_NULL (R);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1274
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1275 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1276 return make_int (PQoidValue (R));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1277 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1278 /* Use the old interface */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1279 return make_int (atoi (PQoidStatus (R)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1280 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1281 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1282
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1283 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1284 DEFUN ("pq-set-nonblocking", Fpq_set_nonblocking, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1285 Sets the PGconn's database connection non-blocking if the arg is TRUE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1286 or makes it non-blocking if the arg is FALSE, this will not protect
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1287 you from PQexec(), you'll only be safe when using the non-blocking API.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1288
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1289 Needs to be called only on a connected database connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1290 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1291 (conn, arg))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1292 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1293 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1294
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1295 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1296 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1297 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1298
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1299 return make_int (PQsetnonblocking (P, !NILP (arg)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1300 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1301
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1302 DEFUN ("pq-is-nonblocking", Fpq_is_nonblocking, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1303 Return the blocking status of the database connection.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1304 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1305 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1306 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1307 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1308
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1309 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1310 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1311 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1312
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1313 return PQisnonblocking (P) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1314 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1315
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1316 DEFUN ("pq-flush", Fpq_flush, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1317 Force the write buffer to be written (or at least try).
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1318 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1319 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1320 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1321 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1322
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1323 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1324 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1325 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1326
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1327 return make_int (PQflush (P));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1328 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1329 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1330
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1331 DEFUN ("pq-notifies", Fpq_notifies, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1332 Return the latest async notification that has not yet been handled.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1333 If there has been a notification, then a list of two elements will be returned.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1334 The first element contains the relation name being notified, the second
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1335 element contains the backend process ID number. nil is returned if there
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1336 aren't any notifications to process.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1337 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1338 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1339 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1340 /* This function cannot GC */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1341 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1342 PGnotify *PGN;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1343
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1344 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1345 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1346 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1347
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1348 PGN = PQnotifies (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1349 if (!PGN)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1350 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1351 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1352 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1353 Lisp_Object temp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1354
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1355 temp = list2 (build_ext_string (PGN->relname, PG_OS_CODING), make_int (PGN->be_pid));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1356 free ((void *)PGN);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1357 return temp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1358 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1359 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1360
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1361 #if defined (HAVE_POSTGRESQLV7) && defined(MULE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1362 DEFUN ("pq-env-2-encoding", Fpq_env_2_encoding, 0, 0, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1363 Get encoding id from environment variable PGCLIENTENCODING.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1364 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1365 ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1366 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1367 return make_int (PQenv2encoding ());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1368 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1369 #endif /* MULE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1370
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1371 DEFUN ("pq-lo-import", Fpq_lo_import, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1372 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1373 (conn, filename))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1374 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1375 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1376 char *c_filename;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1377
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1378 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1379 CHECK_STRING (filename);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1380
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1381 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1382 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1383
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1384 TO_EXTERNAL_FORMAT (LISP_STRING, filename,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1385 C_STRING_ALLOCA, c_filename,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1386 Qfile_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1387
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1388 return make_int ((int)lo_import (P, c_filename));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1389 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1390
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1391 DEFUN ("pq-lo-export", Fpq_lo_export, 3, 3, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1392 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1393 (conn, oid, filename))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1394 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1395 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1396 char *c_filename;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1397
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1398 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1399 CHECK_INT (oid);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1400 CHECK_STRING (filename);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1401
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1402 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1403 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1404
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1405 TO_EXTERNAL_FORMAT (LISP_STRING, filename,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1406 C_STRING_ALLOCA, c_filename, Qfile_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1407
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1408 return make_int ((int)lo_export (P, XINT (oid), c_filename));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1409 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1410
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1411 DEFUN ("pq-make-empty-pgresult", Fpq_make_empty_pgresult, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1412 Make an empty PGresult object with the given status.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1413 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1414 (conn, status))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1415 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1416 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1417 Lisp_PGresult *lpgr;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1418 PGresult *R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1419 ExecStatusType est;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1420
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1421 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1422 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1423 CHECK_LIVE_CONNECTION (P); /* needed here? */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1424
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1425 if (EQ (status, Qpgres_empty_query)) est = PGRES_EMPTY_QUERY;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1426 else if (EQ (status, Qpgres_command_ok)) est = PGRES_COMMAND_OK;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1427 else if (EQ (status, Qpgres_tuples_ok)) est = PGRES_TUPLES_OK;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1428 else if (EQ (status, Qpgres_copy_out)) est = PGRES_COPY_OUT;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1429 else if (EQ (status, Qpgres_copy_in)) est = PGRES_COPY_IN;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1430 else if (EQ (status, Qpgres_bad_response)) est = PGRES_BAD_RESPONSE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1431 else if (EQ (status, Qpgres_nonfatal_error)) est = PGRES_NONFATAL_ERROR;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1432 else if (EQ (status, Qpgres_fatal_error)) est = PGRES_FATAL_ERROR;
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1433 else invalid_constant ("bad status symbol", status);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1434
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1435 R = PQmakeEmptyPGresult (P, est);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1436 if (!R) out_of_memory (0, Qunbound);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1437
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1438 lpgr = allocate_pgresult ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1439 lpgr->pgresult = R;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1440
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1441 return make_pgresult (lpgr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1442 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1443
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1444 DEFUN ("pq-get-line", Fpq_get_line, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1445 Retrieve a line from server in copy in operation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1446 The return value is a dotted pair where the cons cell is an integer code:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1447 -1: Copying is complete
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1448 0: A record is complete
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1449 1: A record is incomplete, it will be continued in the next `pq-get-line'
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1450 operation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1451 and the cdr cell is returned string data.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1452
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1453 The copy operation is complete when the value `\.' (backslash dot) is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1454 returned.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1455 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1456 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1457 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1458 char buffer[BLCKSZ]; /* size of a Postgres disk block */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1459 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1460 int ret;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1461
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1462 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1463 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1464 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1465
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1466 ret = PQgetline (P, buffer, sizeof (buffer));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1467
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1468 return Fcons (make_int (ret), build_ext_string (buffer, PG_OS_CODING));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1469 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1470
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1471 DEFUN ("pq-put-line", Fpq_put_line, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1472 Send a line to the server in copy out operation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1473
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1474 Returns t if the operation succeeded, nil otherwise.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1475 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1476 (conn, string))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1477 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1478 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1479 char *c_string;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1480
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1481 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1482 CHECK_STRING (string);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1483
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1484 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1485 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1486 TO_EXTERNAL_FORMAT (LISP_STRING, string,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1487 C_STRING_ALLOCA, c_string, Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1488
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1489 return !PQputline (P, c_string) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1490 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1491
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1492 DEFUN ("pq-get-line-async", Fpq_get_line_async, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1493 Get a line from the server in copy in operation asynchronously.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1494
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1495 This routine is for applications that want to do "COPY <rel> to stdout"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1496 asynchronously, that is without blocking. Having issued the COPY command
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1497 and gotten a PGRES_COPY_OUT response, the app should call PQconsumeInput
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1498 and this routine until the end-of-data signal is detected. Unlike
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1499 PQgetline, this routine takes responsibility for detecting end-of-data.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1500
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1501 On each call, PQgetlineAsync will return data if a complete newline-
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1502 terminated data line is available in libpq's input buffer, or if the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1503 incoming data line is too long to fit in the buffer offered by the caller.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1504 Otherwise, no data is returned until the rest of the line arrives.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1505
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1506 If -1 is returned, the end-of-data signal has been recognized (and removed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1507 from libpq's input buffer). The caller *must* next call PQendcopy and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1508 then return to normal processing.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1509
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1510 RETURNS:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1511 -1 if the end-of-copy-data marker has been recognized
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1512 0 if no data is available
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1513 >0 the number of bytes returned.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1514 The data returned will not extend beyond a newline character. If possible
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1515 a whole line will be returned at one time. But if the buffer offered by
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1516 the caller is too small to hold a line sent by the backend, then a partial
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1517 data line will be returned. This can be detected by testing whether the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1518 last returned byte is '\n' or not.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1519 The returned string is *not* null-terminated.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1520 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1521 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1522 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1523 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1524 char buffer[BLCKSZ];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1525 int ret;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1526
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1527 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1528
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1529 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1530 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1531
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1532 ret = PQgetlineAsync (P, buffer, sizeof (buffer));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1533
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1534 if (ret == -1) return Qt; /* done! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1535 else if (!ret) return Qnil; /* no data yet */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1536 else return Fcons (make_int (ret),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1537 make_ext_string ((Extbyte *) buffer, ret, PG_OS_CODING));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1538 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1539
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1540 DEFUN ("pq-put-nbytes", Fpq_put_nbytes, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1541 Asynchronous copy out.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1542 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1543 (conn, data))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1544 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1545 /* NULs are not allowed. I don't think this matters at this time. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1546 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1547 char *c_data;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1548
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1549 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1550 CHECK_STRING (data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1551
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1552 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1553 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1554 TO_EXTERNAL_FORMAT (LISP_STRING, data,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1555 C_STRING_ALLOCA, c_data, Qnative);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1556
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1557 return !PQputnbytes (P, c_data, strlen (c_data)) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1558 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1559
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1560 DEFUN ("pq-end-copy", Fpq_end_copy, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1561 End a copying operation.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1562 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1563 (conn))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1564 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1565 PGconn *P;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1566
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1567 CHECK_PGCONN (conn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1568 P = (XPGCONN (conn))->pgconn;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1569 CHECK_LIVE_CONNECTION (P);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1570
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1571 return PQendcopy (P) ? Qt : Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1572 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1573
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1574 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1575 syms_of_postgresql(void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1576 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1577 #ifndef RUNNING_XEMACS_21_1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1578 INIT_LRECORD_IMPLEMENTATION (pgconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1579 INIT_LRECORD_IMPLEMENTATION (pgresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1580 #endif
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1581 DEFSYMBOL (Qpostgresql);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1582
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1583 /* opaque exported types */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1584 DEFSYMBOL (Qpgconnp);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
1585 DEFSYMBOL (Qpgresultp);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1586
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1587 /* connection status types */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1588 defsymbol (&Qpg_connection_ok, "pg::connection-ok");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1589 defsymbol (&Qpg_connection_bad, "pg::connection-bad");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1590 defsymbol (&Qpg_connection_started, "pg::connection-started");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1591 defsymbol (&Qpg_connection_made, "pg::connection-made");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1592 defsymbol (&Qpg_connection_awaiting_response, "pg::connection-awaiting-response");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1593 defsymbol (&Qpg_connection_auth_ok, "pg::connection-auth-ok");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1594 defsymbol (&Qpg_connection_setenv, "pg::connection-setenv");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1595
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1596 /* Fields of PGconn */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1597 defsymbol (&Qpqdb, "pq::db");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1598 defsymbol (&Qpquser, "pq::user");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1599 defsymbol (&Qpqpass, "pq::pass");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1600 defsymbol (&Qpqhost, "pq::host");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1601 defsymbol (&Qpqport, "pq::port");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1602 defsymbol (&Qpqtty, "pq::tty");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1603 defsymbol (&Qpqoptions, "pq::options");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1604 defsymbol (&Qpqstatus, "pq::status");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1605 defsymbol (&Qpqerrormessage, "pq::error-message");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1606 defsymbol (&Qpqbackendpid, "pq::backend-pid");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1607
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1608 /* Query status results */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1609 defsymbol (&Qpgres_empty_query, "pgres::empty-query");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1610 defsymbol (&Qpgres_command_ok, "pgres::command-ok");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1611 defsymbol (&Qpgres_tuples_ok, "pgres::tuples-ok");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1612 defsymbol (&Qpgres_copy_out, "pgres::copy-out");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1613 defsymbol (&Qpgres_copy_in, "pgres::copy-in");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1614 defsymbol (&Qpgres_bad_response, "pgres::bad-response");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1615 defsymbol (&Qpgres_nonfatal_error, "pgres::nonfatal-error");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1616 defsymbol (&Qpgres_fatal_error, "pgres::fatal-error");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1617
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1618 /* Poll status results */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1619 defsymbol (&Qpgres_polling_failed, "pgres::polling-failed");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1620 defsymbol (&Qpgres_polling_reading, "pgres::polling-reading");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1621 defsymbol (&Qpgres_polling_writing, "pgres::polling-writing");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1622 defsymbol (&Qpgres_polling_ok, "pgres::polling-ok");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1623 defsymbol (&Qpgres_polling_active, "pgres::polling-active");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1624
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1625 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1626 DEFSUBR (Fpq_connect_start);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1627 DEFSUBR (Fpq_connect_poll);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1628 #ifdef MULE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1629 DEFSUBR (Fpq_client_encoding);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1630 DEFSUBR (Fpq_set_client_encoding);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1631 #endif /* MULE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1632 #endif /* HAVE_POSTGRESQLV7 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1633 DEFSUBR (Fpq_conn_defaults);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1634 DEFSUBR (Fpq_connectdb);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1635 DEFSUBR (Fpq_finish);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1636 DEFSUBR (Fpq_clear);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1637 DEFSUBR (Fpq_is_busy);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1638 DEFSUBR (Fpq_consume_input);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1639
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1640 DEFSUBR (Fpq_reset);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1641 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1642 DEFSUBR (Fpq_reset_start);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1643 DEFSUBR (Fpq_reset_poll);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1644 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1645 DEFSUBR (Fpq_request_cancel);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1646 DEFSUBR (Fpq_pgconn);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1647
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1648 DEFSUBR (Fpq_exec);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1649 DEFSUBR (Fpq_send_query);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1650 DEFSUBR (Fpq_get_result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1651 DEFSUBR (Fpq_result_status);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1652 DEFSUBR (Fpq_res_status);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1653 DEFSUBR (Fpq_result_error_message);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1654 DEFSUBR (Fpq_ntuples);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1655 DEFSUBR (Fpq_nfields);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1656 DEFSUBR (Fpq_binary_tuples);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1657 DEFSUBR (Fpq_fname);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1658 DEFSUBR (Fpq_fnumber);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1659 DEFSUBR (Fpq_ftype);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1660 DEFSUBR (Fpq_fsize);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1661 DEFSUBR (Fpq_fmod);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1662 /***/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1663 DEFSUBR (Fpq_get_value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1664 DEFSUBR (Fpq_get_length);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1665 DEFSUBR (Fpq_get_is_null);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1666 DEFSUBR (Fpq_cmd_status);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1667 DEFSUBR (Fpq_cmd_tuples);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1668 DEFSUBR (Fpq_oid_value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1669
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1670 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1671 DEFSUBR (Fpq_set_nonblocking);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1672 DEFSUBR (Fpq_is_nonblocking);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1673 DEFSUBR (Fpq_flush);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1674 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1675 DEFSUBR (Fpq_notifies);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1676
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1677 #if defined (HAVE_POSTGRESQLV7) && defined(MULE)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1678 DEFSUBR (Fpq_env_2_encoding);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1679 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1680
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1681 DEFSUBR (Fpq_lo_import);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1682 DEFSUBR (Fpq_lo_export);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1683
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1684 DEFSUBR (Fpq_make_empty_pgresult);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1685
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1686 /* copy in/out functions */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1687 DEFSUBR (Fpq_get_line);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1688 DEFSUBR (Fpq_put_line);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1689 DEFSUBR (Fpq_get_line_async);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1690 DEFSUBR (Fpq_put_nbytes);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1691 DEFSUBR (Fpq_end_copy);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1692 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1693
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1694 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1695 vars_of_postgresql(void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1696 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1697 Fprovide (Qpostgresql);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1698 #ifdef HAVE_POSTGRESQLV7
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1699 Fprovide (intern ("postgresqlv7"));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1700 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1701 #ifndef RUNNING_XEMACS_21_1
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1702 Vpg_coding_system = Qnative;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1703 DEFVAR_LISP ("pg-coding-system", &Vpg_coding_system /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1704 Default Postgres client coding system.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1705 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1706 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1707
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1708 DEFVAR_LISP ("pg:host", &VXPGHOST /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1709 Default PostgreSQL server name.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1710 If not set, the server running on the local host is used. The
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1711 initial value is set from the PGHOST environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1712 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1713
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1714 DEFVAR_LISP ("pg:user", &VXPGUSER /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1715 Default PostgreSQL user name.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1716 This value is used when connecting to a database for authentication.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1717 The initial value is set from the PGUSER environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1718 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1719
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1720 DEFVAR_LISP ("pg:options", &VXPGOPTIONS /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1721 Default PostgreSQL user name.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1722 This value is used when connecting to a database for authentication.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1723 The initial value is set from the PGUSER environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1724 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1725
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1726 DEFVAR_LISP ("pg:port", &VXPGPORT /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1727 Default port to connect to PostgreSQL backend.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1728 This value is used when connecting to a database.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1729 The initial value is set from the PGPORT environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1730 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1731
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1732 DEFVAR_LISP ("pg:tty", &VXPGTTY /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1733 Default debugging TTY.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1734 There is no useful setting of this variable in the XEmacs Lisp API.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1735 The initial value is set from the PGTTY environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1736 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1737
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1738 DEFVAR_LISP ("pg:database", &VXPGDATABASE /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1739 Default database to connect to.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1740 The initial value is set from the PGDATABASE environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1741 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1742
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1743 DEFVAR_LISP ("pg:realm", &VXPGREALM /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1744 Default kerberos realm to use for authentication.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1745 The initial value is set from the PGREALM environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1746 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1747
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1748 #ifdef MULE
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1749 /* It's not clear whether this is any use. My intent is to
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1750 autodetect the coding system from the database. */
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1751 DEFVAR_LISP ("pg:client-encoding", &VXPGCLIENTENCODING /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1752 Default client encoding to use.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1753 The initial value is set from the PGCLIENTENCODING environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1754 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1755 #endif
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1756
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1757 #if !defined(HAVE_POSTGRESQLV7)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1758 DEFVAR_LISP ("pg:authtype", &VXPGAUTHTYPE /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1759 Default authentication to use.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1760 The initial value is set from the PGAUTHTYPE environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1761
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1762 WARNING: This variable has gone away in versions of PostgreSQL newer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1763 than 6.5.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1764 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1765 #endif
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1766
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1767 DEFVAR_LISP ("pg:geqo", &VXPGGEQO /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1768 Genetic Query Optimizer options.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1769 The initial value is set from the PGGEQO environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1770 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1771
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1772 DEFVAR_LISP ("pg:cost-index", &VXPGCOSTINDEX /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1773 Default cost index options.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1774 The initial value is set from the PGCOSTINDEX environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1775 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1776
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1777 DEFVAR_LISP ("pg:cost-heap", &VXPGCOSTHEAP /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1778 Default cost heap options.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1779 The initial value is set from the PGCOSTHEAP environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1780 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1781
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1782 DEFVAR_LISP ("pg:tz", &VXPGTZ /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1783 Default timezone to use.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1784 The initial value is set from the PGTZ environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1785 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1786
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1787 DEFVAR_LISP ("pg:date-style", &VXPGDATESTYLE /*
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1788 Default date style to use.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1789 The initial value is set from the PGDATESTYLE environment variable.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1790 */ );
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1791 }
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1792
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1793 /* These initializations should not be done at dump-time. */
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1794 void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1795 init_postgresql_from_environment (void)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1796 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1797 Intbyte *p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1798
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1799 #define FROB(envvar, var) \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1800 if ((p = egetenv (envvar))) \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1801 var = build_intstring (p); \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1802 else \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1803 var = Qnil
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1804
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1805 if (initialized)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1806 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1807 FROB ("PGHOST", VXPGHOST);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1808 FROB ("PGUSER", VXPGUSER);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1809 FROB ("PGOPTIONS", VXPGOPTIONS);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1810
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1811 if ((p = egetenv ("PGPORT")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1812 VXPGPORT = make_int (atoi ((char *) p));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1813 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1814 VXPGPORT = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1815
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1816 FROB ("PGTTY", VXPGTTY);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1817 FROB ("PGDATABASE", VXPGDATABASE);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1818 FROB ("PGREALM", VXPGREALM);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1819 #ifdef MULE
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1820 /* It's not clear whether this is any use. My intent is to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1821 autodetect the coding system from the database. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1822 FROB ("PGCLIENTENCODING", VXPGCLIENTENCODING);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1823 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1824
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1825 #if !defined(HAVE_POSTGRESQLV7)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1826 FROB ("PGAUTHTYPE", VXPGAUTHTYPE);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1827 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1828
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1829 FROB ("PGGEQO", VXPGGEQO);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1830 FROB ("PGCOSTINDEX", VXPGCOSTINDEX);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1831 FROB ("PGCOSTHEAP", VXPGCOSTHEAP);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1832 FROB ("PGTZ", VXPGTZ);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1833 FROB ("PGDATESTYLE", VXPGDATESTYLE);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 563
diff changeset
1834 #undef FROB
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1835 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
1836 }
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1837