1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

- Remove warning on not used tabtyp variable in connect_assisted_discovery

modified:   storage/connect/ha_connect.cc

- Fix a bug causing CONNECT to loop when expanding a JSON column
  when the expanded column value is null or void array.
- Adding the FullArray option to JSON tables.
- Skipping expanded JSON lines when the expanded column value is null.
  modified:   storage/connect/connect.cc
  modified:   storage/connect/tabdos.h
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h

- Fix MDEV-13353 No file privilege for ODBC, JDBC, MONGO, MAC, WMI file types.
  modified:   storage/connect/ha_connect.cc

- Make some Json UDFs  to accept a non JSON item as 1st parameter.
  modified:   storage/connect/json.cpp
  modified:   storage/connect/json.h
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h

- Update Json UDF tests to cope with above changes.
  modified:   storage/connect/mysql-test/connect/r/json_udf.result
  modified:   storage/connect/mysql-test/connect/r/json_udf_bin.result
  modified:   storage/connect/mysql-test/connect/r/vcol.result
  modified:   storage/connect/mysql-test/connect/t/json_udf.test
  modified:   storage/connect/mysql-test/connect/t/vcol.test

- Fix some compiler warning treated as error
  PlugSubAlloc no more exported because it does throw.
  modified:   storage/connect/global.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h

- Other files modified (?) when going back to wrong merge
  modified:   storage/connect/CMakeLists.txt
  modified:   storage/connect/array.cpp
  modified:   storage/connect/colblk.cpp
  modified:   storage/connect/connect.cc
  modified:   storage/connect/csort.cpp
  modified:   storage/connect/domdoc.cpp
  modified:   storage/connect/filamap.cpp
  modified:   storage/connect/filamgz.cpp
  modified:   storage/connect/filamtxt.cpp
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filter.cpp
  modified:   storage/connect/fmdlex.c
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/macutil.cpp
  modified:   storage/connect/myconn.cpp
  modified:   storage/connect/odbconn.cpp
  modified:   storage/connect/plgdbutl.cpp
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/preparse.h
  modified:   storage/connect/rcmsg.c
  modified:   storage/connect/rcmsg.h
  modified:   storage/connect/reldef.cpp
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabmac.cpp
  modified:   storage/connect/tabmul.cpp
  modified:   storage/connect/tabmysql.cpp
  modified:   storage/connect/tabmysql.h
  modified:   storage/connect/tabodbc.cpp
  modified:   storage/connect/tabtbl.cpp
  modified:   storage/connect/tabxml.cpp
  modified:   storage/connect/value.cpp
  modified:   storage/connect/xobject.cpp
This commit is contained in:
Olivier Bertrand
2018-02-25 14:31:28 +01:00
parent 273233119c
commit 175ce0e7f5
46 changed files with 899 additions and 504 deletions

View File

@@ -45,34 +45,17 @@ add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT )
# OS specific C flags, definitions and source files. # OS specific C flags, definitions and source files.
# #
IF(UNIX) IF(UNIX)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") MY_CHECK_AND_SET_COMPILER_FLAG("-Wall -Wmissing-declarations")
# Bar: -Wfatal-errors removed (does not present in gcc on solaris10) if(NOT WITH_WARNINGS)
if(WITH_WARNINGS) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-function")
add_definitions(-Wall -Wextra -Wmissing-declarations) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-variable")
#message(STATUS "CONNECT: GCC: All warnings enabled") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-value")
else() MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-parentheses")
add_definitions(-Wall -Wmissing-declarations) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-strict-aliasing")
add_definitions(-Wno-write-strings) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-misleading-indentation")
add_definitions(-Wno-unused-variable) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-format-truncation")
# Bar: -Wno-unused-but-set-variables commented (does not present on sol10) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough")
# add_definitions(-Wno-unused-but-set-variable) endif(NOT WITH_WARNINGS)
add_definitions(-Wno-unused-value)
add_definitions(-Wno-unused-function)
add_definitions(-Wno-parentheses)
#add_definitions(-Wno-missing-declarations)
# Bar: -Wno-int-to-pointer-cast commended (does not present in gcc on sol10)
# add_definitions(-Wno-int-to-pointer-cast)
# Bar: -Wno-narrowing commented (does not present in gcc on solaris10)
# add_definitions(-Wno-narrowing)
# This switch is for pure C only:
# add_definitions(-Wno-implicit-function-declaration)
# These switches are for C++ only
# add_definitions(-Wno-reorder)
#message(STATUS "CONNECT: GCC: Some warnings disabled")
endif(WITH_WARNINGS)
endif()
add_definitions( -DUNIX -DLINUX -DUBUNTU ) add_definitions( -DUNIX -DLINUX -DUBUNTU )
@@ -302,7 +285,7 @@ IF(CONNECT_WITH_MONGO)
C:/mongo-c-driver/lib C:/mongo-c-driver/lib
D:/mongo-c-driver/lib) D:/mongo-c-driver/lib)
ENDIF(WIN32) ENDIF(WIN32)
FIND_PACKAGE(libmongoc-1.0 1.7) FIND_PACKAGE(libmongoc-1.0 1.7 QUIET)
IF (libmongoc-1.0_FOUND) IF (libmongoc-1.0_FOUND)
INCLUDE_DIRECTORIES(${MONGOC_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${MONGOC_INCLUDE_DIRS})
SET(MONGOC_LIBRARY ${MONGOC_LIBRARIES}) SET(MONGOC_LIBRARY ${MONGOC_LIBRARIES})
@@ -363,6 +346,23 @@ IF(WIN32)
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
ENDIF(WIN32) ENDIF(WIN32)
IF(NOT TARGET connect)
RETURN()
ENDIF()
# Install some extra files that belong to connect engine
IF(WIN32)
# install ha_connect.lib
GET_TARGET_PROPERTY(CONNECT_LOCATION connect LOCATION)
STRING(REPLACE "dll" "lib" CONNECT_LIB ${CONNECT_LOCATION})
IF(CMAKE_CONFIGURATION_TYPES)
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}"
CONNECT_LIB ${CONNECT_LIB})
ENDIF()
INSTALL(FILES ${CONNECT_LIB}
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
ENDIF(WIN32)
IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND) IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND)
# TODO: Find how to compile and install the java wrapper classes # TODO: Find how to compile and install the java wrapper classes
# Find required libraries and include directories # Find required libraries and include directories
@@ -373,4 +373,3 @@ IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
ENDIF() ENDIF()

View File

@@ -412,4 +412,3 @@ void SIDBLK::ReadColumn(PGLOBAL)
// } // endif Sname // } // endif Sname
} // end of ReadColumn } // end of ReadColumn

View File

