MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / db_sqlite_bind_values

Function db_sqlite_bind_values

modules/db_sqlite/dbase.c:884–939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882
883#ifdef SQLITE_BIND
884static int db_sqlite_bind_values(sqlite3_stmt* stmt, const db_val_t* v, const int n)
885{
886 int i, ret;
887
888 if (n>0 && v) {
889 for (i=0; i<n; i++) {
890 if (VAL_NULL(v+i)) {
891 ret=sqlite3_bind_null(stmt, i+1);
892 goto check_ret;
893 }
894
895
896 switch(VAL_TYPE(v+i)) {
897 /* every param has '+1' index because in sqlite the leftmost
898 * parameter has index '1' */
899 case DB_INT:
900 ret=sqlite3_bind_int(stmt, i+1, VAL_INT(v+i));
901 break;
902 case DB_BIGINT:
903 ret=sqlite3_bind_int64(stmt, i+1, VAL_BIGINT(v+i));
904 break;
905 case DB_DOUBLE:
906 ret=sqlite3_bind_double(stmt, i+1, VAL_DOUBLE(v+i));
907 break;
908 case DB_STRING:
909 ret=sqlite3_bind_text(stmt, i+1, VAL_STRING(v+i),
910 strlen(VAL_STRING(v+i)), SQLITE_STATIC);
911 break;
912 case DB_STR:
913 ret=sqlite3_bind_text(stmt, i+1, VAL_STR(v+i).s,
914 VAL_STR(v+i).len, SQLITE_STATIC);
915 break;
916 case DB_DATETIME:
917 ret=sqlite3_bind_int64(stmt, i+1, (long int)VAL_TIME(v+i));
918 break;
919 case DB_BLOB:
920 ret=sqlite3_bind_blob(stmt, i+1, (void*)VAL_BLOB(v+i).s,
921 VAL_BLOB(v+i).len, SQLITE_STATIC);
922 break;
923 case DB_BITMAP:
924 ret=sqlite3_bind_int(stmt, i+1, (int)VAL_BITMAP(v+i));
925 break;
926 default:
927 LM_BUG("invalid db type\n");
928 return 1;
929 }
930
931check_ret:
932 if (ret != SQLITE_OK) {
933 return ret;
934 }
935 }
936 }
937
938 return SQLITE_OK;
939}
940#endif

Callers 7

db_sqlite_get_query_rowsFunction · 0.85
db_sqlite_queryFunction · 0.85
db_sqlite_insertFunction · 0.85
db_sqlite_deleteFunction · 0.85
db_sqlite_updateFunction · 0.85
db_sqlite_replaceFunction · 0.85
db_insert_updateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected