diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2015-03-18 13:30:14 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2015-03-18 13:30:14 +0100 |
commit | 2bb42803df520285dacd753f728ed21994027116 (patch) | |
tree | 7eb4d32d2c91cda4d0959a42035fd11966ad8d04 /storage/connect/reldef.cpp | |
parent | 57aaccef52c22760450f02618213ec90ba0e873e (diff) | |
download | mariadb-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/reldef.cpp')
-rw-r--r-- | storage/connect/reldef.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 51d777a7d17..c6cbedd9636 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ +/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -153,10 +153,9 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) if (s) { if (!Hc->IsPartitioned() || (stricmp(what, "filename") && stricmp(what, "tabname") - && stricmp(what, "connect"))) { - sval= (char*)PlugSubAlloc(g, NULL, strlen(s) + 1); - strcpy(sval, s); - } else + && stricmp(what, "connect"))) + sval= PlugDup(g, s); + else sval= s; } else if (!stricmp(what, "filename")) { @@ -213,8 +212,7 @@ bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) { int poff = 0; - Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1); - strcpy(Name, name); + Name = (PSZ)PlugDup(g, name); Cat = cat; Hc = ((MYCAT*)cat)->GetHandler(); Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL)); @@ -712,8 +710,7 @@ COLDEF::COLDEF(void) : COLCRT() /***********************************************************************/ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) { - Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1); - strcpy(Name, cfp->Name); + Name = (PSZ)PlugDup(g, cfp->Name); if (!(cfp->Flags & U_SPECIAL)) { Poff = poff; @@ -735,22 +732,16 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) Key = cfp->Key; Freq = cfp->Freq; - if (cfp->Remark && *cfp->Remark) { - Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1); - strcpy(Desc, cfp->Remark); - } // endif Remark + if (cfp->Remark && *cfp->Remark) + Desc = (PSZ)PlugDup(g, cfp->Remark); - if (cfp->Datefmt) { - Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1); - strcpy(Decode, cfp->Datefmt); - } // endif Datefmt + if (cfp->Datefmt) + Decode = (PSZ)PlugDup(g, cfp->Datefmt); } // endif special - if (cfp->Fieldfmt) { - Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1); - strcpy(Fmt, cfp->Fieldfmt); - } // endif Fieldfmt + if (cfp->Fieldfmt) + Fmt = (PSZ)PlugDup(g, cfp->Fieldfmt); Flags = cfp->Flags; return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long; |