@@ -1,4 +1,5 @@
/* Copyright (C) MariaDB Corporation Ab /* Copyright (C) Olivier Bertrand 2004 - 2017
Copyright (C) MariaDB Corporation Ab
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -351,7 +351,7 @@ void CSORT::Qstx(int *base, int *max)
zlo = zhi = cnm = 0; // Avoid warning message zlo = zhi = cnm = 0; // Avoid warning message
lo = max - base; // Number of elements as longs lo = (int)(max - base); // Number of elements as longs
if (Dup) if (Dup)
cnm = Cmpnum(lo); cnm = Cmpnum(lo);
@@ -472,7 +472,7 @@ void CSORT::Qstx(int *base, int *max)
i = him + 1; i = him + 1;
if (Pof) if (Pof)
Pof[him - Pex] = Pof[mid - Pex] = i - j; Pof[him - Pex] = Pof[mid - Pex] = (int)(i - j);
/*******************************************************************/ /*******************************************************************/
/* Look at sizes of the two partitions, do the smaller one first */ /* Look at sizes of the two partitions, do the smaller one first */
@@ -481,8 +481,8 @@ void CSORT::Qstx(int *base, int *max)
/* But only repeat (recursively or by branching) if the partition */ /* But only repeat (recursively or by branching) if the partition */
/* is of at least size THRESH. */ /* is of at least size THRESH. */
/*******************************************************************/ /*******************************************************************/
lo = j - base; lo = (int)(j - base);
hi = max - i; hi = (int)(max - i);
if (Dup) { // Update progress information if (Dup) { // Update progress information
zlo = Cmpnum(lo); zlo = Cmpnum(lo);
@@ -726,7 +726,7 @@ void CSORT::Qstc(int *base, int *max)
zlo = zhi = cnm = 0; // Avoid warning message zlo = zhi = cnm = 0; // Avoid warning message
lo = max - base; // Number of elements as longs lo = (int)(max - base); // Number of elements as longs
if (Dup) if (Dup)
cnm = Cmpnum(lo); cnm = Cmpnum(lo);
@@ -853,7 +853,7 @@ void CSORT::Qstc(int *base, int *max)
/* the offset array values indicating break point and block size. */ /* the offset array values indicating break point and block size. */
/*******************************************************************/ /*******************************************************************/
if (Pof) if (Pof)
Pof[lt - Pex] = Pof[(jj - 1) - Pex] = jj - lt; Pof[lt - Pex] = Pof[(jj - 1) - Pex] = (int)(jj - lt);
/*******************************************************************/ /*******************************************************************/
/* Look at sizes of the two partitions, do the smaller one first */ /* Look at sizes of the two partitions, do the smaller one first */
@@ -862,8 +862,8 @@ void CSORT::Qstc(int *base, int *max)
/* But only repeat (recursively or by branching) if the partition */ /* But only repeat (recursively or by branching) if the partition */
/* is of at least size THRESH. */ /* is of at least size THRESH. */
/*******************************************************************/ /*******************************************************************/
lo = lt - base; lo = (int)(lt - base);
hi = gt - Swix; hi = (int)(gt - Swix);
if (Dup) { // Update progress information if (Dup) { // Update progress information
zlo = Cmpnum(lo); zlo = Cmpnum(lo);

View File

@@ -13,6 +13,7 @@
#elif defined(MSX4) #elif defined(MSX4)
#import "msxml4.dll" //Causes error C2872: DOMNodeType: ambiguous symbol ?? #import "msxml4.dll" //Causes error C2872: DOMNodeType: ambiguous symbol ??
#elif defined(MSX6) #elif defined(MSX6)
#pragma warning(suppress : 4192)
#import "msxml6.dll" //Causes error C2872: DOMNodeType: ambiguous symbol ?? #import "msxml6.dll" //Causes error C2872: DOMNodeType: ambiguous symbol ??
#else // MSX4 #else // MSX4
#error MSX? is not defined #error MSX? is not defined
@@ -540,7 +541,7 @@ PXNODE DOMNODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
// If name has the format m[n] only m is taken as node name // If name has the format m[n] only m is taken as node name
if ((p = strchr(name, '['))) if ((p = strchr(name, '[')))
pn = BufAlloc(g, name, p - name); pn = BufAlloc(g, name, (int)(p - name));
else else
pn = name; pn = name;

View File

@@ -247,7 +247,7 @@ int MAPFAM::GetRowID(void)
/***********************************************************************/ /***********************************************************************/
int MAPFAM::GetPos(void) int MAPFAM::GetPos(void)
{ {
return Fpos - Memory; return (int)(Fpos - Memory);
} // end of GetPos } // end of GetPos
/***********************************************************************/ /***********************************************************************/
@@ -255,7 +255,7 @@ int MAPFAM::GetPos(void)
/***********************************************************************/ /***********************************************************************/
int MAPFAM::GetNextPos(void) int MAPFAM::GetNextPos(void)
{ {
return Mempos - Memory; return (int)(Mempos - Memory);
} // end of GetNextPos } // end of GetNextPos
/***********************************************************************/ /***********************************************************************/
@@ -368,7 +368,7 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
} // endif Mempos } // endif Mempos
// Set caller line buffer // Set caller line buffer
len = (Mempos - Fpos) - n; len = (int)(Mempos - Fpos) - n;
// Don't rely on ENDING setting // Don't rely on ENDING setting
if (len > 0 && *(Mempos - 2) == '\r') if (len > 0 && *(Mempos - 2) == '\r')
@@ -428,7 +428,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
/* not required here, just setting of future Spos and Tpos. */ /* not required here, just setting of future Spos and Tpos. */
/*******************************************************************/ /*******************************************************************/
Tpos = Spos = Fpos; Tpos = Spos = Fpos;
} else if ((n = Fpos - Spos) > 0) { } else if ((n = (int)(Fpos - Spos)) > 0) {
/*******************************************************************/ /*******************************************************************/
/* Non consecutive line to delete. Move intermediate lines. */ /* Non consecutive line to delete. Move intermediate lines. */
/*******************************************************************/ /*******************************************************************/
@@ -461,7 +461,7 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
/*****************************************************************/ /*****************************************************************/
/* Remove extra records. */ /* Remove extra records. */
/*****************************************************************/ /*****************************************************************/
n = Tpos - Memory; n = (int)(Tpos - Memory);
#if defined(__WIN__) #if defined(__WIN__)
DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN);
@@ -627,7 +627,7 @@ int MBKFAM::ReadBuffer(PGLOBAL g)
break; break;
// Set caller line buffer // Set caller line buffer
len = (Mempos - Fpos) - Ending; len = (int)(Mempos - Fpos) - Ending;
memcpy(Tdbp->GetLine(), Fpos, len); memcpy(Tdbp->GetLine(), Fpos, len);
Tdbp->GetLine()[len] = '\0'; Tdbp->GetLine()[len] = '\0';
return RC_OK; return RC_OK;

View File

@@ -537,7 +537,7 @@ int ZBKFAM::ReadBuffer(PGLOBAL g)
while (*NxtLine++ != '\n') ; while (*NxtLine++ != '\n') ;
// Set caller line buffer // Set caller line buffer
n = NxtLine - CurLine - Ending; n = (int)(NxtLine - CurLine - Ending);
memcpy(Tdbp->GetLine(), CurLine, n); memcpy(Tdbp->GetLine(), CurLine, n);
Tdbp->GetLine()[n] = '\0'; Tdbp->GetLine()[n] = '\0';
return RC_OK; return RC_OK;
@@ -588,7 +588,7 @@ int ZBKFAM::ReadBuffer(PGLOBAL g)
for (NxtLine = CurLine; *NxtLine++ != '\n';) ; for (NxtLine = CurLine; *NxtLine++ != '\n';) ;
// Set caller line buffer // Set caller line buffer
n = NxtLine - CurLine - Ending; n = (int)(NxtLine - CurLine - Ending);
memcpy(Tdbp->GetLine(), CurLine, n); memcpy(Tdbp->GetLine(), CurLine, n);
Tdbp->GetLine()[n] = '\0'; Tdbp->GetLine()[n] = '\0';
Rbuf = (CurBlk == Block - 1) ? Last : Nrec; Rbuf = (CurBlk == Block - 1) ? Last : Nrec;
@@ -1087,7 +1087,7 @@ bool ZLBFAM::SetPos(PGLOBAL g, int pos __attribute__((unused)))
/***********************************************************************/ /***********************************************************************/
int ZLBFAM::ReadBuffer(PGLOBAL g) int ZLBFAM::ReadBuffer(PGLOBAL g)
{ {
int n; size_t n;
void *rdbuf; void *rdbuf;
/*********************************************************************/ /*********************************************************************/
@@ -1299,7 +1299,7 @@ int ZLBFAM::WriteBuffer(PGLOBAL g)
else else
NxtLine = CurLine + Lrecl; NxtLine = CurLine + Lrecl;
BlkLen = NxtLine - To_Buf; BlkLen = (int)(NxtLine - To_Buf);
if (WriteCompressedBuffer(g)) { if (WriteCompressedBuffer(g)) {
Closing = TRUE; // To tell CloseDB about a Write error Closing = TRUE; // To tell CloseDB about a Write error

View File

@@ -1351,7 +1351,7 @@ int BLKFAM::GetPos(void)
/***********************************************************************/ /***********************************************************************/
int BLKFAM::GetNextPos(void) int BLKFAM::GetNextPos(void)
{ {
return Fpos + NxtLine - CurLine; return (int)(Fpos + NxtLine - CurLine);
} // end of GetNextPos } // end of GetNextPos
/***********************************************************************/ /***********************************************************************/
@@ -1396,7 +1396,8 @@ int BLKFAM::SkipRecord(PGLOBAL, bool header)
/***********************************************************************/ /***********************************************************************/
int BLKFAM::ReadBuffer(PGLOBAL g) int BLKFAM::ReadBuffer(PGLOBAL g)
{ {
int i, n, rc = RC_OK; int i, rc = RC_OK;
size_t n;
/*********************************************************************/ /*********************************************************************/
/* Sequential reading when Placed is not true. */ /* Sequential reading when Placed is not true. */
@@ -1458,7 +1459,7 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
// Read the entire next block // Read the entire next block
n = fread(To_Buf, 1, (size_t)BlkLen, Stream); n = fread(To_Buf, 1, (size_t)BlkLen, Stream);
if (n == BlkLen) { if ((size_t) n == (size_t) BlkLen) {
// ReadBlks++; // ReadBlks++;
num_read++; num_read++;
Rbuf = (CurBlk == Block - 1) ? Last : Nrec; Rbuf = (CurBlk == Block - 1) ? Last : Nrec;
@@ -1497,7 +1498,7 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
fin: fin:
// Store the current record file position for Delete and Update // Store the current record file position for Delete and Update
Fpos = BlkPos[CurBlk] + CurLine - To_Buf; Fpos = (int)(BlkPos[CurBlk] + CurLine - To_Buf);
return rc; return rc;
} // end of ReadBuffer } // end of ReadBuffer
@@ -1524,7 +1525,7 @@ int BLKFAM::WriteBuffer(PGLOBAL g)
// Now start the writing process. // Now start the writing process.
NxtLine = CurLine + strlen(CurLine); NxtLine = CurLine + strlen(CurLine);
BlkLen = NxtLine - To_Buf; BlkLen = (int)(NxtLine - To_Buf);
if (fwrite(To_Buf, 1, BlkLen, Stream) != (size_t)BlkLen) { if (fwrite(To_Buf, 1, BlkLen, Stream) != (size_t)BlkLen) {
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno)); sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno));

View File

@@ -748,7 +748,7 @@ UNZFAM::UNZFAM(PUNZFAM txfp) : MAPFAM(txfp)
/***********************************************************************/ /***********************************************************************/
int UNZFAM::GetFileLength(PGLOBAL g) int UNZFAM::GetFileLength(PGLOBAL g)
{ {
int len = (zutp && zutp->entryopen) ? Top - Memory int len = (zutp && zutp->entryopen) ? (int)(Top - Memory)
: TXTFAM::GetFileLength(g) * 3; : TXTFAM::GetFileLength(g) * 3;
if (trace(1)) if (trace(1))
@@ -1088,7 +1088,7 @@ int ZIPFAM::WriteBuffer(PGLOBAL g)
// Prepare to write the new line // Prepare to write the new line
strcat(strcpy(To_Buf, Tdbp->GetLine()), (Bin) ? CrLf : "\n"); strcat(strcpy(To_Buf, Tdbp->GetLine()), (Bin) ? CrLf : "\n");
len = strchr(To_Buf, '\n') - To_Buf + 1; len = (int)(strchr(To_Buf, '\n') - To_Buf + 1);
return zutp->writeEntry(g, To_Buf, len); return zutp->writeEntry(g, To_Buf, len);
} // end of WriteBuffer } // end of WriteBuffer

View File

@@ -84,7 +84,7 @@ BYTE OpBmp(PGLOBAL g, OPVAL opc)
case OP_EXIST: bt = 0x00; break; case OP_EXIST: bt = 0x00; break;
default: default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc); sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
throw (int)TYPE_ARRAY; throw (int)TYPE_FILTER;
} // endswitch opc } // endswitch opc
return bt; return bt;
@@ -1707,7 +1707,7 @@ PFIL PrepareFilter(PGLOBAL g, PFIL fp, bool having)
break; // Remove eventual ending separator(s) break; // Remove eventual ending separator(s)
// if (fp->Convert(g, having)) // if (fp->Convert(g, having))
// (int)throw TYPE_ARRAY; // throw (int)TYPE_FILTER;
filp = fp; filp = fp;
fp = fp->Next; fp = fp->Next;

View File

@@ -283,7 +283,7 @@ static void yy_fatal_error YY_PROTO(( const char msg[] ));
*/ */
#define YY_DO_BEFORE_ACTION \ #define YY_DO_BEFORE_ACTION \
yytext_ptr = yy_bp; \ yytext_ptr = yy_bp; \
yyleng = yy_cp - yy_bp; \ yyleng = (int)(yy_cp - yy_bp); \
yy_hold_char = *yy_cp; \ yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \ *yy_cp = '\0'; \
yy_c_buf_p = yy_cp; yy_c_buf_p = yy_cp;
@@ -417,10 +417,10 @@ static PDTP pp;
static void MakeParm(int n); static void MakeParm(int n);
static void MakeMMDD(int n); static void MakeMMDD(int n);
static void MakeAMPM(int n); static void MakeAMPM(int n);
static void MakeIn(char *); static void MakeIn(const char *);
static void MakeOut(char *); static void MakeOut(const char *);
static void Quotin(char *); static void Quotin(const char *);
static void Quotout(char *); static void Quotout(const char *);
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
@@ -529,7 +529,7 @@ YY_DECL
pp->Num = 0; pp->Num = 0;
if (pp->InFmt) {*pp->InFmt = '\0'; pp->InFmt[pp->Outsize -1] = '\0'; } if (pp->InFmt) {*pp->InFmt = '\0'; pp->InFmt[pp->Outsize -1] = '\0'; }
if (pp->OutFmt) {*pp->OutFmt = '\0'; pp->OutFmt[pp->Outsize -1] = '\0'; } if (pp->OutFmt) {*pp->OutFmt = '\0'; pp->OutFmt[pp->Outsize -1] = '\0'; }
pp->Curp = pp->Format; pp->Curp = (char*) pp->Format;
yy_init = 1; /* This is a new input */ yy_init = 1; /* This is a new input */
@@ -695,7 +695,7 @@ case YY_STATE_EOF(dqt):
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
/* Amount of text matched not including the EOB char. */ /* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1; int yy_amount_of_matched_text = (int)(yy_cp - yytext_ptr - 1);
/* Undo the effects of YY_DO_BEFORE_ACTION. */ /* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = yy_hold_char; *yy_cp = yy_hold_char;
@@ -862,7 +862,7 @@ static int yy_get_next_buffer()
/* Try to read more data. */ /* Try to read more data. */
/* First move last chars to start of buffer. */ /* First move last chars to start of buffer. */
number_to_move = yy_c_buf_p - yytext_ptr; number_to_move = (int)(yy_c_buf_p - yytext_ptr);
for ( i = 0; i < number_to_move; ++i ) for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++); *(dest++) = *(source++);
@@ -888,7 +888,7 @@ static int yy_get_next_buffer()
/* just a shorter name for the current buffer */ /* just a shorter name for the current buffer */
YY_BUFFER_STATE b = yy_current_buffer; YY_BUFFER_STATE b = yy_current_buffer;
int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf; int yy_c_buf_p_offset = (int)(yy_c_buf_p - b->yy_ch_buf);
b->yy_buf_size *= 2; b->yy_buf_size *= 2;
b->yy_ch_buf = (char *) b->yy_ch_buf = (char *)
@@ -1492,7 +1492,7 @@ void MakeAMPM(int n)
} /* end of MakeAMPM */ } /* end of MakeAMPM */
void MakeIn(char *text) void MakeIn(const char *text)
{ {
if (!pp->InFmt) if (!pp->InFmt)
return; return;
@@ -1500,14 +1500,14 @@ void MakeIn(char *text)
strncat(pp->InFmt, text, (pp->Outsize - 1) - strlen(pp->InFmt)); strncat(pp->InFmt, text, (pp->Outsize - 1) - strlen(pp->InFmt));
} /* end of MakeIn */ } /* end of MakeIn */
void MakeOut(char *text) void MakeOut(const char *text)
{ {
if (!pp->OutFmt) return; if (!pp->OutFmt) return;
strncat(pp->OutFmt, text, (pp->Outsize - 1) - strlen(pp->OutFmt)); strncat(pp->OutFmt, text, (pp->Outsize - 1) - strlen(pp->OutFmt));
} /* end of MakeOut */ } /* end of MakeOut */
void Quotin(char *text) void Quotin(const char *text)
{ {
if (!pp->InFmt) if (!pp->InFmt)
return; return;
@@ -1516,7 +1516,7 @@ void Quotin(char *text)
pp->InFmt[strlen(pp->InFmt)-1] = '\0'; pp->InFmt[strlen(pp->InFmt)-1] = '\0';
} /* end of Quotin */ } /* end of Quotin */
void Quotout(char *text) void Quotout(const char *text)
{ {
if (!pp->OutFmt) if (!pp->OutFmt)
return; return;

View File

@@ -220,7 +220,7 @@ DllExport BOOL PlugIsAbsolutePath(LPCSTR path);
DllExport bool AllocSarea(PGLOBAL, uint); DllExport bool AllocSarea(PGLOBAL, uint);
DllExport void FreeSarea(PGLOBAL); DllExport void FreeSarea(PGLOBAL);
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
DllExport char *PlugDup(PGLOBAL g, const char *str); DllExport char *PlugDup(PGLOBAL g, const char *str);
DllExport void *MakePtr(void *, OFFSET); DllExport void *MakePtr(void *, OFFSET);
DllExport void htrc(char const *fmt, ...); DllExport void htrc(char const *fmt, ...);

View File

@@ -99,7 +99,7 @@
ha_connect::extra() are hints as to what will be occuring to the request. ha_connect::extra() are hints as to what will be occuring to the request.
Author Olivier Bertrand Author Olivier Bertrand
*/ */
#ifdef USE_PRAGMA_IMPLEMENTATION #ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation #pragma implementation // gcc: Class implementation
@@ -425,7 +425,7 @@ handlerton *connect_hton= NULL;
/* Function to export session variable values to other source files. */ /* Function to export session variable values to other source files. */
/***********************************************************************/ /***********************************************************************/
uint GetTraceValue(void) uint GetTraceValue(void)
{return connect_hton ? THDVAR(current_thd, xtrace) : 0;} {return (uint)(connect_hton ? THDVAR(current_thd, xtrace) : 0);}
bool ExactInfo(void) {return THDVAR(current_thd, exact_info);} bool ExactInfo(void) {return THDVAR(current_thd, exact_info);}
USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);} USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);}
int GetConvSize(void) {return THDVAR(current_thd, conv_size);} int GetConvSize(void) {return THDVAR(current_thd, conv_size);}
@@ -1108,16 +1108,16 @@ PCSZ GetListOption(PGLOBAL g, PCSZ opname, PCSZ oplist, PCSZ def)
return (char*)def; return (char*)def;
char key[16], val[256]; char key[16], val[256];
char *pv, *pn, *pk= (char*)oplist; char *pv, *pn, *pk = (char*)oplist;
PCSZ opval= def; PCSZ opval = def;
int n; int n;
while (*pk == ' ') while (*pk == ' ')
pk++; pk++;
for (; pk; pk= pn) { for (; pk; pk = pn) {
pn= strchr(pk, ','); pn = strchr(pk, ',');
pv= strchr(pk, '='); pv = strchr(pk, '=');
if (pv && (!pn || pv < pn)) { if (pv && (!pn || pv < pn)) {
n = MY_MIN(static_cast<size_t>(pv - pk), sizeof(key) - 1); n = MY_MIN(static_cast<size_t>(pv - pk), sizeof(key) - 1);
@@ -1126,35 +1126,35 @@ PCSZ GetListOption(PGLOBAL g, PCSZ opname, PCSZ oplist, PCSZ def)
while (n && key[n - 1] == ' ') while (n && key[n - 1] == ' ')
n--; n--;
key[n]= 0; key[n] = 0;
while(*(++pv) == ' ') ; while (*(++pv) == ' ');
n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1); n = MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1);
memcpy(val, pv, n); memcpy(val, pv, n);
while (n && val[n - 1] == ' ') while (n && val[n - 1] == ' ')
n--; n--;
val[n]= 0; val[n] = 0;
} else { } else {
n= MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1); n = MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1);
memcpy(key, pk, n); memcpy(key, pk, n);
while (n && key[n - 1] == ' ') while (n && key[n - 1] == ' ')
n--; n--;
key[n]= 0; key[n] = 0;
val[0]= 0; val[0] = 0;
} // endif pv } // endif pv
if (!stricmp(opname, key)) { if (!stricmp(opname, key)) {
opval= PlugDup(g, val); opval = PlugDup(g, val);
break; break;
} else if (!pn) } else if (!pn)
break; break;
while (*(++pn) == ' ') ; while (*(++pn) == ' ');
} // endfor pk } // endfor pk
return opval; return opval;
@@ -4391,24 +4391,23 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
return true; return true;
} // endif path } // endif path
}
} // endif !quick
} else } else
return false; return false;
/* Fall through to check FILE_ACL */ // Fall through
case TAB_ODBC:
case TAB_JDBC:
case TAB_MYSQL: case TAB_MYSQL:
case TAB_MONGO:
case TAB_DIR: case TAB_DIR:
case TAB_MAC:
case TAB_WMI:
case TAB_ZIP: case TAB_ZIP:
case TAB_OEM: case TAB_OEM:
#ifdef NO_EMBEDDED_ACCESS_CHECKS #ifdef NO_EMBEDDED_ACCESS_CHECKS
return false; return false;
#endif #endif
/* /*
Check FILE_ACL
If table or table->mdl_ticket is NULL - it's a DLL, e.g. CREATE TABLE. If table or table->mdl_ticket is NULL - it's a DLL, e.g. CREATE TABLE.
if the table has an MDL_EXCLUSIVE lock - it's a DDL too, e.g. the if the table has an MDL_EXCLUSIVE lock - it's a DDL too, e.g. the
insert step of CREATE ... SELECT. insert step of CREATE ... SELECT.
@@ -4422,21 +4421,28 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
*/ */
if (!table || !table->mdl_ticket || table->mdl_ticket->get_type() == MDL_EXCLUSIVE) if (!table || !table->mdl_ticket || table->mdl_ticket->get_type() == MDL_EXCLUSIVE)
return check_access(thd, FILE_ACL, db, NULL, NULL, 0, 0); return check_access(thd, FILE_ACL, db, NULL, NULL, 0, 0);
if ((!quick && thd->lex->requires_prelocking()) || table->grant.privilege & FILE_ACL) if ((!quick && thd->lex->requires_prelocking()) || table->grant.privilege & FILE_ACL)
return false; return false;
status_var_increment(thd->status_var.access_denied_errors); status_var_increment(thd->status_var.access_denied_errors);
my_error(access_denied_error_code(thd->password), MYF(0), my_error(access_denied_error_code(thd->password), MYF(0),
thd->security_ctx->priv_user, thd->security_ctx->priv_host, thd->security_ctx->priv_user, thd->security_ctx->priv_host,
(thd->password ? ER(ER_YES) : ER(ER_NO))); (thd->password ? ER(ER_YES) : ER(ER_NO)));
return true; return true;
case TAB_ODBC:
// This is temporary until a solution is found case TAB_JDBC:
case TAB_MONGO:
case TAB_MAC:
case TAB_WMI:
return false;
case TAB_TBL: case TAB_TBL:
case TAB_XCL: case TAB_XCL:
case TAB_PRX: case TAB_PRX:
case TAB_OCCUR: case TAB_OCCUR:
case TAB_PIVOT: case TAB_PIVOT:
case TAB_VIR: case TAB_VIR:
// This is temporary until a solution is found
return false; return false;
} // endswitch type } // endswitch type
@@ -5629,7 +5635,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#endif // JAVA_SUPPORT #endif // JAVA_SUPPORT
case TAB_DBF: case TAB_DBF:
dbf = true; dbf = true;
// Passthru // fall through
case TAB_CSV: case TAB_CSV:
if (!fn && fnc != FNC_NO) if (!fn && fnc != FNC_NO)
sprintf(g->Message, "Missing %s file name", topt->type); sprintf(g->Message, "Missing %s file name", topt->type);

