Skip to content

Commit

Permalink
Merge branch 'ob-10.0' into 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Buggynours committed May 7, 2015
2 parents 7704fde + c387e7d commit 5fa2a6c
Show file tree
Hide file tree
Showing 22 changed files with 295 additions and 90 deletions.
Binary file added storage/connect/RelWithDebInfo/ha_connect.exp
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
1 change: 1 addition & 0 deletions storage/connect/connect.dir/RelWithDebInfo/mt.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
La ressource de manifeste a �t� mise � jour pour la derni�re fois � 15:30:20,49 le 24/04/2015
Binary file not shown.
Binary file not shown.
25 changes: 16 additions & 9 deletions storage/connect/filamdbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ typedef struct _descriptor {
/* Side effects: */
/* Moves file pointer to byte 32; fills buffer at buf with */
/* first 32 bytes of file. */
/* Converts numeric values to platform byte ordering (LE in file) */
/****************************************************************************/
static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
{
Expand Down Expand Up @@ -142,6 +143,11 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
} else
strcpy(g->Message, MSG(DBASE_FILE));

// Convert numeric fields to have them in platform byte ordering
buf->Records = uint4korr(&buf->Records);
buf->Headlen = uint2korr(&buf->Headlen);
buf->Reclen = uint2korr(&buf->Reclen);

// Check last byte(s) of header
if (fseek(file, buf->Headlen - dbc, SEEK_SET) != 0) {
sprintf(g->Message, MSG(BAD_HEADER), fn);
Expand Down Expand Up @@ -565,8 +571,8 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
header->Filedate[0] = datm->tm_year - 100;
header->Filedate[1] = datm->tm_mon + 1;
header->Filedate[2] = datm->tm_mday;
header->Headlen = (ushort)hlen;
header->Reclen = (ushort)reclen;
int2store(&header->Headlen, hlen);
int2store(&header->Reclen, reclen);
descp = (DESCRIPTOR*)header;

// Currently only standard Xbase types are supported
Expand Down Expand Up @@ -729,7 +735,7 @@ bool DBFFAM::CopyHeader(PGLOBAL g)
if (Headlen) {
void *hdr = PlugSubAlloc(g, NULL, Headlen);
size_t n, hlen = (size_t)Headlen;
int pos = ftell(Stream);
int pos = ftell(Stream);

if (fseek(Stream, 0, SEEK_SET))
strcpy(g->Message, "Seek error in CopyHeader");
Expand Down Expand Up @@ -863,13 +869,14 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)

if (n > Records) {
// Update the number of rows in the file header
char filename[_MAX_PATH];
char filename[_MAX_PATH], nRecords[4];

int4store(&nRecords, n);
PlugSetPath(filename, To_File, Tdbp->GetPath());
if ((Stream= global_fopen(g, MSGID_OPEN_MODE_STRERROR, filename, "r+b")))
{
fseek(Stream, 4, SEEK_SET); // Get header.Records position
fwrite(&n, sizeof(int), 1, Stream);
fwrite(nRecords, sizeof(nRecords), 1, Stream);
fclose(Stream);
Stream= NULL;
Records= n; // Update Records value
Expand Down Expand Up @@ -944,13 +951,13 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
/************************************************************************/
DBFHEADER *hp = (DBFHEADER*)Memory;

if (Lrecl != (int)hp->Reclen) {
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, hp->Reclen);
if (Lrecl != (int)uint2korr(&hp->Reclen)) {
sprintf(g->Message, MSG(BAD_LRECL), Lrecl, uint2korr(&hp->Reclen));
return true;
} // endif Lrecl

Records = (int)hp->Records;
Headlen = (int)hp->Headlen;
Records = (int)uint4korr(&hp->Records);
Headlen = (int)uint2korr(&hp->Headlen);
} // endif Headlen

/**************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extern "C" {
/* Static variables */
/***********************************************************************/
#if defined(STORAGE)
char sys_stamp[4] = SYS_STAMP;
char sys_stamp[5] = SYS_STAMP;
#else
extern char sys_stamp[];
#endif
Expand Down
73 changes: 32 additions & 41 deletions storage/connect/ha_connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,35 +168,21 @@
#define JSONMAX 10 // JSON Default max grp size

extern "C" {
char version[]= "Version 1.03.0006 April 12, 2015";

char version[]= "Version 1.03.0007 April 30, 2015";
#if defined(WIN32)
char compver[]= "Version 1.03.0006 " __DATE__ " " __TIME__;
char compver[]= "Version 1.03.0007 " __DATE__ " " __TIME__;
char slash= '\\';
#else // !WIN32
char slash= '/';
#endif // !WIN32

// int trace= 0; // The general trace value
// ulong xconv= 0; // The type conversion option
// int zconv= 0; // The text conversion size
} // extern "C"

#if defined(XMAP)
my_bool xmap= false;
#endif // XMAP

// uint worksize= 0;
ulong ha_connect::num= 0;
//int DTVAL::Shift= 0;

/* CONNECT system variables */
//atic int conv_size= 0;
//atic uint work_size= 0;
//atic ulong type_conv= 0;
#if defined(XMAP)
//atic my_bool indx_map= 0;
#endif // XMAP
#if defined(XMSG)
extern "C" {
char *msg_path;
Expand Down Expand Up @@ -613,9 +599,9 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir)
delete_table method in handler.cc
*/
static const char *ha_connect_exts[]= {
".dos", ".fix", ".csv", ".bin", ".fmt", ".dbf", ".xml", ".ini", ".vec",
".dnx", ".fnx", ".bnx", ".vnx", ".dbx", ".dop", ".fop", ".bop", ".vop",
NULL};
".dos", ".fix", ".csv", ".bin", ".fmt", ".dbf", ".xml", ".json", ".ini",
".vec", ".dnx", ".fnx", ".bnx", ".vnx", ".dbx", ".dop", ".fop", ".bop",
".vop", NULL};

/**
@brief
Expand Down Expand Up @@ -4646,8 +4632,13 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)

} // endif pos

} else // Avoid infamous DBUG_ASSERT
thd->get_stmt_da()->reset_diagnostics_area();
} // endif open_table_def

// This below was done to avoid DBUG_ASSERT in some case that
// we don't know anymore what they were. It was suppressed because
// it did cause assertion in other cases (see MDEV-7935)
// } else // Avoid infamous DBUG_ASSERT
// thd->get_stmt_da()->reset_diagnostics_area();

free_table_share(share);
} else // Temporary file
Expand Down Expand Up @@ -4730,6 +4721,25 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
DBUG_RETURN(rows);
} // end of records_in_range

// Used to check whether a MYSQL table is created on itself
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host,
const char *db, char *tab, const char *src, int port)
{
if (src)
return false;
else if (host && stricmp(host, "localhost") && strcmp(host, "127.0.0.1"))
return false;
else if (db && stricmp(db, s->db.str))
return false;
else if (tab && stricmp(tab, s->table_name.str))
return false;
else if (port && port != (signed)GetDefaultPort())
return false;

strcpy(g->Message, "This MySQL table is defined on itself");
return true;
} // end of CheckSelf

/**
Convert an ISO-8859-1 column name to UTF-8
*/
Expand Down Expand Up @@ -4891,7 +4901,7 @@ static int init_table_share(THD* thd,
oom|= sql->append(' ');
oom|= sql->append(opt->name);
oom|= sql->append('=');
oom|= sql->append(vull ? "ON" : "OFF");
oom|= sql->append(vull ? "YES" : "NO");
} // endif vull

break;
Expand Down Expand Up @@ -4933,25 +4943,6 @@ static int init_table_share(THD* thd,
sql->ptr(), sql->length());
} // end of init_table_share

// Used to check whether a MYSQL table is created on itself
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host,
const char *db, char *tab, const char *src, int port)
{
if (src)
return false;
else if (host && stricmp(host, "localhost") && strcmp(host, "127.0.0.1"))
return false;
else if (db && stricmp(db, s->db.str))
return false;
else if (tab && stricmp(tab, s->table_name.str))
return false;
else if (port && port != (signed)GetDefaultPort())
return false;

strcpy(g->Message, "This MySQL table is defined on itself");
return true;
} // end of CheckSelf

