File: libpqmodule.h

package info (click to toggle)
python-pgsql 2.4.0-5sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 984 kB
  • ctags: 1,291
  • sloc: ansic: 5,913; python: 4,334; sh: 73; makefile: 71
file content (121 lines) | stat: -rw-r--r-- 4,359 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ident "@(#) $Id: libpqmodule.h,v 1.10 2003/06/16 11:59:41 ghaering Exp $"
#ifndef Pg_LIBPQMODULE_H
#define Pg_LIBPQMODULE_H
#ifdef __cplusplus
extern "C" {
#endif

/***********************************************************************\
| Copyright 2001 by Billy G. Allie					|
| All rights Reserved.							|
|									|
| Permission to use, copy, modify, and distribute this software and its	|
| documentation for any purpose and without fee is hereby granted, pro-	|
| vided that the above copyright notice appear in all copies and that	|
| both that copyright notice and this permission notice appear in sup-	|
| porting documentation, and that the copyright owner's name not be	|
| used in advertising or publicity pertaining to distribution of the	|
| software without specific, written prior permission.			|
|									|
| THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,	|
| INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN	|
| NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR	|
| CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS	|
| OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE	|
| OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE	|
| USE OR PERFORMANCE OF THIS SOFTWARE.					|
\***********************************************************************/

#include <libpq-fe.h>
#include <libpq/libpq-fs.h>
#include "port/port.h"
#include "pg_types.h"
#include "pgboolean.h"
#include "pgint2object.h"
#include "pgint8object.h"
#include "pgconnection.h"
#include "pgresult.h"
#include "pglargeobject.h"
#include "pgnotify.h"
#include "pgversion.h"

#ifdef MS_WIN32
#define WIN32_LEAN_AND_MEAN
#include <winsock.h>
#include <windows.h>
#include "win32.h"
#endif

#define MODULE_NAME	"libpq"

#if !defined(MAX_BUFFER_SIZE)
#    define MAX_BUFFER_SIZE (8192)	/* Maximum DB tuple size */
#endif

#if !defined(TRUE)
#    define TRUE (1)
#endif

#if !defined(FALSE)
#    define FALSE (0)
#endif

/***********************************************************************\
| The following 'MAGIC' number defines that last reserved OID.		|
\***********************************************************************/

#define MAX_RESERVED_OID	16383	/* 2^14 - 1 */

/***********************************************************************\
| It appears that versions of PostgreSQL prior to version 7.1 do not	|
| define InvalidOid, at least not in an area accessable to external	|
| programs.								|
\***********************************************************************/

#if !defined(InvalidOid)
#    define InvalidOid	((Oid)0)
#endif

/***********************************************************************\
| The following macro definitions (pg_{BEGIN|END}_ALLOW_THREADS) are	|
| used to wrap libpq function calls that can block if the connection is	|
| in blocking mode.  They are based on the Py_{BEGIN|END}_ALLOW_THREADS	|
| macros, which are used to wrap libpq functions that always block.	|
\***********************************************************************/

#if defined(WITH_THREAD)
#   define Pg_BEGIN_ALLOW_THREADS(cnx) \
    { \
	PyThreadState *_save = (PyThreadState *)NULL; \
	if (!PQisnonblocking(cnx)) \
	    _save = PyEval_SaveThread();
#   define Pg_END_ALLOW_THREADS(cnx) \
	if (!PQisnonblocking(cnx)) \
	   PyEval_RestoreThread(_save); \
    }
#else
#   define Pg_BEGIN_ALLOW_THREADS(cnx)
#   define Pg_END_ALLOW_THREADS(cnx)
#endif

/***************************************\
| Exception Objects for this module.	|
\***************************************/
					  /* StandardError		*/
extern PyObject *PqErr_Warning;		  /* |--Warning			*/
extern PyObject *PqErr_Error;		  /* +--Error			*/
extern PyObject *PqErr_InterfaceError;	  /*    |--InterfaceError	*/
extern PyObject *PqErr_DatabaseError;	  /*	+--DatabaseError	*/
extern PyObject *PqErr_DataError;	  /*	   |--DataError		*/
extern PyObject *PqErr_OperationalError;  /*	   |--OperationaError	*/
extern PyObject *PqErr_IntegrityError;	  /*	   |--IntegrityError	*/
extern PyObject *PqErr_InternalError;	  /*	   |--InternalError	*/
extern PyObject *PqErr_ProgrammingError;  /*	   |--ProgrammingError	*/
extern PyObject *PqErr_NotSupportedError; /*	   +--NotSupportedError	*/

void *PyMem_Strdup(void *);

#ifdef __cplusplus
}
#endif
#endif /* !Pg_LIBPQMODULE_H */