minor changes
[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 * Structure of DB connection handle
49 */
50 typedef struct
51 {
52 MYSQL *pMySQL;
53 MUTEX mutexQueryLock;
54 } MYSQL_CONN;
55
56 /**
57 * Structure of prepared statement
58 */
59 typedef struct
60 {
61 MYSQL_CONN *connection;
62 MYSQL_STMT *statement;
63 MYSQL_BIND *bindings;
64 unsigned long *lengthFields;
65 Array *buffers;
66 int paramCount;
67 } MYSQL_STATEMENT;
68
69 /**
70 * Structure of synchronous SELECT result
71 */
72 typedef struct
73 {
74 MYSQL_RES *resultSet;
75 bool isPreparedStatement;
76 MYSQL_STMT *statement;
77 int numColumns;
78 int numRows;
79 int currentRow;
80 MYSQL_BIND *bindings;
81 unsigned long *lengthFields;
82 } MYSQL_RESULT;
83
84 /**
85 * Structure of asynchronous SELECT result
86 */
87 typedef struct
88 {
89 MYSQL_CONN *pConn;
90 MYSQL_RES *pHandle;
91 MYSQL_ROW pCurrRow;
92 BOOL bNoMoreRows;
93 int iNumCols;
94 unsigned long *pulColLengths;
95 } MYSQL_ASYNC_RESULT;
96
97 #endif /* _mysqldrv_h_ */