/**
@brief
connect_assisted_discovery() is called when creating a table with no columns.
Expand Down
94 changes: 80 additions & 14 deletions storage/connect/jsonudf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,45 @@
#include "json.h"

#define MEMFIX 512
#define UDF_EXEC_ARGS \
UDF_INIT*, UDF_ARGS*, char*, unsigned long*, char*, char*

uint GetJsonGrpSize(void);

extern "C" {
DllExport my_bool Json_Value_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Value(UDF_INIT*, UDF_ARGS*, char*,
unsigned long*, char *, char *);
DllExport char *Json_Value(UDF_EXEC_ARGS);
DllExport void Json_Value_deinit(UDF_INIT*);

DllExport my_bool Json_Array_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Array(UDF_INIT*, UDF_ARGS*, char*,
unsigned long*, char *, char *);
DllExport char *Json_Array(UDF_EXEC_ARGS);
DllExport void Json_Array_deinit(UDF_INIT*);

DllExport my_bool Json_Array_Add_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Array_Add(UDF_INIT*, UDF_ARGS*, char*,
unsigned long*, char *, char *);
DllExport char *Json_Array_Add(UDF_EXEC_ARGS);
DllExport void Json_Array_Add_deinit(UDF_INIT*);

DllExport my_bool Json_Array_Delete_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Array_Delete(UDF_EXEC_ARGS);
DllExport void Json_Array_Delete_deinit(UDF_INIT*);

DllExport my_bool Json_Object_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Object(UDF_INIT*, UDF_ARGS*, char*,
unsigned long*, char *, char *);
DllExport char *Json_Object(UDF_EXEC_ARGS);
DllExport void Json_Object_deinit(UDF_INIT*);

DllExport my_bool Json_Object_Nonull_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Object_Nonull(UDF_INIT*, UDF_ARGS*, char*,
unsigned long*, char *, char *);
DllExport char *Json_Object_Nonull(UDF_EXEC_ARGS);
DllExport void Json_Object_Nonull_deinit(UDF_INIT*);

DllExport my_bool Json_Array_Grp_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport void Json_Array_Grp_add(UDF_INIT *, UDF_ARGS *, char *, char *);
DllExport char *Json_Array_Grp(UDF_INIT*, UDF_ARGS*, char*,
unsigned long*, char *, char *);
DllExport char *Json_Array_Grp(UDF_EXEC_ARGS);
DllExport void Json_Array_Grp_clear(UDF_INIT *, char *, char *);
DllExport void Json_Array_Grp_deinit(UDF_INIT*);

DllExport my_bool Json_Object_Grp_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport void Json_Object_Grp_add(UDF_INIT *, UDF_ARGS *, char *, char *);
DllExport char *Json_Object_Grp(UDF_INIT*, UDF_ARGS*, char*,
unsigned long*, char *, char *);
DllExport char *Json_Object_Grp(UDF_EXEC_ARGS);
DllExport void Json_Object_Grp_clear(UDF_INIT *, char *, char *);
DllExport void Json_Object_Grp_deinit(UDF_INIT*);
} // extern "C"
Expand Down Expand Up @@ -404,6 +409,67 @@ void Json_Array_Add_deinit(UDF_INIT* initid)
PlugExit((PGLOBAL)initid->ptr);
} // end of Json_Array_Add_deinit

/***********************************************************************/
/* Add values to a Json array. */
/***********************************************************************/
my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
unsigned long reslen, memlen;

