psqlodbc.h 4.28 KB
Newer Older
1 2 3 4 5 6 7 8 9

/* File:            psqlodbc.h
 *
 * Description:     This file contains defines and declarations that are related to
 *                  the entire driver.
 *
 * Comments:        See "notice.txt" for copyright and license information.
 *
 */
10 11 12 13

#ifndef __PSQLODBC_H__
#define __PSQLODBC_H__

Byron Nikolaidis's avatar
Byron Nikolaidis committed
14
#ifdef HAVE_CONFIG_H
15
#include "config.h"
Byron Nikolaidis's avatar
Byron Nikolaidis committed
16 17
#endif

18 19 20
#include <stdio.h>	/* for FILE* pointers: see GLOBAL_VALUES */

#ifndef WIN32
Byron Nikolaidis's avatar
Byron Nikolaidis committed
21 22 23 24 25 26 27
#define Int4 long int
#define UInt4 unsigned int
#define Int2 short
#define UInt2 unsigned short
typedef float SFLOAT;
typedef double SDOUBLE;
#else
28 29 30 31
#define Int4 int
#define UInt4 unsigned int
#define Int2 short
#define UInt2 unsigned short
Byron Nikolaidis's avatar
Byron Nikolaidis committed
32
#endif
33 34 35

typedef UInt4 Oid;

36 37 38 39 40 41
/* Driver stuff */
#define ODBCVER				0x0200
#define DRIVER_ODBC_VER		"02.00"

#define DRIVERNAME             "PostgreSQL ODBC"
#define DBMS_NAME              "PostgreSQL"
42 43
#define DBMS_VERSION           "06.40.0004 PostgreSQL 6.4"
#define POSTGRESDRIVERVERSION  "06.40.0004"
44 45 46 47 48 49

#ifdef WIN32
#define DRIVER_FILE_NAME		"PSQLODBC.DLL"
#else
#define DRIVER_FILE_NAME		"libpsqlodbc.so"
#endif
50 51 52

/* Limits */
#define MAX_MESSAGE_LEN				8192
53
#define MAX_CONNECT_STRING			4096
54 55
#define ERROR_MSG_LENGTH			4096
#define FETCH_MAX					100		/* default number of rows to cache for declare/fetch */
56
#define TUPLE_MALLOC_INC			100
57
#define SOCK_BUFFER_SIZE			4096	/* default socket buffer size */
58 59 60 61 62
#define MAX_CONNECTIONS				128		/* conns per environment (arbitrary)  */
#define MAX_FIELDS					512
#define BYTELEN						8
#define VARHDRSZ					sizeof(Int4)

Byron Nikolaidis's avatar
Byron Nikolaidis committed
63 64 65 66
#define MAX_TABLE_LEN				32
#define MAX_COLUMN_LEN				32
#define MAX_CURSOR_LEN				32

67 68 69 70
/*	Registry length limits */
#define LARGE_REGISTRY_LEN			4096	/* used for special cases */
#define MEDIUM_REGISTRY_LEN			256		/* normal size for user,database,etc. */
#define SMALL_REGISTRY_LEN			10		/* for 1/0 settings */
71 72 73 74 75 76 77 78 79 80 81 82


/*	These prefixes denote system tables */
#define POSTGRES_SYS_PREFIX	"pg_"
#define KEYS_TABLE			"dd_fkey"

/*	Info limits */
#define MAX_INFO_STRING		128
#define MAX_KEYPARTS		20
#define MAX_KEYLEN			512			//	max key of the form "date+outlet+invoice"
#define MAX_STATEMENT_LEN	MAX_MESSAGE_LEN

83 84

#define PG62	"6.2"		/* "Protocol" key setting to force Postgres 6.2 */
85
#define PG63	"6.3"		/* "Protocol" key setting to force postgres 6.3 */
Byron Nikolaidis's avatar
Byron Nikolaidis committed
86
#define PG64	"6.4"
87 88 89 90 91 92 93 94 95 96 97 98

typedef struct ConnectionClass_ ConnectionClass;
typedef struct StatementClass_ StatementClass;
typedef struct QResultClass_ QResultClass;
typedef struct SocketClass_ SocketClass;
typedef struct BindInfoClass_ BindInfoClass;
typedef struct ParameterInfoClass_ ParameterInfoClass;
typedef struct ColumnInfoClass_ ColumnInfoClass;
typedef struct TupleListClass_ TupleListClass;
typedef struct EnvironmentClass_ EnvironmentClass;
typedef struct TupleNode_ TupleNode;
typedef struct TupleField_ TupleField;
99

Byron Nikolaidis's avatar
Byron Nikolaidis committed
100
typedef struct col_info COL_INFO;
101 102 103 104 105 106 107 108 109 110 111 112
typedef struct lo_arg LO_ARG;

typedef struct GlobalValues_
{
	int					fetch_max;
	int					socket_buffersize;
	int					unknown_sizes;
	int					max_varchar_size;
	int					max_longvarchar_size;
	char				debug;
	char				commlog;
	char				disable_optimizer;
113
	char				ksqo;
114 115 116 117 118 119
	char				unique_index;
	char				readonly;
	char				use_declarefetch;
	char				text_as_longvarchar;
	char				unknowns_as_longvarchar;
	char				bools_as_char;
120
	char				lie;
Byron Nikolaidis's avatar
Byron Nikolaidis committed
121
	char				parse;
122
	char				cancel_as_freestmt;
123 124
	char				extra_systable_prefixes[MEDIUM_REGISTRY_LEN];
	char				conn_settings[LARGE_REGISTRY_LEN];
Byron Nikolaidis's avatar
Byron Nikolaidis committed
125 126
	char				protocol[SMALL_REGISTRY_LEN];

127 128
	FILE*				mylogFP;
	FILE*				qlogFP;	
129 130
} GLOBAL_VALUES;

131 132 133 134 135 136 137 138 139
typedef struct StatementOptions_ {
	int maxRows;
	int maxLength;
	int rowset_size;
	int keyset_size;
	int cursor_type;
	int scroll_concurrency;
	int retrieve_data;
	int bind_size;		        /* size of each structure if using Row Binding */
140
	int use_bookmarks;
141 142 143 144 145 146 147 148 149
} StatementOptions;

/*	Used to pass extra query info to send_query */
typedef struct QueryInfo_ {
	int				row_size;
	QResultClass	*result_in;
	char			*cursor;
} QueryInfo;

150 151 152 153 154

#define PG_TYPE_LO				-999	/* hack until permanent type available */
#define PG_TYPE_LO_NAME			"lo"
#define OID_ATTNUM				-2		/* the attnum in pg_index of the oid */

155
/* sizes */
156 157 158 159
#define TEXT_FIELD_SIZE			4094	/* size of text fields (not including null term) */
#define NAME_FIELD_SIZE			32		/* size of name fields */
#define MAX_VARCHAR_SIZE		254		/* maximum size of a varchar (not including null term) */

160 161 162 163

#include "misc.h"

#endif