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

Function get_cdb_val_size

modules/sql_cacher/sql_cacher.c:576–611  ·  view source on GitHub ↗

returns the total size of the actual value which will be stored in the cachedb*/

Source from the content-addressed store, hash-verified

574
575/* returns the total size of the actual value which will be stored in the cachedb*/
576static unsigned int get_cdb_val_size(cache_entry_t *c_entry, db_val_t *values, int nr_columns)
577{
578 unsigned int i, len = 0;
579 db_type_t val_type;
580
581 /* reload version + integer values + offsets of the string values */
582 len = INT_B64_ENC_LEN + c_entry->nr_ints*INT_B64_ENC_LEN + c_entry->nr_strs*INT_B64_ENC_LEN;
583 /* length of the actual string values*/
584 for (i = 0; i < nr_columns; i++) {
585 val_type = VAL_TYPE(values + i);
586 switch (val_type) {
587 case DB_STRING:
588 len += strlen(VAL_STRING(values + i));
589 break;
590 case DB_STR:
591 len += VAL_STR(values + i).len;
592 break;
593 case DB_BLOB:
594 len += VAL_BLOB(values + i).len;
595 break;
596 case DB_DOUBLE:
597 len += DOUBLE2STR_MAX_LEN;
598 break;
599 case DB_BIGINT:
600 if (sql_cacher_bigint2str) {
601 len += BIGINT2STR_MAX_LEN;
602 break;
603 } else {
604 continue;
605 }
606 default: continue;
607 }
608 }
609
610 return len;
611}
612
613static int insert_in_cachedb(cache_entry_t *c_entry, db_handlers_t *db_hdls,
614 db_val_t *key, db_val_t *values, int reload_version, int nr_columns)

Callers 1

insert_in_cachedbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected