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.
- checksums.yaml +4 -4
- data/CMakeLists.txt +1 -1
- data/README-JA.md +52 -529
- data/README.md +52 -523
- data/bin/common/tdclc_32_3_0.dll +0 -0
- data/bin/common/tdclc_64_3_0.dll +0 -0
- data/build/common/system.cmake +2 -1
- data/build/common/transactd_cl_common.cmake +3 -6
- data/build/swig/ruby/ruby.swg +85 -28
- data/build/swig/ruby/tdclrb_wrap.cpp +3195 -1578
- data/build/swig/tdcl.i +161 -5
- data/build/tdclc/CMakeLists.txt +1 -0
- data/build/tdclc/tdclc.cbproj +7 -1
- data/build/tdclc/tdclc.rc +4 -4
- data/build/tdclcpp/tdclcpp.rc +4 -4
- data/build/tdclcpp/tdclcpp_bc.cbproj +2 -5
- data/build/tdclrb/tdclrb.rc +4 -4
- data/source/bzs/db/blobStructs.h +1 -1
- data/source/bzs/db/engine/mysql/database.cpp +199 -74
- data/source/bzs/db/engine/mysql/database.h +47 -18
- data/source/bzs/db/engine/mysql/dbManager.cpp +1 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +32 -8
- data/source/bzs/db/protocol/tdap/btrDate.cpp +110 -75
- data/source/bzs/db/protocol/tdap/btrDate.h +46 -21
- data/source/bzs/db/protocol/tdap/client/activeTable.cpp +18 -18
- data/source/bzs/db/protocol/tdap/client/activeTable.h +25 -25
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +10 -4
- data/source/bzs/db/protocol/tdap/client/client.cpp +6 -5
- data/source/bzs/db/protocol/tdap/client/client.h +82 -15
- data/source/bzs/db/protocol/tdap/client/database.cpp +531 -142
- data/source/bzs/db/protocol/tdap/client/database.h +19 -6
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +461 -408
- data/source/bzs/db/protocol/tdap/client/dbDef.h +11 -17
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +61 -13
- data/source/bzs/db/protocol/tdap/client/field.cpp +1592 -1398
- data/source/bzs/db/protocol/tdap/client/field.h +110 -121
- data/source/bzs/db/protocol/tdap/client/fields.h +40 -10
- data/source/bzs/db/protocol/tdap/client/filter.h +69 -55
- data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +296 -164
- data/source/bzs/db/protocol/tdap/client/groupQuery.h +77 -25
- data/source/bzs/db/protocol/tdap/client/memRecord.cpp +31 -13
- data/source/bzs/db/protocol/tdap/client/memRecord.h +31 -21
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +1 -1
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +4 -1
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +69 -24
- data/source/bzs/db/protocol/tdap/client/nsTable.h +3 -1
- data/source/bzs/db/protocol/tdap/client/recordset.cpp +1 -0
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +46 -27
- data/source/bzs/db/protocol/tdap/client/request.h +2 -1
- data/source/bzs/db/protocol/tdap/client/serializer.cpp +44 -9
- data/source/bzs/db/protocol/tdap/client/serializer.h +1 -1
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +182 -76
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +23 -12
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +8 -10
- data/source/bzs/db/protocol/tdap/client/table.cpp +172 -93
- data/source/bzs/db/protocol/tdap/client/table.h +112 -37
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +17 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +0 -1
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +0 -2
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +1 -1
- data/source/bzs/db/protocol/tdap/fieldComp.h +698 -14
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +723 -307
- data/source/bzs/db/protocol/tdap/myDateTime.h +294 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +164 -54
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +6 -3
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +133 -550
- data/source/bzs/db/protocol/tdap/mysql/request.h +6 -5
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +217 -82
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +1 -1
- data/source/bzs/db/protocol/tdap/tdapRequest.h +4 -9
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +808 -17
- data/source/bzs/db/protocol/tdap/tdapSchema.h +656 -164
- data/source/bzs/db/protocol/tdap/tdapcapi.h +130 -28
- data/source/bzs/db/protocol/tdap/uri.h +40 -32
- data/source/bzs/db/transactd/connManager.cpp +1 -1
- data/source/bzs/db/transactd/transactd.cpp +7 -0
- data/source/bzs/env/compiler.h +107 -94
- data/source/bzs/env/crosscompile.cpp +24 -12
- data/source/bzs/env/crosscompile.h +75 -6
- data/source/bzs/env/mbcswchrLinux.cpp +2 -2
- data/source/bzs/env/tcharMinGW.h +4 -0
- data/source/bzs/example/changeSchema.cpp +22 -17
- data/source/bzs/example/queryData.cpp +4 -0
- data/source/bzs/netsvc/client/iconnection.h +3 -1
- data/source/bzs/netsvc/client/tcpClient.h +10 -3
- data/source/bzs/rtl/stringBuffers.cpp +7 -0
- data/source/bzs/test/tdclatl/bench_query_atl.js +6 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +8 -1
- data/source/bzs/test/tdclatl/test_query_atl.js +22 -2
- data/source/bzs/test/tdclatl/test_v3.js +1017 -0
- data/source/bzs/test/tdclphp/transactd_Test.php +55 -21
- data/source/bzs/test/tdclphp/transactd_datetime_Test.php +0 -5
- data/source/bzs/test/tdclphp/transactd_pool_Test.php +2 -0
- data/source/bzs/test/tdclphp/transactd_v3_Test.php +743 -0
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +0 -5
- data/source/bzs/test/tdclrb/transactd_pool_spec.rb +2 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +39 -16
- data/source/bzs/test/tdclrb/transactd_v3_spec.rb +748 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +55 -58
- data/source/bzs/test/transactdBench/transactdBench2.cpp +1 -3
- data/source/bzs/test/trdclengn/testField.h +3305 -0
- data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +1050 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +112 -190
- data/source/bzs/test/trdclengn/testbase.h +137 -0
- data/source/global/ormsrcgen/srcgen.cpp +23 -12
- data/source/global/ormsrcgen/template/ormDataClass_template.h +2 -0
- data/source/global/querystmts/querystmts.cpp +2 -3
- data/source/global/tdclatl/Bitset.cpp +38 -0
- data/source/global/tdclatl/Bitset.h +63 -0
- data/source/global/tdclatl/Database.cpp +59 -18
- data/source/global/tdclatl/Database.h +7 -4
- data/source/global/tdclatl/DbDef.cpp +6 -6
- data/source/global/tdclatl/DbDef.h +2 -1
- data/source/global/tdclatl/Field.cpp +112 -0
- data/source/global/tdclatl/Field.h +19 -5
- data/source/global/tdclatl/FieldDef.cpp +137 -16
- data/source/global/tdclatl/FieldDef.h +18 -2
- data/source/global/tdclatl/FieldDefs.cpp +54 -1
- data/source/global/tdclatl/FieldDefs.h +3 -0
- data/source/global/tdclatl/GroupQuery.cpp +8 -8
- data/source/global/tdclatl/QueryBase.cpp +65 -0
- data/source/global/tdclatl/QueryBase.h +10 -0
- data/source/global/tdclatl/Record.cpp +33 -2
- data/source/global/tdclatl/Record.h +3 -1
- data/source/global/tdclatl/RecordsetQuery.cpp +42 -0
- data/source/global/tdclatl/RecordsetQuery.h +8 -0
- data/source/global/tdclatl/Table.cpp +127 -3
- data/source/global/tdclatl/Table.h +10 -1
- data/source/global/tdclatl/TableDef.cpp +41 -8
- data/source/global/tdclatl/TableDef.h +7 -2
- data/source/global/tdclatl/activeTable.cpp +40 -71
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/tdclatl.idl +222 -28
- data/source/linux/tchar.h +100 -96
- data/transactd.gemspec +2 -2
- metadata +13 -11
- data/BUILD_UNIX-JA.md +0 -161
- data/BUILD_WIN-JA.md +0 -326
- data/README_ORMSRCGEN-JA.md +0 -115
- data/README_ORMSRCGEN.md +0 -118
- data/RELEASE_NOTE-JA.md +0 -356
- data/RELEASE_NOTE.md +0 -360
- data/bin/common/tdclc_32_2_4.dll +0 -0
- data/bin/common/tdclc_64_2_4.dll +0 -0
- data/source/bzs/test/trdclengn/test_blob.cpp +0 -375
|
@@ -71,10 +71,8 @@ char g_buf[TMP_BUFSIZE];
|
|
|
71
71
|
#define NOTE_TYPE 12
|
|
72
72
|
#define VAR_TYPE 13
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const char* getFieldTypeName(uchar_td fieldType, int size, bool nobinary,
|
|
77
|
-
const char* charsetName)
|
|
74
|
+
const char* getFieldTypeName(const fielddef& fd, int size, bool nobinary,
|
|
75
|
+
const char* charsetName, int decimals)
|
|
78
76
|
{
|
|
79
77
|
const char* bin_ptr = nobinary ? "" : "binary";
|
|
80
78
|
char charsetString[128] = { " CHARACTER SET " };
|
|
@@ -82,47 +80,68 @@ const char* getFieldTypeName(uchar_td fieldType, int size, bool nobinary,
|
|
|
82
80
|
strcat_s(charsetString, 128, charsetName);
|
|
83
81
|
else
|
|
84
82
|
charsetString[0] = 0x00;
|
|
85
|
-
|
|
86
|
-
switch (fieldType)
|
|
83
|
+
switch (fd.type)
|
|
87
84
|
{
|
|
88
|
-
|
|
89
85
|
case ft_integer:
|
|
90
86
|
case ft_autoinc:
|
|
91
87
|
case ft_currency:
|
|
92
88
|
case ft_date:
|
|
93
89
|
case ft_time:
|
|
90
|
+
case ft_datetime:
|
|
94
91
|
case ft_timestamp:
|
|
95
92
|
if (size == 1)
|
|
96
93
|
return "TINYINT";
|
|
97
94
|
if (size == 2)
|
|
98
95
|
return "SMALLINT";
|
|
96
|
+
if (size == 3)
|
|
97
|
+
return "MEDIUMINT";
|
|
99
98
|
if (size == 4)
|
|
100
99
|
return "INT";
|
|
101
100
|
if (size == 8)
|
|
102
101
|
return "BIGINT";
|
|
102
|
+
case ft_bit:
|
|
103
|
+
sprintf_s(g_buf, TMP_BUFSIZE, "BIT(%d)", size * 8);
|
|
104
|
+
return g_buf;
|
|
105
|
+
case ft_enum:
|
|
106
|
+
case ft_set:
|
|
103
107
|
case ft_uinteger:
|
|
104
108
|
case ft_autoIncUnsigned:
|
|
105
109
|
if (size == 1)
|
|
106
110
|
return "TINYINT UNSIGNED";
|
|
107
111
|
if (size == 2)
|
|
108
112
|
return "SMALLINT UNSIGNED";
|
|
113
|
+
if (size == 3)
|
|
114
|
+
return "MEDIUMINT UNSIGNED";
|
|
109
115
|
if (size == 4)
|
|
110
116
|
return "INT UNSIGNED";
|
|
111
117
|
if (size == 8)
|
|
112
118
|
return "BIGINT UNSIGNED";
|
|
113
119
|
case ft_logical:
|
|
114
|
-
|
|
120
|
+
if (size == 1)
|
|
121
|
+
return "TINYINT UNSIGNED";
|
|
122
|
+
if (size == 2)
|
|
123
|
+
return "SMALLINT UNSIGNED";
|
|
124
|
+
case ft_myyear:
|
|
125
|
+
return "YEAR";
|
|
115
126
|
case ft_mydate:
|
|
116
127
|
return "DATE";
|
|
117
128
|
case ft_mytime:
|
|
118
|
-
|
|
129
|
+
if(fd.isLegacyTimeFormat())
|
|
130
|
+
sprintf_s(g_buf, TMP_BUFSIZE, "TIME");
|
|
131
|
+
else
|
|
132
|
+
sprintf_s(g_buf, TMP_BUFSIZE, "TIME(%d)", decimals);
|
|
119
133
|
return g_buf;
|
|
120
134
|
case ft_mydatetime:
|
|
121
|
-
|
|
135
|
+
if(fd.isLegacyTimeFormat())
|
|
136
|
+
sprintf_s(g_buf, TMP_BUFSIZE, "DATETIME");
|
|
137
|
+
else
|
|
138
|
+
sprintf_s(g_buf, TMP_BUFSIZE, "DATETIME(%d)", decimals);
|
|
122
139
|
return g_buf;
|
|
123
140
|
case ft_mytimestamp:
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
if(fd.isLegacyTimeFormat())
|
|
142
|
+
sprintf_s(g_buf, TMP_BUFSIZE, "TIMESTAMP");
|
|
143
|
+
else
|
|
144
|
+
sprintf_s(g_buf, TMP_BUFSIZE, "TIMESTAMP(%d)", decimals);
|
|
126
145
|
return g_buf;
|
|
127
146
|
case ft_mytext:
|
|
128
147
|
if (size - 8 == 4)
|
|
@@ -140,11 +159,18 @@ const char* getFieldTypeName(uchar_td fieldType, int size, bool nobinary,
|
|
|
140
159
|
else if (size - 8 == 2)
|
|
141
160
|
return "BLOB";
|
|
142
161
|
return "TINYBLOB";
|
|
162
|
+
case ft_myjson:
|
|
163
|
+
return "JSON";
|
|
164
|
+
case ft_mygeometry:
|
|
165
|
+
return "GEOMETRY";
|
|
143
166
|
case ft_float:
|
|
144
167
|
if (size == 4)
|
|
145
168
|
return "FLOAT";
|
|
146
169
|
if (size == 8)
|
|
147
170
|
return "DOUBLE";
|
|
171
|
+
case ft_mydecimal:
|
|
172
|
+
sprintf_s(g_buf, TMP_BUFSIZE, "DECIMAL(%d, %d)", fd.digits, decimals);
|
|
173
|
+
return g_buf;
|
|
148
174
|
case ft_string:
|
|
149
175
|
case ft_wstring:
|
|
150
176
|
sprintf_s(g_buf, TMP_BUFSIZE, "BINARY(%d)", size);
|
|
@@ -157,6 +183,7 @@ const char* getFieldTypeName(uchar_td fieldType, int size, bool nobinary,
|
|
|
157
183
|
case ft_lvar: // var
|
|
158
184
|
sprintf_s(g_buf, TMP_BUFSIZE, "VARBINARY(%d)", size);
|
|
159
185
|
return g_buf;
|
|
186
|
+
case ft_lstring:
|
|
160
187
|
case ft_myvarbinary:
|
|
161
188
|
case ft_myfixedbinary:
|
|
162
189
|
sprintf_s(g_buf, TMP_BUFSIZE, "VARBINARY(%d)", size);
|
|
@@ -164,7 +191,6 @@ const char* getFieldTypeName(uchar_td fieldType, int size, bool nobinary,
|
|
|
164
191
|
case ft_mywvarbinary:
|
|
165
192
|
sprintf_s(g_buf, TMP_BUFSIZE, "VARBINARY(%d)", size);
|
|
166
193
|
return g_buf;
|
|
167
|
-
|
|
168
194
|
case ft_mywvarchar:
|
|
169
195
|
sprintf_s(g_buf, TMP_BUFSIZE, "VARCHAR(%d) %s CHARACTER SET utf16le",
|
|
170
196
|
size, bin_ptr);
|
|
@@ -220,36 +246,34 @@ bool isNumericFieldName(const char* name)
|
|
|
220
246
|
return false;
|
|
221
247
|
}
|
|
222
248
|
|
|
223
|
-
|
|
249
|
+
char* removeTimeStampOptionDecimal(const char* s, char* buf, size_t size)
|
|
224
250
|
{
|
|
225
|
-
|
|
226
|
-
|
|
251
|
+
strcpy_s(buf, size, s);
|
|
252
|
+
char* p = strrchr(buf, '(');
|
|
253
|
+
if (p)
|
|
254
|
+
*p = 0x00;
|
|
255
|
+
return buf;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
char* getBitDefalutValue(char* buf, size_t size, unsigned __int64 v)
|
|
259
|
+
{
|
|
260
|
+
char* p = buf;
|
|
261
|
+
for (int i = 0; i< 64;++i)
|
|
227
262
|
{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
{
|
|
233
|
-
// bit3 all segment NULL key
|
|
234
|
-
// bit9 part segment NULL key
|
|
235
|
-
// if fd.nullValue != 0x00 then this field is type of not null .
|
|
236
|
-
const fielddef& fd = table->fieldDefs[fieldIndex];
|
|
237
|
-
if (((key.segments[j].flags.bit3 ||
|
|
238
|
-
key.segments[j].flags.bit9)) &&
|
|
239
|
-
(fd.nullValue == 0x00))
|
|
240
|
-
ret = true;
|
|
241
|
-
else
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
263
|
+
if (v & (1ULL << (63 - i)))
|
|
264
|
+
*(p++) = '1';
|
|
265
|
+
else if (p != buf)
|
|
266
|
+
*(p++) = '0';
|
|
245
267
|
}
|
|
246
|
-
|
|
268
|
+
*p = 0x00;
|
|
269
|
+
return buf;
|
|
247
270
|
}
|
|
248
271
|
|
|
249
|
-
std::string
|
|
272
|
+
std::string sqlBuilder::getFieldList(const tabledef* table, std::vector<std::string>& fdl, const clsrv_ver* ver)
|
|
250
273
|
{
|
|
251
274
|
std::string s;
|
|
252
275
|
int len;
|
|
276
|
+
char timestamp_tmp[64];
|
|
253
277
|
for (int i = 0; i < table->fieldCount; i++)
|
|
254
278
|
{
|
|
255
279
|
const fielddef& fd = table->fieldDefs[i];
|
|
@@ -274,11 +298,101 @@ std::string getFiledList(const tabledef* table, std::vector<std::string>& fdl)
|
|
|
274
298
|
if (fd.charsetIndex() != table->charsetIndex)
|
|
275
299
|
charsetName = mysql::charsetName(fd.charsetIndex());
|
|
276
300
|
|
|
277
|
-
s += getFieldTypeName(fd
|
|
278
|
-
|
|
279
|
-
|
|
301
|
+
s += getFieldTypeName(fd, len, f.bitA, charsetName, fd.decimals);
|
|
302
|
+
const char* p = fd.defaultValue_str();
|
|
303
|
+
if ((fd.defaultValue() == DFV_TIMESTAMP_DEFAULT) &&
|
|
304
|
+
((fd.type == ft_mytimestamp) || (fd.type == ft_mydatetime)))
|
|
305
|
+
p = timeStampDefaultStr(fd, timestamp_tmp, 64);
|
|
306
|
+
if (fd.isNullable())
|
|
307
|
+
{
|
|
308
|
+
if (fd.isDefaultNull())
|
|
309
|
+
s += " NULL DEFAULT NULL";
|
|
310
|
+
else if (p[0])
|
|
311
|
+
{
|
|
312
|
+
if ((fd.type == ft_mytimestamp) ||
|
|
313
|
+
(fd.type == ft_mydatetime))
|
|
314
|
+
{
|
|
315
|
+
s += " NULL DEFAULT ";
|
|
316
|
+
if (!ver->isSupportDateTimeTimeStamp())
|
|
317
|
+
{
|
|
318
|
+
char tmp[100];
|
|
319
|
+
s += removeTimeStampOptionDecimal(p, tmp, 100);
|
|
320
|
+
}
|
|
321
|
+
else
|
|
322
|
+
s += p;
|
|
323
|
+
}else if (fd.type == ft_bit)
|
|
324
|
+
{
|
|
325
|
+
s += " NULL DEFAULT b'";
|
|
326
|
+
char tmp[100] = {NULL};
|
|
327
|
+
s += getBitDefalutValue(tmp, 100, (unsigned __int64)fd.defaultValue64());
|
|
328
|
+
s += "'";
|
|
329
|
+
}
|
|
330
|
+
else
|
|
331
|
+
{
|
|
332
|
+
s += " NULL DEFAULT '";
|
|
333
|
+
s += p;
|
|
334
|
+
s += "'";
|
|
335
|
+
}
|
|
336
|
+
}else
|
|
337
|
+
{
|
|
338
|
+
if (isStringTypeForIndex(fd.type))
|
|
339
|
+
s += " NULL DEFAULT ''";
|
|
340
|
+
else if (fd.type == ft_mydatetime || fd.type == ft_mytimestamp)
|
|
341
|
+
s += " NULL DEFAULT '0000-00-00 00:00:00'";
|
|
342
|
+
else if (fd.type == ft_mydate)
|
|
343
|
+
s += " NULL DEFAULT '0000-00-00'";
|
|
344
|
+
else if (fd.type == ft_mytime)
|
|
345
|
+
s += " NULL DEFAULT '00:00:00'";
|
|
346
|
+
else if (fd.isNumericType() || fd.isDateTimeType()/*P.SQL date time*/ )
|
|
347
|
+
s += " NULL DEFAULT '0'";
|
|
348
|
+
else
|
|
349
|
+
s += " NULL";
|
|
350
|
+
}
|
|
351
|
+
}
|
|
280
352
|
else
|
|
281
|
-
|
|
353
|
+
{
|
|
354
|
+
s += " NOT NULL ";
|
|
355
|
+
if (p[0])
|
|
356
|
+
{
|
|
357
|
+
if ((fd.type == ft_mytimestamp) ||
|
|
358
|
+
(fd.type == ft_mydatetime))
|
|
359
|
+
{
|
|
360
|
+
s += "DEFAULT ";
|
|
361
|
+
if (!ver->isSupportDateTimeTimeStamp())
|
|
362
|
+
{
|
|
363
|
+
char tmp[100];
|
|
364
|
+
s += removeTimeStampOptionDecimal(p, tmp, 100);
|
|
365
|
+
}
|
|
366
|
+
else
|
|
367
|
+
s += p;
|
|
368
|
+
}else if (fd.type == ft_bit)
|
|
369
|
+
{
|
|
370
|
+
s += "DEFAULT b'";
|
|
371
|
+
char tmp[100] = {NULL};
|
|
372
|
+
s += getBitDefalutValue(tmp, 100, (unsigned __int64)fd.defaultValue());
|
|
373
|
+
s += "'";
|
|
374
|
+
}
|
|
375
|
+
else
|
|
376
|
+
{
|
|
377
|
+
s += "DEFAULT '";
|
|
378
|
+
s += p;
|
|
379
|
+
s += "'";
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
if (fd.isTimeStampOnUpdate())
|
|
384
|
+
{
|
|
385
|
+
char buf[64];
|
|
386
|
+
updateTimeStampStr(&fd, buf, 64);
|
|
387
|
+
if (!ver->isSupportDateTimeTimeStamp())
|
|
388
|
+
{
|
|
389
|
+
char tmp[100];
|
|
390
|
+
s += removeTimeStampOptionDecimal(buf, tmp, 100);
|
|
391
|
+
}
|
|
392
|
+
else
|
|
393
|
+
s += buf;
|
|
394
|
+
}
|
|
395
|
+
|
|
282
396
|
if ((fd.type == ft_autoinc) || (fd.type == ft_autoIncUnsigned))
|
|
283
397
|
s += " AUTO_INCREMENT";
|
|
284
398
|
s += ",";
|
|
@@ -286,50 +400,42 @@ std::string getFiledList(const tabledef* table, std::vector<std::string>& fdl)
|
|
|
286
400
|
return s;
|
|
287
401
|
}
|
|
288
402
|
|
|
289
|
-
|
|
290
|
-
{
|
|
291
|
-
if (key.segmentCount > NIS_FD_KEYSEG_LIMIT)
|
|
292
|
-
{
|
|
293
|
-
// If a first segment is not 1 byte of Logical
|
|
294
|
-
const fielddef& fd = table->fieldDefs[key.segments[0].fieldNum];
|
|
295
|
-
return (!((fd.len == 1) && (fd.type == ft_logical)));
|
|
296
|
-
}
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
void insertNisFields(const tabledef* table, std::vector<std::string>& fdl,
|
|
403
|
+
void sqlBuilder::insertNisFields(const tabledef* td, std::vector<std::string>& fdl,
|
|
301
404
|
std::string& s)
|
|
302
405
|
{
|
|
303
406
|
char buf[20];
|
|
304
|
-
for (int i = 0; i <
|
|
407
|
+
for (int i = 0; i < td->keyCount; i++)
|
|
305
408
|
{
|
|
306
409
|
_ltoa_s(i, buf, 20, 10);
|
|
307
410
|
std::string fddef = "";
|
|
308
|
-
const keydef& key =
|
|
309
|
-
if (
|
|
411
|
+
const keydef& key = td->keyDefs[i];
|
|
412
|
+
if (td->isNullKey(key))
|
|
310
413
|
{
|
|
311
|
-
if (key
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
414
|
+
if (td->isNeedNis(key))
|
|
415
|
+
{
|
|
416
|
+
if (key.segments[0].flags.bit9)
|
|
417
|
+
fddef = std::string("`") + "$nfn" + buf +
|
|
418
|
+
"` TINYINT UNSIGNED NULL,";
|
|
419
|
+
else if (key.segments[0].flags.bit3)
|
|
420
|
+
fddef = std::string("`") + "$nfa" + buf +
|
|
421
|
+
"` TINYINT UNSIGNED NULL,";
|
|
422
|
+
}
|
|
317
423
|
}
|
|
318
424
|
if (fddef != "")
|
|
319
425
|
s += fddef;
|
|
320
426
|
}
|
|
321
427
|
}
|
|
322
428
|
|
|
323
|
-
std::string& getKey(const tabledef*
|
|
324
|
-
int index, std::string& s, bool specifyKeyNum
|
|
429
|
+
std::string& sqlBuilder::getKey(const tabledef* td, std::vector<std::string>& fdl,
|
|
430
|
+
int index, std::string& s, bool specifyKeyNum)
|
|
325
431
|
{
|
|
326
432
|
char buf[20];
|
|
327
|
-
const keydef& key =
|
|
433
|
+
const keydef& key = td->keyDefs[index];
|
|
328
434
|
if (specifyKeyNum)
|
|
329
435
|
_ltoa_s(key.keyNumber, buf, 20, 10);
|
|
330
436
|
else
|
|
331
437
|
_ltoa_s(index, buf, 20, 10);
|
|
332
|
-
if ((
|
|
438
|
+
if ((td->primaryKeyNum == index) &&
|
|
333
439
|
(fdl[key.segments[0].fieldNum] == "auto_id_field"))
|
|
334
440
|
s += " PRIMARY KEY ";
|
|
335
441
|
else
|
|
@@ -345,7 +451,7 @@ std::string& getKey(const tabledef* table, std::vector<std::string>& fdl,
|
|
|
345
451
|
s += "(";
|
|
346
452
|
|
|
347
453
|
// "nf" segment is added to a head.
|
|
348
|
-
if (isNeedNis(
|
|
454
|
+
if (td->isNeedNis(key))
|
|
349
455
|
{
|
|
350
456
|
if (key.segments[0].flags.bit9)
|
|
351
457
|
s += std::string("`") + "$nfn" + buf + "`,";
|
|
@@ -359,7 +465,7 @@ std::string& getKey(const tabledef* table, std::vector<std::string>& fdl,
|
|
|
359
465
|
s += "`";
|
|
360
466
|
|
|
361
467
|
// part key
|
|
362
|
-
const fielddef& fd =
|
|
468
|
+
const fielddef& fd = td->fieldDefs[key.segments[j].fieldNum];
|
|
363
469
|
if (fd.keylen && ((fd.keylen != fd.len) || fd.blobLenBytes()))
|
|
364
470
|
{
|
|
365
471
|
sprintf_s(buf, 20, "(%d)", fd.keylen);
|
|
@@ -375,7 +481,7 @@ std::string& getKey(const tabledef* table, std::vector<std::string>& fdl,
|
|
|
375
481
|
return s;
|
|
376
482
|
}
|
|
377
483
|
|
|
378
|
-
std::string getKeyList(const tabledef* table, std::vector<std::string>& fdl)
|
|
484
|
+
std::string sqlBuilder::getKeyList(const tabledef* table, std::vector<std::string>& fdl)
|
|
379
485
|
{
|
|
380
486
|
std::string s;
|
|
381
487
|
for (int i = 0; i < table->keyCount; i++)
|
|
@@ -420,8 +526,8 @@ void makeSuffixNamesList(const tabledef* table, std::vector<std::string>& fds)
|
|
|
420
526
|
}
|
|
421
527
|
}
|
|
422
528
|
|
|
423
|
-
std::string sqlCreateTable(const char* name /* utf8 */, tabledef* table,
|
|
424
|
-
uchar_td charsetIndexServer)
|
|
529
|
+
std::string sqlBuilder::sqlCreateTable(const char* name /* utf8 */, tabledef* table,
|
|
530
|
+
uchar_td charsetIndexServer, const clsrv_ver* ver)
|
|
425
531
|
{
|
|
426
532
|
// Duplication of a name is inspected and, in duplication, _1 is added.
|
|
427
533
|
// It does not correspond to two or more duplications.
|
|
@@ -441,7 +547,7 @@ std::string sqlCreateTable(const char* name /* utf8 */, tabledef* table,
|
|
|
441
547
|
}
|
|
442
548
|
else
|
|
443
549
|
s += getFileName(table->fileNameA()) + "` (";
|
|
444
|
-
s +=
|
|
550
|
+
s += getFieldList(table, fds, ver);
|
|
445
551
|
insertNisFields(table, fds, s);
|
|
446
552
|
s += getKeyList(table, fds);
|
|
447
553
|
if (s[s.size() - 1] == ',')
|
|
@@ -457,15 +563,15 @@ std::string sqlCreateTable(const char* name /* utf8 */, tabledef* table,
|
|
|
457
563
|
return s;
|
|
458
564
|
}
|
|
459
565
|
|
|
460
|
-
std::string sqlCreateIndex(const tabledef* table, int keyNum,
|
|
461
|
-
bool specifyKeyNum, uchar_td charsetIndexServer)
|
|
566
|
+
std::string sqlBuilder::sqlCreateIndex(const tabledef* table, int keyNum,
|
|
567
|
+
bool specifyKeyNum, uchar_td charsetIndexServer, const clsrv_ver* ver)
|
|
462
568
|
{
|
|
463
569
|
std::string s;
|
|
464
570
|
std::vector<std::string> fds;// suffix added names list
|
|
465
571
|
makeSuffixNamesList(table, fds);
|
|
466
572
|
uint_td schemaCodePage =
|
|
467
573
|
table->schemaCodePage ? table->schemaCodePage : GetACP();
|
|
468
|
-
s +=
|
|
574
|
+
s += getFieldList(table, fds, ver);
|
|
469
575
|
insertNisFields(table, fds, s);
|
|
470
576
|
s = "`";
|
|
471
577
|
s+= getFileName(table->fileNameA());
|
|
@@ -616,8 +722,8 @@ void makeTableDef(tabledef* TableDef, fileSpec* fs, std::vector<fielddef>& fds)
|
|
|
616
722
|
TableDef->fieldCount = (ushort_td)fds.size();
|
|
617
723
|
}
|
|
618
724
|
|
|
619
|
-
std::string sqlCreateTable(const char* fileName, fileSpec* fs,
|
|
620
|
-
uchar_td charsetIndexServer)
|
|
725
|
+
std::string sqlBuilder::sqlCreateTable(const char* fileName, fileSpec* fs,
|
|
726
|
+
uchar_td charsetIndexServer, const clsrv_ver* ver)
|
|
621
727
|
{
|
|
622
728
|
tabledef table;
|
|
623
729
|
memset(&table, 0, sizeof(tabledef));
|
|
@@ -632,7 +738,7 @@ std::string sqlCreateTable(const char* fileName, fileSpec* fs,
|
|
|
632
738
|
table.keyDefs = &kds[0];
|
|
633
739
|
makeTableDef(&table, fs, fds);
|
|
634
740
|
|
|
635
|
-
return sqlCreateTable(fileName, &table, charsetIndexServer);
|
|
741
|
+
return sqlCreateTable(fileName, &table, charsetIndexServer, ver);
|
|
636
742
|
}
|
|
637
743
|
|
|
638
744
|
} // namespace client
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
================================================================= */
|
|
21
21
|
#include <bzs/db/protocol/tdap/tdapSchema.h>
|
|
22
22
|
#include <string>
|
|
23
|
+
#include <vector>
|
|
23
24
|
|
|
24
25
|
namespace bzs
|
|
25
26
|
{
|
|
@@ -32,18 +33,28 @@ namespace tdap
|
|
|
32
33
|
namespace client
|
|
33
34
|
{
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
std::string
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
class sqlBuilder
|
|
37
|
+
{
|
|
38
|
+
static std::string getFieldList(const tabledef* table, std::vector<std::string>& fdl, const clsrv_ver* ver);
|
|
39
|
+
static void insertNisFields(const tabledef* td, std::vector<std::string>& fdl, std::string& s);
|
|
40
|
+
static std::string& getKey(const tabledef* td, std::vector<std::string>& fdl,
|
|
41
|
+
int index, std::string& s, bool specifyKeyNum=false);
|
|
42
|
+
static std::string getKeyList(const tabledef* table, std::vector<std::string>& fdl);
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/** create statement charset must be server default charset.
|
|
46
|
+
* server default charset writen in my.cnf.
|
|
47
|
+
*
|
|
48
|
+
* @param charsetIndexServer server default charset
|
|
49
|
+
*/
|
|
50
|
+
static std::string sqlCreateTable(const char* name, tabledef* table,
|
|
51
|
+
uchar_td charsetIndexServer, const clsrv_ver* ver);
|
|
52
|
+
static std::string sqlCreateTable(const char* fileName, fileSpec* fs,
|
|
53
|
+
uchar_td charsetIndexServer, const clsrv_ver* ver);
|
|
54
|
+
|
|
55
|
+
static std::string sqlCreateIndex(const tabledef* table, int keyNum,
|
|
56
|
+
bool specifyKeyNum, uchar_td charsetIndexServer, const clsrv_ver* ver);
|
|
57
|
+
};
|
|
47
58
|
|
|
48
59
|
} // namespace client
|
|
49
60
|
} // namespace tdap
|
|
@@ -448,7 +448,7 @@ public:
|
|
|
448
448
|
|
|
449
449
|
inline size_t maxStoreBytes() const { return m_fd.len - 1; };
|
|
450
450
|
|
|
451
|
-
inline int padChar() const { return
|
|
451
|
+
inline int padChar() const { return -1; };
|
|
452
452
|
|
|
453
453
|
inline int storeOffsetBytes() const { return 0; };
|
|
454
454
|
|
|
@@ -466,7 +466,7 @@ public:
|
|
|
466
466
|
|
|
467
467
|
inline size_t maxStoreBytes() const { return m_fd.len - sizeof(short); };
|
|
468
468
|
|
|
469
|
-
inline int padChar() const { return
|
|
469
|
+
inline int padChar() const { return -1; };
|
|
470
470
|
|
|
471
471
|
inline int storeOffsetBytes() const { return 0; };
|
|
472
472
|
|
|
@@ -527,8 +527,7 @@ inline WCHAR* memset_t(WCHAR* dest, int c, size_t count)
|
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
template <typename _SF, typename store_type, typename T>
|
|
530
|
-
void store(char* ptr, const T* data, const fielddef& fd, stringConverter* cv
|
|
531
|
-
bool usePad = true)
|
|
530
|
+
void store(char* ptr, const T* data, const fielddef& fd, stringConverter* cv)
|
|
532
531
|
{
|
|
533
532
|
_SF sf(fd);
|
|
534
533
|
|
|
@@ -551,8 +550,7 @@ void store(char* ptr, const T* data, const fielddef& fd, stringConverter* cv,
|
|
|
551
550
|
memcpy_t(strPtr, data, len);
|
|
552
551
|
}
|
|
553
552
|
}
|
|
554
|
-
int fc =
|
|
555
|
-
|
|
553
|
+
int fc = sf.padChar();
|
|
556
554
|
// Trim by max charctor number (not char type length) and invalid mbc lead
|
|
557
555
|
// byte.
|
|
558
556
|
int maxCharnum = sf.maxCharNum();
|
|
@@ -600,7 +598,7 @@ const T* read(char* ptr, ::bzs::rtl::stringBuffer* strBufs, const fielddef& fd,
|
|
|
600
598
|
if ((typeid(T) != typeid(store_type)) ||
|
|
601
599
|
(cv->isNeedConvert() && (typeid(T) == typeid(char))))
|
|
602
600
|
{
|
|
603
|
-
len =
|
|
601
|
+
len = dataLen(fd, (const uchar_td*)ptr) / sizeof(store_type);
|
|
604
602
|
size_t olen =
|
|
605
603
|
len * 2 * sizeof(store_type) + 1; // utf8�ւ�2�{�̉\��������
|
|
606
604
|
result = strBufs->getPtr<T>(olen);
|
|
@@ -608,7 +606,7 @@ const T* read(char* ptr, ::bzs::rtl::stringBuffer* strBufs, const fielddef& fd,
|
|
|
608
606
|
}
|
|
609
607
|
else if (sf.isNeedReadCopy())
|
|
610
608
|
{
|
|
611
|
-
len =
|
|
609
|
+
len = dataLen(fd, (const uchar_td*)ptr);
|
|
612
610
|
if (len == sf.maxStoreBytes())
|
|
613
611
|
{
|
|
614
612
|
result = (T*)strBufs->getPtrA(len + 2);
|
|
@@ -665,8 +663,8 @@ template <typename T>
|
|
|
665
663
|
const T* readBlob(char* ptr, ::bzs::rtl::stringBuffer* strBufs,
|
|
666
664
|
const fielddef& fd, stringConverter* cv)
|
|
667
665
|
{
|
|
668
|
-
int offset =
|
|
669
|
-
size_t len =
|
|
666
|
+
int offset = blobLenBytes(fd);
|
|
667
|
+
size_t len = blobDataLen(fd, (const uchar_td*)ptr);
|
|
670
668
|
T* result;
|
|
671
669
|
if (len)
|
|
672
670
|
{
|