Change in osmo-hlr[master]: add database schema versioning to the HLR database

Stefan Sperling gerrit-no-reply at
Fri Nov 30 11:40:53 UTC 2018

Stefan Sperling has posted comments on this change. ( )

Change subject: add database schema versioning to the HLR database

Patch Set 5:

File src/
PS5, Line 119: 	echo "/* DO NOT EDIT THIS FILE. It is generated from files in osmo-hlr.git/sql/ */" > "$@"
> (wow, I really cooked up some voodoo here didn't I ... now wondering whether a python script "sql2c. […]
Yes, later putayta.
File src/db.c:
PS5, Line 378: 	rc = sqlite3_exec(dbc->db, "PRAGMA journal_mode=WAL; PRAGMA synchonous = NORMAL;", 0, 0, &err_msg);
> (interesting typo in old code: "synchronous" […]
This should not break anything.
It seems this statement is trying to switch the synchronous pragma from 'FULL' to 'NORMAL'.
In a hlr.db freshly created by running osmo-hlr, the pragma is set to 'FULL' by default.
Because 'FULL' is more paranoid than 'NORMAL', we didn't lose anything here except for negligible performance differences.
PS5, Line 383: 	if (!db_is_bootstrapped(dbc)) {
> imagine some future scheme adds a new table. […]
The idea is that this function will only ever check for tables which were already known in schema version 0.
In which case the problems you point out won't occur.
Maybe I should add a comment about that.

Checking for tables which are added in later schema versions should be done as an additional later step.
There's a bit of a blurry line between checking for being bootstrapped and full-on schema verification; so we'll have to find some acceptable trade-off.
PS5, Line 403: 		LOGP(DDB, LOGL_ERROR, "Unable to read user version number from database '%s'\n", dbc->fname);
> Is the user_version always present in an sqlite db? otherwise, if I read this right, when osmo-hlr n […]
No, it will only return -1 if queries return errors.

It seems to me like user_version will always be zero unless we explicitly set it.
On an empty sqlite DB, pragma user_version returns zero.

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8aeaa9a404b622657cbc7138106f38aa6ad8d01b
Gerrit-Change-Number: 11898
Gerrit-PatchSet: 5
Gerrit-Owner: Stefan Sperling <ssperling at>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at>
Gerrit-Reviewer: Stefan Sperling <ssperling at>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at>
Gerrit-Comment-Date: Fri, 30 Nov 2018 11:40:53 +0000
Gerrit-HasComments: Yes
Gerrit-HasLabels: No
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list