OpenSIPS / opensips

OpenSIPS is a GPL implementation of a multi-functionality SIP Server that targets to deliver a high-level technical solution (performance, security and quality) to be used in professional SIP server platforms.
https://opensips.org
Other
1.26k stars 577 forks source link

Rework OpenSIPS table versioning / validation #671

Open liviuchircu opened 8 years ago

liviuchircu commented 8 years ago

The SQL table versioning logic in OpenSIPS has one big pitfall: all OpenSIPS tables must be created with opensipsdbctl. Although this is a solid/recommended way of installing OpenSIPS, real life will often impose restrictions. For example, some tables (dispatcher, drouting, etc.) may actually be SQL views of other platform-related tables.

When views / hand-made tables come in place, OpenSIPS is left without any real mechanism of validating its input table structure, leading to all sort of buggy behaviour, i.e. incorrectly balancing between dispatcher destinations (that show up in fifo ds_list) because the state field is varchar(1) instead of int(11).

This feature request discussion aims at adding a new way of checking SQL tables, by validating the type of each column during OpenSIPS startup and throwing appropriate alerts. It also has the side effect of rendering the entire db_version_table mechanism useless.

For the MySQL driver, the problem can be solved with mysql_fetch_fields() and the MYSQL_FIELD data type. What about others?

Please reply with feedback / ideas / further suggestions.

olivermt commented 8 years ago

Postgresql:

select column_name, data_type, character_maximum_length
from INFORMATION_SCHEMA.COLUMNS where table_name = '<name of table>';

Parse as appropiate from there