This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathdbpostgresql.h
More file actions
147 lines (133 loc) · 4.33 KB
/
dbpostgresql.h
File metadata and controls
147 lines (133 loc) · 4.33 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* Copyright (C) 2003-2015 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
#ifdef WIN32
#include <windows.h>
#endif
#include "database.h"
#ifndef _dbPOSTGRESQL
#define _dbPOSTGRESQL
#include <libpq-fe.h>
#include "dbdrivercommon.h"
#include "large_buffer.h"
#define DB_POSTGRESQL_STRING "POSTGRESQL";
#define PG_TYPE_BOOL 16
#define PG_TYPE_BYTEA 17
#define PG_TYPE_CHAR 18
#define PG_TYPE_NAME 19
#define PG_TYPE_CHAR16 20
#define PG_TYPE_INT2 21
#define PG_TYPE_INT28 22
#define PG_TYPE_INT4 23
#define PG_TYPE_REGPROC 24
#define PG_TYPE_TEXT 25
#define PG_TYPE_OID 26
#define PG_TYPE_TID 27
#define PG_TYPE_XID 28
#define PG_TYPE_CID 29
#define PG_TYPE_OID8 30
#define PG_TYPE_SET 32
#define PG_TYPE_CHAR2 409
#define PG_TYPE_CHAR4 410
#define PG_TYPE_CHAR8 411
#define PG_TYPE_POINT 600
#define PG_TYPE_LSEG 601
#define PG_TYPE_PATH 602
#define PG_TYPE_BOX 603
#define PG_TYPE_POLYGON 604
#define PG_TYPE_FILENAME 605
#define PG_TYPE_FLOAT4 700
#define PG_TYPE_FLOAT8 701
#define PG_TYPE_ABSTIME 702
#define PG_TYPE_RELTIME 703
#define PG_TYPE_TINTERVAL 704
#define PG_TYPE_UNKNOWN 705
#define PG_TYPE_MONEY 790
#define PG_TYPE_OIDINT2 810
#define PG_TYPE_OIDINT4 910
#define PG_TYPE_OIDNAME 911
// Array Types. Not easy to find in the .h files. They are defined in pg_type.h.
#define PG_TYPE_ARR_BOOL 1000
#define PG_TYPE_ARR_BYTEA 1001
#define PG_TYPE_ARR_CHAR 1002
#define PG_TYPE_ARR_NAME 1003
#define PG_TYPE_ARR_INT2 1005
#define PG_TYPE_ARR_INT4 1007
#define PG_TYPE_ARR_REGPROC 1008
#define PG_TYPE_ARR_TEXT 1009
#define PG_TYPE_ARR_OID 1028
#define PG_TYPE_ARR_TID 1010
#define PG_TYPE_ARR_XID 1011
#define PG_TYPE_ARR_CID 1012
#define PG_TYPE_ARR_VARCHAR 1015
#define PG_TYPE_ARR_INT8 1016
#define PG_TYPE_ARR_POINT 1017
#define PG_TYPE_ARR_LSEG 1018
#define PG_TYPE_ARR_PATH 1019
#define PG_TYPE_ARR_BOX 1020
#define PG_TYPE_ARR_FLOAT4 1021
#define PG_TYPE_ARR_FLOAT8 1022
#define PG_TYPE_ARR_ABSTIME 1023
#define PG_TYPE_ARR_RELTIME 1024
#define PG_TYPE_ARR_TINTERVAL 1025
#define PG_TYPE_ARR_POLYGON 1027
#define PG_TYPE_ARR_NUMERIC 1231
#define PG_TYPE_BPCHAR 1042
#define PG_TYPE_VARCHAR 1043
#define PG_TYPE_DATE 1082
#define PG_TYPE_TIME 1083
#define PG_TYPE_DATETIME 1184
#define PG_TYPE_TIMESPAN 1186 //This is not defined and was added.
#define PG_TYPE_TIMESTAMP 1296
#define PG_TYPE_ZPBIT 1560
#define PG_TYPE_VARBIT 1562
#define PG_TYPE_NUMERIC 1700
class DBCursor_POSTGRESQL:public CDBCursor
{
public:
virtual ~DBCursor_POSTGRESQL() {close();}
Bool open(DBConnection *newconnection,PGresult *querycursor);
void close();
Bool first();
Bool last();
Bool next();
Bool prev();
Bool move(int p_record_index);
protected:
Bool getRowData();
Bool getFieldsInformation();
PGresult *POSTGRESQL_res;
};
class DBConnection_POSTGRESQL: public CDBConnection
{
public:
DBConnection_POSTGRESQL(): m_internal_buffer(nullptr) {}
~DBConnection_POSTGRESQL() {disconnect();}
Bool connect(char **args, int numargs);
void disconnect();
Bool sqlExecute(char *query, DBString *args, int numargs, unsigned int &affectedrows);
DBCursor *sqlQuery(char *query, DBString *args, int numargs, int p_rows);
void getTables(char *buffer, int *bufsize);
const char *getconnectionstring();
void transBegin();
void transCommit();
void transRollback();
char *getErrorMessage(Bool p_last);
Bool IsError();
int getConnectionType(void) { return -1; }
int getVersion(void) { return 2; }
protected:
PGconn *dbconn;
PGresult *ExecuteQuery(char *p_query, DBString *p_arguments, int p_argument_count);
private:
large_buffer_t *m_internal_buffer;
};
#endif