1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- Fix json parser (void objects not recognized) modified: json.cpp

This commit is contained in:
Olivier Bertrand
2020-12-18 18:59:52 +01:00
parent a786741000
commit 24c18ce892
2 changed files with 15 additions and 12 deletions

View File

@@ -170,7 +170,7 @@
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 10 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.07.0002 December 12, 2020"; char version[]= "Version 1.07.0002 December 18, 2020";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__; char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
@@ -1070,12 +1070,12 @@ static PGLOBAL GetPlug(THD *thd, PCONNECT& lxp)
/****************************************************************************/ /****************************************************************************/
TABTYPE ha_connect::GetRealType(PTOS pos) TABTYPE ha_connect::GetRealType(PTOS pos)
{ {
TABTYPE type; TABTYPE type= TAB_UNDEF;
if (pos || (pos= GetTableOptionStruct())) { if (pos || (pos= GetTableOptionStruct())) {
type= GetTypeID(pos->type); type= GetTypeID(pos->type);
if (type == TAB_UNDEF) if (type == TAB_UNDEF && !pos->http)
type= pos->srcdef ? TAB_MYSQL : pos->tabname ? TAB_PRX : TAB_DOS; type= pos->srcdef ? TAB_MYSQL : pos->tabname ? TAB_PRX : TAB_DOS;
#if defined(REST_SUPPORT) #if defined(REST_SUPPORT)
else if (pos->http) else if (pos->http)
@@ -1083,6 +1083,7 @@ TABTYPE ha_connect::GetRealType(PTOS pos)
case TAB_JSON: case TAB_JSON:
case TAB_XML: case TAB_XML:
case TAB_CSV: case TAB_CSV:
case TAB_UNDEF:
type = TAB_REST; type = TAB_REST;
break; break;
case TAB_REST: case TAB_REST:
@@ -1093,8 +1094,7 @@ TABTYPE ha_connect::GetRealType(PTOS pos)
} // endswitch type } // endswitch type
#endif // REST_SUPPORT #endif // REST_SUPPORT
} else } // endif pos
type= TAB_UNDEF;
return type; return type;
} // end of GetRealType } // end of GetRealType
@@ -5690,7 +5690,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
try { try {
// Check table type // Check table type
if (ttp == TAB_UNDEF) { if (ttp == TAB_UNDEF && !topt->http) {
topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS"; topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
ttp= GetTypeID(topt->type); ttp= GetTypeID(topt->type);
sprintf(g->Message, "No table_type. Was set to %s", topt->type); sprintf(g->Message, "No table_type. Was set to %s", topt->type);
@@ -5708,6 +5708,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#endif // BSON_SUPPORT #endif // BSON_SUPPORT
case TAB_XML: case TAB_XML:
case TAB_CSV: case TAB_CSV:
case TAB_UNDEF:
ttp = TAB_REST; ttp = TAB_REST;
break; break;
default: default:
@@ -6131,8 +6132,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
} // endif !nblin } // endif !nblin
// Restore language type // Restore language type
if (ttp == TAB_REST) if (ttp == TAB_REST) {
ttp = GetTypeID(topt->type); ttp = GetTypeID(topt->type);
ttp = (ttp == TAB_UNDEF) ? TAB_JSON : ttp;
} // endif ttp
for (i= 0; !rc && i < qrp->Nblin; i++) { for (i= 0; !rc && i < qrp->Nblin; i++) {
typ= len= prec= dec= flg= 0; typ= len= prec= dec= flg= 0;

View File

@@ -554,7 +554,7 @@ PJAR JDOC::ParseArray(PGLOBAL g, int& i)
PJOB JDOC::ParseObject(PGLOBAL g, int& i) PJOB JDOC::ParseObject(PGLOBAL g, int& i)
{ {
PSZ key; PSZ key;
int level = 0; int level = -1;
PJOB jobp = new(g) JOBJECT; PJOB jobp = new(g) JOBJECT;
PJPR jpp = NULL; PJPR jpp = NULL;
@@ -590,7 +590,7 @@ PJOB JDOC::ParseObject(PGLOBAL g, int& i)
break; break;
case '}': case '}':
if (level < 2) { if (level == 0 || level == 1) {
sprintf(g->Message, "Unexpected '}' near %.*s", ARGS); sprintf(g->Message, "Unexpected '}' near %.*s", ARGS);
throw 2; throw 2;
} // endif level } // endif level