insert records with bind params
| 179 | |
| 180 | // insert records with bind params |
| 181 | void insert_records_with_bind_index(cdb2_hndl_tp *db, std::string table) |
| 182 | { |
| 183 | std::ostringstream ss; |
| 184 | std::vector<int> types; |
| 185 | |
| 186 | short palltypes_short; |
| 187 | int palltypes_int; |
| 188 | unsigned short palltypes_u_short; |
| 189 | float palltypes_float; |
| 190 | double palltypes_double; |
| 191 | unsigned char palltypes_byte[17] = "1234567890123456"; |
| 192 | unsigned char palltypes_cstring[16] = "123456789012345"; |
| 193 | unsigned char palltypes_pstring[16] = "123456789012345"; |
| 194 | unsigned char palltypes_blob[1025]; |
| 195 | { |
| 196 | for(unsigned int i = 0 ; i < sizeof(palltypes_blob) - 1; i++) |
| 197 | palltypes_blob[i] = 'a' + (i % 26); |
| 198 | palltypes_blob[sizeof(palltypes_blob)-1] = '\0'; |
| 199 | } |
| 200 | time_t t = 1386783296; //2013-12-11T123456 |
| 201 | cdb2_client_datetime_t datetime = {0}; |
| 202 | gmtime_r(&t, (struct tm *)&datetime.tm); //corrupts memory past the tm member |
| 203 | datetime.msec = 123; // should not be larger than 999 |
| 204 | datetime.tzname[0] = '\0'; |
| 205 | |
| 206 | cdb2_client_datetimeus_t datetimeus = {0}; |
| 207 | gmtime_r(&t, (struct tm *)&datetimeus.tm); |
| 208 | datetimeus.usec = 123456; // should not be larger than 999999 |
| 209 | datetimeus.tzname[0] = '\0'; // gmtime_r corrupts past member tm |
| 210 | cdb2_client_intv_ym_t ym = {1, 5, 2}; |
| 211 | |
| 212 | cdb2_client_intv_ds_t ci = {1, 12, 23, 34, 45, 456 }; |
| 213 | |
| 214 | cdb2_client_intv_dsus_t cidsus = {1, 12, 23, 34, 45, 456789 }; |
| 215 | |
| 216 | int idx = 1; |
| 217 | if(cdb2_bind_index(db, idx++, CDB2_INTEGER, &palltypes_short, sizeof(palltypes_short)) ) |
| 218 | fprintf(stderr, "Error binding palltypes_short.\n"); |
| 219 | if(cdb2_bind_index(db, idx++, CDB2_INTEGER, &palltypes_u_short, sizeof(palltypes_u_short)) ) |
| 220 | fprintf(stderr, "Error binding palltypes_short.\n"); |
| 221 | if(cdb2_bind_index(db, idx++, CDB2_INTEGER, &palltypes_int, sizeof(palltypes_int)) ) |
| 222 | fprintf(stderr, "Error binding palltypes_short.\n"); |
| 223 | if(cdb2_bind_index(db, idx++, CDB2_REAL, &palltypes_float, sizeof(palltypes_float)) ) |
| 224 | fprintf(stderr, "Error binding palltypes_float.\n"); |
| 225 | if(cdb2_bind_index(db, idx++, CDB2_REAL, &palltypes_double, sizeof(palltypes_double)) ) |
| 226 | fprintf(stderr, "Error binding palltypes_double.\n"); |
| 227 | if(cdb2_bind_index(db, idx++, CDB2_BLOB, palltypes_byte, sizeof(palltypes_byte)-1)) |
| 228 | fprintf(stderr, "Error binding palltypes_byte.\n"); |
| 229 | if(cdb2_bind_index(db, idx++, CDB2_BLOB, palltypes_blob, sizeof(palltypes_blob) - 1)) |
| 230 | fprintf(stderr, "Error binding palltypes_blob.\n"); |
| 231 | if(cdb2_bind_index(db, idx++, CDB2_CSTRING, palltypes_cstring, sizeof(palltypes_cstring) - 1)) |
| 232 | fprintf(stderr, "Error binding palltypes_cstring.\n"); |
| 233 | if(cdb2_bind_index(db, idx++, CDB2_CSTRING, palltypes_pstring, sizeof(palltypes_pstring) - 1)) |
| 234 | fprintf(stderr, "Error binding palltypes_cstring.\n"); |
| 235 | if(cdb2_bind_index(db, idx++, CDB2_DATETIME, &datetime, sizeof(datetime))) |
| 236 | fprintf(stderr, "Error binding palltypes_datetime.\n"); |
| 237 | if(cdb2_bind_index(db, idx++, CDB2_DATETIMEUS, &datetimeus, sizeof(datetimeus))) |
| 238 | fprintf(stderr, "Error binding palltypes_datetimeus.\n"); |
no test coverage detected