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

Function sp_column_ptr

lua/sp.c:606–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

604}
605
606void *sp_column_ptr(struct response_data *arg, int col, int type, size_t *len)
607{
608 SP sp = arg->sp;
609 Lua L = sp->lua;
610 int idx = col_to_idx(arg->ncols, col);
611 char *c;
612 blob_t b;
613 lua_cstring_t *cs;
614 switch (type) {
615 case SQLITE_TEXT:
616 switch (luabb_type(L, idx)) {
617 case DBTYPES_LNUMBER:
618 case DBTYPES_LSTRING:
619 c = (char *)lua_tolstring(L, idx, len);
620 break;
621 case DBTYPES_CSTRING:
622 cs = lua_touserdata(L, idx);
623 c = cs->val;
624 *len = strlen(c);
625 break;
626 default:
627 c = (char *)luabb_tostring_noerr(L, idx);
628 if (!c) break;
629 c = strdup(c);
630 *len = strlen(c);
631 luabb_pushcstring_dl(L, c);
632 lua_replace(L, idx);
633 }
634 return c;
635 case SQLITE_BLOB:
636 if (luabb_toblob_noerr(L, idx, &b))
637 break;
638 if (luabb_type(L, idx) != DBTYPES_BLOB) {
639 luabb_pushblob_dl(L, &b);
640 lua_replace(L, idx);
641 }
642 *len = b.length;
643 return b.data;
644 }
645 return NULL;
646}
647
648char *sp_column_name(struct response_data *arg, int col)
649{

Callers 1

newsql.cFile · 0.85

Calls 9

luabb_typeFunction · 0.85
lua_tolstringFunction · 0.85
lua_touserdataFunction · 0.85
luabb_tostring_noerrFunction · 0.85
luabb_pushcstring_dlFunction · 0.85
lua_replaceFunction · 0.85
luabb_toblob_noerrFunction · 0.85
luabb_pushblob_dlFunction · 0.85
strdupFunction · 0.50

Tested by

no test coverage detected