View File

@@ -165,7 +165,7 @@ int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
break; break;
case 92: // TIME case 92: // TIME
type = TYPE_DATE; type = TYPE_DATE;
len = 8 + ((prec) ? (prec+1) : 0); len = 8 + ((prec) ? (prec + 1) : 0);
v = 'T'; v = 'T';
break; break;
case -5: // BIGINT case -5: // BIGINT

View File

@@ -165,7 +165,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
}; // endswitch s[i] }; // endswitch s[i]
if (!jsp) if (!jsp)
sprintf(g->Message, "Invalid Json string '%.*s'", 50, s); sprintf(g->Message, "Invalid Json string '%.*s'", MY_MIN(len, 50), s);
else if (ptyp && pretty == 3) { else if (ptyp && pretty == 3) {
*ptyp = 3; // Not recognized pretty *ptyp = 3; // Not recognized pretty
@@ -1015,6 +1015,20 @@ PJAR JOBJECT::GetKeyList(PGLOBAL g)
return jarp; return jarp;
} // end of GetKeyList } // end of GetKeyList
/***********************************************************************/
/* Return all values as an array. */
/***********************************************************************/
PJAR JOBJECT::GetValList(PGLOBAL g)
{
PJAR jarp = new(g) JARRAY();
for (PJPR jpp = First; jpp; jpp = jpp->Next)
jarp->AddValue(g, jpp->GetVal());
jarp->InitArray(g);
return jarp;
} // end of GetValList
/***********************************************************************/ /***********************************************************************/
/* Get the value corresponding to the given key. */ /* Get the value corresponding to the given key. */
/***********************************************************************/ /***********************************************************************/
@@ -1224,6 +1238,7 @@ PJVAL JARRAY::AddValue(PGLOBAL g, PJVAL jvp, int *x)
Last->Next = jvp; Last->Next = jvp;
Last = jvp; Last = jvp;
Last->Next = NULL;
} // endif x } // endif x
return jvp; return jvp;
@@ -1318,6 +1333,24 @@ bool JARRAY::IsNull(void)
/* -------------------------- Class JVALUE- -------------------------- */ /* -------------------------- Class JVALUE- -------------------------- */
/***********************************************************************/
/* Constructor for a JSON. */
/***********************************************************************/
JVALUE::JVALUE(PJSON jsp) : JSON()
{
if (jsp->GetType() == TYPE_JVAL) {
Jsp = jsp->GetJsp();
Value = jsp->GetValue();
} else {
Jsp = jsp;
Value = NULL;
} // endif Type
Next = NULL;
Del = false;
Size = 1;
} // end of JVALUE constructor
/***********************************************************************/ /***********************************************************************/
/* Constructor for a Value with a given string or numeric value. */ /* Constructor for a Value with a given string or numeric value. */
/***********************************************************************/ /***********************************************************************/

View File

@@ -20,7 +20,8 @@ enum JTYP {TYPE_NULL = TYPE_VOID,
TYPE_BINT = TYPE_BIGINT, TYPE_BINT = TYPE_BIGINT,
TYPE_DTM = TYPE_DATE, TYPE_DTM = TYPE_DATE,
TYPE_INTG = TYPE_INT, TYPE_INTG = TYPE_INT,
TYPE_JSON = 12, TYPE_VAL = 12,
TYPE_JSON,
TYPE_JAR, TYPE_JAR,
TYPE_JOB, TYPE_JOB,
TYPE_JVAL}; TYPE_JVAL};
@@ -157,6 +158,7 @@ class JSON : public BLOCK {
//virtual PJVAL AddValue(PGLOBAL g, PJVAL jvp = NULL, int *x = NULL) {X return NULL;} //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 PJPR AddPair(PGLOBAL g, PCSZ key) {X return NULL;}
virtual PJAR GetKeyList(PGLOBAL g) {X return NULL;} 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 PJVAL GetValue(const char *key) {X return NULL;}
virtual PJOB GetObject(void) {return NULL;} virtual PJOB GetObject(void) {return NULL;}
virtual PJAR GetArray(void) {return NULL;} virtual PJAR GetArray(void) {return NULL;}
@@ -205,6 +207,7 @@ class JOBJECT : public JSON {
virtual PJOB GetObject(void) {return this;} virtual PJOB GetObject(void) {return this;}
virtual PJVAL GetValue(const char* key); virtual PJVAL GetValue(const char* key);
virtual PJAR GetKeyList(PGLOBAL g); virtual PJAR GetKeyList(PGLOBAL g);
virtual PJAR GetValList(PGLOBAL g);
virtual PSZ GetText(PGLOBAL g, PSZ text); virtual PSZ GetText(PGLOBAL g, PSZ text);
virtual bool Merge(PGLOBAL g, PJSON jsp); virtual bool Merge(PGLOBAL g, PJSON jsp);
virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key); virtual void SetValue(PGLOBAL g, PJVAL jvp, PCSZ key);
@@ -258,8 +261,7 @@ class JVALUE : public JSON {
friend bool SerializeValue(JOUT *, PJVAL); friend bool SerializeValue(JOUT *, PJVAL);
public: public:
JVALUE(void) : JSON() {Clear();} JVALUE(void) : JSON() {Clear();}
JVALUE(PJSON jsp) : JSON() JVALUE(PJSON jsp);
{Jsp = jsp; Value = NULL; Next = NULL; Del = false; Size = 1;}
JVALUE(PGLOBAL g, PVAL valp); JVALUE(PGLOBAL g, PVAL valp);
JVALUE(PGLOBAL g, PCSZ strp); JVALUE(PGLOBAL g, PCSZ strp);

File diff suppressed because it is too large Load Diff

View File

@@ -89,6 +89,10 @@ extern "C" {
DllExport char *json_object_list(UDF_EXEC_ARGS); DllExport char *json_object_list(UDF_EXEC_ARGS);
DllExport void json_object_list_deinit(UDF_INIT*); DllExport void json_object_list_deinit(UDF_INIT*);
DllExport my_bool json_object_values_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_object_values(UDF_EXEC_ARGS);
DllExport void json_object_values_deinit(UDF_INIT*);
DllExport my_bool jsonset_grp_size_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsonset_grp_size_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long jsonset_grp_size(UDF_INIT*, UDF_ARGS*, char*, char*); DllExport long long jsonset_grp_size(UDF_INIT*, UDF_ARGS*, char*, char*);

View File

@@ -230,13 +230,13 @@ bool MACINFO::GetOneInfo(PGLOBAL g, int flag, void *v, int lv)
case 11: // Description case 11: // Description
if ((p = strstr(Curp->Description, " - Packet Scheduler Miniport"))) { if ((p = strstr(Curp->Description, " - Packet Scheduler Miniport"))) {
strncpy(buf, Curp->Description, p - Curp->Description); strncpy(buf, Curp->Description, p - Curp->Description);
i = p - Curp->Description; i = (int)(p - Curp->Description);
strncpy(buf, Curp->Description, i); strncpy(buf, Curp->Description, i);
buf[i] = 0; buf[i] = 0;
p = buf; p = buf;
} else if ((p = strstr(Curp->Description, } else if ((p = strstr(Curp->Description,
" - Miniport d'ordonnancement de paquets"))) { " - Miniport d'ordonnancement de paquets"))) {
i = p - Curp->Description; i = (int)(p - Curp->Description);
strncpy(buf, Curp->Description, i); strncpy(buf, Curp->Description, i);
buf[i] = 0; buf[i] = 0;
p = buf; p = buf;

View File

@@ -248,7 +248,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
while (true) { while (true) {
p2 = strchr(p1, '\''); p2 = strchr(p1, '\'');
len = MY_MAX(len, p2 - p1); len = MY_MAX(len, (int)(p2 - p1));
if (*++p2 != ',') break; if (*++p2 != ',') break;
p1 = p2 + 2; p1 = p2 + 2;
} // endwhile } // endwhile
@@ -933,8 +933,9 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM) crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM)
? fld->decimals : 0; ? fld->decimals : 0;
crp->Length = MY_MAX(fld->length, fld->max_length); CHARSET_INFO *cs= get_charset(fld->charsetnr, MYF(0));
crp->Clen = GetTypeSize(crp->Type, crp->Length); crp->Clen = GetTypeSize(crp->Type, fld->length);
crp->Length = fld->length / (cs ? cs->mbmaxlen : 1);
uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false; uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false;
if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows, if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows,

View File

@@ -50,17 +50,19 @@ SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL), 'One more') Arra
Array Array
[56,3.141600,"foo",null,"One more"] [56,3.141600,"foo",null,"One more"]
SELECT Json_Array_Add(JsonValue('one value'), 'One more'); SELECT Json_Array_Add(JsonValue('one value'), 'One more');
ERROR HY000: Can't initialize function 'json_array_add'; First argument must be a json item Json_Array_Add(JsonValue('one value'), 'One more')
["\"one value\"","One more"]
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'; First argument must be a json item Json_Array_Add('one value', 'One more')
["one value","One more"]
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')
one value one value
Warnings: Warnings:
Warning 1105 Error 2 opening one value Warning 1105 Error 2 opening one value
Warning 1105 First argument target is not an array
SELECT Json_Array_Add(5 json_, 'One more'); SELECT Json_Array_Add(5 json_, 'One more');
ERROR HY000: Can't initialize function 'json_array_add'; First argument must be a json item Json_Array_Add(5 json_, 'One more')
[5,"One more"]
SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 0); SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 0);
Json_Array_Add('[5,3,8,7,9]' json_, 4, 0) Json_Array_Add('[5,3,8,7,9]' json_, 4, 0)
[4,5,3,8,7,9] [4,5,3,8,7,9]

View File

@@ -272,10 +272,9 @@ Json_Serialize(Jbin_Array('a','b','c'))
["a","b","c"] ["a","b","c"]
SELECT Json_Serialize(Jbin_Array_Add(Jbin_File('not_exist.json'), 'd')); SELECT Json_Serialize(Jbin_Array_Add(Jbin_File('not_exist.json'), 'd'));
Json_Serialize(Jbin_Array_Add(Jbin_File('not_exist.json'), 'd')) Json_Serialize(Jbin_Array_Add(Jbin_File('not_exist.json'), 'd'))
Null json tree [null,"d"]
Warnings: Warnings:
Warning 1105 Open(map) error 2 on not_exist.json Warning 1105 Open(map) error 2 on not_exist.json
Warning 1105 First argument is not an array
# This does not modify the file # This does not modify the file
SELECT Json_Serialize(Jbin_Array_Add(Jbin_File('bt1.json'), 'd')); SELECT Json_Serialize(Jbin_Array_Add(Jbin_File('bt1.json'), 'd'));
Json_Serialize(Jbin_Array_Add(Jbin_File('bt1.json'), 'd')) Json_Serialize(Jbin_Array_Add(Jbin_File('bt1.json'), 'd'))

View File

@@ -0,0 +1,29 @@
create table t1 (
#linenum int(6) not null default 0 special=rowid,
name char(12) not null,
city char(11) not null,
birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36,
agehired int(3) as (floor(datediff(hired,birth)/365.25))
)
engine=CONNECT table_type=FIX file_name='boys.txt' mapped=YES lrecl=47 ending=1;
select * from t1;
name city birth hired agehired
John Boston 1986-01-25 2010-06-02 24
Henry Boston 1987-06-07 2008-04-01 20
George San Jose 1981-08-10 2010-06-02 28
Sam Chicago 1979-11-22 2007-10-10 27
James Dallas 1992-05-13 2009-12-14 17
Bill Boston 1986-09-11 2008-02-10 21
drop table t1;
create table t1 (
#linenum int(6) not null default 0 special=rowid,
name char(12) not null,
city char(11) not null,
birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36,
agehired int(3) as (floor(datediff(hired,birth)/365.25)),
index (agehired)
)
engine=CONNECT table_type=FIX file_name='boys.txt' mapped=YES lrecl=47 ending=1;
ERROR 42000: Table handler doesn't support NULL in given index. Please change column 'agehired' to be NOT NULL or use another handler

