diff options
Diffstat (limited to 'src/libs/zbxdbupgrade/dbupgrade_5030.c')
-rw-r--r-- | src/libs/zbxdbupgrade/dbupgrade_5030.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5030.c b/src/libs/zbxdbupgrade/dbupgrade_5030.c index 5c814e629c8..87358e3ffac 100644 --- a/src/libs/zbxdbupgrade/dbupgrade_5030.c +++ b/src/libs/zbxdbupgrade/dbupgrade_5030.c @@ -4962,6 +4962,12 @@ static int DBpatch_5030166(void) if (0 == (program_type & ZBX_PROGRAM_TYPE_SERVER)) return SUCCEED; + /* When upgrading from version 5.0 or less trigger_queue will be created later. */ + /* Only when upgrading from version 5.2 there will be trigger queue table which */ + /* must be updated. */ + if (SUCCEED != DBtable_exists("trigger_queue")) + return SUCCEED; + if (ZBX_DB_OK > DBexecute("update trigger_queue set type=4 where type=3")) return FAIL; @@ -5523,6 +5529,17 @@ static int DBpatch_5030170(void) static int DBpatch_5030171(void) { + /* When upgrading from version 5.0 or less the trigger_queue table will be created */ + /* later (DBpatch_5030172). */ + /* Only when upgrading from version 5.2 there will be existing trigger_queue table */ + /* to which primary key must be added. This is done by following steps: */ + /* 1) rename existing table (DBpatch_5030171) */ + /* 2) create new table with the primary key (DBpatch_5030172) */ + /* 2) copy data from old table into new table (DBpatch_5030173) */ + /* 2) delete the old (renamed) table (DBpatch_5030174) */ + if (SUCCEED != DBtable_exists("trigger_queue")) + return SUCCEED; + return DBrename_table("trigger_queue", "trigger_queue_tmp"); } @@ -5552,6 +5569,9 @@ static int DBpatch_5030173(void) zbx_uint64_t objectid, type, clock, ns; int ret; + if (SUCCEED != DBtable_exists("trigger_queue_tmp")) + return SUCCEED; + zbx_db_insert_prepare(&db_insert, "trigger_queue", "trigger_queueid", "objectid", "type", "clock", "ns", NULL); result = DBselect("select objectid,type,clock,ns from trigger_queue_tmp"); @@ -5576,6 +5596,9 @@ static int DBpatch_5030173(void) static int DBpatch_5030174(void) { + if (SUCCEED != DBtable_exists("trigger_queue_tmp")) + return SUCCEED; + return DBdrop_table("trigger_queue_tmp"); } |