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

Method SetArrayOptions

storage/connect/jsonudf.cpp:119–206  ·  view source on GitHub ↗

/ Analyse array processing options. */ /

Source from the content-addressed store, hash-verified

117/* Analyse array processing options. */
118/*********************************************************************************/
119my_bool JSNX::SetArrayOptions(PGLOBAL g, char *p, int i)
120{
121 int n = (int)strlen(p);
122 my_bool dg = true, b = false;
123 PJNODE jnp = &Nodes[i];
124
125 if (*p) {
126 if (p[n - 1] == ']') {
127 p[--n] = 0;
128 } else if (!IsNum(p)) {
129 // Wrong array specification
130 snprintf(g->Message, sizeof(g->Message), "Invalid array specification %s", p);
131 return true;
132 } // endif p
133
134 } else
135 b = true;
136
137 // To check whether a numeric Rank was specified
138 dg = IsNum(p);
139
140 if (!n) {
141 // Default specifications
142 if (jnp->Op != OP_EXP) {
143 if (Wr) {
144 // Force append
145 jnp->Rank = INT_MAX32;
146 jnp->Op = OP_LE;
147 } else if (Jb) {
148 // Return a Json item
149 jnp->Op = OP_XX;
150 } else if (b) {
151 // Return 1st value (B is the index base)
152 jnp->Rank = B;
153 jnp->Op = OP_LE;
154 } else if (!Value->IsTypeNum()) {
155 jnp->CncVal = AllocateValue(g, PlugDup(g, ", "), TYPE_STRING);
156 jnp->Op = OP_CNC;
157 } else
158 jnp->Op = OP_ADD;
159
160 } // endif OP
161
162 } else if (dg) {
163 // Return nth value
164 jnp->Rank = atoi(p) - B;
165 jnp->Op = OP_EQ;
166 } else if (Wr) {
167 snprintf(g->Message, sizeof(g->Message), "Invalid specification %s in a write path", p);
168 return true;
169 } else if (n == 1) {
170 // Set the Op value;
171 switch (*p) {
172 case '+': jnp->Op = OP_ADD; break;
173 case 'x': jnp->Op = OP_MULT; break;
174 case '>': jnp->Op = OP_MAX; break;
175 case '<': jnp->Op = OP_MIN; break;
176 case '!': jnp->Op = OP_SEP; break; // Average

Callers

nothing calls this directly

Calls 5

IsNumFunction · 0.85
AllocateValueFunction · 0.85
PlugDupFunction · 0.85
atoiFunction · 0.85
htrcFunction · 0.70

Tested by

no test coverage detected