View File

@@ -29,12 +29,12 @@ SELECT Json_Make_Array(Json_Make_Array(56, 3.1416, 'foo'), TRUE);
--error ER_CANT_INITIALIZE_UDF --error ER_CANT_INITIALIZE_UDF
SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL)) Array; SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL)) Array;
SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL), 'One more') Array; SELECT Json_Array_Add(Json_Make_Array(56, 3.1416, 'foo', NULL), 'One more') Array;
--error ER_CANT_INITIALIZE_UDF #--error ER_CANT_INITIALIZE_UDF
SELECT Json_Array_Add(JsonValue('one value'), 'One more'); 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_Array_Add(5 json_, 'One more'); SELECT Json_Array_Add(5 json_, 'One more');
SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 0); SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 0);
SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 2) Array; SELECT Json_Array_Add('[5,3,8,7,9]' json_, 4, 2) Array;

View File

@@ -0,0 +1,31 @@
let datadir= `select @@datadir`;
--copy_file $MTR_SUITE_DIR/std_data/boys.txt $datadir/test/boys.txt
create table t1 (
#linenum int(6) not null default 0 special=rowid,
name char(12) not null,
city char(11) not null,
birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36,
agehired int(3) as (floor(datediff(hired,birth)/365.25))
)
engine=CONNECT table_type=FIX file_name='boys.txt' mapped=YES lrecl=47 ending=1;
select * from t1;
drop table t1;
--error ER_NULL_COLUMN_IN_INDEX
create table t1 (
#linenum int(6) not null default 0 special=rowid,
name char(12) not null,
city char(11) not null,
birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36,
agehired int(3) as (floor(datediff(hired,birth)/365.25)),
index (agehired)
)
engine=CONNECT table_type=FIX file_name='boys.txt' mapped=YES lrecl=47 ending=1;
#
# Clean up
#
--remove_file $datadir/test/boys.txt

