[sr-dev] module related crash

Daniel-Constantin Mierla miconda at gmail.com
Mon Oct 1 18:29:37 CEST 2018



On 01.10.18 17:50, Juha Heinanen wrote:
> Daniel-Constantin Mierla writes:
>
>> You have to change:
>>
>> if(VAL_TYPE(ROW_VALUES(row) + 11) != DB1_INT) {
>>
>> to something like:
>>
>> if(VAL_TYPE(ROW_VALUES(row) + 11) != DB1_INT && VAL_TYPE(ROW_VALUES(row) + 11) != DB1_UINT) {
> Why do I need to test both DB1_INT and DB1_UINT, since the column cannot
> hold a negative integer value?

Because postgres, sqlite and other database servers via unixodbc do not
use unsigned types.

If you look at postgres schema, all these columns are just INTEGER, see:

utils/kamctl/postgres/lcr-create.sql

So UNSIGNED is more or less mysql proprietary extension, hitting now
back with the new strict checking of the values in the latest version.
If you search for standard sql data types, there is no 'unsigned' type
listed.

>
>> The alternative is to remove UNSIGNED from the column
>> definition. Alexander Dubovikov mentioned that there is a MySQl server
>> setting for strict data type usage, that is turned on, but can be
>> turned off via mysql server (or client) config.
> There is reason why the column in unsigned int.  I want to be able store
> in that column positive int value 4294967295 (0xFFFFFFFF).  If I change
> the column to int, my understanding is that is cannot anymore store this
> value.
You can store it, but it will be shown as a negative number (-1) when
looking into the database via a query with an sql client.

Inside the C code you can cast to (unsigned int) and then it works fine.
This is how lcr and other module work with the other DB server types,
which do not have unsigned column type.

So, if we want to stick to sql standard, then we have to remove unsigned
from the definition of sql columns. If we want to continue we the
current db schema, the modules must handle both DB1_UINT (for mysql) and
DB1_INT (for the others), casting internally to unsigned int.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com
Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com




More information about the sr-dev mailing list