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

Method WriteColumn

storage/connect/tabjson.cpp:2143–2232  ·  view source on GitHub ↗

/ WriteColumn: */ /

Source from the content-addressed store, hash-verified

2141/* WriteColumn: */
2142/***********************************************************************/
2143void JSONCOL::WriteColumn(PGLOBAL g)
2144{
2145 if (Xpd && Tjp->Pretty < 2) {
2146 safe_strcpy(g->Message, sizeof(g->Message), "Cannot write expanded column when Pretty is not 2");
2147 throw 666;
2148 } // endif Xpd
2149
2150 /*********************************************************************/
2151 /* Check whether this node must be written. */
2152 /*********************************************************************/
2153 if (Value != To_Val)
2154 Value->SetValue_pval(To_Val, FALSE); // Convert the updated value
2155
2156 /*********************************************************************/
2157 /* On INSERT Null values are represented by no node. */
2158 /*********************************************************************/
2159 if (Value->IsNull() && Tjp->Mode == MODE_INSERT)
2160 return;
2161
2162 char *s;
2163 PJOB objp = NULL;
2164 PJAR arp = NULL;
2165 PJVAL jvp = NULL;
2166 PJSON jsp, row = GetRow(g);
2167
2168 switch (row->GetType()) {
2169 case TYPE_JOB: objp = (PJOB)row; break;
2170 case TYPE_JAR: arp = (PJAR)row; break;
2171 case TYPE_JVAL: jvp = (PJVAL)row; break;
2172 default: row = NULL; // ???????????????????????????
2173 } // endswitch Type
2174
2175 if (row) switch (Buf_Type) {
2176 case TYPE_STRING:
2177 if (Nodes[Nod-1].Op == OP_XX) {
2178 s = Value->GetCharValue();
2179
2180 if (s && *s) {
2181 if (!(jsp = ParseJson(G, s, strlen(s)))) {
2182 safe_strcpy(g->Message, sizeof(g->Message), s);
2183 throw 666;
2184 } // endif jsp
2185
2186 } else
2187 jsp = NULL;
2188
2189 if (arp) {
2190 if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
2191 arp->SetArrayValue(G, new(G) JVALUE(jsp), Nodes[Nod-2].Rank);
2192 else
2193 arp->AddArrayValue(G, new(G) JVALUE(jsp));
2194
2195 arp->InitArray(G);
2196 } else if (objp) {
2197 if (Nod > 1 && Nodes[Nod-2].Key)
2198 objp->SetKeyValue(G, new(G) JVALUE(jsp), Nodes[Nod-2].Key);
2199
2200 } else if (jvp)

Callers

nothing calls this directly

Calls 12

safe_strcpyFunction · 0.85
ParseJsonFunction · 0.85
SetValue_pvalMethod · 0.80
InitArrayMethod · 0.80
GetRowFunction · 0.70
IsNullMethod · 0.45
GetTypeMethod · 0.45
GetCharValueMethod · 0.45
SetArrayValueMethod · 0.45
AddArrayValueMethod · 0.45
SetKeyValueMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected