#### Type Of Change - [X] Small bug fix (non-breaking change which fixes an issue) - [X ] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: - [X ] PR should be backported to stable branches - [X] Tested changes locally - [ ] Related to issue #XXXX (replace XXXX with an open issue number)
When using xDB Replication Server with PostgreSQL, "partition" is a reserved name and breaks replication. Therefore let the column name be configurable.
An even better fix would be to also change the default name, as "partition" is a SQL key word which is reserved by SQL:2011. See https://www.postgresql.org/docs/current/static/sql-keywords-appendix.html You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1371
-- Commit Summary --
* Let the partition column be configurable.
-- File Changes --
M src/modules/usrloc/doc/usrloc_admin.xml (20) M src/modules/usrloc/usrloc_mod.c (1)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1371.patch https://github.com/kamailio/kamailio/pull/1371.diff
I will push the patch manually, because the commit message doesn't follow the contribution guidelines:
* https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md#com...
Regarding the reserved words, I think the right solution would be to quote the column names, as mysql module does it. New SQL spec might add other reserved words. Not using postgres myself I am not sure what is the right character to quote columns and table names, if someone writes it here and also helps to test, then I can make a patch to db_postgres module to use it.
From https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-S... it seems that "partition" would do the job. Quote from the page:
There is a second kind of identifier: the delimited identifier or quoted identifier. It is formed by enclosing an arbitrary sequence of characters in double-quotes ("). A delimited identifier is always an identifier, never a key word. So "select" could be used to refer to a column or table named “select”, whereas an unquoted select would be taken as a key word and would therefore provoke a parse error when used where a table or column name is expected
Interesting ... is the string value also in double quotes for postgres? I wonder how it makes the difference between a string value and a quoted identifier ...
String values are used such as: `select foo from baz where bar = 'string'`
So, single quote for string values and double quote for identifiers...
Merged manually.
Closed #1371.