Skip to content

Commit

Permalink
Proper support for BIGINT (as long) in the db_text SQL driver.
Browse files Browse the repository at this point in the history
Many thanks to Jeff Pyle for reporting and troubleshooting this.
  • Loading branch information
bogdan-iancu committed Oct 23, 2013
1 parent 8e61b34 commit 9bf9e54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 10 additions & 8 deletions modules/db_text/dbt_file.c
Expand Up @@ -318,8 +318,8 @@ dbt_table_p dbt_load_file(const str *tbn, const str *dbn)
case DB_INT:
case DB_BIGINT:
case DB_DATETIME:
//LM_DBG("INT value!\n");
dtval.val.int_val = 0;
//LM_DBG("INT/BIGINT/DATETIME value!\n");
dtval.val.bigint_val = 0;
dtval.type = dtp->colv[ccol]->type;

if(c==DBT_DELIM ||
Expand All @@ -339,21 +339,23 @@ dbt_table_p dbt_load_file(const str *tbn, const str *dbn)
goto clean;
while(c>='0' && c<='9')
{
dtval.val.int_val=dtval.val.int_val*10+c-'0';
dtval.val.bigint_val=dtval.val.bigint_val*10+c-'0';
c = fgetc(fin);
}
dtval.val.int_val *= sign;
dtval.val.bigint_val *= sign;
//LM_DBG("data[%d,%d]=%d\n", crow,
// ccol, dtval.val.int_val);
// ccol, dtval.val.bigint_val);
}
if(c!=DBT_DELIM && c!=DBT_DELIM_R && c!=EOF)
goto clean;
if(dbt_row_set_val(rowp,&dtval,dtp->colv[ccol]->type,
ccol))
goto clean;
if(ccol == dtp->auto_col)
max_auto = (max_auto<dtval.val.int_val)?
dtval.val.int_val:max_auto;
max_auto = (max_auto<dtval.val.bigint_val)?
dtval.val.bigint_val:max_auto;
if (dtval.type!=DB_BIGINT)
dtval.val.int_val = (int)dtval.val.bigint_val;
break;

case DB_DOUBLE:
Expand Down Expand Up @@ -533,7 +535,7 @@ int dbt_print_table(dbt_table_p _dtp, str *_dbn)
fprintf(fout, "%.*s(int", colp->name.len, colp->name.s);
break;
case DB_BIGINT:
fprintf(fout, "%.*s(bigint", colp->name.len, colp->name.s);
fprintf(fout, "%.*s(long", colp->name.len, colp->name.s);
break;
case DB_DOUBLE:
fprintf(fout, "%.*s(double", colp->name.len, colp->name.s);
Expand Down
6 changes: 4 additions & 2 deletions modules/dialog/dlg_db_handler.c
Expand Up @@ -520,8 +520,10 @@ static int load_dialog_info_from_db(int dlg_hash_size)
if(dlg->h_entry != VAL_INT(values)){
LM_ERR("inconsistent hash data in the dialog database: "
"you may have restarted opensips using a different "
"hash_size: please erase %.*s database and restart\n",
dialog_table_name.len, dialog_table_name.s);
"hash_size: please erase %.*s database and restart\n"
"dlg : %u, db : %u\n",
dialog_table_name.len, dialog_table_name.s,
dlg->h_entry,VAL_INT(values));
shm_free(dlg);
goto error;
}
Expand Down

0 comments on commit 9bf9e54

Please sign in to comment.