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

Method GetColumnValue

storage/connect/tabjson.cpp:1861–1918  ·  view source on GitHub ↗

/ GetColumnValue: */ /

Source from the content-addressed store, hash-verified

1859/* GetColumnValue: */
1860/***********************************************************************/
1861PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i)
1862{
1863 PJAR arp;
1864 PJVAL val = NULL;
1865
1866 for (; i < Nod && row; i++) {
1867 if (Nodes[i].Op == OP_NUM) {
1868 Value->SetValue(row->GetType() == TYPE_JAR ? ((PJAR)row)->size() : 1);
1869 return(Value);
1870 } else if (Nodes[i].Op == OP_XX) {
1871 return MakeJson(G, row, i);
1872 } else switch (row->GetType()) {
1873 case TYPE_JOB:
1874 if (!Nodes[i].Key) {
1875 // Expected Array was not there, wrap the value
1876 if (i < Nod-1)
1877 continue;
1878 else
1879 val = new(G) JVALUE(row);
1880
1881 } else
1882 val = ((PJOB)row)->GetKeyValue(Nodes[i].Key);
1883
1884 break;
1885 case TYPE_JAR:
1886 arp = (PJAR)row;
1887
1888 if (!Nodes[i].Key) {
1889 if (Nodes[i].Op == OP_EQ)
1890 val = arp->GetArrayValue(Nodes[i].Rank);
1891 else if (Nodes[i].Op == OP_EXP)
1892 return ExpandArray(g, arp, i);
1893 else
1894 return CalculateArray(g, arp, i);
1895
1896 } else {
1897 // Unexpected array, unwrap it as [0]
1898 val = arp->GetArrayValue(0);
1899 i--;
1900 } // endif's
1901
1902 break;
1903 case TYPE_JVAL:
1904 val = (PJVAL)row;
1905 break;
1906 default:
1907 snprintf(g->Message, sizeof(g->Message), "Invalid row JSON type %d", row->GetType());
1908 val = NULL;
1909 } // endswitch Type
1910
1911 if (i < Nod-1)
1912 row = (val) ? val->GetJson() : NULL;
1913
1914 } // endfor i
1915
1916 SetJsonValue(g, Value, val);
1917 return Value;
1918} // end of GetColumnValue

Callers

nothing calls this directly

Calls 6

SetValueMethod · 0.45
GetTypeMethod · 0.45
sizeMethod · 0.45
GetKeyValueMethod · 0.45
GetArrayValueMethod · 0.45
GetJsonMethod · 0.45

Tested by

no test coverage detected