summaryrefslogtreecommitdiff
path: root/storage/connect/valblk.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-04-29 13:50:20 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2013-04-29 13:50:20 +0200
commit4fd74200dd8ff357b7f870ea0407ef8f3c78ff11 (patch)
treed297698912fdf321efb715957a62ffd2b7e5e099 /storage/connect/valblk.cpp
parentbc80fb07ded7abcfb99d368d14e4c5e81a669101 (diff)
downloadmariadb-git-4fd74200dd8ff357b7f870ea0407ef8f3c78ff11.tar.gz
- Adding 3 new table types:
PROXY table base on another table. Used by several other types. XCOL proxy on a table having a colummn containing a list of values OCCUR proxy on a table having several columns containing the same type of values that can be put in a unique column and several rows. TBL Not new but now internally using the PROXY table class. - Fix 2 bugs in add_field: Change '=' to ' ' after the COMMENT keyword. Quote column names between '`' in the SQL string. - Update xml test result to the CONNECT version added: storage/connect/taboccur.cpp storage/connect/taboccur.h storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/tabxcl.cpp storage/connect/tabxcl.h modified: storage/connect/CMakeLists.txt storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/mycat.cc storage/connect/myconn.cpp storage/connect/mysql-test/connect/r/xml.result storage/connect/plgdbsem.h storage/connect/tabmysql.cpp storage/connect/tabtbl.cpp storage/connect/tabtbl.h storage/connect/valblk.cpp storage/connect/valblk.h
Diffstat (limited to 'storage/connect/valblk.cpp')
-rw-r--r--storage/connect/valblk.cpp66
1 files changed, 56 insertions, 10 deletions
diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp
index a56841d8980..a96dec2565c 100644
--- a/storage/connect/valblk.cpp
+++ b/storage/connect/valblk.cpp
@@ -266,7 +266,7 @@ char TYPBLK<char>::GetTypedValue(PVAL valp)
{return valp->GetTinyValue();}
/***********************************************************************/
-/* Set one value in a block. */
+/* Set one value in a block from a zero terminated string. */
/***********************************************************************/
template <class TYPE>
void TYPBLK<TYPE>::SetValue(PSZ p, int n)
@@ -295,6 +295,22 @@ template <>
char TYPBLK<char>::GetTypedValue(PSZ p) {return (char)atoi(p);}
/***********************************************************************/
+/* Set one value in a block from an array of characters. */
+/***********************************************************************/
+template <class TYPE>
+void TYPBLK<TYPE>::SetValue(char *sp, uint len, int n)
+ {
+ PGLOBAL& g = Global;
+ PSZ spz = (PSZ)PlugSubAlloc(g, NULL, 0); // Temporary
+
+ if (sp)
+ memcpy(spz, sp, len);
+
+ spz[len] = 0;
+ SetValue(spz, n);
+ } // end of SetValue
+
+/***********************************************************************/
/* Set one value in a block from a value in another block. */
/***********************************************************************/
template <class TYPE>
@@ -552,11 +568,19 @@ void CHRBLK::SetValue(PVAL valp, int n)
} // end of SetValue
/***********************************************************************/
-/* Set one value in a block. */
+/* Set one value in a block from a zero terminated string. */
/***********************************************************************/
void CHRBLK::SetValue(PSZ sp, int n)
{
- size_t len = (sp) ? strlen(sp) : 0;
+ uint len = (sp) ? strlen(sp) : 0;
+ SetValue(sp, len, n);
+ } // end of SetValue
+
+/***********************************************************************/
+/* Set one value in a block from an array of characters. */
+/***********************************************************************/
+void CHRBLK::SetValue(char *sp, uint len, int n)
+ {
char *p = Chrp + n * Long;
#if defined(_DEBUG) || defined(DEBTRACE)
@@ -568,15 +592,16 @@ void CHRBLK::SetValue(PSZ sp, int n)
#endif
if (sp)
- strncpy(p, sp, Long);
- else
- *p = '\0';
+ memcpy(p, sp, len);
- if (Blanks)
+ if (Blanks) {
// Suppress eventual ending zero and right fill with blanks
for (register int i = len; i < Long; i++)
p[i] = ' ';
+ } else if ((signed)len < Long)
+ p[len] = 0;
+
SetNull(n, false);
} // end of SetValue
@@ -801,12 +826,33 @@ void STRBLK::SetValue(PVAL valp, int n)
} // end of SetValue
/***********************************************************************/
-/* Set one value in a block. */
+/* Set one value in a block from a zero terminated string. */
/***********************************************************************/
void STRBLK::SetValue(PSZ p, int n)
{
- Strp[n] = (PSZ)PlugSubAlloc(Global, NULL, strlen(p) + 1);
- strcpy(Strp[n], p);
+ if (p) {
+ Strp[n] = (PSZ)PlugSubAlloc(Global, NULL, strlen(p) + 1);
+ strcpy(Strp[n], p);
+ } else
+ Strp[n] = NULL;
+
+ } // end of SetValue
+
+/***********************************************************************/
+/* Set one value in a block from an array of characters. */
+/***********************************************************************/
+void STRBLK::SetValue(char *sp, uint len, int n)
+ {
+ PSZ p;
+
+ if (sp) {
+ p = (PSZ)PlugSubAlloc(Global, NULL, len + 1);
+ memcpy(p, sp, len);
+ p[len] = 0;
+ } else
+ p = NULL;
+
+ Strp[n] = p;
} // end of SetValue
/***********************************************************************/