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

Method SetArrayOptions

storage/connect/bsonudf.cpp:195–280  ·  view source on GitHub ↗

/ Analyse array processing options. */ /

Source from the content-addressed store, hash-verified

193/* Analyse array processing options. */
194/*********************************************************************************/
195my_bool BJNX::SetArrayOptions(PGLOBAL g, char* p, int i)
196{
197 int n = (int)strlen(p);
198 my_bool dg = true, b = false;
199 PJNODE jnp = &Nodes[i];
200
201 if (*p) {
202 if (p[n - 1] == ']') {
203 p[--n] = 0;
204 } else if (!IsNum(p)) {
205 // Wrong array specification
206 snprintf(g->Message, sizeof(g->Message), "Invalid array specification %s", p);
207 return true;
208 } // endif p
209
210 } else
211 b = true;
212
213 // To check whether a numeric Rank was specified
214 dg = IsNum(p);
215
216 if (!n) {
217 // Default specifications
218 if (jnp->Op != OP_EXP) {
219 if (Wr) {
220 // Force append
221 jnp->Rank = INT_MAX32;
222 jnp->Op = OP_LE;
223 } else if (Jb) {
224 // Return a Json item
225 jnp->Op = OP_XX;
226 } else if (b) {
227 // Return 1st value (B is the index base)
228 jnp->Rank = B;
229 jnp->Op = OP_LE;
230 } else if (!Value->IsTypeNum()) {
231 jnp->CncVal = AllocateValue(g, PlugDup(g, ", "), TYPE_STRING);
232 jnp->Op = OP_CNC;
233 } else
234 jnp->Op = OP_ADD;
235
236 } // endif OP
237
238 } else if (dg) {
239 // Return nth value
240 jnp->Rank = atoi(p) - B;
241 jnp->Op = OP_EQ;
242 } else if (Wr) {
243 snprintf(g->Message, sizeof(g->Message), "Invalid specification %s in a write path", p);
244 return true;
245 } else if (n == 1) {
246 // Set the Op value;
247 switch (*p) {
248 case '+': jnp->Op = OP_ADD; break;
249 case 'x': jnp->Op = OP_MULT; break;
250 case '>': jnp->Op = OP_MAX; break;
251 case '<': jnp->Op = OP_MIN; break;
252 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