transactd 2.4.5 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/CMakeLists.txt +1 -1
  3. data/README-JA.md +52 -529
  4. data/README.md +52 -523
  5. data/bin/common/tdclc_32_3_0.dll +0 -0
  6. data/bin/common/tdclc_64_3_0.dll +0 -0
  7. data/build/common/system.cmake +2 -1
  8. data/build/common/transactd_cl_common.cmake +3 -6
  9. data/build/swig/ruby/ruby.swg +85 -28
  10. data/build/swig/ruby/tdclrb_wrap.cpp +3195 -1578
  11. data/build/swig/tdcl.i +161 -5
  12. data/build/tdclc/CMakeLists.txt +1 -0
  13. data/build/tdclc/tdclc.cbproj +7 -1
  14. data/build/tdclc/tdclc.rc +4 -4
  15. data/build/tdclcpp/tdclcpp.rc +4 -4
  16. data/build/tdclcpp/tdclcpp_bc.cbproj +2 -5
  17. data/build/tdclrb/tdclrb.rc +4 -4
  18. data/source/bzs/db/blobStructs.h +1 -1
  19. data/source/bzs/db/engine/mysql/database.cpp +199 -74
  20. data/source/bzs/db/engine/mysql/database.h +47 -18
  21. data/source/bzs/db/engine/mysql/dbManager.cpp +1 -0
  22. data/source/bzs/db/engine/mysql/mysqlInternal.h +32 -8
  23. data/source/bzs/db/protocol/tdap/btrDate.cpp +110 -75
  24. data/source/bzs/db/protocol/tdap/btrDate.h +46 -21
  25. data/source/bzs/db/protocol/tdap/client/activeTable.cpp +18 -18
  26. data/source/bzs/db/protocol/tdap/client/activeTable.h +25 -25
  27. data/source/bzs/db/protocol/tdap/client/activeTableImple.h +10 -4
  28. data/source/bzs/db/protocol/tdap/client/client.cpp +6 -5
  29. data/source/bzs/db/protocol/tdap/client/client.h +82 -15
  30. data/source/bzs/db/protocol/tdap/client/database.cpp +531 -142
  31. data/source/bzs/db/protocol/tdap/client/database.h +19 -6
  32. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +461 -408
  33. data/source/bzs/db/protocol/tdap/client/dbDef.h +11 -17
  34. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +61 -13
  35. data/source/bzs/db/protocol/tdap/client/field.cpp +1592 -1398
  36. data/source/bzs/db/protocol/tdap/client/field.h +110 -121
  37. data/source/bzs/db/protocol/tdap/client/fields.h +40 -10
  38. data/source/bzs/db/protocol/tdap/client/filter.h +69 -55
  39. data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +296 -164
  40. data/source/bzs/db/protocol/tdap/client/groupQuery.h +77 -25
  41. data/source/bzs/db/protocol/tdap/client/memRecord.cpp +31 -13
  42. data/source/bzs/db/protocol/tdap/client/memRecord.h +31 -21
  43. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +1 -1
  44. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +4 -1
  45. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +69 -24
  46. data/source/bzs/db/protocol/tdap/client/nsTable.h +3 -1
  47. data/source/bzs/db/protocol/tdap/client/recordset.cpp +1 -0
  48. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +46 -27
  49. data/source/bzs/db/protocol/tdap/client/request.h +2 -1
  50. data/source/bzs/db/protocol/tdap/client/serializer.cpp +44 -9
  51. data/source/bzs/db/protocol/tdap/client/serializer.h +1 -1
  52. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +182 -76
  53. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +23 -12
  54. data/source/bzs/db/protocol/tdap/client/stringConverter.h +8 -10
  55. data/source/bzs/db/protocol/tdap/client/table.cpp +172 -93
  56. data/source/bzs/db/protocol/tdap/client/table.h +112 -37
  57. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +17 -0
  58. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +0 -1
  59. data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +0 -2
  60. data/source/bzs/db/protocol/tdap/client/trdormapi.h +1 -1
  61. data/source/bzs/db/protocol/tdap/fieldComp.h +698 -14
  62. data/source/bzs/db/protocol/tdap/myDateTime.cpp +723 -307
  63. data/source/bzs/db/protocol/tdap/myDateTime.h +294 -0
  64. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +164 -54
  65. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +6 -3
  66. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +133 -550
  67. data/source/bzs/db/protocol/tdap/mysql/request.h +6 -5
  68. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +217 -82
  69. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +1 -1
  70. data/source/bzs/db/protocol/tdap/tdapRequest.h +4 -9
  71. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +808 -17
  72. data/source/bzs/db/protocol/tdap/tdapSchema.h +656 -164
  73. data/source/bzs/db/protocol/tdap/tdapcapi.h +130 -28
  74. data/source/bzs/db/protocol/tdap/uri.h +40 -32
  75. data/source/bzs/db/transactd/connManager.cpp +1 -1
  76. data/source/bzs/db/transactd/transactd.cpp +7 -0
  77. data/source/bzs/env/compiler.h +107 -94
  78. data/source/bzs/env/crosscompile.cpp +24 -12
  79. data/source/bzs/env/crosscompile.h +75 -6
  80. data/source/bzs/env/mbcswchrLinux.cpp +2 -2
  81. data/source/bzs/env/tcharMinGW.h +4 -0
  82. data/source/bzs/example/changeSchema.cpp +22 -17
  83. data/source/bzs/example/queryData.cpp +4 -0
  84. data/source/bzs/netsvc/client/iconnection.h +3 -1
  85. data/source/bzs/netsvc/client/tcpClient.h +10 -3
  86. data/source/bzs/rtl/stringBuffers.cpp +7 -0
  87. data/source/bzs/test/tdclatl/bench_query_atl.js +6 -0
  88. data/source/bzs/test/tdclatl/bench_tdclatl.js +8 -1
  89. data/source/bzs/test/tdclatl/test_query_atl.js +22 -2
  90. data/source/bzs/test/tdclatl/test_v3.js +1017 -0
  91. data/source/bzs/test/tdclphp/transactd_Test.php +55 -21
  92. data/source/bzs/test/tdclphp/transactd_datetime_Test.php +0 -5
  93. data/source/bzs/test/tdclphp/transactd_pool_Test.php +2 -0
  94. data/source/bzs/test/tdclphp/transactd_v3_Test.php +743 -0
  95. data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +0 -5
  96. data/source/bzs/test/tdclrb/transactd_pool_spec.rb +2 -0
  97. data/source/bzs/test/tdclrb/transactd_spec.rb +39 -16
  98. data/source/bzs/test/tdclrb/transactd_v3_spec.rb +748 -0
  99. data/source/bzs/test/transactdBench/transactdBench.cpp +55 -58
  100. data/source/bzs/test/transactdBench/transactdBench2.cpp +1 -3
  101. data/source/bzs/test/trdclengn/testField.h +3305 -0
  102. data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +1050 -0
  103. data/source/bzs/test/trdclengn/test_trdclengn.cpp +112 -190
  104. data/source/bzs/test/trdclengn/testbase.h +137 -0
  105. data/source/global/ormsrcgen/srcgen.cpp +23 -12
  106. data/source/global/ormsrcgen/template/ormDataClass_template.h +2 -0
  107. data/source/global/querystmts/querystmts.cpp +2 -3
  108. data/source/global/tdclatl/Bitset.cpp +38 -0
  109. data/source/global/tdclatl/Bitset.h +63 -0
  110. data/source/global/tdclatl/Database.cpp +59 -18
  111. data/source/global/tdclatl/Database.h +7 -4
  112. data/source/global/tdclatl/DbDef.cpp +6 -6
  113. data/source/global/tdclatl/DbDef.h +2 -1
  114. data/source/global/tdclatl/Field.cpp +112 -0
  115. data/source/global/tdclatl/Field.h +19 -5
  116. data/source/global/tdclatl/FieldDef.cpp +137 -16
  117. data/source/global/tdclatl/FieldDef.h +18 -2
  118. data/source/global/tdclatl/FieldDefs.cpp +54 -1
  119. data/source/global/tdclatl/FieldDefs.h +3 -0
  120. data/source/global/tdclatl/GroupQuery.cpp +8 -8
  121. data/source/global/tdclatl/QueryBase.cpp +65 -0
  122. data/source/global/tdclatl/QueryBase.h +10 -0
  123. data/source/global/tdclatl/Record.cpp +33 -2
  124. data/source/global/tdclatl/Record.h +3 -1
  125. data/source/global/tdclatl/RecordsetQuery.cpp +42 -0
  126. data/source/global/tdclatl/RecordsetQuery.h +8 -0
  127. data/source/global/tdclatl/Table.cpp +127 -3
  128. data/source/global/tdclatl/Table.h +10 -1
  129. data/source/global/tdclatl/TableDef.cpp +41 -8
  130. data/source/global/tdclatl/TableDef.h +7 -2
  131. data/source/global/tdclatl/activeTable.cpp +40 -71
  132. data/source/global/tdclatl/resource.h +0 -0
  133. data/source/global/tdclatl/tdclatl.idl +222 -28
  134. data/source/linux/tchar.h +100 -96
  135. data/transactd.gemspec +2 -2
  136. metadata +13 -11
  137. data/BUILD_UNIX-JA.md +0 -161
  138. data/BUILD_WIN-JA.md +0 -326
  139. data/README_ORMSRCGEN-JA.md +0 -115
  140. data/README_ORMSRCGEN.md +0 -118
  141. data/RELEASE_NOTE-JA.md +0 -356
  142. data/RELEASE_NOTE.md +0 -360
  143. data/bin/common/tdclc_32_2_4.dll +0 -0
  144. data/bin/common/tdclc_64_2_4.dll +0 -0
  145. data/source/bzs/test/trdclengn/test_blob.cpp +0 -375
