summaryrefslogtreecommitdiff
path: root/storage/connect/plugutil.c
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2015-03-18 13:30:14 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2015-03-18 13:30:14 +0100
commit2bb42803df520285dacd753f728ed21994027116 (patch)
tree7eb4d32d2c91cda4d0959a42035fd11966ad8d04 /storage/connect/plugutil.c
parent57aaccef52c22760450f02618213ec90ba0e873e (diff)
downloadmariadb-git-2bb42803df520285dacd753f728ed21994027116.tar.gz
This commit includes changes done in a previous (deleted) branch plus new ones.
From the previous branch: commit eda4928ff122a0845baf5ade83b4aa29244a3a89 Author: Olivier Bertrand <bertrandop@gmail.com> Date: Mon Mar 9 22:34:56 2015 +0100 - Add discovery to JSON tables When columns are not defined, CONNECT analyses the json file to find column definitions. This wors only on table that are an array of objects. Pair keys are used to generate the column names and pair values are used for its definition. When the LEVEL option is defined as a not null integer, the eventual JPATH is scanned up to the LEVEL value. From the current one: - Fix MDEV-7521 when column names are utf8 encoded (not a general multi-charset fix) - Adds more to JSON discovery processing and UDF's - Use PlugDup everywhere it replaces PlugSubAlloc + strcpy.
Diffstat (limited to 'storage/connect/plugutil.c')
-rw-r--r--storage/connect/plugutil.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c
index 18b48b8eccc..36d115e0096 100644
--- a/storage/connect/plugutil.c
+++ b/storage/connect/plugutil.c
@@ -6,7 +6,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 1993-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 1993-2015 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -228,7 +228,6 @@ BOOL PlugIsAbsolutePath(LPCSTR path)
#endif
}
-
/***********************************************************************/
/* Set the full path of a file relatively to a given path. */
/* Note: this routine is not really implemented for Unix. */
@@ -385,8 +384,7 @@ char *PlugReadMessage(PGLOBAL g, int mid, char *m)
err:
if (g) {
// Called by STEP
- msg = (char *)PlugSubAlloc(g, NULL, strlen(stmsg) + 1);
- strcpy(msg, stmsg);
+ msg = PlugDup(g, stmsg);
} else // Called by MSG or PlgGetErrorMsg
msg = stmsg;
@@ -421,8 +419,7 @@ char *PlugGetMessage(PGLOBAL g, int mid)
if (g) {
// Called by STEP
- msg = (char *)PlugSubAlloc(g, NULL, strlen(stmsg) + 1);
- strcpy(msg, stmsg);
+ msg = PlugDup(g, stmsg);
} else // Called by MSG or PlgGetErrorMsg
msg = stmsg;
@@ -537,6 +534,22 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
} /* end of PlugSubAlloc */
/***********************************************************************/
+/* Program for sub-allocating and copying a string in a storage area. */
+/***********************************************************************/
+char *PlugDup(PGLOBAL g, const char *str)
+ {
+ if (str) {
+ char *sm = (char*)PlugSubAlloc(g, NULL, strlen(str) + 1);
+
+ strcpy(sm, str);
+ return sm;
+ } else
+ return NULL;
+
+ } // end of PlugDup
+
+#if 0
+/***********************************************************************/
/* This routine suballocate a copy of the passed string. */
/***********************************************************************/
char *PlugDup(PGLOBAL g, const char *str)
@@ -552,6 +565,7 @@ char *PlugDup(PGLOBAL g, const char *str)
return(buf);
} /* end of PlugDup */
+#endif // 0
/***********************************************************************/
/* This routine makes a pointer from an offset to a memory pointer. */