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

Method SetArrayOptions

storage/connect/tabjson.cpp:1372–1498  ·  view source on GitHub ↗

/ Analyse array processing options. */ /

Source from the content-addressed store, hash-verified

1370/* Analyse array processing options. */
1371/***********************************************************************/
1372bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm)
1373{
1374 int n;
1375 bool dg = true, b = false;
1376 PJNODE jnp = &Nodes[i];
1377
1378 //if (*p == '[') p++; // Old syntax .[ or :[
1379 n = (int)strlen(p);
1380
1381 if (*p) {
1382 if (p[n - 1] == ']') {
1383 p[--n] = 0;
1384 } else if (!IsNum(p)) {
1385 // Wrong array specification
1386 snprintf(g->Message, sizeof(g->Message), "Invalid array specification %s for %s", p, Name);
1387 return true;
1388 } // endif p
1389
1390 } else
1391 b = true;
1392
1393 // To check whether a numeric Rank was specified
1394 dg = IsNum(p);
1395
1396 if (!n) {
1397 // Default specifications
1398 if (CheckExpand(g, i, nm, false))
1399 return true;
1400 else if (jnp->Op != OP_EXP) {
1401 if (b) {
1402 // Return 1st value (B is the index base)
1403 jnp->Rank = Tjp->B;
1404 jnp->Op = OP_EQ;
1405 } else if (!Value->IsTypeNum()) {
1406 jnp->CncVal = AllocateValue(g, (void*)", ", TYPE_STRING);
1407 jnp->Op = OP_CNC;
1408 } else
1409 jnp->Op = OP_ADD;
1410
1411 } // endif OP
1412
1413 } else if (dg) {
1414 // Return nth value
1415 jnp->Rank = atoi(p) - Tjp->B;
1416 jnp->Op = OP_EQ;
1417 } else if (n == 1) {
1418 // Set the Op value;
1419 if (Sep == ':')
1420 switch (*p) {
1421 case '*': *p = 'x'; break;
1422 case 'x':
1423 case 'X': *p = '*'; break; // Expand this array
1424 default: break;
1425 } // endswitch p
1426
1427 switch (*p) {
1428 case '+': jnp->Op = OP_ADD; break;
1429 case 'x': jnp->Op = OP_MULT; break;

Callers

nothing calls this directly

Calls 5

IsNumFunction · 0.85
AllocateValueFunction · 0.85
atoiFunction · 0.85
IsTypeCharFunction · 0.85
GetPrecisionFunction · 0.70

Tested by

no test coverage detected