if (args->arg_count != 2) {
strcpy(message, "Json_Value_Delete must have 2 arguments");
return true;
} else if (!IsJson(args, 0)) {
strcpy(message, "Json_Value_Delete first argument must be a json item");
return true;
} else
CalcLen(args, false, reslen, memlen);

return JsonInit(initid, message, reslen, memlen);
} // end of Json_Array_Delete_init

char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error)
{
char *str;
int n;
PJVAL jvp;
PJAR arp;
PGLOBAL g = (PGLOBAL)initid->ptr;

PlugSubSet(g, g->Sarea, g->Sarea_Size);
jvp = MakeValue(g, args, 0);

if (jvp->GetValType() != TYPE_JAR) {
push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0,
"First argument is not an array");
str = args->args[0];
} else if (args->arg_type[1] != INT_RESULT) {
push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0,
"Second argument is not an integer");
str = args->args[0];
} else {
n = *(int*)args->args[1];
arp = jvp->GetArray();
arp->DeleteValue(n - 1);
arp->InitArray(g);

if (!(str = Serialize(g, arp, NULL, 0))) {
str = strcpy(result, g->Message);
push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, str);
} // endif str

} // endif's

*res_length = strlen(str);
return str;
} // end of Json_Array_Delete

void Json_Array_Delete_deinit(UDF_INIT* initid)
{
PlugExit((PGLOBAL)initid->ptr);
} // end of Json_Array_Delete_deinit

/***********************************************************************/
/* Make a Json Oject containing all the parameters. */
/***********************************************************************/
Expand Down
12 changes: 6 additions & 6 deletions storage/connect/mysql-test/connect/r/json.result
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher L
UPDATE t1 SET AuthorFN = 'Philippe' WHERE AuthorLN = 'Knab';
SELECT * FROM t1 WHERE ISBN = '9782212090819';
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
9782212090819 fr applications Philippe Bernadac Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Fran�ois Knab Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Philippe Knab Construire une application XML NULL NULL Eyrolles Paris 1999
#
# To add an author a new table must be created
#
Expand All @@ -104,8 +104,8 @@ William J. Pardi
INSERT INTO t2 VALUES('Charles','Dickens');
SELECT * FROM t1;
ISBN Language Subject AuthorFN AuthorLN Title Translation Translator Publisher Location Year
9782212090819 fr applications Philippe Bernadac Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Fran�ois Knab Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Jean-Christophe Bernadac Construire une application XML NULL NULL Eyrolles Paris 1999
9782212090819 fr applications Philippe Knab Construire une application XML NULL NULL Eyrolles Paris 1999
9782840825685 fr applications William J. Pardi XML en Action adapt� de l'anglais par James Guerin Microsoft Press Paris 1999
9782840825685 fr applications Charles Dickens XML en Action adapt� de l'anglais par James Guerin Microsoft Press Paris 1999
DROP TABLE t1;
Expand All @@ -127,11 +127,11 @@ line
"SUBJECT": "applications",
"AUTHOR": [
{
"FIRSTNAME": "Philippe",
"FIRSTNAME": "Jean-Christophe",
"LASTNAME": "Bernadac"
},
{
"FIRSTNAME": "Fran�ois",
"FIRSTNAME": "Philippe",
"LASTNAME": "Knab"
}
],
Expand Down
Loading

0 comments on commit 5fa2a6c

Please sign in to comment.