Skip to content

Commit

Permalink
Revert "retrieve table name from select queries on raw_query in order…
Browse files Browse the repository at this point in the history
… to use sqlite library functions later"

This reverts commit 779996d.
  • Loading branch information
ionutrazvanionita committed Sep 9, 2015
1 parent a5e4a71 commit 3df19e5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 67 deletions.
23 changes: 0 additions & 23 deletions modules/db_sqlite/dbase.c
Expand Up @@ -328,9 +328,6 @@ int db_sqlite_raw_query(const db_con_t* _h, const str* _s, db_res_t** _r)
int ret=-1;
char* errmsg;
str select_str={"select", 6};
str from_str={"from", 4};
str table_name;
char *from_start;

CON_RESET_CURR_PS(_h);
if (!str_strstr(_s, &select_str)) {
Expand Down Expand Up @@ -359,26 +356,6 @@ int db_sqlite_raw_query(const db_con_t* _h, const str* _s, db_res_t** _r)
LM_ERR("failed to prepare: (%s)\n",
sqlite3_errmsg(CON_CONNECTION(_h)));

/* fetch table name */
from_start = str_strcasestr(_s, &from_str);
if (!from_start) {
LM_ERR("failed to fetch table name\n");
return -1;
}

table_name.s = from_start + from_str.len;
/* search for table name begin */

while (!isalpha(table_name.s[0]))
table_name.s++;

/* search for table name end */
table_name.len = 0;
while (isalpha(table_name.s[table_name.len]))
table_name.len++;

db_sqlite_use_table(*((db_con_t**)&_h), &table_name);

if (_r) {
ret = db_sqlite_store_result(_h, _r, NULL, 0);
} else {
Expand Down
45 changes: 1 addition & 44 deletions ut.h
Expand Up @@ -627,7 +627,7 @@ static inline int str_strcmp(const str *stra, const str *strb)
}

/*
* search strb in stra case sensitive
* search strb in stra
*/
static inline char* str_strstr(const str *stra, const str *strb)
{
Expand Down Expand Up @@ -669,49 +669,6 @@ static inline char* str_strstr(const str *stra, const str *strb)
return NULL;
}

/*
* search strb in stra case insensitive
*/
static inline char* str_strcasestr(const str *stra, const str *strb)
{
int i;
int len;

if (stra==NULL || strb==NULL || stra->s==NULL || strb->s==NULL
|| stra->len<=0 || strb->len<=0) {
LM_ERR("bad parameters\n");
return NULL;
}

if (strb->len > stra->len) {
LM_ERR("str to find should be smaller\n");
return NULL;
}


len=0;
while (stra->len-len >= strb->len){
if (tolower(stra->s[len]) != tolower(strb->s[0])) {
len++;
continue;
}

for (i=1; i<strb->len; i++)
if (tolower(stra->s[len+i])!=tolower(strb->s[i])) {
len++;
break;
}

if (i != strb->len)
continue;

return stra->s+len;
}


return NULL;
}


/*
* case-insensitive compare two str's
Expand Down

0 comments on commit 3df19e5

Please sign in to comment.