View File

@@ -2261,10 +2261,10 @@ public:
return (SQLCHAR *) (m_part[i].length ? m_part[i].str : NULL); return (SQLCHAR *) (m_part[i].length ? m_part[i].str : NULL);
} // end of ptr } // end of ptr
size_t length(uint i) SQLSMALLINT length(uint i)
{ {
DBUG_ASSERT(i < max_parts); DBUG_ASSERT(i < max_parts);
return m_part[i].length; return (SQLSMALLINT)m_part[i].length;
} // end of length } // end of length
}; // end of class SQLQualifiedName }; // end of class SQLQualifiedName
@@ -2438,7 +2438,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
else if (vlen[n] == SQL_NULL_DATA) else if (vlen[n] == SQL_NULL_DATA)
pval[n]->SetNull(true); pval[n]->SetNull(true);
else if (crp->Type == TYPE_STRING/* && vlen[n] != SQL_NULL_DATA*/) else if (crp->Type == TYPE_STRING/* && vlen[n] != SQL_NULL_DATA*/)
pval[n]->SetValue_char(pbuf[n], vlen[n]); pval[n]->SetValue_char(pbuf[n], (int)vlen[n]);
else else
pval[n]->SetNull(false); pval[n]->SetNull(false);

View File

@@ -519,7 +519,7 @@ bool EvalLikePattern(LPCSTR sp, LPCSTR tp)
{ {
LPSTR p; LPSTR p;
char c; char c;
int n; ssize_t n;
bool b, t = false; bool b, t = false;
if (trace(2)) if (trace(2))

View File

@@ -162,7 +162,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
/*******************************************************************/ /*******************************************************************/
if (worksize && AllocSarea(g, worksize)) { if (worksize && AllocSarea(g, worksize)) {
char errmsg[MAX_STR]; char errmsg[MAX_STR];
sprintf(errmsg, MSG(WORK_AREA), g->Message); snprintf(errmsg, sizeof(errmsg) - 1, MSG(WORK_AREA), g->Message);
strcpy(g->Message, errmsg); strcpy(g->Message, errmsg);
} // endif Sarea } // endif Sarea

View File

@@ -8,7 +8,7 @@
/***********************************************************************/ /***********************************************************************/
typedef struct _datpar { typedef struct _datpar {
const char *Format; // Points to format to decode const char *Format; // Points to format to decode
char *Curp; // Points to current parsing position const char *Curp; // Points to current parsing position
char *InFmt; // Start of input format char *InFmt; // Start of input format
char *OutFmt; // Start of output format char *OutFmt; // Start of output format
int Index[8]; // Indexes of date values int Index[8]; // Indexes of date values

View File

@@ -27,9 +27,9 @@
char *msglang(void); char *msglang(void);
char *GetMsgid(int id) const char *GetMsgid(int id)
{ {
char *p = NULL; const char *p = NULL;
// This conditional until a real fix is found for MDEV-7304 // This conditional until a real fix is found for MDEV-7304
#if defined(FRENCH) #if defined(FRENCH)
@@ -55,7 +55,8 @@ char *GetMsgid(int id)
int GetRcString(int id, char *buf, int bufsize) int GetRcString(int id, char *buf, int bufsize)
{ {
char *p = NULL, msg[32]; const char *p = NULL;
char msg[32];
if (!(p = GetMsgid(id))) { if (!(p = GetMsgid(id))) {
sprintf(msg, "ID=%d unknown", id); sprintf(msg, "ID=%d unknown", id);

View File

@@ -5,7 +5,7 @@
extern "C" { extern "C" {
#endif #endif
char *GetMsgid(int id); const char *GetMsgid(int id);
int GetRcString(int id, char *buf, int bufsize); int GetRcString(int id, char *buf, int bufsize);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -547,10 +547,8 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
} // endif dladdr } // endif dladdr
#endif // 0 #endif // 0
// Is the library already loaded?
if (!Hdll && !(Hdll = dlopen(soname, RTLD_NOLOAD)))
// Load the desired shared library // Load the desired shared library
if (!(Hdll = dlopen(soname, RTLD_LAZY))) { if (!Hdll && !(Hdll = dlopen(soname, RTLD_LAZY))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error)); sprintf(g->Message, MSG(SHARED_LIB_ERR), soname, SVP(error));
return NULL; return NULL;

View File

@@ -2881,4 +2881,3 @@ bool DOSCOL::AddDistinctValue(PGLOBAL g)
} // end of AddDistinctValue } // end of AddDistinctValue
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */

View File

@@ -934,7 +934,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
if (p) { if (p) {
//len = p++ - p2; //len = p++ - p2;
len = p - p2 - 1;; len = (int)(p - p2 - 1);
// if (Sep != ' ') // if (Sep != ' ')
// for (; *p == ' '; p++) ; // Skip blanks // for (; *p == ' '; p++) ; // Skip blanks
@@ -978,7 +978,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
return RC_NF; return RC_NF;
} else if ((p = strchr(p2, Sep))) } else if ((p = strchr(p2, Sep)))
len = p - p2; len = (int)(p - p2);
else if (i == Fields - 1) else if (i == Fields - 1)
len = strlen(p2); len = strlen(p2);
else if (Accept && Maxerr == 0) { else if (Accept && Maxerr == 0) {
@@ -996,7 +996,7 @@ int TDBCSV::ReadBuffer(PGLOBAL g)
} else } else
len = 0; len = 0;
Offset[i] = p2 - To_Line; Offset[i] = (int)(p2 - To_Line);
if (Mode != MODE_UPDATE) if (Mode != MODE_UPDATE)
Fldlen[i] = len; Fldlen[i] = len;

View File

@@ -94,7 +94,7 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
return NULL; return NULL;
} // endif Multiple } // endif Multiple
pjdc = new(g) JSONDISC(g, (int*)length); pjdc = new(g) JSONDISC(g, length);
if (!(n = pjdc->GetColumns(g, db, dsn, topt))) if (!(n = pjdc->GetColumns(g, db, dsn, topt)))
return NULL; return NULL;
@@ -157,7 +157,7 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
/***********************************************************************/ /***********************************************************************/
/* Class used to get the columns of a JSON table. */ /* Class used to get the columns of a JSON table. */
/***********************************************************************/ /***********************************************************************/
JSONDISC::JSONDISC(PGLOBAL g, int *lg) JSONDISC::JSONDISC(PGLOBAL g, uint *lg)
{ {
length = lg; length = lg;
jcp = fjcp = pjcp = NULL; jcp = fjcp = pjcp = NULL;

View File

@@ -47,7 +47,7 @@ typedef struct _jncol {
class JSONDISC : public BLOCK { class JSONDISC : public BLOCK {
public: public:
// Constructor // Constructor
JSONDISC(PGLOBAL g, int *lg); JSONDISC(PGLOBAL g, uint *lg);
// Functions // Functions
int GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt); int GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt);
@@ -66,7 +66,7 @@ public:
PJOB row; PJOB row;
PCSZ sep; PCSZ sep;
char colname[65], fmt[129], buf[16]; char colname[65], fmt[129], buf[16];
int *length; uint *length;
int i, n, bf, ncol, lvl; int i, n, bf, ncol, lvl;
bool all; bool all;
}; // end of JSONDISC }; // end of JSONDISC

View File

@@ -367,13 +367,13 @@ void MACCOL::ReadColumn(PGLOBAL g)
case 11: // Description case 11: // Description
if ((p = strstr(adp->Description, " - Packet Scheduler Miniport"))) { if ((p = strstr(adp->Description, " - Packet Scheduler Miniport"))) {
strncpy(buf, adp->Description, p - adp->Description); strncpy(buf, adp->Description, p - adp->Description);
i = p - adp->Description; i = (int)(p - adp->Description);
strncpy(buf, adp->Description, i); strncpy(buf, adp->Description, i);
buf[i] = 0; buf[i] = 0;
p = buf; p = buf;
} else if ((p = strstr(adp->Description, } else if ((p = strstr(adp->Description,
" - Miniport d'ordonnancement de paquets"))) { " - Miniport d'ordonnancement de paquets"))) {
i = p - adp->Description; i = (int)(p - adp->Description);
strncpy(buf, adp->Description, i); strncpy(buf, adp->Description, i);
buf[i] = 0; buf[i] = 0;
p = buf; p = buf;

View File

@@ -203,12 +203,12 @@ bool TDBMUL::InitFileNames(PGLOBAL g)
// Data files can be imported from Windows (having CRLF) // Data files can be imported from Windows (having CRLF)
if (*p == '\n' || *p == '\r') { if (*p == '\n' || *p == '\r') {
// is this enough for Unix ??? // is this enough for Unix ???
*p--; // Eliminate ending CR or LF character p--; // Eliminate ending CR or LF character
if (p >= filename) if (p >= filename)
// is this enough for Unix ??? // is this enough for Unix ???
if (*p == '\n' || *p == '\r') if (*p == '\n' || *p == '\r')
*p--; // Eliminate ending CR or LF character p--; // Eliminate ending CR or LF character
} // endif p } // endif p

View File

@@ -124,8 +124,8 @@ bool MYSQLDEF::GetServerInfo(PGLOBAL g, const char *server_name)
DBUG_RETURN(true); DBUG_RETURN(true);
} // endif server } // endif server
DBUG_PRINT("info", ("get_server_by_name returned server at %lx", DBUG_PRINT("info", ("get_server_by_name returned server at %p",
(size_t) server)); server));
// TODO: We need to examine which of these can really be NULL // TODO: We need to examine which of these can really be NULL
Hostname = PlugDup(g, server->host); Hostname = PlugDup(g, server->host);
@@ -681,7 +681,7 @@ bool TDBMYSQL::MakeCommand(PGLOBAL g)
strlwr(strcpy(name, Name)); // Not a keyword strlwr(strcpy(name, Name)); // Not a keyword
if ((p = strstr(qrystr, name))) { if ((p = strstr(qrystr, name))) {
Query->Set(Qrystr, p - qrystr); Query->Set(Qrystr, (uint)(p - qrystr));
if (qtd && *(p-1) == ' ') { if (qtd && *(p-1) == ' ') {
Query->Append('`'); Query->Append('`');

View File

@@ -135,7 +135,7 @@ class TDBMYSQL : public TDBEXT {
int m_Rc; // Return code from command int m_Rc; // Return code from command
//int AftRows; // The number of affected rows //int AftRows; // The number of affected rows
int N; // The current table index int N; // The current table index
int Port; // MySQL port number (0 = default) unsigned Port; // MySQL port number (0 = default)
//int Nparm; // The number of statement parameters //int Nparm; // The number of statement parameters
//int Quoted; // The identifier quoting level //int Quoted; // The identifier quoting level
}; // end of class TDBMYSQL }; // end of class TDBMYSQL

View File

@@ -289,7 +289,7 @@ void TDBODBC::SetFile(PGLOBAL g, PCSZ fn)
sprintf(Connect, MulConn, fn); sprintf(Connect, MulConn, fn);
} // endif MultConn } // endif MultConn
DBQ = (PSZ)fn; DBQ = PlugDup(g, fn);
} // end of SetFile } // end of SetFile
/***********************************************************************/ /***********************************************************************/

View File

@@ -656,7 +656,7 @@ bool TDBTBM::IsLocal(PTABLE tbp)
return ((!stricmp(tdbp->Host, "localhost") || return ((!stricmp(tdbp->Host, "localhost") ||
!strcmp(tdbp->Host, "127.0.0.1")) && !strcmp(tdbp->Host, "127.0.0.1")) &&
tdbp->Port == (int)GetDefaultPort()); (int) tdbp->Port == (int)GetDefaultPort());
} // end of IsLocal } // end of IsLocal
/***********************************************************************/ /***********************************************************************/

View File

@@ -1374,7 +1374,7 @@ bool TYPVAL<PSZ>::SetValue_char(const char *cp, int n)
} else if (cp != Strp) { } else if (cp != Strp) {
const char *p = cp + n - 1; const char *p = cp + n - 1;
for (p; p >= cp; p--, n--) for (; p >= cp; p--, n--)
if (*p && *p != ' ') if (*p && *p != ' ')
break; break;
@@ -1747,7 +1747,7 @@ DECVAL::DECVAL(PSZ s) : TYPVAL<PSZ>(s)
if (s) { if (s) {
char *p = strchr(Strp, '.'); char *p = strchr(Strp, '.');
Prec = (p) ? Len - (p - Strp) : 0; Prec = (p) ? (int)(Len - (p - Strp)) : 0;
} // endif s } // endif s
Type = TYPE_DECIM; Type = TYPE_DECIM;
@@ -2656,7 +2656,7 @@ bool DTVAL::SetValue_char(const char *p, int n)
// Trim trailing blanks // Trim trailing blanks
for (p2 = p + n -1; p < p2 && *p2 == ' '; p2--); for (p2 = p + n -1; p < p2 && *p2 == ' '; p2--);
if ((rc = (n = p2 - p + 1) > Len)) if ((rc = (n = (int)(p2 - p + 1)) > Len))
n = Len; n = Len;
memcpy(Sdate, p, n); memcpy(Sdate, p, n);

View File

@@ -204,7 +204,7 @@ STRING::STRING(PGLOBAL g, uint n, PCSZ str)
*Strp = 0; *Strp = 0;
Next = GetNext(); Next = GetNext();
Size = Next - Strp; Size = (int)(Next - Strp);
Trc = false; Trc = false;
} else { } else {
// This should normally never happen // This should normally never happen
@@ -239,7 +239,7 @@ char *STRING::Realloc(uint len)
p = Strp; p = Strp;
Next = GetNext(); Next = GetNext();
Size = Next - p; Size = (int)(Next - p);
return p; return p;
} // end of Realloc } // end of Realloc
@@ -439,4 +439,3 @@ bool STRING::Resize(uint newsize)
return newsize > Size; return newsize > Size;
} // end of Resize } // end of Resize