transactd 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/BUILD_UNIX-JA +174 -0
  3. data/BUILD_WIN-JA +256 -0
  4. data/CMakeLists.txt +96 -0
  5. data/COPYING +339 -0
  6. data/README +406 -0
  7. data/README-JA +424 -0
  8. data/bin/common/tdclc_32_1_0.dll +0 -0
  9. data/bin/common/tdclc_64_1_0.dll +0 -0
  10. data/build/common/check_for_link_iconv.cmake +73 -0
  11. data/build/common/copyifgreater.cmd +30 -0
  12. data/build/common/copyifgreater.js +290 -0
  13. data/build/common/get_boost_libs.cmake +106 -0
  14. data/build/common/get_ruby_path.cmake +115 -0
  15. data/build/common/options.cmake +127 -0
  16. data/build/common/smart_install.cmake +263 -0
  17. data/build/common/system.cmake +122 -0
  18. data/build/common/transactd.rc.in +52 -0
  19. data/build/common/transactd_cl_common.cmake +101 -0
  20. data/build/common/transactd_cl_output.cmake +93 -0
  21. data/build/common/transactd_common.cmake +237 -0
  22. data/build/common/transactd_required.cmake +28 -0
  23. data/build/swig/ruby/generate.cmake.in +35 -0
  24. data/build/swig/ruby/generate.cmd.in +19 -0
  25. data/build/swig/ruby/ruby.swg +101 -0
  26. data/build/swig/tdcl.i +188 -0
  27. data/build/tdclc/BUILDNUMBER.txt +1 -0
  28. data/build/tdclc/CMakeLists.txt +170 -0
  29. data/build/tdclc/tdclc_32.cbproj +181 -0
  30. data/build/tdclc/tdclc_64.cbproj +205 -0
  31. data/build/tdclcpp/BUILDNUMBER.txt +1 -0
  32. data/build/tdclcpp/CMakeLists.txt +142 -0
  33. data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
  34. data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
  35. data/build/tdclrb/BUILDNUMBER.txt +1 -0
  36. data/build/tdclrb/CMakeLists.txt +258 -0
  37. data/build/tdclrb/GEM_VERSION +3 -0
  38. data/build/tdclrb/bldgem/extconf.rb +123 -0
  39. data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
  40. data/build/tdclrb/gem/Makefile.win32-VS +65 -0
  41. data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
  42. data/build/tdclrb/gem/detect.rb +31 -0
  43. data/build/tdclrb/gem/helper.rb +113 -0
  44. data/build/tdclrb/gem/transactd.rb +22 -0
  45. data/build/tdclrb/gem_output.cmake +44 -0
  46. data/source/bzs/db/IBlobBuffer.h +51 -0
  47. data/source/bzs/db/blobBuffer.h +177 -0
  48. data/source/bzs/db/blobStructs.h +85 -0
  49. data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
  50. data/source/bzs/db/engine/mysql/bookmark.h +195 -0
  51. data/source/bzs/db/engine/mysql/database.cpp +1882 -0
  52. data/source/bzs/db/engine/mysql/database.h +465 -0
  53. data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
  54. data/source/bzs/db/engine/mysql/dbManager.h +143 -0
  55. data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
  56. data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
  57. data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
  58. data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
  59. data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
  60. data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
  61. data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
  62. data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
  63. data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
  64. data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
  65. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
  66. data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
  67. data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
  68. data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
  69. data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
  70. data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
  71. data/source/bzs/db/protocol/tdap/client/client.h +292 -0
  72. data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
  73. data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
  74. data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
  75. data/source/bzs/db/protocol/tdap/client/database.h +118 -0
  76. data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
  77. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
  78. data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
  79. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
  80. data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
  81. data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
  82. data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
  83. data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
  84. data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
  85. data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
  86. data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
  87. data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
  88. data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
  89. data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
  90. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
  91. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
  92. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
  93. data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
  94. data/source/bzs/db/protocol/tdap/client/request.h +198 -0
  95. data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
  96. data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
  97. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
  98. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
  99. data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
  100. data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
  101. data/source/bzs/db/protocol/tdap/client/table.h +221 -0
  102. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
  103. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
  104. data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
  105. data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
  106. data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
  107. data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
  108. data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
  109. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
  110. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
  111. data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
  112. data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
  113. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
  114. data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
  115. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
  116. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
  117. data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
  118. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
  119. data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
  120. data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
  121. data/source/bzs/db/transactd/appBuilderImple.h +55 -0
  122. data/source/bzs/db/transactd/appModule.cpp +183 -0
  123. data/source/bzs/db/transactd/appModule.h +80 -0
  124. data/source/bzs/db/transactd/connManager.cpp +201 -0
  125. data/source/bzs/db/transactd/connManager.h +60 -0
  126. data/source/bzs/db/transactd/connectionRecord.h +69 -0
  127. data/source/bzs/db/transactd/transactd.cpp +325 -0
  128. data/source/bzs/env/compiler.h +135 -0
  129. data/source/bzs/env/crosscompile.cpp +130 -0
  130. data/source/bzs/env/crosscompile.h +150 -0
  131. data/source/bzs/env/fileopen.h +36 -0
  132. data/source/bzs/env/mbcswchrLinux.cpp +40 -0
  133. data/source/bzs/env/mbcswchrLinux.h +88 -0
  134. data/source/bzs/env/tstring.h +183 -0
  135. data/source/bzs/example/changeSchema.cpp +117 -0
  136. data/source/bzs/example/changeSchema_c.cpp +78 -0
  137. data/source/bzs/example/connection_pool_c.cpp +171 -0
  138. data/source/bzs/example/createDatabase.cpp +305 -0
  139. data/source/bzs/example/createDatabase_c.cpp +202 -0
  140. data/source/bzs/example/deleteRecords.cpp +87 -0
  141. data/source/bzs/example/deleteRecords_c.cpp +57 -0
  142. data/source/bzs/example/dropDatabase.cpp +59 -0
  143. data/source/bzs/example/dropDatabase_c.cpp +34 -0
  144. data/source/bzs/example/insertRecords.cpp +212 -0
  145. data/source/bzs/example/insertRecords_c.cpp +153 -0
  146. data/source/bzs/example/readRecords.cpp +141 -0
  147. data/source/bzs/example/readRecords_c.cpp +107 -0
  148. data/source/bzs/example/updateRecords.cpp +99 -0
  149. data/source/bzs/example/updateRecords_c.cpp +71 -0
  150. data/source/bzs/example/update_with_transaction.cpp +104 -0
  151. data/source/bzs/example/update_with_transaction_c.cpp +80 -0
  152. data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
  153. data/source/bzs/netsvc/client/tcpClient.h +489 -0
  154. data/source/bzs/netsvc/server/IAppModule.h +94 -0
  155. data/source/bzs/netsvc/server/iserver.h +65 -0
  156. data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
  157. data/source/bzs/netsvc/server/serverCpt.h +88 -0
  158. data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
  159. data/source/bzs/netsvc/server/serverPipe.h +96 -0
  160. data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
  161. data/source/bzs/netsvc/server/serverTpool.h +84 -0
  162. data/source/bzs/rtl/benchmark.cpp +96 -0
  163. data/source/bzs/rtl/benchmark.h +65 -0
  164. data/source/bzs/rtl/datetime.cpp +375 -0
  165. data/source/bzs/rtl/datetime.h +53 -0
  166. data/source/bzs/rtl/debuglog.cpp +106 -0
  167. data/source/bzs/rtl/debuglog.h +97 -0
  168. data/source/bzs/rtl/exception.h +116 -0
  169. data/source/bzs/rtl/stl_uty.cpp +35 -0
  170. data/source/bzs/rtl/stl_uty.h +29 -0
  171. data/source/bzs/rtl/stringBuffers.cpp +101 -0
  172. data/source/bzs/rtl/stringBuffers.h +58 -0
  173. data/source/bzs/rtl/strtrim.cpp +135 -0
  174. data/source/bzs/rtl/strtrim.h +46 -0
  175. data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
  176. data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
  177. data/source/bzs/test/tdclrb/prepare.rb +226 -0
  178. data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
  179. data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
  180. data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
  181. data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
  182. data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
  183. data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
  184. data/source/global/tdclatl/Database.cpp +503 -0
  185. data/source/global/tdclatl/Database.h +139 -0
  186. data/source/global/tdclatl/DbDef.cpp +242 -0
  187. data/source/global/tdclatl/DbDef.h +79 -0
  188. data/source/global/tdclatl/Field.cpp +92 -0
  189. data/source/global/tdclatl/Field.h +59 -0
  190. data/source/global/tdclatl/FieldDef.cpp +238 -0
  191. data/source/global/tdclatl/FieldDef.h +87 -0
  192. data/source/global/tdclatl/Flags.cpp +111 -0
  193. data/source/global/tdclatl/Flags.h +55 -0
  194. data/source/global/tdclatl/KeyDef.cpp +51 -0
  195. data/source/global/tdclatl/KeyDef.h +55 -0
  196. data/source/global/tdclatl/KeySegment.cpp +55 -0
  197. data/source/global/tdclatl/Table.cpp +600 -0
  198. data/source/global/tdclatl/Table.h +144 -0
  199. data/source/global/tdclatl/TableDef.cpp +291 -0
  200. data/source/global/tdclatl/TableDef.h +86 -0
  201. data/source/global/tdclatl/TdVersion.cpp +74 -0
  202. data/source/global/tdclatl/TdVersion.h +54 -0
  203. data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
  204. data/source/global/tdclatl/dllmain.cpp +30 -0
  205. data/source/global/tdclatl/dllmain.h +27 -0
  206. data/source/global/tdclatl/keySegment.h +57 -0
  207. data/source/global/tdclatl/resource.h +0 -0
  208. data/source/global/tdclatl/stdafx.cpp +2 -0
  209. data/source/global/tdclatl/stdafx.h +25 -0
  210. data/source/global/tdclatl/targetver.h +4 -0
  211. data/source/global/tdclatl/tdclatl.cpp +68 -0
  212. data/source/global/tdclatl/tdclatl.def +10 -0
  213. data/source/global/tdclatl/tdclatl.idl +1035 -0
  214. data/source/linux/charsetConvert.h +112 -0
  215. data/source/linux/linuxTypes.h +33 -0
  216. data/source/linux/tchar.h +428 -0
  217. data/transactd.gemspec +97 -0
  218. metadata +267 -0
