mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Re-fix compile error (overloaded-virtual)
This commit is contained in:
parent
e4294729d4
commit
fb86a496c0
4 changed files with 112 additions and 128 deletions
|
@ -531,7 +531,7 @@ PJAR JDOC::ParseArray(PGLOBAL g, int& i)
|
|||
sprintf(g->Message, "Unexpected value near %.*s", ARGS);
|
||||
throw 1;
|
||||
} else
|
||||
jarp->AddValue(g, ParseValue(g, i));
|
||||
jarp->AddArrayValue(g, ParseValue(g, i));
|
||||
|
||||
level = (b) ? 1 : 2;
|
||||
break;
|
||||
|
@ -886,7 +886,7 @@ bool JDOC::SerializeArray(PJAR jarp, bool b)
|
|||
|
||||
} // endif b
|
||||
|
||||
if (SerializeValue(jarp->GetValue(i)))
|
||||
if (SerializeValue(jarp->GetArrayValue(i)))
|
||||
return true;
|
||||
|
||||
} // endfor i
|
||||
|
@ -1010,7 +1010,7 @@ PJAR JOBJECT::GetKeyList(PGLOBAL g)
|
|||
PJAR jarp = new(g) JARRAY();
|
||||
|
||||
for (PJPR jpp = First; jpp; jpp = jpp->Next)
|
||||
jarp->AddValue(g, new(g) JVALUE(g, jpp->Key));
|
||||
jarp->AddArrayValue(g, new(g) JVALUE(g, jpp->Key));
|
||||
|
||||
jarp->InitArray(g);
|
||||
return jarp;
|
||||
|
@ -1024,7 +1024,7 @@ PJAR JOBJECT::GetValList(PGLOBAL g)
|
|||
PJAR jarp = new(g) JARRAY();
|
||||
|
||||
for (PJPR jpp = First; jpp; jpp = jpp->Next)
|
||||
jarp->AddValue(g, jpp->Val);
|
||||
jarp->AddArrayValue(g, jpp->Val);
|
||||
|
||||
jarp->InitArray(g);
|
||||
return jarp;
|
||||
|
@ -1033,7 +1033,7 @@ PJAR JOBJECT::GetValList(PGLOBAL g)
|
|||
/***********************************************************************/
|
||||
/* Get the value corresponding to the given key. */
|
||||
/***********************************************************************/
|
||||
PJVAL JOBJECT::GetValue(const char* key)
|
||||
PJVAL JOBJECT::GetKeyValue(const char* key)
|
||||
{
|
||||
for (PJPR jp = First; jp; jp = jp->Next)
|
||||
if (!strcmp(jp->Key, key))
|
||||
|
@ -1111,7 +1111,7 @@ bool JOBJECT::Merge(PGLOBAL g, PJSON jsp)
|
|||
PJOB jobp = (PJOB)jsp;
|
||||
|
||||
for (PJPR jpp = jobp->First; jpp; jpp = jpp->Next)
|
||||
SetValue(g, jpp->Val, jpp->Key);
|
||||
SetKeyValue(g, jpp->Val, jpp->Key);
|
||||
|
||||
return false;
|
||||
} // end of Marge;
|
||||
|
@ -1119,7 +1119,7 @@ bool JOBJECT::Merge(PGLOBAL g, PJSON jsp)
|
|||
/***********************************************************************/
|
||||
/* Set or add a value corresponding to the given key. */
|
||||
/***********************************************************************/
|
||||
void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PCSZ key)
|
||||
void JOBJECT::SetKeyValue(PGLOBAL g, PJVAL jvp, PCSZ key)
|
||||
{
|
||||
PJPR jp;
|
||||
|
||||
|
@ -1166,6 +1166,18 @@ bool JOBJECT::IsNull(void)
|
|||
|
||||
/* -------------------------- Class JARRAY --------------------------- */
|
||||
|
||||
/***********************************************************************/
|
||||
/* JARRAY constructor. */
|
||||
/***********************************************************************/
|
||||
JARRAY::JARRAY(void) : JSON()
|
||||
{
|
||||
Type = TYPE_JAR;
|
||||
Size = 0;
|
||||
Alloc = 0;
|
||||
First = Last = NULL;
|
||||
Mvals = NULL;
|
||||
} // end of JARRAY constructor
|
||||
|
||||
/***********************************************************************/
|
||||
/* Return the number of values in this object. */
|
||||
/***********************************************************************/
|
||||
|
@ -1216,7 +1228,7 @@ void JARRAY::InitArray(PGLOBAL g)
|
|||
/***********************************************************************/
|
||||
/* Get the Nth value of an Array. */
|
||||
/***********************************************************************/
|
||||
PJVAL JARRAY::GetValue(int i)
|
||||
PJVAL JARRAY::GetArrayValue(int i)
|
||||
{
|
||||
if (Mvals && i >= 0 && i < Size)
|
||||
return Mvals[i];
|
||||
|
@ -1227,7 +1239,7 @@ PJVAL JARRAY::GetValue(int i)
|
|||
/***********************************************************************/
|
||||
/* Add a Value to the Array Value list. */
|
||||
/***********************************************************************/
|
||||
PJVAL JARRAY::AddValue(PGLOBAL g, PJVAL jvp, int *x)
|
||||
PJVAL JARRAY::AddArrayValue(PGLOBAL g, PJVAL jvp, int *x)
|
||||
{
|
||||
if (!jvp)
|
||||
jvp = new(g) JVALUE;
|
||||
|
@ -1271,7 +1283,7 @@ bool JARRAY::Merge(PGLOBAL g, PJSON jsp)
|
|||
PJAR arp = (PJAR)jsp;
|
||||
|
||||
for (int i = 0; i < arp->size(); i++)
|
||||
AddValue(g, arp->GetValue(i));
|
||||
AddArrayValue(g, arp->GetArrayValue(i));
|
||||
|
||||
InitArray(g);
|
||||
return false;
|
||||
|
@ -1280,7 +1292,7 @@ bool JARRAY::Merge(PGLOBAL g, PJSON jsp)
|
|||
/***********************************************************************/
|
||||
/* Set the nth Value of the Array Value list. */
|
||||
/***********************************************************************/
|
||||
bool JARRAY::SetValue(PGLOBAL g, PJVAL jvp, int n)
|
||||
bool JARRAY::SetArrayValue(PGLOBAL g, PJVAL jvp, int n)
|
||||
{
|
||||
int i = 0;
|
||||
PJVAL jp, *jpp = &First;
|
||||
|
@ -1340,7 +1352,7 @@ PSZ JARRAY::GetText(PGLOBAL g, PSTRG text)
|
|||
/***********************************************************************/
|
||||
bool JARRAY::DeleteValue(int n)
|
||||
{
|
||||
PJVAL jvp = GetValue(n);
|
||||
PJVAL jvp = GetArrayValue(n);
|
||||
|
||||
if (jvp) {
|
||||
jvp->Del = true;
|
||||
|
@ -1365,7 +1377,7 @@ bool JARRAY::IsNull(void)
|
|||
/* -------------------------- Class JVALUE- -------------------------- */
|
||||
|
||||
/***********************************************************************/
|
||||
/* Constructor for a JSON. */
|
||||
/* Constructor for a JVALUE. */
|
||||
/***********************************************************************/
|
||||
JVALUE::JVALUE(PJSON jsp) : JSON()
|
||||
{
|
||||
|
@ -1383,7 +1395,7 @@ JVALUE::JVALUE(PJSON jsp) : JSON()
|
|||
} // end of JVALUE constructor
|
||||
|
||||
/***********************************************************************/
|
||||
/* Constructor for a Val with a given string or numeric value. */
|
||||
/* Constructor for a JVALUE with a given string or numeric value. */
|
||||
/***********************************************************************/
|
||||
JVALUE::JVALUE(PGLOBAL g, PVL vlp) : JSON()
|
||||
{
|
||||
|
@ -1395,7 +1407,7 @@ JVALUE::JVALUE(PGLOBAL g, PVL vlp) : JSON()
|
|||
} // end of JVALUE constructor
|
||||
|
||||
/***********************************************************************/
|
||||
/* Constructor for a Value with a given string or numeric value. */
|
||||
/* Constructor for a JVALUE with a given string or numeric value. */
|
||||
/***********************************************************************/
|
||||
JVALUE::JVALUE(PGLOBAL g, PVAL valp) : JSON() {
|
||||
Jsp = NULL;
|
||||
|
|
|
@ -140,36 +140,16 @@ public:
|
|||
|
||||
// Methods
|
||||
virtual int size(void) { return 1; }
|
||||
// virtual JTYP GetValType(void) { X return TYPE_JSON; }
|
||||
// virtual void InitArray(PGLOBAL g) { X }
|
||||
//virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;}
|
||||
// virtual PJPR AddPair(PGLOBAL g, PCSZ key) { X return NULL; }
|
||||
virtual void Clear(void) { X }
|
||||
// virtual PJAR GetKeyList(PGLOBAL g) { X return NULL; }
|
||||
// virtual PJAR GetValList(PGLOBAL g) { X return NULL; }
|
||||
// virtual PJVAL GetValue(const char* key) { X return NULL; }
|
||||
virtual PJOB GetObject(void) { return NULL; }
|
||||
virtual PJAR GetArray(void) { return NULL; }
|
||||
virtual PJVAL GetValue(int i) { X return NULL; }
|
||||
virtual PJVAL GetArrayValue(int i) { X return NULL; }
|
||||
virtual int GetSize(bool b) { X return 0; }
|
||||
//virtual PVL GetVal(void) { X return NULL; }
|
||||
virtual PJSON GetJsp(void) { X return NULL; }
|
||||
// virtual PJSON GetJson(void) { X return NULL; }
|
||||
virtual PJPR GetFirst(void) { X return NULL; }
|
||||
// virtual int GetInteger(void) { X return 0; }
|
||||
// virtual double GetFloat() { X return 0.0; }
|
||||
// virtual PSZ GetString(PGLOBAL g, char *buff = NULL) { X return NULL; }
|
||||
virtual PSZ GetText(PGLOBAL g, PSTRG text) { X return NULL; }
|
||||
virtual bool Merge(PGLOBAL g, PJSON jsp) { X return true; }
|
||||
// virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) { X return true; }
|
||||
// virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key) { X }
|
||||
// virtual void SetVal(PVL vlp) { X }
|
||||
// virtual void SetValue(PGLOBAL g, PVAL valp) { X }
|
||||
virtual void SetValue(PJSON jsp) { X }
|
||||
// virtual void SetString(PGLOBAL g, PSZ s, short c) { X }
|
||||
// virtual void SetInteger(PGLOBAL g, int n) { X }
|
||||
// virtual void SetFloat(PGLOBAL g, double f) { X }
|
||||
// virtual void DeleteKey(PCSZ k) { X }
|
||||
virtual bool DeleteValue(int i) { X return true; }
|
||||
virtual bool IsNull(void) { X return true; }
|
||||
|
||||
|
@ -188,9 +168,6 @@ public:
|
|||
JOBJECT(void) : JSON() { Type = TYPE_JOB; First = Last = NULL; }
|
||||
JOBJECT(int i) : JSON(i) {}
|
||||
|
||||
//using JSON::GetVal;
|
||||
//using JSON::SetVal;
|
||||
|
||||
// Methods
|
||||
virtual void Clear(void) {First = Last = NULL;}
|
||||
//virtual JTYP GetValType(void) {return TYPE_JOB;}
|
||||
|
@ -203,10 +180,10 @@ public:
|
|||
|
||||
// Specific
|
||||
PJPR AddPair(PGLOBAL g, PCSZ key);
|
||||
PJVAL GetValue(const char* key);
|
||||
PJVAL GetKeyValue(const char* key);
|
||||
PJAR GetKeyList(PGLOBAL g);
|
||||
PJAR GetValList(PGLOBAL g);
|
||||
void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key);
|
||||
void SetKeyValue(PGLOBAL g, PJVAL jvp, PCSZ key);
|
||||
void DeleteKey(PCSZ k);
|
||||
|
||||
protected:
|
||||
|
@ -220,28 +197,23 @@ public:
|
|||
class JARRAY : public JSON {
|
||||
friend class SWAP;
|
||||
public:
|
||||
JARRAY(void) : JSON()
|
||||
{ Type = TYPE_JAR; Alloc = 0; First = Last = NULL; Mvals = NULL; }
|
||||
JARRAY(void);
|
||||
JARRAY(int i) : JSON(i) {}
|
||||
|
||||
//using JSON::GetVal;
|
||||
//using JSON::SetVal;
|
||||
|
||||
// Methods
|
||||
virtual void Clear(void) {First = Last = NULL; Size = 0;}
|
||||
virtual int size(void) { return Size; }
|
||||
//virtual JTYP GetType(void) {return TYPE_JAR;}
|
||||
virtual PJAR GetArray(void) {return this;}
|
||||
virtual int GetSize(bool b);
|
||||
virtual PJVAL GetValue(int i);
|
||||
virtual PJVAL GetArrayValue(int i);
|
||||
virtual PSZ GetText(PGLOBAL g, PSTRG text);
|
||||
virtual bool Merge(PGLOBAL g, PJSON jsp);
|
||||
virtual bool DeleteValue(int n);
|
||||
virtual bool IsNull(void);
|
||||
|
||||
// Specific
|
||||
PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int* x = NULL);
|
||||
bool SetValue(PGLOBAL g, PJVAL jvp, int i);
|
||||
PJVAL AddArrayValue(PGLOBAL g, PJVAL jvp = NULL, int* x = NULL);
|
||||
bool SetArrayValue(PGLOBAL g, PJVAL jvp, int i);
|
||||
void InitArray(PGLOBAL g);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -457,7 +457,7 @@ PJVAL JSNX::GetRowValue(PGLOBAL g, PJSON row, int i, my_bool b)
|
|||
} //endif Op
|
||||
|
||||
} else
|
||||
val = ((PJOB)row)->GetValue(Nodes[i].Key);
|
||||
val = ((PJOB)row)->GetKeyValue(Nodes[i].Key);
|
||||
|
||||
break;
|
||||
case TYPE_JAR:
|
||||
|
@ -465,7 +465,7 @@ PJVAL JSNX::GetRowValue(PGLOBAL g, PJSON row, int i, my_bool b)
|
|||
|
||||
if (!Nodes[i].Key) {
|
||||
if (Nodes[i].Op == OP_EQ || Nodes[i].Op == OP_LE)
|
||||
val = arp->GetValue(Nodes[i].Rank);
|
||||
val = arp->GetArrayValue(Nodes[i].Rank);
|
||||
else if (Nodes[i].Op == OP_EXP)
|
||||
return (PJVAL)ExpandArray(g, arp, i);
|
||||
else
|
||||
|
@ -473,7 +473,7 @@ PJVAL JSNX::GetRowValue(PGLOBAL g, PJSON row, int i, my_bool b)
|
|||
|
||||
} else {
|
||||
// Unexpected array, unwrap it as [0]
|
||||
val = arp->GetValue(0);
|
||||
val = arp->GetArrayValue(0);
|
||||
i--;
|
||||
} // endif's
|
||||
|
||||
|
@ -524,7 +524,7 @@ PVAL JSNX::CalculateArray(PGLOBAL g, PJAR arp, int n)
|
|||
htrc("CalculateArray size=%d op=%d\n", ars, op);
|
||||
|
||||
for (i = 0; i < ars; i++) {
|
||||
jvrp = arp->GetValue(i);
|
||||
jvrp = arp->GetArrayValue(i);
|
||||
|
||||
if (trace(1))
|
||||
htrc("i=%d nv=%d\n", i, nv);
|
||||
|
@ -617,13 +617,13 @@ my_bool JSNX::CheckPath(PGLOBAL g)
|
|||
} else switch (row->GetType()) {
|
||||
case TYPE_JOB:
|
||||
if (Nodes[i].Key)
|
||||
val = ((PJOB)row)->GetValue(Nodes[i].Key);
|
||||
val = ((PJOB)row)->GetKeyValue(Nodes[i].Key);
|
||||
|
||||
break;
|
||||
case TYPE_JAR:
|
||||
if (!Nodes[i].Key)
|
||||
if (Nodes[i].Op == OP_EQ || Nodes[i].Op == OP_LE)
|
||||
val = ((PJAR)row)->GetValue(Nodes[i].Rank);
|
||||
val = ((PJAR)row)->GetArrayValue(Nodes[i].Rank);
|
||||
|
||||
break;
|
||||
case TYPE_JVAL:
|
||||
|
@ -660,20 +660,20 @@ PJSON JSNX::GetRow(PGLOBAL g)
|
|||
// Expected Array was not there, wrap the value
|
||||
continue;
|
||||
|
||||
val = ((PJOB)row)->GetValue(Nodes[i].Key);
|
||||
val = ((PJOB)row)->GetKeyValue(Nodes[i].Key);
|
||||
break;
|
||||
case TYPE_JAR:
|
||||
arp = (PJAR)row;
|
||||
|
||||
if (!Nodes[i].Key) {
|
||||
if (Nodes[i].Op == OP_EQ)
|
||||
val = arp->GetValue(Nodes[i].Rank);
|
||||
val = arp->GetArrayValue(Nodes[i].Rank);
|
||||
else
|
||||
val = arp->GetValue(Nodes[i].Rx);
|
||||
val = arp->GetArrayValue(Nodes[i].Rx);
|
||||
|
||||
} else {
|
||||
// Unexpected array, unwrap it as [0]
|
||||
val = arp->GetValue(0);
|
||||
val = arp->GetArrayValue(0);
|
||||
i--;
|
||||
} // endif Nodes
|
||||
|
||||
|
@ -700,9 +700,9 @@ PJSON JSNX::GetRow(PGLOBAL g)
|
|||
nwr = new(g)JOBJECT;
|
||||
|
||||
if (row->GetType() == TYPE_JOB) {
|
||||
((PJOB)row)->SetValue(g, new(g)JVALUE(nwr), Nodes[i-1].Key);
|
||||
((PJOB)row)->SetKeyValue(g, new(g)JVALUE(nwr), Nodes[i-1].Key);
|
||||
} else if (row->GetType() == TYPE_JAR) {
|
||||
((PJAR)row)->AddValue(g, new(g)JVALUE(nwr));
|
||||
((PJAR)row)->AddArrayValue(g, new(g)JVALUE(nwr));
|
||||
((PJAR)row)->InitArray(g);
|
||||
} else {
|
||||
strcpy(g->Message, "Wrong type when writing new row");
|
||||
|
@ -745,16 +745,16 @@ my_bool JSNX::WriteValue(PGLOBAL g, PJVAL jvalp)
|
|||
if (arp) {
|
||||
if (!Nodes[Nod-1].Key) {
|
||||
if (Nodes[Nod-1].Op == OP_EQ)
|
||||
arp->SetValue(g, jvalp, Nodes[Nod-1].Rank);
|
||||
arp->SetArrayValue(g, jvalp, Nodes[Nod-1].Rank);
|
||||
else
|
||||
arp->AddValue(g, jvalp);
|
||||
arp->AddArrayValue(g, jvalp);
|
||||
|
||||
arp->InitArray(g);
|
||||
} // endif Key
|
||||
|
||||
} else if (objp) {
|
||||
if (Nodes[Nod-1].Key)
|
||||
objp->SetValue(g, jvalp, Nodes[Nod-1].Key);
|
||||
objp->SetKeyValue(g, jvalp, Nodes[Nod-1].Key);
|
||||
|
||||
} else if (jvp)
|
||||
jvp->SetValue(jvalp);
|
||||
|
@ -835,7 +835,7 @@ my_bool JSNX::LocateArray(PGLOBAL g, PJAR jarp)
|
|||
if (Jp->WriteStr(s))
|
||||
return true;
|
||||
|
||||
if (LocateValue(g, jarp->GetValue(i)))
|
||||
if (LocateValue(g, jarp->GetArrayValue(i)))
|
||||
return true;
|
||||
|
||||
} // endfor i
|
||||
|
@ -958,7 +958,7 @@ my_bool JSNX::LocateArrayAll(PGLOBAL g, PJAR jarp)
|
|||
for (int i = 0; i < jarp->size(); i++) {
|
||||
Jpnp[I].N = i;
|
||||
|
||||
if (LocateValueAll(g, jarp->GetValue(i)))
|
||||
if (LocateValueAll(g, jarp->GetArrayValue(i)))
|
||||
return true;
|
||||
|
||||
} // endfor i
|
||||
|
@ -1027,7 +1027,7 @@ my_bool JSNX::CompareTree(PGLOBAL g, PJSON jp1, PJSON jp2)
|
|||
|
||||
} else if (jp1->GetType() == TYPE_JAR) {
|
||||
for (int i = 0; found && i < jp1->size(); i++)
|
||||
found = (CompareTree(g, jp1->GetValue(i), jp2->GetValue(i)));
|
||||
found = (CompareTree(g, jp1->GetArrayValue(i), jp2->GetArrayValue(i)));
|
||||
|
||||
} else if (jp1->GetType() == TYPE_JOB) {
|
||||
PJPR p1 = jp1->GetFirst(), p2 = jp2->GetFirst();
|
||||
|
@ -2018,7 +2018,7 @@ char *json_make_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
PJAR arp = new(g)JARRAY;
|
||||
|
||||
for (uint i = 0; i < args->arg_count; i++)
|
||||
arp->AddValue(g, MakeValue(g, args, i));
|
||||
arp->AddArrayValue(g, MakeValue(g, args, i));
|
||||
|
||||
arp->InitArray(g);
|
||||
|
||||
|
@ -2088,13 +2088,13 @@ char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
|
||||
if (jvp->GetValType() != TYPE_JAR) {
|
||||
arp = new(g)JARRAY;
|
||||
arp->AddValue(g, jvp);
|
||||
arp->AddArrayValue(g, jvp);
|
||||
top = arp;
|
||||
} else
|
||||
arp = jvp->GetArray();
|
||||
|
||||
for (uint i = 1; i < args->arg_count; i++)
|
||||
arp->AddValue(g, MakeValue(g, args, i));
|
||||
arp->AddArrayValue(g, MakeValue(g, args, i));
|
||||
|
||||
arp->InitArray(g);
|
||||
str = MakeResult(g, args, top, args->arg_count);
|
||||
|
@ -2186,7 +2186,7 @@ char *json_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
|
||||
if (jvp->GetValType() != TYPE_JAR) {
|
||||
if ((arp = (PJAR)JsonNew(gb, TYPE_JAR))) {
|
||||
arp->AddValue(gb, JvalNew(gb, TYPE_JVAL, jvp));
|
||||
arp->AddArrayValue(gb, JvalNew(gb, TYPE_JVAL, jvp));
|
||||
jvp->SetValue(arp);
|
||||
|
||||
if (!top)
|
||||
|
@ -2198,7 +2198,7 @@ char *json_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
arp = jvp->GetArray();
|
||||
|
||||
if (arp) {
|
||||
arp->AddValue(gb, MakeValue(gb, args, 1), x);
|
||||
arp->AddArrayValue(gb, MakeValue(gb, args, 1), x);
|
||||
arp->InitArray(gb);
|
||||
str = MakeResult(g, args, top, n);
|
||||
} else
|
||||
|
@ -2367,7 +2367,7 @@ long long jsonsum_int(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *err
|
|||
PJAR arp = jvp->GetArray();
|
||||
|
||||
for (int i = 0; i < arp->size(); i++)
|
||||
n += arp->GetValue(i)->GetBigint();
|
||||
n += arp->GetArrayValue(i)->GetBigint();
|
||||
|
||||
} else {
|
||||
PUSH_WARNING("First argument target is not an array");
|
||||
|
@ -2442,7 +2442,7 @@ double jsonsum_real(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error
|
|||
PJAR arp = jvp->GetArray();
|
||||
|
||||
for (int i = 0; i < arp->size(); i++)
|
||||
n += arp->GetValue(i)->GetFloat();
|
||||
n += arp->GetArrayValue(i)->GetFloat();
|
||||
|
||||
} else {
|
||||
PUSH_WARNING("First argument target is not an array");
|
||||
|
@ -2507,7 +2507,7 @@ double jsonavg_real(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error
|
|||
|
||||
if (arp->size()) {
|
||||
for (int i = 0; i < arp->size(); i++)
|
||||
n += arp->GetValue(i)->GetFloat();
|
||||
n += arp->GetArrayValue(i)->GetFloat();
|
||||
|
||||
n /= arp->size();
|
||||
} // endif size
|
||||
|
@ -2566,7 +2566,7 @@ char *json_make_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
|
||||
if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
|
||||
for (uint i = 0; i < args->arg_count; i++)
|
||||
objp->SetValue(g, MakeValue(g, args, i), MakeKey(g, args, i));
|
||||
objp->SetKeyValue(g, MakeValue(g, args, i), MakeKey(g, args, i));
|
||||
|
||||
str = Serialize(g, objp, NULL, 0);
|
||||
} // endif objp
|
||||
|
@ -2616,7 +2616,7 @@ char *json_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
|
||||
for (uint i = 0; i < args->arg_count; i++)
|
||||
if (!(jvp = MakeValue(g, args, i))->IsNull())
|
||||
objp->SetValue(g, jvp, MakeKey(g, args, i));
|
||||
objp->SetKeyValue(g, jvp, MakeKey(g, args, i));
|
||||
|
||||
str = Serialize(g, objp, NULL, 0);
|
||||
} // endif objp
|
||||
|
@ -2668,7 +2668,7 @@ char *json_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
|
||||
if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
|
||||
for (uint i = 0; i < args->arg_count; i += 2)
|
||||
objp->SetValue(g, MakeValue(g, args, i + 1), MakePSZ(g, args, i));
|
||||
objp->SetKeyValue(g, MakeValue(g, args, i + 1), MakePSZ(g, args, i));
|
||||
|
||||
str = Serialize(g, objp, NULL, 0);
|
||||
} // endif objp
|
||||
|
@ -2752,7 +2752,7 @@ char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
jobp = jvp->GetObject();
|
||||
jvp = MakeValue(gb, args, 1);
|
||||
key = MakeKey(gb, args, 1);
|
||||
jobp->SetValue(gb, jvp, key);
|
||||
jobp->SetKeyValue(gb, jvp, key);
|
||||
str = MakeResult(g, args, top);
|
||||
} else {
|
||||
PUSH_WARNING("First argument target is not an object");
|
||||
|
@ -3105,7 +3105,7 @@ void json_array_grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
|
|||
PJAR arp = (PJAR)g->Activityp;
|
||||
|
||||
if (arp && g->N-- > 0)
|
||||
arp->AddValue(g, MakeValue(g, args, 0));
|
||||
arp->AddArrayValue(g, MakeValue(g, args, 0));
|
||||
|
||||
} // end of json_array_grp_add
|
||||
|
||||
|
@ -3182,7 +3182,7 @@ void json_object_grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
|
|||
PJOB objp = (PJOB)g->Activityp;
|
||||
|
||||
if (g->N-- > 0)
|
||||
objp->SetValue(g, MakeValue(g, args, 1), MakePSZ(g, args, 0));
|
||||
objp->SetKeyValue(g, MakeValue(g, args, 1), MakePSZ(g, args, 0));
|
||||
|
||||
} // end of json_object_grp_add
|
||||
|
||||
|
@ -4664,7 +4664,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
strcat(bsp->Msg, " array");
|
||||
|
||||
for (uint i = 0; i < args->arg_count; i++)
|
||||
arp->AddValue(g, MakeValue(g, args, i));
|
||||
arp->AddArrayValue(g, MakeValue(g, args, i));
|
||||
|
||||
arp->InitArray(g);
|
||||
} // endif arp && bsp
|
||||
|
@ -4725,7 +4725,7 @@ char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
|
||||
if (jvp->GetValType() != TYPE_JAR) {
|
||||
if ((arp = (PJAR)JsonNew(gb, TYPE_JAR))) {
|
||||
arp->AddValue(gb, jvp);
|
||||
arp->AddArrayValue(gb, jvp);
|
||||
top = arp;
|
||||
} // endif arp
|
||||
|
||||
|
@ -4733,7 +4733,7 @@ char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
arp = jvp->GetArray();
|
||||
|
||||
for (uint i = 1; i < args->arg_count; i++)
|
||||
arp->AddValue(gb, MakeValue(gb, args, i));
|
||||
arp->AddArrayValue(gb, MakeValue(gb, args, i));
|
||||
|
||||
arp->InitArray(gb);
|
||||
|
||||
|
@ -4816,7 +4816,7 @@ char *jbin_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
|
||||
if (jvp->GetValType() != TYPE_JAR) {
|
||||
if ((arp = (PJAR)JsonNew(gb, TYPE_JAR))) {
|
||||
arp->AddValue(gb, (PJVAL)JvalNew(gb, TYPE_JVAL, jvp));
|
||||
arp->AddArrayValue(gb, (PJVAL)JvalNew(gb, TYPE_JVAL, jvp));
|
||||
jvp->SetValue(arp);
|
||||
|
||||
if (!top)
|
||||
|
@ -4827,7 +4827,7 @@ char *jbin_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
} else
|
||||
arp = jvp->GetArray();
|
||||
|
||||
arp->AddValue(gb, MakeValue(gb, args, 1), x);
|
||||
arp->AddArrayValue(gb, MakeValue(gb, args, 1), x);
|
||||
arp->InitArray(gb);
|
||||
} else {
|
||||
PUSH_WARNING("First argument target is not an array");
|
||||
|
@ -4955,7 +4955,7 @@ char *jbin_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
|
||||
if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
|
||||
for (uint i = 0; i < args->arg_count; i++)
|
||||
objp->SetValue(g, MakeValue(g, args, i), MakeKey(g, args, i));
|
||||
objp->SetKeyValue(g, MakeValue(g, args, i), MakeKey(g, args, i));
|
||||
|
||||
|
||||
if ((bsp = JbinAlloc(g, args, initid->max_length, objp)))
|
||||
|
@ -5012,7 +5012,7 @@ char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
|
||||
for (uint i = 0; i < args->arg_count; i++)
|
||||
if (!(jvp = MakeValue(g, args, i))->IsNull())
|
||||
objp->SetValue(g, jvp, MakeKey(g, args, i));
|
||||
objp->SetKeyValue(g, jvp, MakeKey(g, args, i));
|
||||
|
||||
if ((bsp = JbinAlloc(g, args, initid->max_length, objp)))
|
||||
strcat(bsp->Msg, " object");
|
||||
|
@ -5071,7 +5071,7 @@ char *jbin_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
|
||||
if ((objp = (PJOB)JsonNew(g, TYPE_JOB))) {
|
||||
for (uint i = 0; i < args->arg_count; i += 2)
|
||||
objp->SetValue(g, MakeValue(g, args, i + 1), MakePSZ(g, args, i));
|
||||
objp->SetKeyValue(g, MakeValue(g, args, i + 1), MakePSZ(g, args, i));
|
||||
|
||||
if ((bsp = JbinAlloc(g, args, initid->max_length, objp)))
|
||||
strcat(bsp->Msg, " object");
|
||||
|
@ -5149,7 +5149,7 @@ char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
|||
jobp = jvp->GetObject();
|
||||
jvp = MakeValue(gb, args, 1);
|
||||
key = MakeKey(gb, args, 1);
|
||||
jobp->SetValue(gb, jvp, key);
|
||||
jobp->SetKeyValue(gb, jvp, key);
|
||||
} else {
|
||||
PUSH_WARNING("First argument target is not an object");
|
||||
// if (g->Mrr) *error = 1; (only if no path)
|
||||
|
|
|
@ -240,7 +240,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||
if (tjsp->MakeDocument(g))
|
||||
return 0;
|
||||
|
||||
jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL;
|
||||
jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetArrayValue(0) : NULL;
|
||||
} else {
|
||||
if (!((tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))) {
|
||||
if (!mgo) {
|
||||
|
@ -365,7 +365,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
|
|||
} // endswitch ReadDB
|
||||
|
||||
} else
|
||||
jsp = tjsp->GetDoc()->GetValue(i);
|
||||
jsp = tjsp->GetDoc()->GetArrayValue(i);
|
||||
|
||||
if (!(row = (jsp) ? jsp->GetObject() : NULL))
|
||||
break;
|
||||
|
@ -483,7 +483,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
|
|||
strncat(fmt, (tdp->Uri ? sep : "[*]"), n);
|
||||
}
|
||||
|
||||
if (Find(g, jar->GetValue(k), "", j))
|
||||
if (Find(g, jar->GetArrayValue(k), "", j))
|
||||
return true;
|
||||
|
||||
*p = *pc = 0;
|
||||
|
@ -922,7 +922,7 @@ PJSON TDBJSN::FindRow(PGLOBAL g)
|
|||
|
||||
if (*objpath != '[' && !IsNum(objpath)) { // objpass is a key
|
||||
val = (jsp->GetType() == TYPE_JOB) ?
|
||||
jsp->GetObject()->GetValue(objpath) : NULL;
|
||||
jsp->GetObject()->GetKeyValue(objpath) : NULL;
|
||||
} else {
|
||||
if (*objpath == '[') {
|
||||
if (objpath[strlen(objpath) - 1] == ']')
|
||||
|
@ -932,7 +932,7 @@ PJSON TDBJSN::FindRow(PGLOBAL g)
|
|||
} // endif [
|
||||
|
||||
val = (jsp->GetType() == TYPE_JAR) ?
|
||||
jsp->GetArray()->GetValue(atoi(objpath) - B) : NULL;
|
||||
jsp->GetArray()->GetArrayValue(atoi(objpath) - B) : NULL;
|
||||
} // endif objpath
|
||||
|
||||
jsp = (val) ? val->GetJson() : NULL;
|
||||
|
@ -1128,7 +1128,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
|||
val->SetValue(objp);
|
||||
|
||||
val = new(g) JVALUE;
|
||||
objp->SetValue(g, val, objpath);
|
||||
objp->SetKeyValue(g, val, objpath);
|
||||
} else {
|
||||
if (*objpath == '[') {
|
||||
// Old style
|
||||
|
@ -1150,7 +1150,7 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp)
|
|||
|
||||
val = new(g) JVALUE;
|
||||
i = atoi(objpath) - B;
|
||||
arp->SetValue(g, val, i);
|
||||
arp->SetArrayValue(g, val, i);
|
||||
arp->InitArray(g);
|
||||
} // endif objpath
|
||||
|
||||
|
@ -1703,7 +1703,7 @@ PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i)
|
|||
val = new(G) JVALUE(row);
|
||||
|
||||
} else
|
||||
val = ((PJOB)row)->GetValue(Nodes[i].Key);
|
||||
val = ((PJOB)row)->GetKeyValue(Nodes[i].Key);
|
||||
|
||||
break;
|
||||
case TYPE_JAR:
|
||||
|
@ -1711,7 +1711,7 @@ PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i)
|
|||
|
||||
if (!Nodes[i].Key) {
|
||||
if (Nodes[i].Op == OP_EQ)
|
||||
val = arp->GetValue(Nodes[i].Rank);
|
||||
val = arp->GetArrayValue(Nodes[i].Rank);
|
||||
else if (Nodes[i].Op == OP_EXP)
|
||||
return ExpandArray(g, arp, i);
|
||||
else
|
||||
|
@ -1719,7 +1719,7 @@ PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i)
|
|||
|
||||
} else {
|
||||
// Unexpected array, unwrap it as [0]
|
||||
val = arp->GetValue(0);
|
||||
val = arp->GetArrayValue(0);
|
||||
i--;
|
||||
} // endif's
|
||||
|
||||
|
@ -1757,7 +1757,7 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n)
|
|||
return Value;
|
||||
} // endif ars
|
||||
|
||||
if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) {
|
||||
if (!(jvp = arp->GetArrayValue((Nodes[n].Rx = Nodes[n].Nx)))) {
|
||||
strcpy(g->Message, "Logical error expanding array");
|
||||
throw 666;
|
||||
} // endif jvp
|
||||
|
@ -1801,7 +1801,7 @@ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
|
|||
ars, op, nextsame);
|
||||
|
||||
for (i = 0; i < ars; i++) {
|
||||
jvrp = arp->GetValue(i);
|
||||
jvrp = arp->GetArrayValue(i);
|
||||
|
||||
if (trace(1))
|
||||
htrc("i=%d nv=%d\n", i, nv);
|
||||
|
@ -1901,20 +1901,20 @@ PJSON JSONCOL::GetRow(PGLOBAL g)
|
|||
// Expected Array was not there, wrap the value
|
||||
continue;
|
||||
|
||||
val = ((PJOB)row)->GetValue(Nodes[i].Key);
|
||||
val = ((PJOB)row)->GetKeyValue(Nodes[i].Key);
|
||||
break;
|
||||
case TYPE_JAR:
|
||||
arp = (PJAR)row;
|
||||
|
||||
if (!Nodes[i].Key) {
|
||||
if (Nodes[i].Op == OP_EQ)
|
||||
val = arp->GetValue(Nodes[i].Rank);
|
||||
val = arp->GetArrayValue(Nodes[i].Rank);
|
||||
else
|
||||
val = arp->GetValue(Nodes[i].Rx);
|
||||
val = arp->GetArrayValue(Nodes[i].Rx);
|
||||
|
||||
} else {
|
||||
// Unexpected array, unwrap it as [0]
|
||||
val = arp->GetValue(0);
|
||||
val = arp->GetArrayValue(0);
|
||||
i--;
|
||||
} // endif Nodes
|
||||
|
||||
|
@ -1941,9 +1941,9 @@ PJSON JSONCOL::GetRow(PGLOBAL g)
|
|||
nwr = new(G) JOBJECT;
|
||||
|
||||
if (row->GetType() == TYPE_JOB) {
|
||||
((PJOB)row)->SetValue(G, new(G) JVALUE(nwr), Nodes[i-1].Key);
|
||||
((PJOB)row)->SetKeyValue(G, new(G) JVALUE(nwr), Nodes[i-1].Key);
|
||||
} else if (row->GetType() == TYPE_JAR) {
|
||||
((PJAR)row)->AddValue(G, new(G) JVALUE(nwr));
|
||||
((PJAR)row)->AddArrayValue(G, new(G) JVALUE(nwr));
|
||||
((PJAR)row)->InitArray(G);
|
||||
} else {
|
||||
strcpy(g->Message, "Wrong type when writing new row");
|
||||
|
@ -2008,14 +2008,14 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
|||
|
||||
if (arp) {
|
||||
if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ)
|
||||
arp->SetValue(G, new(G) JVALUE(jsp), Nodes[Nod-2].Rank);
|
||||
arp->SetArrayValue(G, new(G) JVALUE(jsp), Nodes[Nod-2].Rank);
|
||||
else
|
||||
arp->AddValue(G, new(G) JVALUE(jsp));
|
||||
arp->AddArrayValue(G, new(G) JVALUE(jsp));
|
||||
|
||||
arp->InitArray(G);
|
||||
} else if (objp) {
|
||||
if (Nod > 1 && Nodes[Nod-2].Key)
|
||||
objp->SetValue(G, new(G) JVALUE(jsp), Nodes[Nod-2].Key);
|
||||
objp->SetKeyValue(G, new(G) JVALUE(jsp), Nodes[Nod-2].Key);
|
||||
|
||||
} else if (jvp)
|
||||
jvp->SetValue(jsp);
|
||||
|
@ -2032,14 +2032,14 @@ void JSONCOL::WriteColumn(PGLOBAL g)
|
|||
case TYPE_DOUBLE:
|
||||
if (arp) {
|
||||
if (Nodes[Nod-1].Op == OP_EQ)
|
||||
arp->SetValue(G, new(G) JVALUE(G, Value), Nodes[Nod-1].Rank);
|
||||
arp->SetArrayValue(G, new(G) JVALUE(G, Value), Nodes[Nod-1].Rank);
|
||||
else
|
||||
arp->AddValue(G, new(G) JVALUE(G, Value));
|
||||
arp->AddArrayValue(G, new(G) JVALUE(G, Value));
|
||||
|
||||
arp->InitArray(G);
|
||||
} else if (objp) {
|
||||
if (Nodes[Nod-1].Key)
|
||||
objp->SetValue(G, new(G) JVALUE(G, Value), Nodes[Nod-1].Key);
|
||||
objp->SetKeyValue(G, new(G) JVALUE(G, Value), Nodes[Nod-1].Key);
|
||||
|
||||
} else if (jvp)
|
||||
jvp->SetValue(g, Value);
|
||||
|
@ -2189,7 +2189,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
|
|||
key = p;
|
||||
objp = jsp->GetObject();
|
||||
arp = NULL;
|
||||
val = objp->GetValue(key);
|
||||
val = objp->GetKeyValue(key);
|
||||
|
||||
if (!val || !(jsp = val->GetJson())) {
|
||||
sprintf(g->Message, "Cannot find object key %s", key);
|
||||
|
@ -2215,7 +2215,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
|
|||
arp = jsp->GetArray();
|
||||
objp = NULL;
|
||||
i = atoi(p) - B;
|
||||
val = arp->GetValue(i);
|
||||
val = arp->GetArrayValue(i);
|
||||
|
||||
if (!val) {
|
||||
sprintf(g->Message, "Cannot find array value %d", i);
|
||||
|
@ -2236,17 +2236,17 @@ int TDBJSON::MakeDocument(PGLOBAL g)
|
|||
Doc = new(g) JARRAY;
|
||||
|
||||
if (val) {
|
||||
Doc->AddValue(g, val);
|
||||
Doc->AddArrayValue(g, val);
|
||||
Doc->InitArray(g);
|
||||
} else if (jsp) {
|
||||
Doc->AddValue(g, new(g) JVALUE(jsp));
|
||||
Doc->AddArrayValue(g, new(g) JVALUE(jsp));
|
||||
Doc->InitArray(g);
|
||||
} // endif val
|
||||
|
||||
if (objp)
|
||||
objp->SetValue(g, new(g) JVALUE(Doc), key);
|
||||
objp->SetKeyValue(g, new(g) JVALUE(Doc), key);
|
||||
else if (arp)
|
||||
arp->SetValue(g, new(g) JVALUE(Doc), i);
|
||||
arp->SetArrayValue(g, new(g) JVALUE(Doc), i);
|
||||
else
|
||||
Top = Doc;
|
||||
|
||||
|
@ -2409,7 +2409,7 @@ int TDBJSON::ReadDB(PGLOBAL)
|
|||
M++;
|
||||
rc = RC_OK;
|
||||
} else if (++Fpos < (signed)Doc->size()) {
|
||||
Row = Doc->GetValue(Fpos);
|
||||
Row = Doc->GetArrayValue(Fpos);
|
||||
|
||||
if (Row->GetType() == TYPE_JVAL)
|
||||
Row = ((PJVAL)Row)->GetJson();
|
||||
|
@ -2432,25 +2432,25 @@ int TDBJSON::WriteDB(PGLOBAL g)
|
|||
PJVAL vp = new(g) JVALUE(Row);
|
||||
|
||||
if (Mode == MODE_INSERT) {
|
||||
Doc->AddValue(g, vp);
|
||||
Doc->AddArrayValue(g, vp);
|
||||
Row = new(g) JOBJECT;
|
||||
} else if (Doc->SetValue(g, vp, Fpos))
|
||||
} else if (Doc->SetArrayValue(g, vp, Fpos))
|
||||
return RC_FX;
|
||||
|
||||
} else if (Jmode == MODE_ARRAY) {
|
||||
PJVAL vp = new(g) JVALUE(Row);
|
||||
|
||||
if (Mode == MODE_INSERT) {
|
||||
Doc->AddValue(g, vp);
|
||||
Doc->AddArrayValue(g, vp);
|
||||
Row = new(g) JARRAY;
|
||||
} else if (Doc->SetValue(g, vp, Fpos))
|
||||
} else if (Doc->SetArrayValue(g, vp, Fpos))
|
||||
return RC_FX;
|
||||
|
||||
} else { // if (Jmode == MODE_VALUE)
|
||||
if (Mode == MODE_INSERT) {
|
||||
Doc->AddValue(g, (PJVAL)Row);
|
||||
Doc->AddArrayValue(g, (PJVAL)Row);
|
||||
Row = new(g) JVALUE;
|
||||
} else if (Doc->SetValue(g, (PJVAL)Row, Fpos))
|
||||
} else if (Doc->SetArrayValue(g, (PJVAL)Row, Fpos))
|
||||
return RC_FX;
|
||||
|
||||
} // endif Jmode
|
||||
|
|
Loading…
Reference in a new issue