The recommended My SQL quires for database schema change during Kamailio upgrading from v.5.3 to 5.4 fails:
```
mysql> ALTER TABLE version ADD COLUMN `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
```
The correct command is:
```
mysql> ALTER TABLE `version` ADD COLUMN `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (`id`);
Query OK, 0 rows affected (0.80 sec)
```
In this case the second recommended command
```
ALTER TABLE version ADD PRIMARY KEY (`id`);
```
is not needed.
Tested on Ubuntu 18.04, with mysql v.5.7.31
Best regards,
Leonid Fainshtein
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2424
Module: kamailio
Branch: 5.2
Commit: e6c91219fd8202f0b1a2dd368537f3eb3516882b
URL: https://github.com/kamailio/kamailio/commit/e6c91219fd8202f0b1a2dd368537f3e…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-08-03T09:25:00+02:00
pua: update_version_puadb() use pres_id to select record
* only relevant when db_mode is PUA_DB_ONLY
* call_id/to_tag/from_tag values can be "", for instance with
DIALOG_PUBLISH.* records. Then **ALL** records get version
field update
* update_vesion_puadb() is called from send_publish() and pres->id
value is valid after a call to get_record_puadb()
related to #2414
(cherry picked from commit 733f5f240b4cf0c6e951257dc344d9b2c885331f)
---
Modified: src/modules/pua/pua_db.c
---
Diff: https://github.com/kamailio/kamailio/commit/e6c91219fd8202f0b1a2dd368537f3e…
Patch: https://github.com/kamailio/kamailio/commit/e6c91219fd8202f0b1a2dd368537f3e…
---
diff --git a/src/modules/pua/pua_db.c b/src/modules/pua/pua_db.c
index fda1a6ce5b..3e3147ce1e 100644
--- a/src/modules/pua/pua_db.c
+++ b/src/modules/pua/pua_db.c
@@ -1485,8 +1485,8 @@ int update_contact_puadb(ua_pres_t *pres, str *contact)
int update_version_puadb(ua_pres_t *pres)
{
- db_key_t q_cols[3], db_cols[1];
- db_val_t q_vals[3], db_vals[1];
+ db_key_t q_cols[1], db_cols[1];
+ db_val_t q_vals[1], db_vals[1];
int n_query_cols= 0, n_update_cols=0;
if (pres==NULL)
@@ -1496,22 +1496,10 @@ int update_version_puadb(ua_pres_t *pres)
}
/* cols and values used for search query */
- q_cols[n_query_cols] = &str_call_id_col;
- q_vals[n_query_cols].type = DB1_STR;
- q_vals[n_query_cols].nul = 0;
- q_vals[n_query_cols].val.str_val = pres->call_id;
- n_query_cols++;
-
- q_cols[n_query_cols] = &str_to_tag_col;
- q_vals[n_query_cols].type = DB1_STR;
- q_vals[n_query_cols].nul = 0;
- q_vals[n_query_cols].val.str_val = pres->to_tag;
- n_query_cols++;
-
- q_cols[n_query_cols] = &str_from_tag_col;
+ q_cols[n_query_cols] = &str_pres_id_col;
q_vals[n_query_cols].type = DB1_STR;
q_vals[n_query_cols].nul = 0;
- q_vals[n_query_cols].val.str_val = pres->from_tag;
+ q_vals[n_query_cols].val.str_val = pres->id;
n_query_cols++;
/* we overwrite contact even if not changed */
Module: kamailio
Branch: 5.4
Commit: 73c97ee8ca89bea202b09f6b75722396fbe05ba6
URL: https://github.com/kamailio/kamailio/commit/73c97ee8ca89bea202b09f6b7572239…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-08-01T10:44:00+02:00
pua: update_version_puadb() use pres_id to select record
* only relevant when db_mode is PUA_DB_ONLY
* call_id/to_tag/from_tag values can be "", for instance with
DIALOG_PUBLISH.* records. Then **ALL** records get version
field update
* update_vesion_puadb() is called from send_publish() and pres->id
value is valid after a call to get_record_puadb()
related to #2414
(cherry picked from commit e4aed5c272c8144dd1ddf58163c3ba501bb46a5b)
---
Modified: src/modules/pua/pua_db.c
---
Diff: https://github.com/kamailio/kamailio/commit/73c97ee8ca89bea202b09f6b7572239…
Patch: https://github.com/kamailio/kamailio/commit/73c97ee8ca89bea202b09f6b7572239…
---
diff --git a/src/modules/pua/pua_db.c b/src/modules/pua/pua_db.c
index 9a5c34b8ec..9f9b36cab4 100644
--- a/src/modules/pua/pua_db.c
+++ b/src/modules/pua/pua_db.c
@@ -1485,8 +1485,8 @@ int update_contact_puadb(ua_pres_t *pres, str *contact)
int update_version_puadb(ua_pres_t *pres)
{
- db_key_t q_cols[3], db_cols[1];
- db_val_t q_vals[3], db_vals[1];
+ db_key_t q_cols[1], db_cols[1];
+ db_val_t q_vals[1], db_vals[1];
int n_query_cols= 0, n_update_cols=0;
if (pres==NULL)
@@ -1496,22 +1496,10 @@ int update_version_puadb(ua_pres_t *pres)
}
/* cols and values used for search query */
- q_cols[n_query_cols] = &str_call_id_col;
- q_vals[n_query_cols].type = DB1_STR;
- q_vals[n_query_cols].nul = 0;
- q_vals[n_query_cols].val.str_val = pres->call_id;
- n_query_cols++;
-
- q_cols[n_query_cols] = &str_to_tag_col;
- q_vals[n_query_cols].type = DB1_STR;
- q_vals[n_query_cols].nul = 0;
- q_vals[n_query_cols].val.str_val = pres->to_tag;
- n_query_cols++;
-
- q_cols[n_query_cols] = &str_from_tag_col;
+ q_cols[n_query_cols] = &str_pres_id_col;
q_vals[n_query_cols].type = DB1_STR;
q_vals[n_query_cols].nul = 0;
- q_vals[n_query_cols].val.str_val = pres->from_tag;
+ q_vals[n_query_cols].val.str_val = pres->id;
n_query_cols++;
/* we overwrite contact even if not changed */