@@ -0,0 +1,294 @@
1
+ #ifndef BZS_DB_PROTOCOL_TDAP_MYDATETIME_H
2
+ #define BZS_DB_PROTOCOL_TDAP_MYDATETIME_H
3
+ /*=================================================================
4
+ Copyright (C) 2015 BizStation Corp All rights reserved.
5
+
6
+ This program is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU General Public License
8
+ as published by the Free Software Foundation; either version 2
9
+ of the License, or (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program; if not, write to the Free Software
18
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
+ 02111-1307, USA.
20
+ =================================================================*/
21
+ #include <tchar.h>
22
+ #include <bzs/env/compiler.h>
23
+ #include <stddef.h>
24
+
25
+ namespace bzs
26
+ {
27
+ namespace db
28
+ {
29
+ namespace protocol
30
+ {
31
+ namespace tdap
32
+ {
33
+ /** @cond INTERNAL */
34
+
35
+ #pragma pack(push, 1)
36
+ pragma_pack1;
37
+
38
+ struct PACKAGE myDate
39
+ {
40
+ union
41
+ {
42
+ struct
43
+ {
44
+ unsigned int dd : 5;
45
+ unsigned int mm : 4;
46
+ unsigned int yy : 15;
47
+ unsigned int tmp : 8;
48
+ };
49
+ int i;
50
+ };
51
+ inline myDate() {};
52
+ inline myDate(int /*dec*/, bool /*bigendian*/) {};
53
+ void setValue(int v, bool btrDate_i = false);
54
+ int getValue(bool btrvValue = false);
55
+ char* toString(char* p, size_t size, bool w3_format = false);
56
+ myDate& operator=(const char* p);
57
+ #ifdef _WIN32
58
+ wchar_t* toString(wchar_t* p, size_t size, bool w3_format = false);
59
+ myDate& operator=(const wchar_t* p);
60
+ #endif
61
+ inline __int64 internalValue() const { return i; }
62
+ inline void setInternalValue(__int64 v) { i = (int)v; }
63
+ };
64
+
65
+ struct PACKAGE myTime
66
+ {
67
+
68
+ protected:
69
+ int m_dec;
70
+ bool m_bigendian;
71
+ public:
72
+ union
73
+ {
74
+ struct
75
+ {
76
+ unsigned __int64 ms : 24;
77
+ unsigned __int64 ss : 6;
78
+ unsigned __int64 nn : 6;
79
+ unsigned __int64 hh : 10;
80
+ unsigned __int64 unused : 1;
81
+ unsigned __int64 sign : 1;
82
+ unsigned __int64 tmp : 16;
83
+ };
84
+ __int64 i64;
85
+ };
86
+
87
+ public:
88
+ inline myTime(int dec, bool bigendian) : m_dec(dec),
89
+ m_bigendian(bigendian){};
90
+ virtual void setValue(__int64 v, bool btrTime_i = false);
91
+ virtual __int64 getValue(bool btrTime_i = false);
92
+ char* toString(char* p, size_t size);
93
+ myTime& operator=(const char* p);
94
+ #ifdef _WIN32
95
+ wchar_t* toString(wchar_t* p, size_t size);
96
+ myTime& operator=(const wchar_t* p);
97
+ #endif
98
+ inline __int64 internalValue() const { return i64; }
99
+ inline void setInternalValue(__int64 v) { i64 = v; }
100
+ };
101
+
102
+ struct PACKAGE maTime : public myTime
103
+ {
104
+ virtual void setValue(__int64 v, bool btrTime_i = false);
105
+ virtual __int64 getValue(bool btrTime_i = false);
106
+ public:
107
+ inline maTime(int dec, bool bigendian) : myTime(dec, bigendian){}
108
+ maTime& operator=(const char* p);
109
+ #ifdef _WIN32
110
+ maTime& operator=(const wchar_t* p) ;
111
+ #endif
112
+ };
113
+
114
+ struct PACKAGE myDateTime
115
+ {
116
+ protected:
117
+ int m_dec;
118
+ bool m_bigendian;
119
+ public:
120
+ union
121
+ {
122
+ struct
123
+ {
124
+ unsigned __int64 ms : 24;
125
+ unsigned __int64 ss : 6;
126
+ unsigned __int64 nn : 6;
127
+ unsigned __int64 hh : 5;
128
+ unsigned __int64 dd : 5;
129
+ unsigned __int64 yymm : 17; // yy*13+mm (yy 0-9999, mm 0-12)
130
+ unsigned __int64 sign : 1; //always 1 0 is reserved
131
+ };
132
+ __int64 i64;
133
+ };
134
+
135
+ inline myDateTime(int dec, bool bigendian) : m_dec(dec), m_bigendian(bigendian){};
136
+ virtual void setValue(__int64 v);
137
+ virtual __int64 getValue();
138
+ char* toString(char* p, size_t size) const;
139
+ myDateTime& operator=(const char* p);
140
+ char* dateStr(char* p, size_t size) const;
141
+ char* timeStr(char* p, size_t size) const;
142
+ void setTime(const char* p);
143
+
144
+ #ifdef _WIN32
145
+ wchar_t* toString(wchar_t* p, size_t size) const ;
146
+ myDateTime& operator=(const wchar_t* p) ;
147
+ wchar_t* dateStr(wchar_t* p, size_t size) const;
148
+ wchar_t* timeStr(wchar_t*, size_t size) const;
149
+ void setTime(const wchar_t* p);
150
+ #endif
151
+ inline __int64 internalValue() const { return i64; }
152
+ inline void setInternalValue(__int64 v) { i64 = v; }
153
+ };
154
+
155
+ struct PACKAGE maDateTime : public myDateTime
156
+ {
157
+ virtual void setValue(__int64 v);
158
+ virtual __int64 getValue();
159
+ public:
160
+ inline maDateTime(int dec, bool bigendian) : myDateTime(dec, bigendian){};
161
+ maDateTime& operator=(const char* p);
162
+ #ifdef _WIN32
163
+ maDateTime& operator=(const wchar_t* p) ;
164
+ #endif
165
+ };
166
+
167
+ struct PACKAGE myTimeStamp
168
+ {
169
+ private:
170
+ int m_dec;
171
+ bool m_bigendian;
172
+ protected:
173
+ bool m_mariadb;
174
+ public:
175
+ union
176
+ {
177
+ struct
178
+ {
179
+ unsigned __int64 ms : 24;
180
+ unsigned __int64 datetime : 32;
181
+ unsigned __int64 tmp : 8;
182
+ };
183
+ __int64 i64;
184
+ };
185
+
186
+ inline myTimeStamp(int dec, bool bigendian) : m_dec(dec),
187
+ m_bigendian(bigendian), m_mariadb(false){};
188
+ void setValue(__int64 v);
189
+ __int64 getValue();
190
+ char* toString(char* p, size_t size);
191
+ myTimeStamp& operator=(const char* p);
192
+ char* dateStr(char* p, size_t size) const;
193
+ char* timeStr(char* p, size_t size) const;
194
+
195
+ #ifdef _WIN32
196
+ wchar_t* toString(wchar_t* p, size_t size);
197
+ myTimeStamp& operator=(const wchar_t* p);
198
+ wchar_t* dateStr(wchar_t* p, size_t size) const;
199
+ wchar_t* timeStr(wchar_t* p, size_t size) const;
200
+ #endif
201
+ inline __int64 internalValue() const { return i64; }
202
+ inline void setInternalValue(__int64 v) { i64 = v; }
203
+ };
204
+
205
+
206
+ struct PACKAGE maTimeStamp : public myTimeStamp
207
+ {
208
+
209
+ inline maTimeStamp (int dec, bool bigendian) : myTimeStamp(dec, bigendian)
210
+ {
211
+ m_mariadb = true;
212
+ }
213
+ inline maTimeStamp& operator=(const char* p){ myTimeStamp::operator=(p); return *this;}
214
+ #ifdef _WIN32
215
+ inline maTimeStamp& operator=(const wchar_t* p) { myTimeStamp::operator=(p); return *this; }
216
+ #endif
217
+ };
218
+
219
+ inline int btrdateToMydate(int btrd)
220
+ {
221
+ myDate myd;
222
+ myd.setValue(btrd, true);
223
+ return myd.getValue(true);
224
+ }
225
+
226
+ // Do not work at maridab
227
+ inline __int64 btrtimeToMytime(int btrTime_i, bool bigendian)
228
+ {
229
+ myTime myt(4, bigendian);
230
+ myt.setValue(btrTime_i, true);
231
+ return myt.getValue(true);
232
+ }
233
+
234
+ inline int mydateToBtrdate(int myDate_i)
235
+ {
236
+ myDate myd;
237
+ myd.setValue(myDate_i, false);
238
+ return myd.getValue(true);
239
+ }
240
+
241
+ inline int mytimeToBtrtime(__int64 myTime_i, bool bigendian, int dec)
242
+ {
243
+ myTime myt(dec, bigendian);
244
+ myt.setValue(myTime_i, false);
245
+ return (int)myt.getValue(true);
246
+ }
247
+
248
+ template <class T>
249
+ __int64 getInternalValue(int dec, bool bigendian, __int64 value)
250
+ {
251
+ T t(dec, bigendian);
252
+ t.setValue(value);
253
+ return t.internalValue();
254
+ }
255
+
256
+ template <class T>
257
+ __int64 getStoreValue(int dec, bool bigendian, __int64 value)
258
+ {
259
+ T t(dec, bigendian);
260
+ t.setInternalValue(value);
261
+ return t.getValue();
262
+ }
263
+
264
+ #pragma warning(disable : 4244)
265
+ template <class T, typename CHAR>
266
+ const CHAR* date_time_str(int dec, bool bigendian, __int64 value, CHAR* buf, size_t size)
267
+ {
268
+ T t(dec, bigendian);
269
+ t.setValue(value);
270
+ return t.toString(buf, size);
271
+ }
272
+
273
+ template <class T, class T2>
274
+ inline __int64 str_to_64(int dec, bool bigendian, const T2* data)
275
+ {
276
+ T t(dec, bigendian);
277
+ t = data;
278
+ return t.getValue();
279
+ }
280
+
281
+ #pragma warning(default : 4244)
282
+
283
+
284
+
285
+ #pragma pack(pop)
286
+ pragma_pop;
287
+ /** @endcond */
288
+
289
+ } // namespace tdap
290
+ } // namespace protocol
291
+ } // namespace db
292
+ } // namespace bzs
293
+
294
+ #endif //BZS_DB_PROTOCOL_TDAP_MYDATETIME_H
@@ -43,7 +43,7 @@ namespace tdap
43
43
  namespace mysql
