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

Method GetRowValue

storage/connect/jsonudf.cpp:434–500  ·  view source on GitHub ↗

/ GetRowValue: */ /

Source from the content-addressed store, hash-verified

432/* GetRowValue: */
433/*********************************************************************************/
434PJVAL JSNX::GetRowValue(PGLOBAL g, PJSON row, int i, my_bool b)
435{
436 PJAR arp;
437 PJVAL val = NULL;
438
439 for (; i < Nod && row; i++) {
440 if (Nodes[i].Op == OP_NUM) {
441 Value->SetValue(row->GetType() == TYPE_JAR ? ((PJAR)row)->size() : 1);
442 val = new(g) JVALUE(g, Value);
443 return val;
444 } else if (Nodes[i].Op == OP_XX) {
445 return MakeJson(g, row, i);
446 } else switch (row->GetType()) {
447 case TYPE_JOB:
448 if (!Nodes[i].Key) {
449 // Expected Array was not there
450 if (Nodes[i].Op == OP_LE) {
451 if (i < Nod-1)
452 continue;
453 else
454 val = new(g)JVALUE(row);
455
456 } else {
457 snprintf(g->Message, sizeof(g->Message), "Unexpected object");
458 val = NULL;
459 } //endif Op
460
461 } else
462 val = ((PJOB)row)->GetKeyValue(Nodes[i].Key);
463
464 break;
465 case TYPE_JAR:
466 arp = (PJAR)row;
467
468 if (!Nodes[i].Key) {
469 if (Nodes[i].Op == OP_EQ || Nodes[i].Op == OP_LE)
470 val = arp->GetArrayValue(Nodes[i].Rank);
471 else if (Nodes[i].Op == OP_EXP)
472 return (PJVAL)ExpandArray(g, arp, i);
473 else
474 return new(g) JVALUE(g, CalculateArray(g, arp, i));
475
476 } else {
477 // Unexpected array, unwrap it as [0]
478 val = arp->GetArrayValue(0);
479 i--;
480 } // endif's
481
482 break;
483 case TYPE_JVAL:
484 val = (PJVAL)row;
485 break;
486 default:
487 snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
488 val = NULL;
489 } // endswitch Type
490
491 if (i < Nod-1)

Callers 1

jbin_get_itemFunction · 0.45

Calls 6

SetValueMethod · 0.45
GetTypeMethod · 0.45
sizeMethod · 0.45
GetKeyValueMethod · 0.45
GetArrayValueMethod · 0.45
GetJspMethod · 0.45

Tested by

no test coverage detected