Skip to content

Commit 801a6d5

Browse files
committed
- Add new JPATH features
modified: storage/connect/bson.cpp modified: storage/connect/bsonudf.cpp modified: storage/connect/bsonudf.h modified: storage/connect/json.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/jsonudf.h modified: storage/connect/mysql-test/connect/r/json_udf.result modified: storage/connect/tabbson.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h
1 parent d788225 commit 801a6d5

File tree

10 files changed

+230
-122
lines changed

10 files changed

+230
-122
lines changed

storage/connect/bson.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,12 +1352,17 @@ PBVAL BJSON::NewVal(PVAL valp)
13521352
/***********************************************************************/
13531353
/* Sub-allocate and initialize a BVAL from another BVAL. */
13541354
/***********************************************************************/
1355-
PBVAL BJSON::DupVal(PBVAL bvlp) {
1356-
PBVAL bvp = NewVal();
1355+
PBVAL BJSON::DupVal(PBVAL bvlp)
1356+
{
1357+
if (bvlp) {
1358+
PBVAL bvp = NewVal();
1359+
1360+
*bvp = *bvlp;
1361+
bvp->Next = 0;
1362+
return bvp;
1363+
} else
1364+
return NULL;
13571365

1358-
*bvp = *bvlp;
1359-
bvp->Next = 0;
1360-
return bvp;
13611366
} // end of DupVal
13621367

13631368
/***********************************************************************/

storage/connect/bsonudf.cpp

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ BJNX::BJNX(PGLOBAL g) : BDOC(g)
114114
Jp = NULL;
115115
Nodes = NULL;
116116
Value = NULL;
117-
MulVal = NULL;
117+
//MulVal = NULL;
118118
Jpath = NULL;
119119
Buf_Type = TYPE_STRING;
120120
Long = len;
@@ -145,7 +145,7 @@ BJNX::BJNX(PGLOBAL g, PBVAL row, int type, int len, int prec, my_bool wr) : BDOC
145145
Jp = NULL;
146146
Nodes = NULL;
147147
Value = AllocateValue(g, type, len, prec);
148-
MulVal = NULL;
148+
//MulVal = NULL;
149149
Jpath = NULL;
150150
Buf_Type = type;
151151
Long = len;
@@ -270,40 +270,6 @@ my_bool BJNX::SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm)
270270
return true;
271271
} // endif's
272272

273-
#if 0
274-
// For calculated arrays, a local Value must be used
275-
switch (jnp->Op) {
276-
case OP_NUM:
277-
jnp->Valp = AllocateValue(g, TYPE_INT);
278-
break;
279-
case OP_ADD:
280-
case OP_MULT:
281-
case OP_SEP:
282-
if (!IsTypeChar(Buf_Type))
283-
jnp->Valp = AllocateValue(g, Buf_Type, 0, GetPrecision());
284-
else
285-
jnp->Valp = AllocateValue(g, TYPE_DOUBLE, 0, 2);
286-
287-
break;
288-
case OP_MIN:
289-
case OP_MAX:
290-
jnp->Valp = AllocateValue(g, Buf_Type, Long, GetPrecision());
291-
break;
292-
case OP_CNC:
293-
if (IsTypeChar(Buf_Type))
294-
jnp->Valp = AllocateValue(g, TYPE_STRING, Long, GetPrecision());
295-
else
296-
jnp->Valp = AllocateValue(g, TYPE_STRING, 512);
297-
298-
break;
299-
default:
300-
break;
301-
} // endswitch Op
302-
303-
if (jnp->Valp)
304-
MulVal = AllocateValue(g, jnp->Valp);
305-
#endif // 0
306-
307273
return false;
308274
} // end of SetArrayOptions
309275

@@ -449,6 +415,8 @@ PBVAL BJNX::MakeJson(PGLOBAL g, PBVAL bvp, int n)
449415
{
450416
PBVAL vlp, jvp = bvp;
451417

418+
Jb = false;
419+
452420
if (n < Nod -1) {
453421
if (bvp->Type == TYPE_JAR) {
454422
int ars = GetArraySize(bvp);

storage/connect/bsonudf.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ typedef struct _jnode {
4141
PSZ Key; // The key used for object
4242
OPVAL Op; // Operator used for this node
4343
PVAL CncVal; // To cont value used for OP_CNC
44-
PVAL Valp; // The internal array VALUE
4544
int Rank; // The rank in array
4645
int Rx; // Read row number
4746
int Nx; // Next to read row number
@@ -153,7 +152,7 @@ class BJNX : public BDOC {
153152
JOUTSTR *Jp;
154153
JNODE *Nodes; // The intermediate objects
155154
PVAL Value;
156-
PVAL MulVal; // To value used by multiple column
155+
//PVAL MulVal; // To value used by multiple column
157156
char *Jpath; // The json path
158157
int Buf_Type;
159158
int Long;

storage/connect/json.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e);
5454
#endif // SE_CATCH
5555

5656
char *GetJsonNull(void);
57+
int GetDefaultPrec(void);
5758

5859
/***********************************************************************/
5960
/* IsNum: check whether this string is all digits. */
@@ -1762,7 +1763,7 @@ void JVALUE::SetBigint(PGLOBAL g, long long ll)
17621763
void JVALUE::SetFloat(PGLOBAL g, double f)
17631764
{
17641765
F = f;
1765-
Nd = 6;
1766+
Nd = GetDefaultPrec();
17661767
DataType = TYPE_DBL;
17671768
} // end of SetFloat
17681769

0 commit comments

Comments
 (0)