1 /********************************************************************/ 2 /* */ 3 /* db_post.h PostgreSQL interfaces used by Seed7. */ 4 /* Copyright (C) 1989 - 2014 Thomas Mertes */ 5 /* */ 6 /* This file is part of the Seed7 Runtime Library. */ 7 /* */ 8 /* The Seed7 Runtime Library is free software; you can */ 9 /* redistribute it and/or modify it under the terms of the GNU */ 10 /* Lesser General Public License as published by the Free Software */ 11 /* Foundation; either version 2.1 of the License, or (at your */ 12 /* option) any later version. */ 13 /* */ 14 /* The Seed7 Runtime Library is distributed in the hope that it */ 15 /* will be useful, but WITHOUT ANY WARRANTY; without even the */ 16 /* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */ 17 /* PURPOSE. See the GNU Lesser General Public License for more */ 18 /* details. */ 19 /* */ 20 /* You should have received a copy of the GNU Lesser General */ 21 /* Public License along with this program; if not, write to the */ 22 /* Free Software Foundation, Inc., 51 Franklin Street, */ 23 /* Fifth Floor, Boston, MA 02110-1301, USA. */ 24 /* */ 25 /* Module: Seed7 Runtime Library */ 26 /* File: seed7/src/db_post.h */ 27 /* Changes: 2014 Thomas Mertes */ 28 /* Content: PostgreSQL interfaces used by Seed7. */ 29 /* */ 30 /********************************************************************/ 31 32 #if defined(__cplusplus) || defined(c_plusplus) 33 extern "C" { 34 #endif 35 36 typedef struct pg_conn PGconn; 37 typedef struct pg_result PGresult; 38 typedef unsigned int Oid; 39 40 typedef enum { 41 PGRES_EMPTY_QUERY = 0, 42 PGRES_COMMAND_OK, 43 PGRES_TUPLES_OK, 44 PGRES_COPY_OUT, 45 PGRES_COPY_IN, 46 PGRES_BAD_RESPONSE, 47 PGRES_NONFATAL_ERROR, 48 PGRES_FATAL_ERROR, 49 PGRES_COPY_BOTH 50 } ExecStatusType; 51 52 typedef enum { 53 CONNECTION_OK, 54 CONNECTION_BAD, 55 CONNECTION_STARTED, 56 CONNECTION_MADE, 57 CONNECTION_AWAITING_RESPONSE, 58 CONNECTION_AUTH_OK, 59 CONNECTION_SETENV, 60 CONNECTION_SSL_STARTUP, 61 CONNECTION_NEEDED 62 } ConnStatusType; 63 64 #define BOOLOID 16 65 #define BYTEAOID 17 66 #define CHAROID 18 67 #define NAMEOID 19 68 #define INT8OID 20 69 #define INT2OID 21 70 #define INT2VECTOROID 22 71 #define INT4OID 23 72 #define REGPROCOID 24 73 #define TEXTOID 25 74 #define OIDOID 26 75 #define TIDOID 27 76 #define XIDOID 28 77 #define CIDOID 29 78 #define OIDVECTOROID 30 79 #define XMLOID 142 80 #define PGNODETREEOID 194 81 #define POINTOID 600 82 #define LSEGOID 601 83 #define PATHOID 602 84 #define BOXOID 603 85 #define POLYGONOID 604 86 #define LINEOID 628 87 #define FLOAT4OID 700 88 #define FLOAT8OID 701 89 #define ABSTIMEOID 702 90 #define RELTIMEOID 703 91 #define TINTERVALOID 704 92 #define UNKNOWNOID 705 93 #define CIRCLEOID 718 94 #define CASHOID 790 95 #define MACADDROID 829 96 #define INETOID 869 97 #define CIDROID 650 98 #define INT2ARRAYOID 1005 99 #define INT4ARRAYOID 1007 100 #define TEXTARRAYOID 1009 101 #define OIDARRAYOID 1028 102 #define FLOAT4ARRAYOID 1021 103 #define ACLITEMOID 1033 104 #define CSTRINGARRAYOID 1263 105 #define BPCHAROID 1042 106 #define VARCHAROID 1043 107 #define DATEOID 1082 108 #define TIMEOID 1083 109 #define TIMESTAMPOID 1114 110 #define TIMESTAMPTZOID 1184 111 #define INTERVALOID 1186 112 #define TIMETZOID 1266 113 #define BITOID 1560 114 #define VARBITOID 1562 115 #define NUMERICOID 1700 116 #define REFCURSOROID 1790 117 #define REGPROCEDUREOID 2202 118 #define REGOPEROID 2203 119 #define REGOPERATOROID 2204 120 #define REGCLASSOID 2205 121 #define REGTYPEOID 2206 122 #define REGTYPEARRAYOID 2211 123 #define TSVECTOROID 3614 124 #define GTSVECTOROID 3642 125 #define TSQUERYOID 3615 126 #define REGCONFIGOID 3734 127 #define REGDICTIONARYOID 3769 128 #define RECORDOID 2249 129 #define RECORDARRAYOID 2287 130 #define CSTRINGOID 2275 131 #define ANYOID 2276 132 #define ANYARRAYOID 2277 133 #define VOIDOID 2278 134 #define TRIGGEROID 2279 135 #define LANGUAGE_HANDLEROID 2280 136 #define INTERNALOID 2281 137 #define OPAQUEOID 2282 138 #define ANYELEMENTOID 2283 139 #define ANYNONARRAYOID 2776 140 #define ANYENUMOID 3500 141 #define FDW_HANDLEROID 3115 142 143 #ifndef CDECL 144 #if defined(_WIN32) && HAS_CDECL 145 #define CDECL __cdecl 146 #else 147 #define CDECL 148 #endif 149 #endif 150 151 extern void CDECL PQclear (PGresult *res); 152 extern PGresult *CDECL PQdescribePrepared (PGconn *conn, const char *stmt); 153 extern char *CDECL PQerrorMessage (const PGconn *conn); 154 extern PGresult *CDECL PQexec (PGconn *conn, const char *query); 155 extern PGresult *CDECL PQexecPrepared (PGconn *conn, 156 const char *stmtName, 157 int nParams, 158 const char *const * paramValues, 159 const int *paramLengths, 160 const int *paramFormats, 161 int resultFormat); 162 extern void CDECL PQfinish (PGconn *conn); 163 extern char *CDECL PQfname (const PGresult *res, int field_num); 164 extern Oid CDECL PQftype (const PGresult *res, int field_num); 165 extern int CDECL PQgetisnull (const PGresult *res, int tup_num, int field_num); 166 extern int CDECL PQgetlength (const PGresult *res, int tup_num, int field_num); 167 extern char *CDECL PQgetvalue (const PGresult *res, int tup_num, int field_num); 168 extern int CDECL PQnfields (const PGresult *res); 169 extern int CDECL PQnparams (const PGresult *res); 170 extern int CDECL PQntuples (const PGresult *res); 171 extern const char *CDECL PQparameterStatus (const PGconn *conn, const char *paramName); 172 extern Oid CDECL PQparamtype (const PGresult *res, int param_num); 173 extern PGresult *CDECL PQprepare (PGconn *conn, const char *stmtName, 174 const char *query, int nParams, 175 const Oid *paramTypes); 176 extern char *CDECL PQresStatus (ExecStatusType status); 177 extern char *CDECL PQresultErrorMessage (const PGresult *res); 178 extern ExecStatusType CDECL PQresultStatus (const PGresult *res); 179 extern int CDECL PQsetClientEncoding (PGconn *conn, const char *encoding); 180 extern PGconn *CDECL PQsetdbLogin (const char *pghost, const char *pgport, 181 const char *pgoptions, const char *pgtty, 182 const char *dbName, 183 const char *login, const char *pwd); 184 extern ConnStatusType CDECL PQstatus (const PGconn *conn); 185 186 #if defined(__cplusplus) || defined(c_plusplus) 187 } 188 #endif 189