44
44
  {
45
45
 
46
- schemaBuilder::schemaBuilder(void)
46
+ schemaBuilder::schemaBuilder(void): m_stat(0)
47
47
  {
48
48
  }
49
49
 
@@ -72,12 +72,12 @@ uchar_td convFieldType(enum enum_field_types type, uint flags, bool binary,
72
72
  switch (type)
73
73
  {
74
74
  case MYSQL_TYPE_DECIMAL:
75
- return ft_decimal;
75
+ case MYSQL_TYPE_NEWDECIMAL:
76
+ return ft_mydecimal;
76
77
  case MYSQL_TYPE_TINY:
77
78
  case MYSQL_TYPE_SHORT:
78
79
  case MYSQL_TYPE_LONG:
79
80
  case MYSQL_TYPE_LONGLONG:
80
- case MYSQL_TYPE_YEAR:
81
81
  case MYSQL_TYPE_INT24:
82
82
  if (flags & AUTO_INCREMENT_FLAG)
83
83
  return (flags & UNSIGNED_FLAG) ? ft_autoIncUnsigned : ft_autoinc;
@@ -85,29 +85,24 @@ uchar_td convFieldType(enum enum_field_types type, uint flags, bool binary,
85
85
  return ft_uinteger;
86
86
  return ft_integer;
87
87
  case MYSQL_TYPE_ENUM:
88
+ return ft_enum;
88
89
  case MYSQL_TYPE_SET:
90
+ return ft_set;
89
91
  case MYSQL_TYPE_BIT:
90
- return ft_uinteger;
92
+ return ft_bit;
91
93
  case MYSQL_TYPE_FLOAT:
92
94
  case MYSQL_TYPE_DOUBLE:
93
95
  return ft_float;
96
+ case MYSQL_TYPE_YEAR:
97
+ return ft_myyear;
94
98
  case MYSQL_TYPE_DATE:
95
- case MYSQL_TYPE_NEWDATE:
99
+ case MYSQL_TYPE_NEWDATE:
96
100
  return ft_mydate;
97
101
  case MYSQL_TYPE_TIME:
98
- #if(MYSQL_VERSION_ID > 50600)
99
- case MYSQL_TYPE_TIME2:
100
- #endif
101
102
  return ft_mytime;
102
103
  case MYSQL_TYPE_DATETIME:
103
- #if(MYSQL_VERSION_ID > 50600)
104
- case MYSQL_TYPE_DATETIME2:
105
- #endif
106
104
  return ft_mydatetime;
107
105
  case MYSQL_TYPE_TIMESTAMP:
108
- #if(MYSQL_VERSION_ID > 50600)
109
- case MYSQL_TYPE_TIMESTAMP2:
110
- #endif
111
106
  return ft_mytimestamp;
112
107
  case MYSQL_TYPE_VARCHAR:
113
108
  case MYSQL_TYPE_VAR_STRING: //?
@@ -125,6 +120,20 @@ uchar_td convFieldType(enum enum_field_types type, uint flags, bool binary,
125
120
  if (flags & BINARY_FLAG)
126
121
  return ft_myblob;
127
122
  return ft_mytext;
123
+ case MYSQL_TYPE_GEOMETRY:
124
+ return ft_mygeometry;
125
+ #if ((MYSQL_VERSION_ID > 50700) && (MYSQL_VERSION_ID < 100000))
126
+ case MYSQL_TYPE_JSON:
127
+ return ft_myjson;
128
+ #endif
129
+ #if(MYSQL_VERSION_ID > 50600)
130
+ case MYSQL_TYPE_TIME2:
131
+ return ft_mytime;
132
+ case MYSQL_TYPE_DATETIME2:
133
+ return ft_mydatetime;
134
+ case MYSQL_TYPE_TIMESTAMP2:
135
+ return ft_mytimestamp;
136
+ #endif
128
137
  default: // MYSQL_TYPE_NEWDECIMAL MYSQL_TYPE_GEOMETRY
129
138
  return unicode ? ft_wstring : ft_string;
130
139
  }
@@ -142,67 +151,136 @@ bool isBinary(const CHARSET_INFO& cs)
142
151
  return (&cs == &my_charset_bin);
143
152
  }
144
153
 
145
- short schemaBuilder::insertMetaRecord(table* mtb, table* src, int id)
146
- {
154
+ tabledef* schemaBuilder::getTabledef(engine::mysql::table* src, int id,
155
+ bool nouseNullkey, uchar* rec, size_t size)
156
+ {
157
+
158
+ src->restoreRecord();
159
+ size_t tdSizelen = (sizeof(tabledef) + (sizeof(fielddef) * src->fields()) +
160
+ (sizeof(keydef) * src->keys()));
161
+
162
+ if (size < tdSizelen)
163
+ {
164
+ m_stat = STATUS_BUFFERTOOSMALL;
165
+ return NULL;
166
+ }
167
+ // index
168
+ keynumConvert kc(&src->keyDef(0), src->keys());
169
+
147
170
  uint_td datalen = 0;
148
- boost::shared_array<uchar> rec(new uchar[65000]);
149
171
  // table
150
- tabledef& tdef = (tabledef&)(*rec.get());
151
- initTableDef(src, tdef, id);
152
- tdef.fieldCount = (uchar_td)src->fields();
153
- tdef.keyCount = (uchar_td)src->keys();
154
- tdef.charsetIndex = charsetIndex(src->charset().csname);
155
- tdef.primaryKeyNum =
156
- (src->primarykey() < tdef.keyCount) ? src->primarykey() : -1;
172
+ tabledef& td = (*((tabledef*)rec));
173
+ initTableDef(src, td, id);
174
+ td.fieldCount = (uchar_td)src->fields();
175
+ td.keyCount = (uchar_td)src->keys();
176
+ td.charsetIndex = charsetIndex(src->charset().csname);
177
+ td.primaryKeyNum =
178
+ (src->primarykeyNum() < td.keyCount) ? kc.clientKeynum(src->primarykeyNum()) : -1;
157
179
  #ifdef USE_BTRV_VARIABLE_LEN
158
- tdef.flags.bit0 = (src->recordFormatType() & RF_FIXED_PLUS_VALIABLE_LEN);
180
+ td.flags.bit0 = (src->recordFormatType() & RF_FIXED_PLUS_VALIABLE_LEN);
159
181
  if (src->recordFormatType() & RF_FIXED_PLUS_VALIABLE_LEN)
160
- tdef.fixedRecordLen =
182
+ td.fixedRecordLen =
161
183
  (ushort_td)(src->recordLenCl() - src->lastVarFieldDataLen());
162
184
  else
163
185
  #endif
164
- tdef.fixedRecordLen = (ushort_td)src->recordLenCl();
165
- tdef.maxRecordLen = (ushort_td)src->recordLenCl();
166
- tdef.pageSize = 2048;
167
- tdef.optionFlags.bitA = ((src->recordFormatType() & RF_VALIABLE_LEN) != 0);
168
- tdef.optionFlags.bitB = (src->blobFields() != 0);
169
-
186
+ td.fixedRecordLen = (ushort_td)src->recordLenCl();
187
+ td.m_maxRecordLen = (ushort_td)src->recordLenCl();
188
+ td.optionFlags.bitA = ((src->recordFormatType() & RF_VALIABLE_LEN) != 0);
189
+ td.optionFlags.bitB = (src->blobFields() != 0);
190
+ #if defined(MARIADB_BASE_VERSION)
191
+ td.m_useInMariadb = true;
192
+ #else
193
+ td.m_useInMariadb = false;
194
+ #endif
195
+ td.m_srvMinorVer = (MYSQL_VERSION_ID / 100) % 100;
170
196
  datalen += sizeof(tabledef);
171
- tdef.fieldDefs = (fielddef*)(rec.get() + datalen);
197
+ td.fieldDefs = (fielddef*)(rec + datalen);
172
198
  // field
173
199
  ushort_td pos = 0;
200
+ String str;
174
201
  for (int i = 0; i < src->fields(); ++i)
175
202
  {
176
203
  if (isNisField(src->fieldName(i)))
177
- --tdef.fieldCount;
204
+ --td.fieldCount;
178
205
  else
179
206
  {
180
207
  fielddef fd;
181
- memset(&fd, 0, sizeof(fielddef));
208
+ Field* f = src->field(i);
209
+ memset(&fd, 0, sizeof(fd));
182
210
  fd.setName(src->fieldName(i));
183
211
  fd.len = src->fieldLen(i); // filed->pack_length();
184
212
  fd.pos = pos;
185
213
  fd.type = convFieldType(src->fieldRealType(i), src->fieldFlags(i),
186
214
  isBinary(src->fieldCharset(i)),
187
215
  isUnicode(src->fieldCharset(i)));
188
- bool usePadChar = ((fd.type == ft_mychar) || (fd.type == ft_mywchar));
189
- fd.setPadCharSettings(usePadChar, true);
190
- fd.setCharsetIndex(charsetIndex(src->fieldCharset(i).csname));
216
+ if ((fd.type == ft_mytime) || (fd.type == ft_mydatetime) || (fd.type == ft_mytimestamp))
217
+ {
218
+ if (src->isLegacyTimeFormat(i))
219
+ fd.m_options |= FIELD_OPTION_REGACY_TIME;
220
+
221
+ //for mariadb
222
+ #if defined(MARIADB_BASE_VERSION)
223
+ if(td.isMariaTimeFormat())
224
+ fd.m_options |= FIELD_OPTION_MARIADB;
225
+ #endif
226
+ }
227
+
228
+ if (fd.type == ft_mydecimal)
229
+ {
230
+ fd.digits = my_decimal_length_to_precision(f->field_length, f->decimals(),
231
+ (f->flags & UNSIGNED_FLAG) != 0);
232
+ }
233
+
234
+ fd.setPadCharSettings(false, true);
235
+ if (fd.isStringType())
236
+ fd.setCharsetIndex(charsetIndex(src->fieldCharset(i).csname));
237
+
238
+ if ((fd.type == ft_mydatetime || fd.type == ft_mytimestamp) && (f->val_real() == 0))
239
+ {// No constant value
240
+ fd.setDefaultValue(0.0f);
241
+ if (cp_has_insert_default_function(f))
242
+ fd.setDefaultValue(DFV_TIMESTAMP_DEFAULT);
243
+ }
244
+ else if (fd.isIntegerType())
245
+ fd.setDefaultValue((__int64)f->val_int());
246
+ else
247
+ {
248
+ f->val_str(&str, &str);
249
+ fd.setDefaultValue(str.c_ptr());
250
+ }
251
+ fd.setNullable(f->null_bit != 0, f->is_null());
252
+ if (fd.isNullable()) ++td.m_nullfields;
253
+ if ((fd.type == ft_mydatetime || fd.type == ft_mytimestamp) &&
254
+ cp_has_update_default_function(f))
255
+ fd.setTimeStampOnUpdate(true);
256
+
257
+ fd.decimals = (uchar_td)f->decimals();
258
+ if (fd.decimals == NOT_FIXED_DEC)
259
+ fd.decimals = 0;
260
+
261
+ if (td.isLegacyTimeFormat(fd))
262
+ {
263
+ fd.m_options |= FIELD_OPTION_REGACY_TIME;
264
+ fd.decimals = 0;
265
+ }
266
+ else
267
+ fd.m_options &= ~FIELD_OPTION_REGACY_TIME;
191
268
  pos += fd.len;
192
269
  datalen =
193
- copyToRecordImage(rec.get(), &fd, sizeof(fielddef), datalen);
270
+ copyToRecordImage(rec, &fd, sizeof(fielddef), datalen);
194
271
  }
195
272
  }
273
+ td.m_nullbytes = (td.m_nullfields + 7) / 8;
196
274
 
197
- // index
198
275
  for (int i = 0; i < src->keys(); ++i)
199
276
  {
200
- const KEY& key = src->keyDef(i);
277
+ const KEY& key = src->keyDef(kc.keyNumByMakeOrder(i));
201
278
  keydef kd;
202
279
  memset(&kd, 0, sizeof(keydef));
203
280
  kd.segmentCount = key.user_defined_key_parts;
204
281
  kd.keyNumber = i;
205
282
  int segNum = 0;
283
+ bool allNullkey = true;
206
284
  for (int j = 0; j < (int)key.user_defined_key_parts; ++j)
207
285
  {
208
286
  keySegment& sg = kd.segments[segNum];
@@ -216,7 +294,9 @@ short schemaBuilder::insertMetaRecord(table* mtb, table* src, int id)
216
294
  sg.flags.bit1 = 1; // change able
217
295
  sg.flags.bit4 = (j != kd.segmentCount - 1); // segment
218
296
  sg.flags.bit8 = 1; // extend key type
219
- sg.flags.bit9 = ks.null_bit ? 1 : 0; // null key
297
+ if (nouseNullkey == false)
298
+ sg.flags.bit9 = ks.null_bit ? 1 : 0; // null key
299
+ allNullkey = allNullkey & sg.flags.bit9;
220
300
  if (isStringTypeForIndex(convFieldType(
221
301
  src->fieldType(sg.fieldNum),
222
302
  src->fieldFlags(sg.fieldNum),
@@ -224,21 +304,51 @@ short schemaBuilder::insertMetaRecord(table* mtb, table* src, int id)
224
304
  isUnicode(src->fieldCharset(sg.fieldNum)))))
225
305
  sg.flags.bitA =
226
306
  !(src->fieldFlags(sg.fieldNum) & BINARY_FLAG);// case in-sencitive
227
- if (src->fieldDataLen(sg.fieldNum) != ks.length)
228
- {
229
- fielddef& fd = tdef.fieldDefs[sg.fieldNum];
230
- // suppot prefix key
231
- fd.keylen = ks.length;
232
- }
307
+
308
+ Field* f = src->field(sg.fieldNum);
309
+ if (f->pack_length() != ks.length + var_bytes_if(f))
310
+ td.fieldDefs[sg.fieldNum].keylen = ks.length ; // suppot prefix key
233
311
  ++segNum;
234
312
  }
235
313
  }
236
- datalen = copyToRecordImage(rec.get(), &kd, sizeof(keydef), datalen);
314
+ if (allNullkey)
315
+ {
316
+ for (int i=0;i<kd.segmentCount; ++i)
317
+ {
318
+ kd.segments[segNum].flags.bit9 = 0; //part segment null key
319
+ kd.segments[segNum].flags.bit3 = 1; //all segment null key
320
+ }
321
+ }
322
+ datalen = copyToRecordImage(rec, &kd, sizeof(keydef), datalen);
323
+ }
324
+ td = (tabledef&)(*rec);
325
+ td.varSize = datalen - 4;
326
+ td.setFielddefsPtr();
327
+ td.setKeydefsPtr();
328
+
329
+ return &td;
330
+ }
331
+
332
+ tabledef* schemaBuilder::getTabledef(database* db, const char* tablename, uchar* rec, size_t size)
333
+ {
334
+ table* tb = db->openTable(tablename, TD_OPEN_READONLY, NULL);
335
+ if (db->stat())
336
+ {
337
+ m_stat = db->stat();
338
+ return NULL;
237
339
  }
238
- tdef = (tabledef&)(*rec.get());
239
- tdef.varSize = datalen - 4;
340
+ tabledef* td = getTabledef(tb, 0, true, rec, size);
341
+ db->closeTable(tb);
342
+ return td;
343
+ }
344
+
345
+ short schemaBuilder::insertMetaRecord(table* mtb, table* src, int id, bool nouseNullkey)
346
+ {
347
+ boost::shared_array<uchar> rec(new uchar[65000]);
348
+
349
+ tabledef* td = getTabledef(src, id, nouseNullkey, rec.get(), 65000);
240
350
  mtb->clearBuffer();
241
- mtb->setRecordFromPacked(rec.get(), datalen, NULL);
351
+ mtb->setRecordFromPacked(rec.get(), td->varSize + 4, NULL);
242
352
  mtb->insert(true);
243
353
  return mtb->stat();
244
354
  }
@@ -299,7 +409,7 @@ void schemaBuilder::listSchemaTable(database* db, std::vector<std::string>& shce
299
409
  }
300
410
  }
301
411
 
302
- short schemaBuilder::execute(database* db, table* mtb)
412
+ short schemaBuilder::execute(database* db, table* mtb, bool nouseNullkey)
303
413
  {
304
414
  char path[FN_REFLEN + 1];
305
415
  build_table_filename(path, sizeof(path) - 1, db->name().c_str(), "", "", 0);
@@ -336,7 +446,7 @@ short schemaBuilder::execute(database* db, table* mtb)
336
446
  smartTransction trn(db);
337
447
  for (size_t i = 0; i < tables.size(); ++i)
338
448
  {
339
- if ((stat = insertMetaRecord(mtb, tables[i], ++id)) != 0)
449
+ if ((stat = insertMetaRecord(mtb, tables[i], ++id, nouseNullkey)) != 0)
340
450
  break;
341
451
  }
342
452
  if (stat == 0) trn.end();
@@ -47,12 +47,15 @@ namespace mysql
47
47
  class schemaBuilder
48
48
  {
49
49
  short insertMetaRecord(engine::mysql::table* mtb, engine::mysql::table* src,
50
- int id);
51
-
50
+ int id, bool nouseNullkey);
51
+ short m_stat;
52
52
  public:
53
53
  schemaBuilder();
54
54
  ~schemaBuilder();
55
- short execute(engine::mysql::database* db, engine::mysql::table* mtb);
55
+ short stat() const { return m_stat;}
56
+ tabledef* getTabledef(engine::mysql::table* src, int id, bool nouseNullkey, uchar* rec, size_t size);
57
+ tabledef* getTabledef(engine::mysql::database* db, const char* tablename, uchar* rec, size_t size);
58
+ short execute(engine::mysql::database* db, engine::mysql::table* mtb, bool nouseNullkey);
56
59
  static void listSchemaTable(engine::mysql::database* db, std::vector<std::string>& shcemaNames);
57
60
  };
58
61