MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / test_bind_blob_array

Function test_bind_blob_array

tests/tools/cdb2bind.c:483–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483static void test_bind_blob_array()
484{
485 cdb2_hndl_tp *hndl = NULL;
486 test_open(&hndl, db);
487 const int N = INT16_MAX;
488 struct {
489 size_t len;
490 void *data;
491 } blobs[N];
492 uint8_t db[N];
493 memset(db, 0xdb, sizeof(db));
494 for (int i = 0, j = N - 1; i < N; ++i, --j) {
495 /* desc order so first blob is not zero-length (which server return as string) */
496 blobs[i].len = j;
497 blobs[i].data = db;
498 }
499 cdb2_bind_array(hndl, "blobs", CDB2_BLOB, blobs, N, 0);
500 test_exec(hndl, "select * from carray(@blobs)");
501 int rc , i = -1, j = N;
502 while ((rc = cdb2_next_record(hndl)) == CDB2_OK) {
503 ++i;
504 --j;
505 if (cdb2_column_type(hndl, 0) != CDB2_BLOB) {
506 fprintf(stderr, "row:%d bad cdb2_column_type:%d expected:%d\n", i, cdb2_column_type(hndl, i), CDB2_BLOB);
507 abort();
508 }
509 if (cdb2_column_size(hndl, 0) != j) {
510 fprintf(stderr, "row:%d bad cdb2_column_size:%d expected:%d\n", i, cdb2_column_size(hndl, i), i);
511 abort();
512 }
513 if (memcmp(db, cdb2_column_value(hndl, 0), j) != 0) {
514 fprintf(stderr, "row:%d bad cdb2_column_value of size:%d\n", i, i);
515 abort();
516 }
517 }
518 if (rc != CDB2_OK_DONE) {
519 fprintf(stderr, "cdb2_next_record rc:%d err:%s\n", rc, cdb2_errstr(hndl));
520 abort();
521 }
522 cdb2_clearbindings(hndl);
523 test_close(hndl);
524}
525
526static void create_procedure_sp_array(void)
527{

Callers 1

mainFunction · 0.85

Calls 10

cdb2_bind_arrayFunction · 0.85
cdb2_next_recordFunction · 0.85
cdb2_column_typeFunction · 0.85
cdb2_column_sizeFunction · 0.85
cdb2_column_valueFunction · 0.85
cdb2_errstrFunction · 0.85
cdb2_clearbindingsFunction · 0.85
test_closeFunction · 0.85
test_openFunction · 0.70
test_execFunction · 0.70

Tested by

no test coverage detected