| 130 | |
| 131 | |
| 132 | int sqlops_db_bind(void) |
| 133 | { |
| 134 | unsigned int i; |
| 135 | |
| 136 | for(i=0;i<no_db_urls;i++) { |
| 137 | if (db_bind_mod(&db_urls[i].url, &db_urls[i].dbf )) { |
| 138 | LM_CRIT("cannot bind to database module for %.*s! " |
| 139 | "Did you load a database module ?\n", |
| 140 | db_urls[i].url.len,db_urls[i].url.s); |
| 141 | return -1; |
| 142 | } |
| 143 | |
| 144 | if (!DB_CAPABILITY(db_urls[i].dbf, DB_CAP_ALL)) { |
| 145 | LM_CRIT("database modules (%.*s) does not " |
| 146 | "provide all functions needed by sqlops module\n", |
| 147 | db_urls[i].url.len,db_urls[i].url.s); |
| 148 | return -1; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /* |
| 153 | * we cannot catch the default DB url usage at fixup time |
| 154 | * as we do with the other bunch of extra sqlops DB URLs |
| 155 | * |
| 156 | * so just dig through the whole script tree |
| 157 | */ |
| 158 | if (is_script_func_used("db_query", 1) || |
| 159 | is_script_func_used("db_query", 2)) { |
| 160 | if (!DB_CAPABILITY(default_db_url->dbf, DB_CAP_RAW_QUERY)) { |
| 161 | LM_ERR("driver for DB URL [default] does not support " |
| 162 | "raw queries!\n"); |
| 163 | return -1; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if (is_script_async_func_used("db_query", 1) || |
| 168 | is_script_async_func_used("db_query", 2)) { |
| 169 | if (!DB_CAPABILITY(default_db_url->dbf, DB_CAP_ASYNC_RAW_QUERY)) |
| 170 | LM_WARN("async() calls for DB URL [default] will work " |
| 171 | "in normal mode due to driver limitations\n"); |
| 172 | } |
| 173 | |
| 174 | return 0; |
| 175 | } |
| 176 | |
| 177 | |
| 178 | int sqlops_db_init(const str* db_table, str** db_cols) |
no test coverage detected