2380cb02952fd2c2703e2b8fa130e862b22e34ec
[public/netxms.git] / src / db / dbdrv / mysql / mysqldrv.h
1 /*
2 ** MySQL Database Driver
3 ** Copyright (C) 2003 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** File: mysqldrv.h
20 **
21 **/
22
23 #ifndef _mysqldrv_h_
24 #define _mysqldrv_h_
25
26 #ifdef _WIN32
27
28 #ifndef _WIN32_WINNT
29 #define _WIN32_WINNT 0x0502
30 #endif
31
32 #include <winsock2.h>
33 #include <windows.h>
34 #define EXPORT __declspec(dllexport)
35 #else
36 #include <string.h>
37 #define EXPORT
38 #endif /* _WIN32 */
39
40 #include <dbdrv.h>
41 #include <nms_util.h>
42
43 #undef GROUP_FLAG
44 #include <mysql.h>
45 #include <errmsg.h>
46
47
48 //
49 // Structure of DB connection handle
50 //
51
52 typedef struct
53 {
54 MYSQL *pMySQL;
55 MUTEX mutexQueryLock;
56 } MYSQL_CONN;
57
58
59 //
60 // Structure of prepared statement
61 //
62
63 typedef struct
64 {
65 MYSQL_CONN *connection;
66 MYSQL_STMT *statement;
67 MYSQL_BIND *bindings;
68 unsigned long *lengthFields;
69 Array *buffers;
70 int paramCount;
71 } MYSQL_STATEMENT;
72
73
74 //
75 // Structure of synchronous SELECT result
76 //
77
78 typedef struct
79 {
80 MYSQL_RES *resultSet;
81 bool isPreparedStatement;
82 MYSQL_STMT *statement;
83 int numColumns;
84 int numRows;
85 int currentRow;
86 MYSQL_BIND *bindings;
87 unsigned long *lengthFields;
88 } MYSQL_RESULT;
89
90
91 //
92 // Structure of asynchronous SELECT result
93 //
94
95 typedef struct
96 {
97 MYSQL_CONN *pConn;
98 MYSQL_RES *pHandle;
99 MYSQL_ROW pCurrRow;
100 BOOL bNoMoreRows;
101 int iNumCols;
102 unsigned long *pulColLengths;
103 } MYSQL_ASYNC_RESULT;
104
105 #endif /* _mysqldrv_h_ */