1 /* 2 ** Zabbix 3 ** Copyright (C) 2001-2021 Zabbix SIA 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 **/ 19 20 #ifndef ZABBIX_DBSCHEMA_H 21 #define ZABBIX_DBSCHEMA_H 22 23 /* flags */ 24 #define ZBX_NOTNULL 0x01 25 #define ZBX_PROXY 0x02 26 27 /* FK flags */ 28 #define ZBX_FK_CASCADE_DELETE 0x01 29 30 /* field types */ 31 #define ZBX_TYPE_INT 0 32 #define ZBX_TYPE_CHAR 1 33 #define ZBX_TYPE_FLOAT 2 34 #define ZBX_TYPE_BLOB 3 35 #define ZBX_TYPE_TEXT 4 36 #define ZBX_TYPE_UINT 5 37 #define ZBX_TYPE_ID 6 38 #define ZBX_TYPE_SHORTTEXT 7 39 #define ZBX_TYPE_LONGTEXT 8 40 41 #define ZBX_MAX_FIELDS 107 /* maximum number of fields in a table plus one for null terminator in dbschema.c */ 42 #define ZBX_TABLENAME_LEN 26 43 #define ZBX_TABLENAME_LEN_MAX (ZBX_TABLENAME_LEN + 1) 44 #define ZBX_FIELDNAME_LEN 28 45 #define ZBX_FIELDNAME_LEN_MAX (ZBX_FIELDNAME_LEN + 1) 46 47 typedef struct 48 { 49 const char *name; 50 const char *default_value; 51 const char *fk_table; 52 const char *fk_field; 53 unsigned short length; 54 unsigned char type; 55 unsigned char flags; 56 unsigned char fk_flags; 57 } 58 ZBX_FIELD; 59 60 typedef struct 61 { 62 const char *table; 63 const char *recid; 64 unsigned char flags; 65 ZBX_FIELD fields[ZBX_MAX_FIELDS]; 66 const char *uniq; 67 } 68 ZBX_TABLE; 69 70 extern const ZBX_TABLE tables[]; 71 extern const char *const db_schema; 72 extern const char *const db_schema_fkeys[]; 73 extern const char *const db_schema_fkeys_drop[]; 74 75 #endif 76