Explorar el Código

lib/srdb1: store BIGINT result also as 32-bit integer if it fits

BIGINT is always converted to string. Additionally it is now stored as INT too.

MySQL (at least on 64-bit) is returning BIGINT for all "generated" INT values,
like COUNT(*). By storing thee results as INT (if possible), the config script
will be compatible with both 32-bit and 64-bit column values.
Alex Hermann hace 14 años
padre
commit
58e81b6c42
Se han modificado 1 ficheros con 5 adiciones y 0 borrados
  1. 5 0
      lib/srdb1/db_ut.c

+ 5 - 0
lib/srdb1/db_ut.c

@@ -464,6 +464,11 @@ int db_val2pv_spec(struct sip_msg* msg, db_val_t *dbval, pv_spec_t *pvs)
 				pv.rs.len = LL_LEN;
 				db_longlong2str(dbval->val.ll_val, ll_buf, &pv.rs.len);
 				pv.rs.s = ll_buf;
+				/* if it fits, also store as 32 bit integer*/
+				if (! ((unsigned long)dbval->val.ll_val & 0xffffffff00000000)) {
+					pv.flags |= PV_VAL_INT | PV_TYPE_INT;
+					pv.ri = (int)dbval->val.ll_val;
+				}
 			break;
 			default:
 				LM_NOTICE("unknown field type: %d, setting value to null\n",