/************** mongo C++ Program Source Code File (.CPP) **************/ /* PROGRAM NAME: mongo Version 1.1 */ /* (C) Copyright to the author Olivier BERTRAND 2021 */ /* These programs are the MGODEF class execution routines. */ /***********************************************************************/
/***********************************************************************/ /* Include relevant sections of the MariaDB header file. */ /***********************************************************************/ #include <my_global.h>
/***********************************************************************/ /* Include application header files: */ /* global.h is header containing all global declarations. */ /* plgdbsem.h is header containing the DB application declarations. */ /***********************************************************************/ #include"global.h" #include"plgdbsem.h" #include"xtable.h" #include"tabext.h" #include"filter.h" #ifdefined(CMGO_SUPPORT) #include"tabcmg.h" #endif// CMGO_SUPPORT #ifdefined(JAVA_SUPPORT) #include"tabjmg.h" #endif// JAVA_SUPPORT #include"resource.h"
/***********************************************************************/ /* This should be an option. */ /***********************************************************************/ #define MAXCOL 200/* Default max column nb in result */ #define TYPE_UNKNOWN 12/* Must be greater than other types */
switch (opc) { case OP_EQ:
s->Append("eq"); break; case OP_NE:
s->Append("ne"); break; case OP_GT:
s->Append("gt"); break; case OP_GE:
s->Append("gte"); break; case OP_LT:
s->Append("lt"); break; case OP_LE:
s->Append("lte"); break; case OP_NULL: case OP_LIKE: case OP_EXIST: default: returntrue;
} // endswitch Opc
skipit: if (trace(1))
htrc("MGOColumns: n=%d len=%d\n", n, length[0]);
/*********************************************************************/ /* Allocate the structures used to refer to the result set. */ /*********************************************************************/
qrp = PlgAllocResult(g, ncol, n, IDS_COLUMNS + 3,
buftyp, fldtyp, length, false, false);
/*********************************************************************/ /* Now get the results into blocks. */ /*********************************************************************/ for (i = 0, bcp = cmgd->fbcp; bcp; i++, bcp = bcp->Next) { if (bcp->Type == TYPE_UNKNOWN) // Void column
bcp->Type = TYPE_STRING;
crp = qrp->Colresp; // Column Name
crp->Kdata->SetValue(bcp->Name, i);
crp = crp->Next; // Data Type
crp->Kdata->SetValue(bcp->Type, i);
crp = crp->Next; // Type Name
crp->Kdata->SetValue(GetTypeName(bcp->Type), i);
crp = crp->Next; // Precision
crp->Kdata->SetValue(bcp->Len, i);
crp = crp->Next; // Length
crp->Kdata->SetValue(bcp->Len, i);
crp = crp->Next; // Scale (precision)
crp->Kdata->SetValue(bcp->Scale, i);
crp = crp->Next; // Nullable
crp->Kdata->SetValue(bcp->Cbn ? 1 : 0, i);
crp = crp->Next; // Field format
if (crp->Kdata)
crp->Kdata->SetValue(bcp->Fmt, i);
} // endfor i
/*********************************************************************/ /* Return the result pointer. */ /*********************************************************************/ return qrp;
err: if (cmgd && cmgd->tmgp)
cmgd->tmgp->CloseDB(g);
return NULL;
} // end of MGOColumns
/***********************************************************************/ /* Class used to get the columns of a mongo collection. */ /***********************************************************************/
MGODISC::MGODISC(PGLOBAL g, int *lg) {
length = lg;
fbcp = NULL;
pbcp = NULL;
tmgp = NULL;
drv = NULL;
i = ncol = lvl = 0;
all = false;
} // end of MGODISC constructor
/***********************************************************************/ /* Class used to get the columns of a mongo collection. */ /***********************************************************************/ int MGODISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt)
{
PMGODEF tdp;
/*********************************************************************/ /* Analyse the BSON tree and define columns. */ /*********************************************************************/ for (i = 1; ; i++) { switch (tmgp->ReadDB(g)) { case RC_EF: return ncol; case RC_FX: return -1; default:
GetDoc();
} // endswitch ReadDB
if (Find(g)) return -1;
// Missing columns can be null for (bcp = fbcp; bcp; bcp = bcp->Next) {
bcp->Cbn |= !bcp->Found;
bcp->Found = false;
} // endfor bcp
} // endfor i
return ncol;
} // end of GetColumns
/***********************************************************************/ /* Add a new column in the column list. */ /***********************************************************************/ void MGODISC::AddColumn(PGLOBAL g, PCSZ colname, PCSZ fmt, int k)
{ // Check whether this column was already found for (bcp = fbcp; bcp; bcp = bcp->Next) if (!strcmp(colname, bcp->Name)) break;
if (bcp) { if (bcp->Type != bcol.Type)
bcp->Type = TYPE_STRING;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.