MCPcopy Create free account
hub / github.com/MariaDB/server / MakeBinResult

Function MakeBinResult

storage/connect/jsonudf.cpp:1465–1503  ·  view source on GitHub ↗

/ Make the binary result according to the first argument type. */ /

Source from the content-addressed store, hash-verified

1463/* Make the binary result according to the first argument type. */
1464/*********************************************************************************/
1465static PBSON MakeBinResult(PGLOBAL g, UDF_ARGS *args, PJSON top, ulong len, int n = 2)
1466{
1467 PBSON bsnp = JbinAlloc(g, args, len, top);
1468
1469 if (!bsnp)
1470 return NULL;
1471
1472 if (IsJson(args, 0) == 2) {
1473 int pretty = 0;
1474
1475 for (uint i = n; i < args->arg_count; i++)
1476 if (args->arg_type[i] == INT_RESULT) {
1477 pretty = (int)*(longlong*)args->args[i];
1478 break;
1479 } // endif type
1480
1481 bsnp->Pretty = pretty;
1482
1483 if ((bsnp->Filename = (char*)args->args[0])) {
1484 bsnp->Filename = MakePSZ(g, args, 0);
1485 strmake(bsnp->Msg, bsnp->Filename, BMX-1);
1486 } else
1487 strmake(bsnp->Msg, "null filename", BMX-1);
1488
1489 } else if (IsJson(args, 0) == 3) {
1490 PBSON bsp = (PBSON)args->args[0];
1491
1492 if (bsp->Filename) {
1493 bsnp->Filename = bsp->Filename;
1494 strmake(bsnp->Msg, bsp->Filename, BMX-1);
1495 bsnp->Pretty = bsp->Pretty;
1496 } else
1497 strcpy(bsnp->Msg, "Json Binary item");
1498
1499 } else
1500 strcpy(bsnp->Msg, "Json Binary item");
1501
1502 return bsnp;
1503} // end of MakeBinResult
1504
1505/*********************************************************************************/
1506/* Returns a pointer to the first integer argument found from the nth argument. */

Callers 6

jbin_array_addFunction · 0.85
jbin_array_deleteFunction · 0.85
jbin_object_addFunction · 0.85
jbin_object_deleteFunction · 0.85
jbin_item_mergeFunction · 0.85
bin_handle_itemFunction · 0.85

Calls 4

JbinAllocFunction · 0.85
IsJsonFunction · 0.85
MakePSZFunction · 0.85
strmakeFunction · 0.85

Tested by

no test coverage detected