@@ -0,0 +1,184 @@
1
+ /*=================================================================
2
+ Copyright (C) 2012 2013 BizStation Corp All rights reserved.
3
+
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17
+ 02111-1307, USA.
18
+ =================================================================*/
19
+ #include "characterset.h"
20
+ #include <string.h>
21
+ #include <assert.h>
22
+ #ifdef __BCPLUSPLUS__
23
+ #pragma package(smart_init)
24
+ #endif
25
+
26
+ namespace bzs
27
+ {
28
+ namespace db
29
+ {
30
+ namespace protocol
31
+ {
32
+ namespace tdap
33
+ {
34
+ namespace mysql
35
+ {
36
+
37
+ struct SCHARSET_INFO
38
+ {
39
+ unsigned short codePage;
40
+ char name[12];
41
+ char charSize;
42
+
43
+ };
44
+
45
+
46
+ SCHARSET_INFO
47
+ charsetInfo[MAX_CHAR_INFO] =
48
+ {
49
+ {1252,"acp",1}, //0
50
+ {1252,"latin1",1}, //1
51
+ {950,"big5",2}, //2
52
+ {850,"dec8",1}, //3
53
+ {850,"cp850",1}, //4
54
+ {0,"hp8",1}, //5
55
+ {20866,"koi8r",1}, //6
56
+ {28592,"latin2",1}, //7
57
+ {20107,"swe7",1}, //8
58
+ {1252,"ascii",1}, //9
59
+ {50220,"ujis",3}, //10
60
+ {932,"sjis",2}, //11
61
+ {1255,"hebrew",1}, //12
62
+ {0,"tis620",1}, //13
63
+ {949,"euckr",2}, //14
64
+ {20866,"koi8u",1}, //15
65
+ {936,"gb2312",2}, //16
66
+ {1253,"greek",1}, //17
67
+ {1250,"cp1250",1}, //18
68
+ {0,"gbk",2}, //19
69
+ {0,"latin5",1}, //20
70
+ {0,"armscii8",1}, //21
71
+ {65001,"utf8",3}, //22
72
+ {1200,"ucs2",2}, //23
73
+ {866,"cp866",1}, //24
74
+ {0,"keybcs2",1}, //25
75
+ {0,"macce",1}, //26
76
+ {0,"macroman",1}, //27
77
+ {852,"cp852",1}, //28
78
+ {0,"latin7",1}, //29
79
+ {65001,"utf8mb4",4}, //30
80
+ {1251,"cp1251",1}, //31
81
+ {1201,"utf16",4}, //32
82
+ {1200,"utf16le",4}, //33 //5.6.1 or upper
83
+ {1256,"cp1256",1}, //34
84
+ {1257,"cp1257",1}, //35
85
+ {12000,"utf32",4}, //36
86
+ {0,"binary",1}, //37
87
+ {932,"cp932",2}, //38
88
+ {0,"geostd8",1}, //39
89
+ {51932,"eucjpms",3} //40
90
+ };
91
+ /* 5.5.28
92
+ +----------+----------------+---------------------+--------+
93
+ | Charset | Description | Default collation | Maxlen |
94
+ +----------+----------------+---------------------+--------+
95
+ | big5 | | big5_chinese_ci | 2 |
96
+ | dec8 | | dec8_swedish_ci | 1 |
97
+ | cp850 | | cp850_general_ci | 1 |
98
+ | hp8 | | hp8_english_ci | 1 |
99
+ | koi8r | | koi8r_general_ci | 1 |
100
+ | latin1 | | latin1_swedish_ci | 1 |
101
+ | latin2 | | latin2_general_ci | 1 |
102
+ | swe7 | | swe7_swedish_ci | 1 |
103
+ | ascii | | ascii_general_ci | 1 |
104
+ | ujis | | ujis_japanese_ci | 3 |
105
+ | sjis | | sjis_japanese_ci | 2 |
106
+ | hebrew | | hebrew_general_ci | 1 |
107
+ | tis620 | | tis620_thai_ci | 1 |
108
+ | euckr | | euckr_korean_ci | 2 |
109
+ | koi8u | | koi8u_general_ci | 1 |
110
+ | gb2312 | | gb2312_chinese_ci | 2 |
111
+ | greek | | greek_general_ci | 1 |
112
+ | cp1250 | | cp1250_general_ci | 1 |
113
+ | gbk | | gbk_chinese_ci | 2 |
114
+ | latin5 | | latin5_turkish_ci | 1 |
115
+ | armscii8 | | armscii8_general_ci | 1 |
116
+ | utf8 | | utf8_general_ci | 3 |
117
+ | ucs2 | | ucs2_general_ci | 2 |
118
+ | cp866 | | cp866_general_ci | 1 |
119
+ | keybcs2 | | keybcs2_general_ci | 1 |
120
+ | macce | | macce_general_ci | 1 |
121
+ | macroman | | macroman_general_ci | 1 |
122
+ | cp852 | | cp852_general_ci | 1 |
123
+ | latin7 | | latin7_general_ci | 1 |
124
+ | utf8mb4 | UTF-8 Unicode | utf8mb4_general_ci | 4 |
125
+ | cp1251 | | cp1251_general_ci | 1 |
126
+ | utf16 | UTF-16 Unicode | utf16_general_ci | 4 |
127
+ | cp1256 | | cp1256_general_ci | 1 |
128
+ | cp1257 | | cp1257_general_ci | 1 |
129
+ | utf32 | UTF-32 Unicode | utf32_general_ci | 4 |
130
+ | binary | | binary | 1 |
131
+ | geostd8 | | geostd8_general_ci | 1 |
132
+ | cp932 | | cp932_japanese_ci | 2 |
133
+ | eucjpms | | eucjpms_japanese_ci | 3 |
134
+ +----------+----------------+---------------------+--------+
135
+ */
136
+
137
+ unsigned int charsize(int index)
138
+ {
139
+ if (index < MAX_CHAR_INFO)
140
+ return charsetInfo[index].charSize;
141
+ return 1;
142
+ }
143
+
144
+ const char* charsetName(int index)
145
+ {
146
+ if ((index > 0) && index < MAX_CHAR_INFO)
147
+ return charsetInfo[index].name;
148
+ assert(0);
149
+ return "";
150
+ }
151
+
152
+ unsigned int charsetIndex(const char* name)
153
+ {
154
+ for (int i=1;i<MAX_CHAR_INFO;++i)
155
+ {
156
+ if (strcmp(charsetInfo[i].name, name)==0)
157
+ return i;
158
+ }
159
+ return -1;
160
+ }
161
+
162
+ unsigned int charsetIndex(unsigned short codePage)
163
+ {
164
+ for (int i=1;i<MAX_CHAR_INFO;++i)
165
+ {
166
+ if (charsetInfo[i].codePage == codePage)
167
+ return i;
168
+ }
169
+ return -1;
170
+ }
171
+
172
+ unsigned int codePage(unsigned short charsetIndex)
173
+ {
174
+ if ((charsetIndex > 0) && charsetIndex < MAX_CHAR_INFO)
175
+ return charsetInfo[charsetIndex].codePage;
176
+ assert(0);
177
+ return 0;
178
+ }
179
+
180
+ }//namespace mysql
181
+ }//namespace tdap
182
+ }//namespace protocol
183
+ }//namespace db
184
+ }//namespace bzs
@@ -0,0 +1,60 @@
1
+ #ifndef BZS_DB_PROTOCOL_TDAP_MYSQL_CHARACTERSET_H
2
+ #define BZS_DB_PROTOCOL_TDAP_MYSQL_CHARACTERSET_H
3
+ /*=================================================================
4
+ Copyright (C) 2012 2013 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
+
22
+ #include <bzs/env/compiler.h>
23
+
24
+
25
+
26
+ #define MAX_CHAR_INFO 41
27
+ #define CHARSET_LATIN1 1
28
+ #define CHARSET_CP850 4
29
+ #define CHARSET_ASCII 9
30
+ #define CHARSET_SJIS 11
31
+ #define CHARSET_UTF8 22
32
+ #define CHARSET_USC2 23
33
+ #define CHARSET_UTF8B4 30
34
+ #define CHARSET_UTF16LE 33
35
+ #define CHARSET_CP932 38
36
+ #define CHARSET_EUCJ 40
37
+
38
+ namespace bzs
39
+ {
40
+ namespace db
41
+ {
42
+ namespace protocol
43
+ {
44
+ namespace tdap
45
+ {
46
+ namespace mysql
47
+ {
48
+
49
+ PACKAGE unsigned int charsize(int index);
50
+ PACKAGE const char* charsetName(int index);
51
+ PACKAGE unsigned int charsetIndex(const char* name);
52
+ PACKAGE unsigned int charsetIndex(unsigned short codePage);
53
+ PACKAGE unsigned int codePage(unsigned short charsetIndex);
54
+
55
+ }//namespace mysql
56
+ }//namespace tdap
57
+ }//namespace protocol
58
+ }//namespace db
59
+ }//namespace bzs
60
+ #endif //BZS_DB_PROTOCOL_TDAP_MYSQL_CHARACTERSET_H
@@ -0,0 +1,284 @@
1
+ /*=================================================================
2
+ Copyright (C) 2013 BizStation Corp All rights reserved.
3
+
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17
+ 02111-1307, USA.
18
+ =================================================================*/
19
+ #include <boost/filesystem.hpp>
20
+ #include <boost/shared_array.hpp>
21
+ #include <bzs/db/engine/mysql/database.h>
22
+ #include <bzs/db/engine/mysql/mysqlInternal.h>
23
+ #include "databaseSchema.h"
24
+
25
+ #include <bzs/db/protocol/tdap/mysql/characterset.h>
26
+ #ifdef LINUX
27
+ #include <bzs/env/mbcswchrLinux.h>
28
+ #endif
29
+
30
+ namespace fs = boost::filesystem;
31
+
32
+ namespace bzs
33
+ {
34
+ using namespace db::engine::mysql;
35
+ namespace db
36
+ {
37
+ using namespace protocol;
38
+ namespace protocol
39
+ {
40
+ namespace tdap
41
+ {
42
+ namespace mysql
43
+ {
44
+
45
+ schemaBuilder::schemaBuilder(void)
46
+ {
47
+ }
48
+
49
+ schemaBuilder::~schemaBuilder(void)
50
+ {
51
+ }
52
+
53
+ void initTableDef(table* tb, tabledef& tdef, int id)
54
+ {
55
+ tdef.cleanup();
56
+ tdef.setTableName(tb->name().c_str());
57
+ tdef.setFileName(tb->name().c_str());
58
+ tdef.id = id;
59
+ tdef.schemaCodePage = CP_UTF8;
60
+
61
+ }
62
+
63
+ uint_td copyToRecordImage(uchar* rec, void* p, uint_td size, uint_td offset)
64
+ {
65
+ memcpy(rec+offset, p, size);
66
+ return offset+size;
67
+ }
68
+
69
+ bool isStringType(char type)
70
+ {
71
+ switch(type)
72
+ {
73
+ case ft_zstring:
74
+ case ft_string:
75
+ case ft_mychar:
76
+ case ft_myvarchar:
77
+ case ft_myvarbinary:
78
+ case ft_wzstring:
79
+ case ft_wstring:
80
+ case ft_mywchar:
81
+ case ft_mywvarchar:
82
+ case ft_mywvarbinary:
83
+ return true;
84
+ default:
85
+ return false;
86
+ }
87
+ }
88
+
89
+ uchar_td convFieldType(enum enum_field_types type, uint flags, bool binary, bool unicode)
90
+ {
91
+ switch(type)
92
+ {
93
+ case MYSQL_TYPE_DECIMAL:return ft_decimal;
94
+ case MYSQL_TYPE_TINY:
95
+ case MYSQL_TYPE_SHORT:
96
+ case MYSQL_TYPE_LONG:
97
+ case MYSQL_TYPE_LONGLONG:
98
+ case MYSQL_TYPE_YEAR:
99
+ case MYSQL_TYPE_INT24:
100
+ if (flags & AUTO_INCREMENT_FLAG)
101
+ return ft_autoinc;
102
+ if ((flags & UNSIGNED_FLAG) || (type == MYSQL_TYPE_YEAR))
103
+ return ft_uinteger;
104
+ return ft_integer;
105
+ case MYSQL_TYPE_FLOAT:
106
+ case MYSQL_TYPE_DOUBLE:return ft_float;
107
+ case MYSQL_TYPE_DATE:return ft_mydate;
108
+ case MYSQL_TYPE_TIME:return ft_mytime;
109
+ case MYSQL_TYPE_DATETIME:return ft_mydatetime;
110
+ case MYSQL_TYPE_TIMESTAMP:return ft_mytimestamp;
111
+ case MYSQL_TYPE_VARCHAR:
112
+ case MYSQL_TYPE_VAR_STRING: //?
113
+ if (binary)
114
+ return unicode ? ft_mywvarbinary : ft_myvarbinary;
115
+ return unicode ? ft_mywvarchar : ft_myvarchar;
116
+ case MYSQL_TYPE_STRING:
117
+ if (binary)
118
+ return unicode ? ft_wstring : ft_string;
119
+ return unicode ? ft_mywchar : ft_mychar;
120
+ case MYSQL_TYPE_TINY_BLOB:
121
+ case MYSQL_TYPE_BLOB:
122
+ case MYSQL_TYPE_LONG_BLOB:
123
+ case MYSQL_TYPE_MEDIUM_BLOB:
124
+ if (flags & BINARY_FLAG)
125
+ return ft_myblob;
126
+ return ft_mytext;
127
+ default:
128
+ return unicode ? ft_wzstring : ft_zstring;
129
+ }
130
+ return 0;
131
+ }
132
+
133
+ bool isUnicode(const CHARSET_INFO& cs)
134
+ {
135
+ return (charsetIndex(cs.csname)==CHARSET_UTF16LE);
136
+ }
137
+
138
+ bool isBinary(const CHARSET_INFO& cs)
139
+ {
140
+ return (&cs == &my_charset_bin);
141
+ }
142
+
143
+ short schemaBuilder::insertMetaRecord(table* mtb, table* src, int id)
144
+ {
145
+ uint_td datalen = 0;
146
+ boost::shared_array<uchar> rec(new uchar[65000]);
147
+ //table
148
+ tabledef& tdef = (tabledef&)(*rec.get());
149
+ initTableDef(src, tdef, id);
150
+ tdef.fieldCount = (uchar_td)src->fields();
151
+ tdef.keyCount = (uchar_td)src->keys();
152
+ tdef.charsetIndex = charsetIndex(src->charset().csname);
153
+ tdef.flags.bit0 = (src->recordFormatType()== RF_FIXED_PLUS_VALIABLE_LEN);//�•ϒ�
154
+
155
+ tdef.primaryKeyNum = (src->primarykey()<tdef.keyCount) ? src->primarykey():-1;
156
+ if (src->recordFormatType()== RF_FIXED_PLUS_VALIABLE_LEN)
157
+ tdef.fixedRecordLen = (ushort_td)(src->recordLenCl()-src->lastVarFieldDataLen());
158
+ else
159
+ tdef.fixedRecordLen = (ushort_td)src->recordLenCl();
160
+ tdef.maxRecordLen = (ushort_td)src->recordLenCl();
161
+ tdef.pageSize = 2048;
162
+ tdef.optionFlags.bitA = (src->recordFormatType() & RF_VALIABLE_LEN);
163
+ tdef.optionFlags.bitB = src->blobFields()!=0;
164
+
165
+ datalen+=sizeof(tabledef);
166
+ tdef.fieldDefs = (fielddef*)(rec.get() + datalen);
167
+ //field
168
+ ushort_td pos = 0;
169
+ for (int i=0;i<src->fields();++i)
170
+ {
171
+ if (isNisField(src->fieldName(i)))
172
+ --tdef.fieldCount;
173
+ else
174
+ {
175
+ fielddef fd;
176
+ memset(&fd, 0, sizeof(fielddef));
177
+ fd.setName(src->fieldName(i));
178
+ fd.len = src->fieldLen(i);// filed->pack_length();
179
+ fd.pos = pos;
180
+ fd.type = convFieldType(src->fieldType(i), src->fieldFlags(i)
181
+ ,isBinary(src->fieldCharset(i)), isUnicode(src->fieldCharset(i)));
182
+ pos += fd.len;
183
+ datalen = copyToRecordImage(rec.get(), &fd, sizeof(fielddef), datalen);
184
+ }
185
+ }
186
+
187
+ //index
188
+ for (int i=0;i<src->keys();++i)
189
+ {
190
+ const KEY& key = src->keyDef(i);
191
+ keydef kd;
192
+ memset(&kd, 0, sizeof(keydef));
193
+ kd.segmentCount = key.user_defined_key_parts;
194
+ kd.keyNumber = i;
195
+ int segNum = 0;
196
+ for (int j=0;j<(int)key.user_defined_key_parts;++j)
197
+ {
198
+ keySegment& sg = kd.segments[segNum];
199
+ KEY_PART_INFO& ks = key.key_part[j];
200
+ if (isNisField(ks.field->field_name))
201
+ --kd.segmentCount;
202
+ else
203
+ {
204
+ sg.fieldNum = (uchar_td)ks.field->field_index;
205
+ sg.flags.bit0 = !(key.flags & HA_NOSAME);//duplicate
206
+ sg.flags.bit1 = 1;//change able
207
+ sg.flags.bit4 = (j!=kd.segmentCount-1);//segment
208
+ sg.flags.bit8 = 1;//extend key type
209
+ sg.flags.bit9 = ks.null_bit ? 1:0;//null key
210
+ if (isStringType(convFieldType(src->fieldType(sg.fieldNum), src->fieldFlags(sg.fieldNum)
211
+ ,isBinary(src->fieldCharset(i)), isUnicode(src->fieldCharset(sg.fieldNum)))))
212
+ sg.flags.bitA = !(src->fieldFlags(sg.fieldNum) & BINCMP_FLAG);
213
+ if (src->fieldDataLen(sg.fieldNum) != ks.length)
214
+ {
215
+ fielddef& fd = tdef.fieldDefs[sg.fieldNum];
216
+ //suppot prefix key
217
+ fd.keylen = ks.length;
218
+
219
+ }
220
+ if (sg.fieldNum == tdef.fieldCount-1)
221
+ {
222
+ tdef.flags.bit0 = 0; //NOT valiable length
223
+ tdef.optionFlags.bitA = 0;//NOT RF_VALIABLE_LEN
224
+ }
225
+ ++segNum;
226
+ }
227
+ }
228
+ datalen = copyToRecordImage(rec.get(), &kd, sizeof(keydef), datalen);
229
+ }
230
+ mtb->clearBuffer();
231
+ mtb->setRecordFromPacked(rec.get(), datalen, NULL);
232
+ __int64 aincValue = mtb->insert(true);
233
+ return mtb->stat();
234
+ }
235
+
236
+ bool isFrmFile(const std::string& name)
237
+ {
238
+ size_t pos = name.find(TRANSACTD_SCHEMANAME);
239
+ if (pos != std::string::npos)
240
+ return false;
241
+ pos = name.find(".frm");
242
+ if (pos != std::string::npos)
243
+ return pos == name.size()-4;
244
+ return false;
245
+ }
246
+
247
+ short schemaBuilder::execute(database* db, table* mtb)
248
+ {
249
+ char path[FN_REFLEN + 1];
250
+ build_table_filename(path, sizeof(path) - 1, db->name().c_str(), "", "", 0);
251
+
252
+ std::string s = path;
253
+ fs::path p = s;
254
+ fs::directory_iterator it(p);
255
+ fs::directory_iterator end;
256
+ int id = 0;
257
+ short stat=0;
258
+ smartTransction trn(db);
259
+ for(fs::directory_iterator it(p); it!=end; ++it)
260
+ {
261
+ if(!is_directory(*it))
262
+ {
263
+ std::string s = it->path().filename().string();
264
+ if (isFrmFile(s))
265
+ {
266
+ filename_to_tablename(it->path().stem().string().c_str(), path, FN_REFLEN);
267
+ table* tb = db->openTable(path, TD_OPEN_READONLY);
268
+ if (!tb->isView())
269
+ {
270
+ if ((stat = insertMetaRecord(mtb, tb, ++id))!=0)
271
+ return stat;
272
+ }
273
+ }
274
+ }
275
+ }
276
+ trn.end();
277
+ return stat;
278
+ }
279
+
280
+ }//namespace mysql
281
+ }//namespace protocol
282
+ }//namespace db
283
+ }//namespace tdap
284
+ }//namespace bzs
@@ -0,0 +1,53 @@
1
+ #ifndef BZS_DB_PROTOCOL_TDAP_MYSQL_DATABASESCHEMA_H
2
+ #define BZS_DB_PROTOCOL_TDAP_MYSQL_DATABASESCHEMA_H
3
+ /*=================================================================
4
+ Copyright (C) 2013 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
+
22
+ #include <bzs/db/protocol/tdap/tdapSchema.h>
23
+ #include <string>
24
+
25
+ namespace bzs
26
+ {
27
+
28
+ namespace db
29
+ {
30
+ namespace engine{namespace mysql{class table;class database;}}
31
+
32
+ namespace protocol
33
+ {
34
+ namespace tdap
35
+ {
36
+ namespace mysql
37
+ {
38
+
39
+ class schemaBuilder
40
+ {
41
+ short insertMetaRecord(engine::mysql::table* mtb, engine::mysql::table* src, int id);
42
+ public:
43
+ schemaBuilder();
44
+ ~schemaBuilder();
45
+ short execute(engine::mysql::database* db, engine::mysql::table* mtb);
46
+ };
47
+
48
+ }//namespace mysql
49
+ }//namespace protocol
50
+ }//namespace db
51
+ }//namespace tdap
52
+ }//namespace bzs
53
+ #endif //BZS_DB_PROTOCOL_TDAP_MYSQL_DATABASESCHEMA_H