mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
Fix assert error for where clause with UDF's
was fixed in HA_CONNECT::CondFilter moving res= pval->val_str(&tmp) but this was wrong. Now res is only used for strings. Change version number modified: storage/connect/ha_connect.cc Add some new UDF's modified: storage/connect/json.cpp modified: storage/connect/json.h modified: storage/connect/jsonudf.cpp modified: storage/connect/jsonudf.h Fix change in tests json_udf modified: storage/connect/mysql-test/connect/r/json_udf.result modified: storage/connect/mysql-test/connect/t/json_udf.inc modified: storage/connect/mysql-test/connect/t/json_udf.test
This commit is contained in:
parent
8a154ecde0
commit
f4fe138321
8 changed files with 1033 additions and 134 deletions
|
@ -169,9 +169,9 @@
|
||||||
#define JSONMAX 10 // JSON Default max grp size
|
#define JSONMAX 10 // JSON Default max grp size
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
char version[]= "Version 1.04.0001 June 29, 2015";
|
char version[]= "Version 1.04.0003 September 15, 2015";
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
char compver[]= "Version 1.04.0001 " __DATE__ " " __TIME__;
|
char compver[]= "Version 1.04.0003 " __DATE__ " " __TIME__;
|
||||||
char slash= '\\';
|
char slash= '\\';
|
||||||
#else // !__WIN__
|
#else // !__WIN__
|
||||||
char slash= '/';
|
char slash= '/';
|
||||||
|
@ -2544,12 +2544,10 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
|
||||||
if (!i && (ismul))
|
if (!i && (ismul))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((res= pval->val_str(&tmp)) == NULL)
|
switch (args[i]->real_type()) {
|
||||||
return NULL; // To be clarified
|
|
||||||
|
|
||||||
switch (args[i]->real_type()) {
|
|
||||||
case COND::STRING_ITEM:
|
case COND::STRING_ITEM:
|
||||||
pp->Value= PlugSubAllocStr(g, NULL, res->ptr(), res->length());
|
res= pval->val_str(&tmp);
|
||||||
|
pp->Value= PlugSubAllocStr(g, NULL, res->ptr(), res->length());
|
||||||
pp->Type= (pp->Value) ? TYPE_STRING : TYPE_ERROR;
|
pp->Type= (pp->Value) ? TYPE_STRING : TYPE_ERROR;
|
||||||
break;
|
break;
|
||||||
case COND::INT_ITEM:
|
case COND::INT_ITEM:
|
||||||
|
@ -2578,8 +2576,8 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endswitch type
|
} // endswitch type
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
htrc("Value=%.*s\n", res->length(), res->ptr());
|
htrc("Value type=%hd\n", pp->Type);
|
||||||
|
|
||||||
// Append the value to the argument list
|
// Append the value to the argument list
|
||||||
if (pprec)
|
if (pprec)
|
||||||
|
@ -6722,7 +6720,7 @@ maria_declare_plugin(connect)
|
||||||
0x0104, /* version number (1.04) */
|
0x0104, /* version number (1.04) */
|
||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
connect_system_variables, /* system variables */
|
connect_system_variables, /* system variables */
|
||||||
"1.04.0001", /* string version */
|
"1.04.0003", /* string version */
|
||||||
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
|
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
|
||||||
}
|
}
|
||||||
maria_declare_plugin_end;
|
maria_declare_plugin_end;
|
||||||
|
|
|
@ -942,12 +942,30 @@ PSZ JOBJECT::GetText(PGLOBAL g, PSZ text)
|
||||||
return text + n;
|
return text + n;
|
||||||
} // end of GetValue;
|
} // end of GetValue;
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Merge two objects. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool JOBJECT::Merge(PGLOBAL g, PJSON jsp)
|
||||||
|
{
|
||||||
|
if (jsp->GetType() != TYPE_JOB) {
|
||||||
|
strcpy(g->Message, "Second argument is not an object");
|
||||||
|
return true;
|
||||||
|
} // endif Type
|
||||||
|
|
||||||
|
PJOB jobp = (PJOB)jsp;
|
||||||
|
|
||||||
|
for (PJPR jpp = jobp->First; jpp; jpp = jpp->Next)
|
||||||
|
SetValue(g, jpp->GetVal(), jpp->GetKey());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // end of Marge;
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Set or add a value corresponding to the given key. */
|
/* Set or add a value corresponding to the given key. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key)
|
void JOBJECT::SetValue(PGLOBAL g, PJVAL jvp, PSZ key)
|
||||||
{
|
{
|
||||||
PJPR jp;
|
PJPR jp;
|
||||||
|
|
||||||
for (jp = First; jp; jp = jp->Next)
|
for (jp = First; jp; jp = jp->Next)
|
||||||
if (!strcmp(jp->Key, key)) {
|
if (!strcmp(jp->Key, key)) {
|
||||||
|
@ -1063,6 +1081,25 @@ PJVAL JARRAY::AddValue(PGLOBAL g, PJVAL jvp, int *x)
|
||||||
return jvp;
|
return jvp;
|
||||||
} // end of AddValue
|
} // end of AddValue
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Merge two arrays. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool JARRAY::Merge(PGLOBAL g, PJSON jsp)
|
||||||
|
{
|
||||||
|
if (jsp->GetType() != TYPE_JAR) {
|
||||||
|
strcpy(g->Message, "Second argument is not an array");
|
||||||
|
return true;
|
||||||
|
} // endif Type
|
||||||
|
|
||||||
|
PJAR arp = (PJAR)jsp;
|
||||||
|
|
||||||
|
for (int i = 0; i < jsp->size(); i++)
|
||||||
|
AddValue(g, arp->GetValue(i));
|
||||||
|
|
||||||
|
InitArray(g);
|
||||||
|
return false;
|
||||||
|
} // end of Merge
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Set the nth Value of the Array Value list. */
|
/* Set the nth Value of the Array Value list. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
|
@ -162,7 +162,8 @@ class JSON : public BLOCK {
|
||||||
virtual double GetFloat() {X return 0.0;}
|
virtual double GetFloat() {X return 0.0;}
|
||||||
virtual PSZ GetString() {X return NULL;}
|
virtual PSZ GetString() {X return NULL;}
|
||||||
virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;}
|
virtual PSZ GetText(PGLOBAL g, PSZ text) {X return NULL;}
|
||||||
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i) {X return true;}
|
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, PSZ key) {X}
|
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key) {X}
|
||||||
virtual void SetValue(PVAL valp) {X}
|
virtual void SetValue(PVAL valp) {X}
|
||||||
virtual void SetValue(PJSON jsp) {X}
|
virtual void SetValue(PJSON jsp) {X}
|
||||||
|
@ -197,7 +198,8 @@ class JOBJECT : public JSON {
|
||||||
virtual PJVAL GetValue(const char* key);
|
virtual PJVAL GetValue(const char* key);
|
||||||
virtual PJAR GetKeyList(PGLOBAL g);
|
virtual PJAR GetKeyList(PGLOBAL g);
|
||||||
virtual PSZ GetText(PGLOBAL g, PSZ text);
|
virtual PSZ GetText(PGLOBAL g, PSZ text);
|
||||||
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key);
|
virtual bool Merge(PGLOBAL g, PJSON jsp);
|
||||||
|
virtual void SetValue(PGLOBAL g, PJVAL jvp, PSZ key);
|
||||||
virtual void DeleteKey(char *k);
|
virtual void DeleteKey(char *k);
|
||||||
virtual bool IsNull(void);
|
virtual bool IsNull(void);
|
||||||
|
|
||||||
|
@ -222,7 +224,8 @@ class JARRAY : public JSON {
|
||||||
virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL);
|
virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL);
|
||||||
virtual void InitArray(PGLOBAL g);
|
virtual void InitArray(PGLOBAL g);
|
||||||
virtual PJVAL GetValue(int i);
|
virtual PJVAL GetValue(int i);
|
||||||
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i);
|
virtual bool Merge(PGLOBAL g, PJSON jsp);
|
||||||
|
virtual bool SetValue(PGLOBAL g, PJVAL jvp, int i);
|
||||||
virtual bool DeleteValue(int n);
|
virtual bool DeleteValue(int n);
|
||||||
virtual bool IsNull(void);
|
virtual bool IsNull(void);
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
/******************** tabjson H Declares Source Code File (.H) *******************/
|
/******************** tabjson H Declares Source Code File (.H) *******************/
|
||||||
/* Name: jsonudf.h Version 1.1 */
|
/* Name: jsonudf.h Version 1.2 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2015 */
|
/* (C) Copyright to the author Olivier BERTRAND 2015 */
|
||||||
/* */
|
/* */
|
||||||
|
@ -33,9 +33,9 @@ typedef class JOUTPATH *PJTP;
|
||||||
typedef class JOUTALL *PJTA;
|
typedef class JOUTALL *PJTA;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
DllExport my_bool Json_Value_init(UDF_INIT*, UDF_ARGS*, char*);
|
DllExport my_bool JsonValue_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
DllExport char *Json_Value(UDF_EXEC_ARGS);
|
DllExport char *JsonValue(UDF_EXEC_ARGS);
|
||||||
DllExport void Json_Value_deinit(UDF_INIT*);
|
DllExport void JsonValue_deinit(UDF_INIT*);
|
||||||
|
|
||||||
DllExport my_bool Json_Array_init(UDF_INIT*, UDF_ARGS*, char*);
|
DllExport my_bool Json_Array_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
DllExport char *Json_Array(UDF_EXEC_ARGS);
|
DllExport char *Json_Array(UDF_EXEC_ARGS);
|
||||||
|
@ -89,6 +89,10 @@ extern "C" {
|
||||||
DllExport char *Json_Get_Item(UDF_EXEC_ARGS);
|
DllExport char *Json_Get_Item(UDF_EXEC_ARGS);
|
||||||
DllExport void Json_Get_Item_deinit(UDF_INIT*);
|
DllExport void Json_Get_Item_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Json_Item_Merge_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Json_Item_Merge(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Json_Item_Merge_deinit(UDF_INIT*);
|
||||||
|
|
||||||
DllExport my_bool JsonGetString_init(UDF_INIT*, UDF_ARGS*, char*);
|
DllExport my_bool JsonGetString_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
DllExport char *JsonGetString(UDF_EXEC_ARGS);
|
DllExport char *JsonGetString(UDF_EXEC_ARGS);
|
||||||
DllExport void JsonGetString_deinit(UDF_INIT*);
|
DllExport void JsonGetString_deinit(UDF_INIT*);
|
||||||
|
@ -117,17 +121,57 @@ extern "C" {
|
||||||
DllExport char *Jfile_Make(UDF_EXEC_ARGS);
|
DllExport char *Jfile_Make(UDF_EXEC_ARGS);
|
||||||
DllExport void Jfile_Make_deinit(UDF_INIT*);
|
DllExport void Jfile_Make_deinit(UDF_INIT*);
|
||||||
|
|
||||||
DllExport my_bool Bson_Array_init(UDF_INIT*, UDF_ARGS*, char*);
|
DllExport my_bool Jbin_Array_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
DllExport char *Bson_Array(UDF_EXEC_ARGS);
|
DllExport char *Jbin_Array(UDF_EXEC_ARGS);
|
||||||
DllExport void Bson_Array_deinit(UDF_INIT*);
|
DllExport void Jbin_Array_deinit(UDF_INIT*);
|
||||||
|
|
||||||
DllExport my_bool Bson_Object_init(UDF_INIT*, UDF_ARGS*, char*);
|
DllExport my_bool Jbin_Array_Add_Values_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
DllExport char *Bson_Object(UDF_EXEC_ARGS);
|
DllExport char *Jbin_Array_Add_Values(UDF_EXEC_ARGS);
|
||||||
DllExport void Bson_Object_deinit(UDF_INIT*);
|
DllExport void Jbin_Array_Add_Values_deinit(UDF_INIT*);
|
||||||
|
|
||||||
DllExport my_bool Bson_File_init(UDF_INIT*, UDF_ARGS*, char*);
|
DllExport my_bool Jbin_Array_Add_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
DllExport char *Bson_File(UDF_EXEC_ARGS);
|
DllExport char *Jbin_Array_Add(UDF_EXEC_ARGS);
|
||||||
DllExport void Bson_File_deinit(UDF_INIT*);
|
DllExport void Jbin_Array_Add_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_Array_Delete_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_Array_Delete(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_Array_Delete_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_Object_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_Object(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_Object_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_Object_Nonull_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_Object_Nonull(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_Object_Nonull_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_Object_Add_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_Object_Add(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_Object_Add_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_Object_Delete_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_Object_Delete(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_Object_Delete_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_Object_List_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_Object_List(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_Object_List_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_Get_Item_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_Get_Item(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_Get_Item_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_Item_Merge_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_Item_Merge(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_Item_Merge_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Jbin_File_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Jbin_File(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Jbin_File_deinit(UDF_INIT*);
|
||||||
|
|
||||||
|
DllExport my_bool Json_Serialize_init(UDF_INIT*, UDF_ARGS*, char*);
|
||||||
|
DllExport char *Json_Serialize(UDF_EXEC_ARGS);
|
||||||
|
DllExport void Json_Serialize_deinit(UDF_INIT*);
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
|
@ -155,6 +199,7 @@ public:
|
||||||
my_bool SetJpath(PGLOBAL g, char *path, my_bool jb = false);
|
my_bool SetJpath(PGLOBAL g, char *path, my_bool jb = false);
|
||||||
my_bool ParseJpath(PGLOBAL g);
|
my_bool ParseJpath(PGLOBAL g);
|
||||||
void ReadValue(PGLOBAL g);
|
void ReadValue(PGLOBAL g);
|
||||||
|
PJVAL GetValue(PGLOBAL g, PJSON row, int i, my_bool b = true);
|
||||||
PJVAL GetJson(PGLOBAL g);
|
PJVAL GetJson(PGLOBAL g);
|
||||||
char *Locate(PGLOBAL g, PJSON jsp, PJVAL jvp, int k = 1);
|
char *Locate(PGLOBAL g, PJSON jsp, PJVAL jvp, int k = 1);
|
||||||
char *LocateAll(PGLOBAL g, PJSON jsp, PJVAL jvp, int mx = 10);
|
char *LocateAll(PGLOBAL g, PJSON jsp, PJVAL jvp, int mx = 10);
|
||||||
|
@ -162,7 +207,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
my_bool SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm);
|
my_bool SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm);
|
||||||
PVAL GetColumnValue(PGLOBAL g, PJSON row, int i);
|
PVAL GetColumnValue(PGLOBAL g, PJSON row, int i);
|
||||||
PJVAL GetValue(PGLOBAL g, PJSON row, int i);
|
|
||||||
PVAL ExpandArray(PGLOBAL g, PJAR arp, int n);
|
PVAL ExpandArray(PGLOBAL g, PJAR arp, int n);
|
||||||
PVAL CalculateArray(PGLOBAL g, PJAR arp, int n);
|
PVAL CalculateArray(PGLOBAL g, PJAR arp, int n);
|
||||||
PVAL MakeJson(PGLOBAL g, PJSON jsp);
|
PVAL MakeJson(PGLOBAL g, PJSON jsp);
|
||||||
|
|
|
@ -18,32 +18,30 @@ ERROR HY000: Can't initialize function 'Json_Array_Add'; Json_Array_Add must hav
|
||||||
SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL),'One more') Array;
|
SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL),'One more') Array;
|
||||||
Array
|
Array
|
||||||
[56,3.141600,"foo",null,"One more"]
|
[56,3.141600,"foo",null,"One more"]
|
||||||
SELECT Json_Array_Add(Json_Value('one value'),'One more');
|
SELECT Json_Array_Add(JsonValue('one value'),'One more');
|
||||||
Json_Array_Add(Json_Value('one value'),'One more')
|
ERROR HY000: Can't initialize function 'Json_Array_Add'; Json_Array_Add first argument must be a json item
|
||||||
NULL
|
|
||||||
Warnings:
|
|
||||||
Warning 1105 First argument is not an array
|
|
||||||
SELECT Json_Array_Add('one value','One more');
|
SELECT Json_Array_Add('one value','One more');
|
||||||
ERROR HY000: Can't initialize function 'Json_Array_Add'; Json_Array_Add first argument must be a json item
|
ERROR HY000: Can't initialize function 'Json_Array_Add'; Json_Array_Add first argument must be a json item
|
||||||
SELECT Json_Array_Add('one value' json_,'One more');
|
SELECT Json_Array_Add('one value' json_,'One more');
|
||||||
Json_Array_Add('one value' json_,'One more')
|
Json_Array_Add('one value' json_,'One more')
|
||||||
NULL
|
NULL
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 1105 Unexpected character 'o' near one value
|
Warning 1105 Error 2 opening one value
|
||||||
|
Warning 1105 Void JSON object
|
||||||
Warning 1105 First argument is not an array
|
Warning 1105 First argument is not an array
|
||||||
SELECT Json_Value(56,3.1416,'foo',NULL);
|
SELECT JsonValue(56,3.1416,'foo',NULL);
|
||||||
ERROR HY000: Can't initialize function 'Json_Value'; Json_Value cannot accept more than 1 argument
|
ERROR HY000: Can't initialize function 'JsonValue'; JsonValue cannot accept more than 1 argument
|
||||||
SELECT Json_Value(3.1416);
|
SELECT JsonValue(3.1416);
|
||||||
Json_Value(3.1416)
|
JsonValue(3.1416)
|
||||||
3.141600
|
3.141600
|
||||||
SELECT Json_Value('foo');
|
SELECT JsonValue('foo');
|
||||||
Json_Value('foo')
|
JsonValue('foo')
|
||||||
"foo"
|
"foo"
|
||||||
SELECT Json_Value(NULL);
|
SELECT JsonValue(NULL);
|
||||||
Json_Value(NULL)
|
JsonValue(NULL)
|
||||||
null
|
null
|
||||||
SELECT Json_Value();
|
SELECT JsonValue();
|
||||||
Json_Value()
|
JsonValue()
|
||||||
null
|
null
|
||||||
SELECT Json_Object();
|
SELECT Json_Object();
|
||||||
Json_Object()
|
Json_Object()
|
||||||
|
@ -165,6 +163,6 @@ DROP FUNCTION Json_Array;
|
||||||
DROP FUNCTION Json_Array_Add;
|
DROP FUNCTION Json_Array_Add;
|
||||||
DROP FUNCTION Json_Object;
|
DROP FUNCTION Json_Object;
|
||||||
DROP FUNCTION Json_Object_Nonull;
|
DROP FUNCTION Json_Object_Nonull;
|
||||||
DROP FUNCTION Json_Value;
|
DROP FUNCTION JsonValue;
|
||||||
DROP FUNCTION Json_Array_Grp;
|
DROP FUNCTION Json_Array_Grp;
|
||||||
DROP FUNCTION Json_Object_Grp;
|
DROP FUNCTION Json_Object_Grp;
|
||||||
|
|
|
@ -9,28 +9,13 @@ if (!$HA_CONNECT_SO) {
|
||||||
--skip Needs a dynamically built ha_connect.so
|
--skip Needs a dynamically built ha_connect.so
|
||||||
}
|
}
|
||||||
|
|
||||||
let $is_win = `select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows")`;
|
CREATE FUNCTION Json_Array RETURNS STRING SONAME 'ha_connect';
|
||||||
|
CREATE FUNCTION Json_Array_Add RETURNS STRING SONAME 'ha_connect';
|
||||||
|
CREATE FUNCTION Json_Object RETURNS STRING SONAME 'ha_connect';
|
||||||
|
CREATE FUNCTION Json_Object_Nonull RETURNS STRING SONAME 'ha_connect';
|
||||||
|
CREATE FUNCTION JsonValue RETURNS STRING SONAME 'ha_connect';
|
||||||
|
CREATE AGGREGATE FUNCTION Json_Array_Grp RETURNS STRING SONAME 'ha_connect';
|
||||||
|
CREATE AGGREGATE FUNCTION Json_Object_Grp RETURNS STRING SONAME 'ha_connect';
|
||||||
|
|
||||||
if ($is_win)
|
|
||||||
{
|
|
||||||
--eval CREATE FUNCTION Json_Array RETURNS STRING SONAME 'ha_connect.dll';
|
|
||||||
--eval CREATE FUNCTION Json_Array_Add RETURNS STRING SONAME 'ha_connect.dll';
|
|
||||||
--eval CREATE FUNCTION Json_Object RETURNS STRING SONAME 'ha_connect.dll';
|
|
||||||
--eval CREATE FUNCTION Json_Object_Nonull RETURNS STRING SONAME 'ha_connect.dll';
|
|
||||||
--eval CREATE FUNCTION Json_Value returns STRING SONAME 'ha_connect.dll';
|
|
||||||
--eval CREATE AGGREGATE FUNCTION Json_Array_Grp RETURNS STRING SONAME 'ha_connect.dll';
|
|
||||||
--eval CREATE AGGREGATE FUNCTION Json_Object_Grp RETURNS STRING SONAME 'ha_connect.dll';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$is_win)
|
|
||||||
{
|
|
||||||
--eval CREATE FUNCTION Json_Array RETURNS STRING SONAME 'ha_connect.so';
|
|
||||||
--eval CREATE FUNCTION Json_Array_Add RETURNS STRING SONAME 'ha_connect.so';
|
|
||||||
--eval CREATE FUNCTION Json_Object RETURNS STRING SONAME 'ha_connect.so';
|
|
||||||
--eval CREATE FUNCTION Json_Object_Nonull RETURNS STRING SONAME 'ha_connect.so';
|
|
||||||
--eval CREATE FUNCTION Json_Value returns STRING SONAME 'ha_connect.so';
|
|
||||||
--eval CREATE AGGREGATE FUNCTION Json_Array_Grp RETURNS STRING SONAME 'ha_connect.so';
|
|
||||||
--eval CREATE AGGREGATE FUNCTION Json_Object_Grp RETURNS STRING SONAME 'ha_connect.so';
|
|
||||||
}
|
|
||||||
--enable_query_log
|
--enable_query_log
|
||||||
|
|
||||||
|
|
|
@ -15,16 +15,17 @@ SELECT Json_Array(56,3.1416,'My name is "Foo"',NULL);
|
||||||
--error ER_CANT_INITIALIZE_UDF
|
--error ER_CANT_INITIALIZE_UDF
|
||||||
SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL)) Array;
|
SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL)) Array;
|
||||||
SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL),'One more') Array;
|
SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL),'One more') Array;
|
||||||
SELECT Json_Array_Add(Json_Value('one value'),'One more');
|
--error ER_CANT_INITIALIZE_UDF
|
||||||
|
SELECT Json_Array_Add(JsonValue('one value'),'One more');
|
||||||
--error ER_CANT_INITIALIZE_UDF
|
--error ER_CANT_INITIALIZE_UDF
|
||||||
SELECT Json_Array_Add('one value','One more');
|
SELECT Json_Array_Add('one value','One more');
|
||||||
SELECT Json_Array_Add('one value' json_,'One more');
|
SELECT Json_Array_Add('one value' json_,'One more');
|
||||||
--error ER_CANT_INITIALIZE_UDF
|
--error ER_CANT_INITIALIZE_UDF
|
||||||
SELECT Json_Value(56,3.1416,'foo',NULL);
|
SELECT JsonValue(56,3.1416,'foo',NULL);
|
||||||
SELECT Json_Value(3.1416);
|
SELECT JsonValue(3.1416);
|
||||||
SELECT Json_Value('foo');
|
SELECT JsonValue('foo');
|
||||||
SELECT Json_Value(NULL);
|
SELECT JsonValue(NULL);
|
||||||
SELECT Json_Value();
|
SELECT JsonValue();
|
||||||
SELECT Json_Object();
|
SELECT Json_Object();
|
||||||
SELECT Json_Object(Json_Array(56,3.1416,'foo'),NULL);
|
SELECT Json_Object(Json_Array(56,3.1416,'foo'),NULL);
|
||||||
SELECT Json_Array(Json_Array(56,3.1416,'foo'),NULL);
|
SELECT Json_Array(Json_Array(56,3.1416,'foo'),NULL);
|
||||||
|
@ -82,7 +83,7 @@ DROP FUNCTION Json_Array;
|
||||||
DROP FUNCTION Json_Array_Add;
|
DROP FUNCTION Json_Array_Add;
|
||||||
DROP FUNCTION Json_Object;
|
DROP FUNCTION Json_Object;
|
||||||
DROP FUNCTION Json_Object_Nonull;
|
DROP FUNCTION Json_Object_Nonull;
|
||||||
DROP FUNCTION Json_Value;
|
DROP FUNCTION JsonValue;
|
||||||
DROP FUNCTION Json_Array_Grp;
|
DROP FUNCTION Json_Array_Grp;
|
||||||
DROP FUNCTION Json_Object_Grp;
|
DROP FUNCTION Json_Object_Grp;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue