Commit | Line | Data |
---|---|---|
7f6ecb6d | 1 | /* |
5039dede | 2 | ** nxdbmgr - NetXMS database manager |
8e6e8ef1 | 3 | ** Copyright (C) 2004-2016 Victor Kirhenshtein |
5039dede AK |
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 | ** | |
1e558daf | 19 | ** File: nxdbmgr.h |
5039dede AK |
20 | ** |
21 | **/ | |
22 | ||
23 | #ifndef _nxdbmgr_h_ | |
24 | #define _nxdbmgr_h_ | |
25 | ||
26 | #include <nms_common.h> | |
27 | #include <nms_util.h> | |
28 | #include <uuid.h> | |
29 | #include <nxsrvapi.h> | |
9d88cdc9 | 30 | #include <nxdbapi.h> |
5039dede AK |
31 | #include <netxmsdb.h> |
32 | ||
33 | ||
5039dede AK |
34 | // |
35 | // Non-standard data type codes | |
36 | // | |
37 | ||
38 | #define SQL_TYPE_TEXT 0 | |
50da2d20 VK |
39 | #define SQL_TYPE_TEXT4K 1 |
40 | #define SQL_TYPE_INT64 2 | |
5039dede | 41 | |
40dedf5d VK |
42 | /** |
43 | * Execute with error check | |
44 | */ | |
ef607e62 | 45 | #define CHK_EXEC(x) do { if (!(x)) if (!g_bIgnoreErrors) return false; } while (0) |
8ec9bcc9 | 46 | |
5039dede AK |
47 | |
48 | // | |
49 | // Functions | |
50 | // | |
51 | ||
63604cda | 52 | DB_HANDLE ConnectToDatabase(); |
1e558daf | 53 | void CheckDatabase(); |
08b214c6 | 54 | void InitDatabase(const char *pszInitFile); |
9b4a2a0e | 55 | bool ClearDatabase(bool preMigration); |
4f23eecc | 56 | void ExportDatabase(const char *file); |
890a0930 | 57 | void ImportDatabase(const char *file); |
84ee0f9c | 58 | void MigrateDatabase(const TCHAR *sourceConfig); |
1e558daf VK |
59 | void UpgradeDatabase(); |
60 | void UnlockDatabase(); | |
7541bca2 | 61 | void ReindexIData(); |
5039dede | 62 | DB_RESULT SQLSelect(const TCHAR *pszQuery); |
f17cf019 | 63 | DB_UNBUFFERED_RESULT SQLSelectUnbuffered(const TCHAR *pszQuery); |
c85c8ef2 VK |
64 | bool SQLExecute(DB_STATEMENT hStmt); |
65 | bool SQLQuery(const TCHAR *pszQuery); | |
66 | bool SQLBatch(const TCHAR *pszBatch); | |
67 | bool SQLDropColumn(const TCHAR *table, const TCHAR *column); | |
a4743a0f | 68 | bool GetYesNo(const TCHAR *format, ...); |
5039dede | 69 | void ShowQuery(const TCHAR *pszQuery); |
c85c8ef2 VK |
70 | bool ExecSQLBatch(const char *pszFile); |
71 | bool ValidateDatabase(); | |
5039dede | 72 | |
06b83321 | 73 | bool IsDatabaseRecordExist(const TCHAR *table, const TCHAR *idColumn, UINT32 id); |
035a4d73 | 74 | |
3783d300 | 75 | BOOL MetaDataReadStr(const TCHAR *pszVar, TCHAR *pszBuffer, int iBufSize, const TCHAR *pszDefault); |
2f1bc68b | 76 | int MetaDataReadInt(const TCHAR *pszVar, int iDefault); |
5039dede AK |
77 | BOOL ConfigReadStr(const TCHAR *pszVar, TCHAR *pszBuffer, int iBufSize, const TCHAR *pszDefault); |
78 | int ConfigReadInt(const TCHAR *pszVar, int iDefault); | |
79 | DWORD ConfigReadULong(const TCHAR *pszVar, DWORD dwDefault); | |
c85c8ef2 VK |
80 | bool CreateConfigParam(const TCHAR *name, const TCHAR *value, bool isVisible, bool needRestart, bool forceUpdate = false); |
81 | bool CreateConfigParam(const TCHAR *name, const TCHAR *value, const TCHAR *description, char dataType, bool isVisible, bool needRestart, bool isPublic, bool forceUpdate = false); | |
5039dede | 82 | |
63604cda VK |
83 | BOOL IsDataTableExist(const TCHAR *format, DWORD id); |
84 | ||
85 | bool RenameDatabaseTable(const TCHAR *oldName, const TCHAR *newName); | |
86 | ||
85ae39bc | 87 | BOOL CreateIDataTable(DWORD nodeId); |
63604cda | 88 | BOOL CreateTDataTable(DWORD nodeId); |
22aaa779 | 89 | BOOL CreateTDataTable_preV281(DWORD nodeId); |
5039dede | 90 | |
c614ca60 AK |
91 | void ResetAdmin(); |
92 | ||
5039dede AK |
93 | // |
94 | // Global variables | |
95 | // | |
96 | ||
97 | extern DB_HANDLE g_hCoreDB; | |
98 | extern BOOL g_bIgnoreErrors; | |
99 | extern BOOL g_bTrace; | |
a4743a0f | 100 | extern bool g_isGuiMode; |
0d9b58ef | 101 | extern bool g_checkData; |
daf3c104 | 102 | extern bool g_checkDataTablesOnly; |
ffaafdce VK |
103 | extern bool g_dataOnlyMigration; |
104 | extern bool g_skipDataMigration; | |
09f1c9bf VK |
105 | extern bool g_skipDataSchemaMigration; |
106 | extern int g_migrationTxnSize; | |
2a964810 | 107 | extern int g_dbSyntax; |
5039dede | 108 | extern const TCHAR *g_pszTableSuffix; |
99d1de07 | 109 | extern const TCHAR *g_pszSqlType[6][3]; |
5039dede | 110 | |
5039dede | 111 | #endif |