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

Method MakeCursor

storage/connect/jmgoconn.cpp:236–407  ·  view source on GitHub ↗

/ OpenDB: Data Base open routine for MONGO access method. */ /

Source from the content-addressed store, hash-verified

234/* OpenDB: Data Base open routine for MONGO access method. */
235/***********************************************************************/
236bool JMgoConn::MakeCursor(PGLOBAL g, PTDB tdbp, PCSZ options,
237 PCSZ filter, bool pipe)
238{
239 const char *p;
240 bool id, b = false, all = false;
241 uint len;
242 PCOL cp;
243 PSZ jp;
244 PCSZ op = NULL, sf = NULL, Options = options;
245 PSTRG s = NULL;
246 PFIL filp = tdbp->GetFilter();
247
248 if (Options && !stricmp(Options, "all")) {
249 Options = NULL;
250 all = true;
251 } else
252 id = (tdbp->GetMode() == MODE_UPDATE || tdbp->GetMode() == MODE_DELETE);
253
254 for (cp = tdbp->GetColumns(); cp && !all; cp = cp->GetNext())
255 if (cp->GetFmt() && !strcmp(cp->GetFmt(), "*") && (!Options || pipe))
256 all = true;
257 else if (!id)
258 id = !strcmp(cp->GetJpath(g, false), "_id");
259
260 if (pipe && Options) {
261 if (trace(1))
262 htrc("Pipeline: %s\n", Options);
263
264 p = strrchr(Options, ']');
265
266 if (!p) {
267 snprintf(g->Message, sizeof(g->Message), "Missing ] in pipeline");
268 return true;
269 } else
270 *(char*)p = 0;
271
272 s = new(g) STRING(g, 1023, (PSZ)Options);
273
274 if (filp) {
275 s->Append(",{\"$match\":");
276
277 if (MakeSelector(g, filp, s)) {
278 snprintf(g->Message, sizeof(g->Message), "Failed making selector");
279 return true;
280 } else
281 s->Append('}');
282
283 tdbp->SetFilter(NULL); // Not needed anymore
284 } // endif To_Filter
285
286 if (!all && tdbp->GetColumns()) {
287 // Project list
288 len = s->GetLength();
289 s->Append(",{\"$project\":{\"");
290
291 if (!id)
292 s->Append("_id\":0,\"");
293

Callers

nothing calls this directly

Calls 12

MakeSelectorFunction · 0.85
PlugDupFunction · 0.85
AppendMethod · 0.80
ResizeMethod · 0.80
SetMethod · 0.80
htrcFunction · 0.70
GetColumnsMethod · 0.45
GetNextMethod · 0.45
GetJpathMethod · 0.45
GetLengthMethod · 0.45
PrintsMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected