-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drouting: allow DB_BIGINT for dr_rules.ruleid column #3203
base: master
Are you sure you want to change the base?
Conversation
Shouldn't we extrapolate this to all tables with IDs? the |
Yes good catch. I added |
@john08burke , your note points out a real issue actually. The DB_BIGINT is actually a
So, at least, we need to upgrade the |
check_val( id_drd_col, ROW_VALUES(row), DB_INT, 1, 0); | ||
if ( VAL_TYPE( ROW_VALUES(row) ) == DB_INT || VAL_TYPE( ROW_VALUES(row) ) == DB_BIGINT ) { | ||
/* if INT or BIGINT type, convert it to string */ | ||
check_val2( id_drd_col, ROW_VALUES(row), DB_INT, DB_BIGINT, 1, 0); | ||
/* int2bstr returns a null terminated string */ | ||
str_vals[STR_VALS_ID_DRD_COL] = | ||
int2bstr((unsigned long)VAL_INT(ROW_VALUES(row)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we need to read as VAL_INT or VAL_BIGINT, to ensure correctness.
check_val( id_drc_col, ROW_VALUES(row), DB_INT, 1, 0); | ||
if ( VAL_TYPE( ROW_VALUES(row) ) == DB_INT || VAL_TYPE( ROW_VALUES(row) ) == DB_BIGINT ) { | ||
/* if INT or BIGINT type, convert it to string */ | ||
check_val2( id_drc_col, ROW_VALUES(row), DB_INT, DB_BIGINT, 1, 0); | ||
/* int2bstr returns a null terminated string */ | ||
str_vals[STR_VALS_ID_DRC_COL] = | ||
int2bstr((unsigned long)VAL_INT(ROW_VALUES(row)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar, read as VAL_INT or VAL_BIGINT.
@@ -641,7 +641,7 @@ rt_data_t* dr_load_routing_info(struct head_db *part, | |||
for(i=0; i < RES_ROW_N(res); i++) { | |||
row = RES_ROWS(res) + i; | |||
/* RULE_ID column */ | |||
check_val( rule_id_drr_col, ROW_VALUES(row), DB_INT, 1, 0); | |||
check_val2( rule_id_drr_col, ROW_VALUES(row), DB_INT, DB_BIGINT, 1, 0); | |||
int_vals[INT_VALS_RULE_ID_DRR_COL] = VAL_INT (ROW_VALUES(row)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar, read as VAL_INT or VAL_BIGINT.
Also, the rule ID is exposed as AVP to script, so as an integer :-/ (for Carriers and GWs we have string ID which is used only for log printing and it is not stored into internal structures), so it may be subject to an overflow (while reading 64b from DB)
So, at least, we need to upgrade the rule->id to long long (and also check the implications of that - not sure where this ID is used further in the code). And the rule_id_avp
to expose the ID as string, not int.
Hey @bogdan-iancu, I'll take a look this week and try to address your comments! |
Summary
Currently the
drouting
module only has support forDB_INT
type for the dr_rules.ruleid column. This PR adds support for theDB_BIGINT
type as well.Details
I ran into this when trying to integrate the
drouting
module with some customVIEW
based schema that was usingBIGINT
for the ID column. The resulting logs are below and the table fails to load.This should be a pretty safe one!