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

Method GetRow

storage/connect/jsonudf.cpp:733–806  ·  view source on GitHub ↗

/ GetRow: Set the complete path of the object to be set. */ /

Source from the content-addressed store, hash-verified

731/* GetRow: Set the complete path of the object to be set. */
732/***********************************************************************/
733PJSON JSNX::GetRow(PGLOBAL g)
734{
735 PJVAL val = NULL;
736 PJAR arp;
737 PJSON nwr, row = Row;
738
739 for (int i = 0; i < Nod - 1 && row; i++) {
740 if (Nodes[i].Op == OP_XX)
741 break;
742 else switch (row->GetType()) {
743 case TYPE_JOB:
744 if (!Nodes[i].Key)
745 // Expected Array was not there, wrap the value
746 continue;
747
748 val = ((PJOB)row)->GetKeyValue(Nodes[i].Key);
749 break;
750 case TYPE_JAR:
751 arp = (PJAR)row;
752
753 if (!Nodes[i].Key) {
754 if (Nodes[i].Op == OP_EQ)
755 val = arp->GetArrayValue(Nodes[i].Rank);
756 else
757 val = arp->GetArrayValue(Nodes[i].Rx);
758
759 } else {
760 // Unexpected array, unwrap it as [0]
761 val = arp->GetArrayValue(0);
762 i--;
763 } // endif Nodes
764
765 break;
766 case TYPE_JVAL:
767 val = (PJVAL)row;
768 break;
769 default:
770 snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
771 val = NULL;
772 } // endswitch Type
773
774 if (val) {
775 row = val->GetJson();
776 } else {
777 // Construct missing objects
778 for (i++; row && i < Nod; i++) {
779 if (Nodes[i].Op == OP_XX)
780 break;
781 else if (!Nodes[i].Key)
782 // Construct intermediate array
783 nwr = new(g)JARRAY;
784 else
785 nwr = new(g)JOBJECT;
786
787 if (row->GetType() == TYPE_JOB) {
788 ((PJOB)row)->SetKeyValue(g, new(g)JVALUE(nwr), Nodes[i-1].Key);
789 } else if (row->GetType() == TYPE_JAR) {
790 ((PJAR)row)->AddArrayValue(g, new(g)JVALUE(nwr));

Callers

nothing calls this directly

Calls 7

InitArrayMethod · 0.80
GetTypeMethod · 0.45
GetKeyValueMethod · 0.45
GetArrayValueMethod · 0.45
GetJsonMethod · 0.45
SetKeyValueMethod · 0.45
AddArrayValueMethod · 0.45

Tested by

no test coverage detected