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

Function push_param

lua/sp.c:5888–5947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5886}
5887
5888static int push_param(Lua L, struct sqlclntstate *clnt, int64_t index)
5889{
5890 struct param_data p = {0};
5891 if (param_value(clnt, &p, index) != 0) {
5892 if (p.type > CLIENT_MINTYPE && p.type < CLIENT_MAXTYPE)
5893 return p.type;
5894 return -1;
5895 }
5896 if (p.null || p.type == COMDB2_NULL_TYPE) {
5897 return push_null(L, p.type);
5898 }
5899 if (p.arraylen) {
5900 switch (p.type) {
5901 case CLIENT_BLOB: return push_blob_array(L, &p);
5902 case CLIENT_CSTR: return push_string_array(L, &p);
5903 case CLIENT_INT: return push_int_array(L, &p);
5904 case CLIENT_REAL: return push_real_array(L, &p);
5905 }
5906 return -1;
5907 }
5908 switch (p.type) {
5909 case CLIENT_INT:
5910 case CLIENT_UINT: luabb_pushinteger(L, p.u.i); break;
5911 case CLIENT_REAL: luabb_pushreal(L, p.u.r); break;
5912 case CLIENT_CSTR:
5913 case CLIENT_PSTR:
5914 case CLIENT_PSTR2:
5915 case CLIENT_VUTF8: luabb_pushcstringlen(L, p.u.p, p.len); break;
5916 case CLIENT_BYTEARRAY:
5917 case CLIENT_BLOB: {
5918 blob_t b = {.length = p.len, .data = p.u.p};
5919 luabb_pushblob(L, &b);
5920 break;
5921 }
5922 case CLIENT_DATETIME: {
5923 cdb2_client_datetime_t t;
5924 dttz_to_client_datetime(&p.u.dt, clnt->tzname, &t);
5925 datetime_t datetime;
5926 client_datetime_to_datetime_t(&t, &datetime, 0);
5927 luabb_pushdatetime(L, &datetime);
5928 break;
5929 }
5930 case CLIENT_DATETIMEUS: {
5931 cdb2_client_datetimeus_t t;
5932 dttz_to_client_datetimeus(&p.u.dt, clnt->tzname, &t);
5933 datetime_t datetime;
5934 client_datetimeus_to_datetime_t(&t, &datetime, 0);
5935 luabb_pushdatetime(L, &datetime);
5936 break;
5937 }
5938 default:
5939 logmsg(LOGMSG_ERROR, "Unknown type %d\n", p.type);
5940 return -1;
5941 }
5942 if (gbl_dump_sql_dispatched) {
5943 logmsg(LOGMSG_USER, "%s type %d %s len %d null %d bind\n", p.name,
5944 p.type, strtype(p.type), p.len, p.null);
5945 }

Callers 1

push_argsFunction · 0.85

Calls 15

param_valueFunction · 0.85
push_nullFunction · 0.85
push_blob_arrayFunction · 0.85
push_string_arrayFunction · 0.85
push_int_arrayFunction · 0.85
push_real_arrayFunction · 0.85
luabb_pushintegerFunction · 0.85
luabb_pushrealFunction · 0.85
luabb_pushcstringlenFunction · 0.85
luabb_pushblobFunction · 0.85
dttz_to_client_datetimeFunction · 0.85

Tested by

no test coverage detected