{"action":"created","issue":{"url":"https://api.github.com/repos/OpenSIPS/opensips/issues/471","labels_url":"https://api.github.com/repos/OpenSIPS/opensips/issues/471/labels{/name}","comments_url":"https://api.github.com/repos/OpenSIPS/opensips/issues/471/comments","events_url":"https://api.github.com/repos/OpenSIPS/opensips/issues/471/events","html_url":"https://github.com/OpenSIPS/opensips/issues/471","id":69321450,"number":471,"title":"modules/db_sqlite: error loading drouting ","user":{"login":"jarrodb","id":485817,"avatar_url":"https://avatars.githubusercontent.com/u/485817?v=3","gravatar_id":"","url":"https://api.github.com/users/jarrodb","html_url":"https://github.com/jarrodb","followers_url":"https://api.github.com/users/jarrodb/followers","following_url":"https://api.github.com/users/jarrodb/following{/other_user}","gists_url":"https://api.github.com/users/jarrodb/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrodb/subscriptions","organizations_url":"https://api.github.com/users/jarrodb/orgs","repos_url":"https://api.github.com/users/jarrodb/repos","events_url":"https://api.github.com/users/jarrodb/events{/privacy}","received_events_url":"https://api.github.com/users/jarrodb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/OpenSIPS/opensips/milestones/9","html_url":"https://github.com/OpenSIPS/opensips/milestones/2.2","labels_url":"https://api.github.com/repos/OpenSIPS/opensips/milestones/9/labels","id":1048771,"number":9,"title":"2.2","description":"","creator":{"login":"bogdan-iancu","id":3973594,"avatar_url":"https://avatars.githubusercontent.com/u/3973594?v=3","gravatar_id":"","url":"https://api.github.com/users/bogdan-iancu","html_url":"https://github.com/bogdan-iancu","followers_url":"https://api.github.com/users/bogdan-iancu/followers","following_url":"https://api.github.com/users/bogdan-iancu/following{/other_user}","gists_url":"https://api.github.com/users/bogdan-iancu/gists{/gist_id}","starred_url":"https://api.github.com/users/bogdan-iancu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogdan-iancu/subscriptions","organizations_url":"https://api.github.com/users/bogdan-iancu/orgs","repos_url":"https://api.github.com/users/bogdan-iancu/repos","events_url":"https://api.github.com/users/bogdan-iancu/events{/privacy}","received_events_url":"https://api.github.com/users/bogdan-iancu/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":6,"state":"open","created_at":"2015-04-01T14:02:12Z","updated_at":"2015-04-20T09:26:07Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-04-18T15:52:49Z","updated_at":"2015-04-20T17:27:07Z","closed_at":null,"body":"##### opensips.cfg \r\n```\r\n# ----- drouting -----\r\nmodparam(\"drouting\", \"db_url\", \"sqlite://var/db/opensips\")\r\n```\r\n##### opensips.log\r\n```\r\nApr 18 15:39:39 localhost opensips: INFO:drouting:dr_init: Dynamic-Routing - initializing\r\nApr 18 15:39:39 localhost opensips: ERROR:db_sqlite:db_sqlite_query: failed to prepare: (no such table: version)\r\nApr 18 15:39:39 localhost opensips: ERROR:db_sqlite:db_sqlite_get_query_rows: failed to prepare query\r\n```\r\n#####  opens incorrect sqlite db handler:\r\n```\r\n# ls -al /var/db\r\n-rw-r--r--  1 root root      0 Apr 18 15:28 opensips?  <-- this is created\r\n```\r\n\r\n##### gdb\r\n```\r\n(gdb) break modules/db_sqlite/dbase.c:162\r\n(gdb) print _h->url\r\n$2 = {s = 0x7ffff7431bd0 \"sqlite://var/db/opensips8\", len = 24}\r\n(gdb) print query_holder\r\n$3 = {s = 0x852740 <sql_buf> \"select table_version from version where table_name='dr_gateways's\", len = 64}\r\n167\t\tif (ret!=SQLITE_OK)\r\n(gdb) s\r\n168\t\t\tLM_ERR(\"failed to prepare: (%s)\\n\", sqlite3_errmsg(CON_CONNECTION(_h)));\r\n(gdb) print ret\r\n$4 = 1\r\n```\r\n\r\n##### Synopsis\r\nSeems like the pointer arithmetic in val2str for type DB_STR (modules/db_sqlite/val.c:229) is off (the trailing s is from the previous sql_buf that dialog populates however the length is correct), but the other issue is its not accessing the proper db_url string that is set correctly.  It's weird that the other modules do not seem to have this issue.  \r\n\r\nFor example, dialog is the first to load, and the gdb printout of _h->url returns the same data for its query and everything else seems ok.  Perhaps there is an invalid or lacking CON_<X> macro call?\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/OpenSIPS/opensips/issues/comments/94515788","html_url":"https://github.com/OpenSIPS/opensips/issues/471#issuecomment-94515788","issue_url":"https://api.github.com/repos/OpenSIPS/opensips/issues/471","id":94515788,"user":{"login":"ionutrazvanionita","id":7924437,"avatar_url":"https://avatars.githubusercontent.com/u/7924437?v=3","gravatar_id":"","url":"https://api.github.com/users/ionutrazvanionita","html_url":"https://github.com/ionutrazvanionita","followers_url":"https://api.github.com/users/ionutrazvanionita/followers","following_url":"https://api.github.com/users/ionutrazvanionita/following{/other_user}","gists_url":"https://api.github.com/users/ionutrazvanionita/gists{/gist_id}","starred_url":"https://api.github.com/users/ionutrazvanionita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ionutrazvanionita/subscriptions","organizations_url":"https://api.github.com/users/ionutrazvanionita/orgs","repos_url":"https://api.github.com/users/ionutrazvanionita/repos","events_url":"https://api.github.com/users/ionutrazvanionita/events{/privacy}","received_events_url":"https://api.github.com/users/ionutrazvanionita/received_events","type":"User","site_admin":false},"created_at":"2015-04-20T17:27:07Z","updated_at":"2015-04-20T17:27:07Z","body":"@jarrodb https://gist.github.com/ionutrazvanionita/5f09ec2d96ddc60f6695 this patch fixes the bad '\\0' issue."}}