Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndris Zeila <andris.zeila@zabbix.com>2022-11-09 17:18:07 +0300
committerAndris Zeila <andris.zeila@zabbix.com>2022-11-09 17:20:40 +0300
commitc610d300d1e6ce85ced71f40f481c2135548dc80 (patch)
tree4a18099711a7efd92e331d2bb0807d0637fde82b
parent0a98d2a4b3d65103059875a96556365ceb8ff5c6 (diff)
.......... [ZBX-21869] changed trigger_queue handling when upgrading from 5.0 or 5.2
Merge in ZBX/zabbix from feature/ZBX-21869-6.0 to release/6.0 * commit '843424eb3d9585ac5c00c899697b4ec2b19f9a41': .......... [ZBX-21869] changed trigger_queue handling when upgrading from 5.0 or 5.2 (cherry picked from commit 70be0421244eaf107478833d1466fc17e8f041bb)
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5010.c19
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5030.c23
2 files changed, 23 insertions, 19 deletions
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5010.c b/src/libs/zbxdbupgrade/dbupgrade_5010.c
index 4c5a690be0e..48b294307e3 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5010.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5010.c
@@ -326,24 +326,6 @@ static int DBpatch_5010036(void)
return DBadd_field("triggers", &field);
}
-static int DBpatch_5010037(void)
-{
- const ZBX_TABLE table =
- {"trigger_queue", "trigger_queueid", 0,
- {
- {"trigger_queueid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
- {"objectid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
- {"type", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
- {"clock", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
- {"ns", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
- {0}
- },
- NULL
- };
-
- return DBcreate_table(&table);
-}
-
static int DBpatch_5010038(void)
{
const ZBX_FIELD field = {"templateid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, 0, 0};
@@ -1828,7 +1810,6 @@ DBPATCH_ADD(5010033, 0, 1)
DBPATCH_ADD(5010034, 0, 1)
DBPATCH_ADD(5010035, 0, 1)
DBPATCH_ADD(5010036, 0, 1)
-DBPATCH_ADD(5010037, 0, 1)
DBPATCH_ADD(5010038, 0, 1)
DBPATCH_ADD(5010039, 0, 1)
DBPATCH_ADD(5010040, 0, 1)
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");
}