From e57876eacf9c74fa3452c793672f220ee8c8135d Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 14 Dec 2015 23:49:17 +0100 Subject: [PATCH] - Fix MDEV-9279. Replacing exit(1) in yy_fatal_error by a longjmp. modified: storage/connect/fmdlex.c modified: storage/connect/plgdbutl.cpp --- storage/connect/fmdlex.c | 9 +++++++-- storage/connect/mysql-test/connect/t/json.test | 2 +- storage/connect/plgdbutl.cpp | 10 ++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index 22c3a1e79ad..548a7ae5b7e 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -1,3 +1,5 @@ +#include + #define yyFlexLexer fmdfFlexLexer #define yy_create_buffer fmdf_create_buffer #define yy_delete_buffer fmdf_delete_buffer @@ -506,13 +508,16 @@ YY_MALLOC_DECL #define YY_BREAK break; #endif +static jmp_buf env; + YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; - + if (setjmp(env)) + return -1; /*************************************************************************/ /* Flex parser to analyze date format and produce input and/or output */ @@ -1316,7 +1321,7 @@ char msg[]; #endif { (void) fprintf( stderr, "%s\n", msg ); - exit( 1 ); + longjmp(env, 1 ); } diff --git a/storage/connect/mysql-test/connect/t/json.test b/storage/connect/mysql-test/connect/t/json.test index b743071b1be..fa962d3b302 100644 --- a/storage/connect/mysql-test/connect/t/json.test +++ b/storage/connect/mysql-test/connect/t/json.test @@ -135,7 +135,7 @@ CREATE TABLE t1 Year int(4) FIELD_FORMAT='DATEPUB', INDEX IX(ISBN) ) -ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=350 OPTION_LIST='Pretty=0'; +ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0'; SHOW INDEX FROM t1; SELECT * FROM t1; DESCRIBE SELECT * FROM t1 WHERE ISBN = '9782212090819'; diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index 9e236da2d93..1ec1108c639 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -679,7 +679,8 @@ void PlugConvertConstant(PGLOBAL g, void* & value, short& type) /* non quoted blanks are not included in the output format. */ /***********************************************************************/ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag) - { +{ + int rc; PDTP pdp = (PDTP)PlugSubAlloc(g, NULL, sizeof(DATPAR)); if (trace) @@ -708,7 +709,7 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag) pthread_mutex_lock(&parmut); #endif // !__WIN__ #endif // THREAD - /*int rc =*/ fmdflex(pdp); + rc = fmdflex(pdp); #if defined(THREAD) #if defined(__WIN__) LeaveCriticalSection((LPCRITICAL_SECTION)&parsec); @@ -718,9 +719,10 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag) #endif // THREAD if (trace) - htrc("Done: in=%s out=%s\n", SVP(pdp->InFmt), SVP(pdp->OutFmt)); + htrc("Done: in=%s out=%s rc=%d\n", SVP(pdp->InFmt), SVP(pdp->OutFmt), rc); + return pdp; - } // end of MakeDateFormat +} // end of MakeDateFormat /***********************************************************************/ /* Extract the date from a formatted string according to format. */