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 14:34:30 +0300
committerAndris Zeila <andris.zeila@zabbix.com>2022-11-09 14:34:30 +0300
commit843424eb3d9585ac5c00c899697b4ec2b19f9a41 (patch)
tree1b191edeb00183fd7346d955263894f9df0175bc
parent94ed6d554f2faea1576437cea95b18e94e7b9976 (diff)
.......... [ZBX-21869] changed trigger_queue handling when upgrading from 5.0 or 5.2
-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 34e25584a9d..176cd99a3d6 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5010.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5010.c
@@ -327,24 +327,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};
@@ -1829,7 +1811,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 064d23c3372..45d94fbd029 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5030.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5030.c
@@ -4959,6 +4959,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;
@@ -5514,6 +5520,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");
}
@@ -5543,6 +5560,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");
@@ -5567,6 +5587,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");
}