transactd 2.1.0 → 2.2.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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/bin/common/tdclc_32_2_2.dll +0 -0
  3. data/bin/common/tdclc_64_2_2.dll +0 -0
  4. data/build/swig/ruby/generate.cmd +45 -0
  5. data/build/swig/ruby/generate.sh +40 -0
  6. data/build/swig/ruby/tdclrb_wrap.cpp +406 -969
  7. data/build/swig/tdcl.i +88 -0
  8. data/build/tdclc/CMakeLists.txt +5 -1
  9. data/build/tdclc/tdclc.cbproj +1 -1
  10. data/build/tdclc/tdclc.rc +4 -4
  11. data/build/tdclcpp/tdclcpp.rc +4 -4
  12. data/build/tdclcpp/tdclcpp_bc.cbproj +1 -1
  13. data/build/tdclrb/tdclrb.rc +4 -4
  14. data/source/bzs/db/engine/mysql/database.cpp +165 -74
  15. data/source/bzs/db/engine/mysql/database.h +19 -5
  16. data/source/bzs/db/engine/mysql/dbManager.cpp +33 -11
  17. data/source/bzs/db/engine/mysql/dbManager.h +6 -1
  18. data/source/bzs/db/engine/mysql/mydebuglog.h +12 -0
  19. data/source/bzs/db/engine/mysql/mysqlInternal.h +10 -3
  20. data/source/bzs/db/engine/mysql/mysqlThd.cpp +20 -8
  21. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +12 -7
  22. data/source/bzs/db/protocol/hs/hsCommandExecuter.h +1 -1
  23. data/source/bzs/db/protocol/tdap/client/activeTableImple.h +1 -0
  24. data/source/bzs/db/protocol/tdap/client/client.cpp +17 -15
  25. data/source/bzs/db/protocol/tdap/client/client.h +102 -30
  26. data/source/bzs/db/protocol/tdap/client/connectionPool.cpp +1 -1
  27. data/source/bzs/db/protocol/tdap/client/database.cpp +32 -10
  28. data/source/bzs/db/protocol/tdap/client/database.h +1 -0
  29. data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +0 -2
  30. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +2 -0
  31. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +47 -42
  32. data/source/bzs/db/protocol/tdap/client/fields.h +3 -1
  33. data/source/bzs/db/protocol/tdap/client/filter.h +3 -3
  34. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +18 -2
  35. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +3 -2
  36. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +14 -6
  37. data/source/bzs/db/protocol/tdap/client/nsTable.h +12 -12
  38. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +6 -3
  39. data/source/bzs/db/protocol/tdap/client/request.h +1 -0
  40. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +101 -64
  41. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +3 -0
  42. data/source/bzs/db/protocol/tdap/client/stringConverter.h +9 -13
  43. data/source/bzs/db/protocol/tdap/client/table.cpp +73 -56
  44. data/source/bzs/db/protocol/tdap/client/table.h +8 -8
  45. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +52 -100
  46. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +8 -1
  47. data/source/bzs/db/protocol/tdap/mysql/request.h +6 -0
  48. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +349 -189
  49. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +28 -12
  50. data/source/bzs/db/protocol/tdap/tdapRequest.h +5 -4
  51. data/source/bzs/db/protocol/tdap/tdapSchema.h +6 -1
  52. data/source/bzs/db/protocol/tdap/tdapcapi.h +29 -4
  53. data/source/bzs/db/protocol/tdap/uri.h +297 -0
  54. data/source/bzs/db/transactd/appModule.cpp +41 -16
  55. data/source/bzs/db/transactd/appModule.h +1 -2
  56. data/source/bzs/db/transactd/transactd.cpp +37 -14
  57. data/source/bzs/env/crosscompile.h +1 -3
  58. data/source/bzs/example/queryData.cpp +2 -2
  59. data/source/bzs/netsvc/client/iconnection.h +3 -1
  60. data/source/bzs/netsvc/client/tcpClient.cpp +75 -28
  61. data/source/bzs/netsvc/client/tcpClient.h +94 -62
  62. data/source/bzs/netsvc/server/IAppModule.h +2 -2
  63. data/source/bzs/netsvc/server/serverCpt.cpp +17 -10
  64. data/source/bzs/netsvc/server/serverPipe.cpp +26 -19
  65. data/source/bzs/netsvc/server/serverTpool.cpp +8 -2
  66. data/source/bzs/rtl/debuglog.cpp +21 -5
  67. data/source/bzs/rtl/debuglog.h +1 -1
  68. data/source/bzs/test/tdclphp/transactd_Test.php +183 -37
  69. data/source/bzs/test/tdclphp/transactd_pool_Test.php +1 -2
  70. data/source/bzs/test/tdclrb/transactd_spec.rb +183 -39
  71. data/source/bzs/test/transactdBench/scaling_bench.cpp +3 -3
  72. data/source/bzs/test/trdclengn/test_trdclengn.cpp +172 -57
  73. data/source/global/boost/sha1.hpp +223 -0
  74. data/source/global/tdclatl/ConnectParams.cpp +2 -2
  75. data/source/global/tdclatl/ConnectParams.h +1 -1
  76. data/source/global/tdclatl/Database.cpp +18 -0
  77. data/source/global/tdclatl/Database.h +5 -0
  78. data/source/global/tdclatl/tdclatl.idl +23 -1
  79. data/source/linux/linuxTypes.h +2 -0
  80. metadata +8 -6
  81. data/bin/common/tdclc_32_2_1.dll +0 -0
  82. data/bin/common/tdclc_64_2_1.dll +0 -0
  83. data/source/bzs/db/protocol/tdap/client/memRecordset.cpp +0 -448
  84. data/source/bzs/db/protocol/tdap/client/memRecordset.h +0 -159
data/build/swig/tdcl.i CHANGED
@@ -782,6 +782,91 @@ using namespace bzs::db::protocol::tdap::client;
782
782
  // * bzs/db/protocol/tdap/tdapcapi.h *
783
783
  %ignore BOOKMARK_ALLOC_SIZE;
784
784
  %ignore BTRV_MAX_DATA_SIZE;
785
+ %ignore POS_BLOCK_SIZE;
786
+ %ignore MAX_KEYLEN;
787
+ %ignore TD_OPENTABLE;
788
+ %ignore TD_CLOSETABLE;
789
+ %ignore TD_REC_INSERT;
790
+ %ignore TD_REC_UPDATE;
791
+ %ignore TD_REC_DELETE;
792
+ %ignore TD_KEY_SEEK;
793
+ %ignore TD_KEY_NEXT;
794
+ %ignore TD_KEY_PREV;
795
+ %ignore TD_KEY_AFTER;
796
+ %ignore TD_KEY_OR_AFTER;
797
+ %ignore TD_KEY_BEFORE;
798
+ %ignore TD_KEY_OR_BEFORE;
799
+ %ignore TD_KEY_FIRST;
800
+ %ignore TD_KEY_LAST;
801
+ %ignore TD_CREATETABLE;
802
+ %ignore TD_TABLE_INFO;
803
+ %ignore TD_SETDIRECTORY;
804
+ %ignore TD_GETDIRECTORY;
805
+ %ignore TD_BEGIN_TRANSACTION;
806
+ %ignore TD_END_TRANSACTION;
807
+ %ignore TD_ABORT_TRANSACTION;
808
+ %ignore TD_BOOKMARK;
809
+ %ignore TD_MOVE_BOOKMARK;
810
+ %ignore TD_POS_NEXT;
811
+ %ignore TD_STOP_ENGINE;
812
+ %ignore TD_VERSION;
813
+ %ignore TD_UNLOCK;
814
+ %ignore TD_RESET_CLIENT;
815
+ %ignore TD_SET_OWNERNAME;
816
+ %ignore TD_CLEAR_OWNERNAME;
817
+ %ignore TD_BUILD_INDEX;
818
+ %ignore TD_DROP_INDEX;
819
+ %ignore TD_POS_FIRST;
820
+ %ignore TD_POS_LAST;
821
+ %ignore TD_POS_PREV;
822
+ %ignore TD_KEY_NEXT_MULTI;
823
+ %ignore TD_KEY_PREV_MULTI;
824
+ %ignore TD_POS_NEXT_MULTI;
825
+ %ignore TD_POS_PREV_MULTI;
826
+ %ignore TD_INSERT_BULK;
827
+ %ignore TD_BACKUPMODE;
828
+ %ignore TD_MOVE_PER;
829
+ %ignore TD_GET_PER;
830
+ %ignore TD_UPDATE_PART;
831
+ %ignore TD_KEY_EQUAL_KO;
832
+ %ignore TD_KEY_NEXT_KO;
833
+ %ignore TD_KEY_PREV_KO;
834
+ %ignore TD_KEY_GT_KO;
835
+ %ignore TD_KEY_GE_KO;
836
+ %ignore TD_KEY_LT_KO;
837
+ %ignore TD_KEY_LE_KO;
838
+ %ignore TD_KEY_FIRST_KO;
839
+ %ignore TD_KEY_LAST_KO;
840
+ %ignore TD_CREATE_TEMP;
841
+ %ignore TD_TABLE_INFO_EX;
842
+ %ignore TD_REC_UPDATEATKEY;
843
+ %ignore TD_REC_DELLETEATKEY;
844
+ %ignore TD_KEY_GE_NEXT_MULTI;
845
+ %ignore TD_KEY_LE_PREV_MULTI;
846
+ %ignore TD_CONNECT;
847
+ %ignore TD_BEGIN_SHAPSHOT;
848
+ %ignore TD_END_SNAPSHOT;
849
+ %ignore TD_AUTOMEKE_SCHEMA;
850
+ %ignore TD_GETSERVER_CHARSET;
851
+ %ignore TD_ADD_SENDBLOB;
852
+ %ignore TD_GET_BLOB_BUF;
853
+ %ignore TD_STASTISTICS;
854
+ %ignore TD_KEY_SEEK_MULTI;
855
+ %ignore CR_SUBOP_DROP;
856
+ %ignore CR_SUBOP_RENAME;
857
+ %ignore CR_SUBOP_SWAPNAME;
858
+ %ignore CR_SUBOP_BY_FILESPEC;
859
+ %ignore CR_SUBOP_BY_FILESPEC_NOCKECK;
860
+ %ignore CR_SUBOP_BY_TABLEDEF;
861
+ %ignore CR_SUBOP_BY_TABLEDEF_NOCKECK;
862
+ %ignore CR_SUB_FLAG_EXISTCHECK;
863
+ %ignore TD_ASBLOB_ENDROW;
864
+ %ignore TD_STSTCS_READ;
865
+ %ignore TD_STSTCS_DISCONNECT_ONE;
866
+ %ignore TD_STSTCS_DISCONNECT_ALL;
867
+ %ignore LG_SUBOP_CONNECT;
868
+ %ignore LG_SUBOP_DISCONNECT;
869
+ %ignore LG_SUBOP_NEWCONNECT;
785
870
  %ignore C_INTERFACE_VER_MAJOR;
786
871
  %ignore C_INTERFACE_VER_MINOR;
787
872
  %ignore C_INTERFACE_VER_RELEASE;
@@ -801,6 +886,9 @@ using namespace bzs::db::protocol::tdap::client;
801
886
  %ignore TD_CPP_LIB_PRE;
802
887
  %ignore TD_FILTER_PREPARE;
803
888
  %ignore TD_LIB_PART;
889
+ %ignore trdVersiton;
890
+ %ignore handshale_t;
891
+ %ignore MYSQL_SCRAMBLE_LENGTH;
804
892
 
805
893
  // * bzs/db/protocol/tdap/tdapSchema.h *
806
894
  %ignore DLLUNLOADCALLBACK_PTR;
@@ -132,7 +132,11 @@ if(CAN_LINK_ICONV)
132
132
  endif()
133
133
  if(NOT MSVC)
134
134
  target_link_libraries(${this_target} pthread)
135
- target_link_libraries(${this_target} -Wl,--version-script,"${TRANSACTD_ROOT}/build/tdclc/libtdclcm.map")
135
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
136
+ ## target_link_libraries(${this_target} "${TRANSACTD_ROOT}/build/tdclc/libtdclcm.map")
137
+ else()
138
+ target_link_libraries(${this_target} -Wl,--version-script,"${TRANSACTD_ROOT}/build/tdclc/libtdclcm.map")
139
+ endif()
136
140
  endif()
137
141
 
138
142
 
@@ -62,7 +62,7 @@
62
62
  <VerInfo_Locale>1041</VerInfo_Locale>
63
63
  <BRCC_CompilerToUse>rc</BRCC_CompilerToUse>
64
64
  <BRCC_IncludePath>$(BDSINCLUDE)\windows\sdk;$(BRCC_IncludePath)</BRCC_IncludePath>
65
- <DllSuffix>_2_1</DllSuffix>
65
+ <DllSuffix>_2_2</DllSuffix>
66
66
  <DynamicRTL>false</DynamicRTL>
67
67
  <BPILibOutputDir>..\..\lib</BPILibOutputDir>
68
68
  <BCC_PCHUsage>None</BCC_PCHUsage>
data/build/tdclc/tdclc.rc CHANGED
@@ -29,8 +29,8 @@
29
29
  //
30
30
 
31
31
  VS_VERSION_INFO VERSIONINFO
32
- FILEVERSION 2,1,0,10
33
- PRODUCTVERSION 2,1,0,10
32
+ FILEVERSION 2,2,0,10
33
+ PRODUCTVERSION 2,2,0,10
34
34
  FILEFLAGSMASK 0x3fL
35
35
  #ifdef _DEBUG
36
36
  FILEFLAGS 0x1L
@@ -47,9 +47,9 @@ BEGIN
47
47
  BEGIN
48
48
  VALUE "CompanyName", "BizStation Corp."
49
49
  VALUE "FileDescription", "Transactd C client"
50
- VALUE "FileVersion", "2.1.0.10"
50
+ VALUE "FileVersion", "2.2.0.10"
51
51
  VALUE "LegalCopyright", "Copyright(C) 2014 BizStation Corp"
52
- VALUE "ProductVersion", "2.1.0.10"
52
+ VALUE "ProductVersion", "2.2.0.10"
53
53
  VALUE "ProductName", "Transactd Client (GPL V2)"
54
54
  END
55
55
  END
@@ -29,8 +29,8 @@
29
29
  //
30
30
 
31
31
  VS_VERSION_INFO VERSIONINFO
32
- FILEVERSION 2,1,0,10
33
- PRODUCTVERSION 2,1,0,10
32
+ FILEVERSION 2,2,0,10
33
+ PRODUCTVERSION 2,2,0,10
34
34
  FILEFLAGSMASK 0x3fL
35
35
  #ifdef _DEBUG
36
36
  FILEFLAGS 0x1L
@@ -47,9 +47,9 @@ BEGIN
47
47
  BEGIN
48
48
  VALUE "CompanyName", "BizStation Corp."
49
49
  VALUE "FileDescription", "Transactd C++ client"
50
- VALUE "FileVersion", "2.1.0.10"
50
+ VALUE "FileVersion", "2.2.0.10"
51
51
  VALUE "LegalCopyright", "Copyright(C) 2014 BizStation Corp"
52
- VALUE "ProductVersion", "2.1.0.10"
52
+ VALUE "ProductVersion", "2.2.0.10"
53
53
  VALUE "ProductName", "Transactd Client (GPL V2)"
54
54
  END
55
55
  END
@@ -152,7 +152,7 @@
152
152
  <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
153
153
  <BCC_ExtendedErrorInfo>true</BCC_ExtendedErrorInfo>
154
154
  <TD_VER_MAJOR>2</TD_VER_MAJOR>
155
- <TD_VER_MINOR>1</TD_VER_MINOR>
155
+ <TD_VER_MINOR>2</TD_VER_MINOR>
156
156
  <DllSuffix>$(TD_VER_MAJOR)_$(TD_VER_MINOR)</DllSuffix>
157
157
  <TD_CPU>32</TD_CPU>
158
158
  </PropertyGroup>
@@ -29,8 +29,8 @@
29
29
  //
30
30
 
31
31
  VS_VERSION_INFO VERSIONINFO
32
- FILEVERSION 2,1,0,10
33
- PRODUCTVERSION 2,1,0,10
32
+ FILEVERSION 2,2,0,10
33
+ PRODUCTVERSION 2,2,0,10
34
34
  FILEFLAGSMASK 0x3fL
35
35
  #ifdef _DEBUG
36
36
  FILEFLAGS 0x1L
@@ -47,9 +47,9 @@ BEGIN
47
47
  BEGIN
48
48
  VALUE "CompanyName", "BizStation Corp."
49
49
  VALUE "FileDescription", "Transactd Ruby client"
50
- VALUE "FileVersion", "2.1.0.10"
50
+ VALUE "FileVersion", "2.2.0.10"
51
51
  VALUE "LegalCopyright", "Copyright(C) 2014 BizStation Corp"
52
- VALUE "ProductVersion", "2.1.0.10"
52
+ VALUE "ProductVersion", "2.2.0.10"
53
53
  VALUE "ProductName", "Transactd Client (GPL V2)"
54
54
  END
55
55
  END
@@ -53,8 +53,6 @@ using namespace std;
53
53
  #error "MODE_READ_EXCLUSIVE != TD_OPEN_READONLY_EXCLUSIVE"
54
54
  #endif
55
55
 
56
-
57
-
58
56
  unsigned int hash(const char* s, size_t len)
59
57
  {
60
58
  unsigned int h = 0;
@@ -155,7 +153,6 @@ thr_lock_type locktype(bool trn, enum_sql_command cmd)
155
153
  return lock_type;
156
154
  }
157
155
 
158
-
159
156
  bool unlockTables(bool releaseStatementLock, THD* thd, bool rollback, database::tableList* tables)
160
157
  {
161
158
  if (thd->lock)
@@ -171,7 +168,6 @@ bool unlockTables(bool releaseStatementLock, THD* thd, bool rollback, database::
171
168
  {
172
169
  for (size_t i=0;i<tables->size();++i)
173
170
  mysql_lock_remove(thd, thd->lock, (*tables)[i]->internalTable());
174
-
175
171
  }else
176
172
  {
177
173
  mysql_unlock_tables(thd, thd->lock);
@@ -191,7 +187,7 @@ tableCacheCounter database::tableRef;
191
187
  database::database(const char* name, short cid)
192
188
  : m_dbname(name), m_thd(createThdForThread()),
193
189
  m_inTransaction(0), m_inSnapshot(0), m_stat(0), m_usingExclusive(false),
194
- m_inAutoTransaction(NULL), m_trnType(0), m_cid(cid)
190
+ m_inAutoTransaction(NULL), m_trnType(0), m_cid(cid), m_privilege(0xFFFF)
195
191
  {
196
192
  m_thd->security_ctx->skip_grants();
197
193
  }
@@ -209,6 +205,97 @@ database::~database()
209
205
  deleteThdForThread(m_thd);
210
206
  }
211
207
 
208
+ unsigned char* database::getUserSha1Passwd(const char* host, const char* user,
209
+ unsigned char* buf)
210
+ {
211
+ table* tb2 = NULL;
212
+ table* tb = NULL;
213
+ unsigned char* retPtr = NULL;
214
+ std::string dbname = m_dbname;
215
+ m_dbname = "mysql";
216
+ try
217
+ {
218
+ use();
219
+ tb2 = openTable("user", TD_OPEN_READONLY, "");
220
+ if (tb2)
221
+ {
222
+ tb = useTable(tb2->id(), SQLCOM_SELECT, NULL);
223
+ if (tb)
224
+ {
225
+ tb->setKeyNum((char)0);
226
+ std::vector<std::string> keyValues;
227
+ keyValues.push_back(host);
228
+ keyValues.push_back(user);
229
+ tb->setKeyValues(keyValues, -1, NULL);
230
+ tb->seekKey(HA_READ_KEY_EXACT, tb->keymap());
231
+ if (tb->stat() == 0)
232
+ {
233
+ int size;
234
+ const char* p = tb->valStr(MYSQL_USER_FIELD_PASSWORD, size);
235
+ if (strlen(p))
236
+ {
237
+ get_salt_from_password(buf, p);
238
+ retPtr = buf;
239
+ }
240
+ }
241
+ tb->unUse();
242
+ }
243
+ closeTable(tb2);
244
+ }
245
+ m_dbname = dbname;
246
+ return retPtr;
247
+ }
248
+ catch (...)
249
+ {
250
+ }
251
+ if (tb)
252
+ tb->unUse();
253
+ if (tb2)
254
+ closeTable(tb2);
255
+ m_dbname = dbname;
256
+ return retPtr;
257
+ }
258
+
259
+
260
+ // true ok false fail
261
+ bool database::setGrant(const char* host, const char* user)
262
+ {
263
+ bool ret = (acl_getroot(m_thd->security_ctx, my_strdup(user, MYF(0)),
264
+ my_strdup(host, MYF(0)), my_strdup(host, MYF(0)), (char*)m_dbname.c_str())) == false;
265
+ if (ret)
266
+ check_access(m_thd, SELECT_ACL, m_dbname.c_str(), &m_privilege, NULL, false, true);
267
+
268
+ return ret;
269
+ }
270
+
271
+ // for mysql database only
272
+ short database::aclReload()
273
+ {
274
+ if (name() != "mysql")
275
+ return STATUS_ACCESS_DENIED;
276
+ if(!(m_privilege & GRANT_ACL))
277
+ return STATUS_ACCESS_DENIED;
278
+ short ret = STATUS_SUCCESS;
279
+
280
+ THD* thdCur = _current_thd();
281
+ THD* thd = NULL;
282
+ try
283
+ {
284
+ thd = createThdForThread();
285
+ attachThd(thd);
286
+ thd->clear_error();
287
+ acl_reload(thd);
288
+ }
289
+ catch (...)
290
+ {
291
+ ret = 1;
292
+ }
293
+ if (thd)
294
+ deleteThdForThread(thd);
295
+ attachThd(thdCur);
296
+ return ret;
297
+ }
298
+
212
299
  void database::use() const
213
300
  {
214
301
  attachThd(m_thd);
@@ -304,6 +391,24 @@ void database::changeIntentionLock(table* tb, thr_lock_type lock_type)
304
391
  }
305
392
  }
306
393
 
394
+ inline void database::checkACL(enum_sql_command cmd)
395
+ {
396
+ switch(cmd)
397
+ {
398
+ case SQLCOM_UPDATE:
399
+ if (!(m_privilege & UPDATE_ACL)) THROW_BZS_ERROR_WITH_CODE(STATUS_ACCESS_DENIED);
400
+ break;
401
+ case SQLCOM_INSERT:
402
+ if (!(m_privilege & INSERT_ACL)) THROW_BZS_ERROR_WITH_CODE(STATUS_ACCESS_DENIED);
403
+ break;
404
+ case SQLCOM_DELETE:
405
+ if (!(m_privilege & DELETE_ACL)) THROW_BZS_ERROR_WITH_CODE(STATUS_ACCESS_DENIED);
406
+ break;
407
+ default:
408
+ break;
409
+ }
410
+ }
411
+
307
412
  /*
308
413
  How to set the lock value to InnoDB prebuilt->select_lock_type variable.
309
414
 
@@ -331,7 +436,7 @@ table* database::useTable(int index, enum_sql_command cmd, rowLockMode* lck)
331
436
  {
332
437
  if (index >= (int)m_tables.size())
333
438
  THROW_BZS_ERROR_WITH_CODEMSG(1, "Invalid table id.");
334
-
439
+
335
440
  table* tb = m_tables[index].get();
336
441
  if (tb == NULL)
337
442
  THROW_BZS_ERROR_WITH_CODEMSG(STATUS_FILE_NOT_OPENED,
@@ -362,9 +467,7 @@ table* database::useTable(int index, enum_sql_command cmd, rowLockMode* lck)
362
467
  return tb;
363
468
  }
364
469
 
365
- if (tb->m_table == NULL)
366
- THROW_BZS_ERROR_WITH_CODEMSG(STATUS_FILE_NOT_OPENED,
367
- "Invalid table id.");
470
+ checkACL(cmd);
368
471
  prebuildLocktype(tb, cmd, lck);
369
472
 
370
473
  if (m_thd->lock == 0)
@@ -572,6 +675,12 @@ TABLE* database::doOpenTable(const std::string& name, short mode,
572
675
  m_thd->variables.lock_wait_timeout = OPEN_TABLE_TIMEOUT_SEC;
573
676
  tables.init_one_table(m_dbname.c_str(), m_dbname.size(), name.c_str(),
574
677
  name.size(), name.c_str(), TL_READ);
678
+ if(!(m_privilege & SELECT_ACL) &&
679
+ (check_grant(m_thd, SELECT_ACL, &tables, FALSE, 1, true)))
680
+ {
681
+ m_stat = STATUS_ACCESS_DENIED;
682
+ return NULL;
683
+ }
575
684
  tables.mdl_request.set_type(MDL_SHARED_READ);
576
685
 
577
686
  Open_table_context ot_act(m_thd, MYSQL_OPEN_GET_NEW_TABLE);
@@ -581,9 +690,9 @@ TABLE* database::doOpenTable(const std::string& name, short mode,
581
690
  m_stat = STATUS_TABLE_NOTOPEN;
582
691
  if (ER_LOCK_WAIT_TIMEOUT == m_thd->cp_get_sql_error())
583
692
  m_stat = STATUS_CANNOT_LOCK_TABLE;
584
- THROW_BZS_ERROR_WITH_CODEMSG(m_stat, name.c_str());
693
+ return NULL;
585
694
  }
586
-
695
+
587
696
  // Check owner name
588
697
  if (ownerName && ownerName[0])
589
698
  {
@@ -608,31 +717,26 @@ TABLE* database::doOpenTable(const std::string& name, short mode,
608
717
  sprintf(buf, "%d", tables.table->field[1]->key_length());
609
718
  OutputDebugString(buf);
610
719
  #endif
720
+ m_stat = STATUS_SUCCESS;
611
721
  return tables.table;
612
722
  }
613
723
 
614
724
  table* database::openTable(const std::string& name, short mode,
615
725
  const char* ownerName)
616
726
  {
617
- if (existsTable(name))
727
+ TABLE* t = doOpenTable(name, mode, ownerName);
728
+ if (t)
618
729
  {
619
-
620
- TABLE* t = doOpenTable(name, mode, ownerName);
621
- if (t)
622
- {
623
- boost::shared_ptr<table> tb(
624
- new table(t, *this, name, mode, (int)m_tables.size()));
625
- m_tables.push_back(tb);
626
- m_stat = STATUS_SUCCESS;
627
- if (tb->isExclusveMode())
628
- ++m_usingExclusive;
629
- tableRef.addref(m_dbname, name); // addef first then table open.
630
- return tb.get();
631
- }
632
- return NULL;
730
+ boost::shared_ptr<table> tb(
731
+ new table(t, *this, name, mode, (int)m_tables.size()));
732
+ m_tables.push_back(tb);
733
+ m_stat = STATUS_SUCCESS;
734
+ if (tb->isExclusveMode())
735
+ ++m_usingExclusive;
736
+ tableRef.addref(m_dbname, name); // addef first then table open.
737
+ return tb.get();
633
738
  }
634
- m_stat = STATUS_TABLE_NOTOPEN;
635
- THROW_BZS_ERROR_WITH_CODEMSG(m_stat, name.c_str());
739
+ return NULL;
636
740
  }
637
741
 
638
742
  void database::closeTable(const std::string& name, bool drop)
@@ -685,8 +789,15 @@ void database::closeTable(table* tb)
685
789
  }else
686
790
  m_tables[i]->unUse();
687
791
 
688
- m_tables[i].reset();
792
+ m_tables[i]->m_table->file->ha_index_or_rnd_end();
689
793
 
794
+ TABLE** tbl;
795
+ for (tbl= &m_thd->open_tables; *tbl; tbl= &((*tbl)->next))
796
+ if(*tbl == m_tables[i]->m_table)
797
+ break;
798
+ if (*tbl)
799
+ close_thread_table(m_thd, tbl);
800
+ m_tables[i].reset();
690
801
  DEBUG_WRITELOG_SP1("CLOSE TABLE table id=%d \n", i);
691
802
  }
692
803
  }
@@ -725,31 +836,12 @@ void database::reopen()
725
836
  }
726
837
  }
727
838
 
728
- bool database::existsTable(const std::string& name)
729
- {
730
- char tmp[FN_REFLEN + 1];
731
-
732
- build_table_filename(tmp, sizeof(tmp) - 1, m_dbname.c_str(), name.c_str(),
733
- reg_ext, 0);
734
- MY_STAT st;
735
- if (mysql_file_stat(0, tmp, &st, MYF(0)))
736
- return true;
737
- return false;
738
- }
739
-
740
839
  bool database::existsDatabase()
741
840
  {
742
- char tmp[FN_REFLEN + 1];
743
- size_t len =
744
- build_table_filename(tmp, sizeof(tmp) - 1, m_dbname.c_str(), "", "", 0);
745
- tmp[len - 1] = 0x00;
746
-
747
- MY_STAT stat;
748
- if (mysql_file_stat(0, tmp, &stat, MYF(0)))
749
- return true;
750
- return false;
841
+ return !check_db_dir_existence(m_dbname.c_str());
751
842
  }
752
843
 
844
+
753
845
  class autoincSetup
754
846
  {
755
847
  TABLE* m_table;
@@ -776,7 +868,6 @@ unsigned short nisFieldNum(TABLE* tb)
776
868
  return (unsigned short)(tb->s->fields - i - offset);
777
869
  return tb->s->fields;
778
870
  }
779
-
780
871
  return 0;
781
872
  }
782
873
 
@@ -1058,8 +1149,8 @@ void* table::record() const
1058
1149
  }
1059
1150
 
1060
1151
  /** if offset and lastVarLenBytes() is non zero that is
1061
- * m_recordFormatType=RF_FIXED_PLUS_VALIABLE_LEN.
1062
- * ptr is excluding null flag sgement.
1152
+ �@m_recordFormatType=RF_FIXED_PLUS_VALIABLE_LEN.
1153
+ ptr is excluding null flag sgement.
1063
1154
  */
1064
1155
  void table::setRecord(void* ptr, unsigned short size, int offset)
1065
1156
  {
@@ -2290,6 +2381,27 @@ uint table::makeBlobFieldList(int fieldNum)
2290
2381
  return count;
2291
2382
  }
2292
2383
 
2384
+ inline void setSegmentValue(const KEY_PART_INFO& segment, const std::string& v)
2385
+ {
2386
+ segment.field->set_notnull();
2387
+ if (!((v.size() == 1) && (v[0] == 0x00)))
2388
+ segment.field->store(v.c_str(), (uint)v.size(), &my_charset_bin);
2389
+ else
2390
+ segment.field->set_null();
2391
+ }
2392
+
2393
+ void table::setKeyValues(const std::vector<std::string>& values, int keypart,
2394
+ const std::string* inValue)
2395
+ {
2396
+ KEY& key = m_table->key_info[m_keyNum];
2397
+ for (int i = 0; i < (int)key.user_defined_key_parts; i++)
2398
+ if (i < (int)values.size())
2399
+ setSegmentValue(key.key_part[i], values[i]);
2400
+ if (keypart != -1)
2401
+ setSegmentValue(key.key_part[keypart], *inValue);
2402
+ key_copy(&m_keybuf[0], m_table->record[0], &key, KEYLEN_ALLCOPY);
2403
+ }
2404
+
2293
2405
  #ifdef USE_HANDLERSOCKET
2294
2406
 
2295
2407
  int table::fieldIndexByName(const char* name) const
@@ -2312,27 +2424,6 @@ void table::setUseFieldList(const std::string& csv)
2312
2424
  addUseField(fieldIndexByName(values[i].c_str()));
2313
2425
  }
2314
2426
 
2315
- inline void setSegmentValue(const KEY_PART_INFO& segment, const std::string& v)
2316
- {
2317
- segment.field->set_notnull();
2318
- if (!((v.size() == 1) && (v[0] == 0x00)))
2319
- segment.field->store(v.c_str(), (uint)v.size(), &my_charset_bin);
2320
- else
2321
- segment.field->set_null();
2322
- }
2323
-
2324
- void table::setKeyValues(const std::vector<std::string>& values, int keypart,
2325
- const std::string* inValue)
2326
- {
2327
- KEY& key = m_table->key_info[m_keyNum];
2328
- for (int i = 0; i < (int)key.user_defined_key_parts; i++)
2329
- if (i < (int)values.size())
2330
- setSegmentValue(key.key_part[i], values[i]);
2331
- if (keypart != -1)
2332
- setSegmentValue(key.key_part[keypart], *inValue);
2333
- key_copy(&m_keybuf[0], m_table->record[0], &key, KEYLEN_ALLCOPY);
2334
- }
2335
-
2336
2427
  void table::setValue(int index, const std::string& v, int type)
2337
2428
  {
2338
2429
  Field* field = *(m_table->field + index);
@@ -119,6 +119,7 @@ private:
119
119
  short m_cid;
120
120
  enum_tx_isolation m_iso;
121
121
  tableList m_tables;
122
+ ulong m_privilege;
122
123
 
123
124
  TABLE* doOpenTable(const std::string& name, short mode,
124
125
  const char* ownerName);
@@ -128,12 +129,16 @@ private:
128
129
  void prebuildExclusieLockMode(table* tb);
129
130
  void prebuildLocktype(table* tb, enum_sql_command& cmd, rowLockMode* lck) ;
130
131
  void changeIntentionLock(table* tb, thr_lock_type lock_type);
131
-
132
+ void checkACL(enum_sql_command cmd);
132
133
  public:
133
134
 
134
135
 
135
136
  database(const char* name, short cid);
136
137
  ~database();
138
+ bool setGrant(const char* host, const char* user);
139
+
140
+ unsigned char* getUserSha1Passwd(const char* host, const char* user,
141
+ unsigned char* buf);
137
142
 
138
143
  int stat() { return m_stat; }
139
144
 
@@ -163,7 +168,6 @@ public:
163
168
  bool beginTrn(short type, enum_tx_isolation iso);
164
169
  bool commitTrn();
165
170
  bool abortTrn();
166
- bool existsTable(const std::string& name);
167
171
  bool existsDatabase();
168
172
  void closeTable(const std::string& name, bool drop);
169
173
  void closeTable(table* tb);
@@ -185,7 +189,10 @@ public:
185
189
  return ((m_inSnapshot + m_inTransaction) == 0);
186
190
  }
187
191
 
192
+ short aclReload();
193
+
188
194
  static tableCacheCounter tableRef;
195
+
189
196
  };
190
197
 
191
198
  typedef std::vector<boost::shared_ptr<database> > databases;
@@ -194,7 +201,8 @@ class IReadRecordsHandler;
194
201
  class IPrepare;
195
202
  class bookmarks;
196
203
 
197
-
204
+ //unsigned char* getUserSha1Passwd(const char* host, const char* user, unsigned char* buf);
205
+ //short aclReload();
198
206
  /*
199
207
  * Since it differs from the key number which a client specifies
200
208
  * , and an internal key number, it changes.
@@ -323,8 +331,6 @@ class table : private boost::noncopyable
323
331
  public:
324
332
  std::vector<int>& useFields() { return m_useFields; };
325
333
  void setUseFieldList(const std::string& csv);
326
- void setKeyValues(const std::vector<std::string>& values, int keypart,
327
- const std::string* inValue = NULL);
328
334
  void setValue(int index, const std::string& v, int type);
329
335
  void setUseValues(const std::vector<std::string>& values, int type);
330
336
 
@@ -547,6 +553,11 @@ public:
547
553
  return m_table->field[fieldNum]->type();
548
554
  }
549
555
 
556
+ inline enum enum_field_types fieldRealType(int fieldNum) const
557
+ {
558
+ return m_table->field[fieldNum]->real_type();
559
+ }
560
+
550
561
  inline unsigned int fieldFlags(int fieldNum) const
551
562
  {
552
563
  return m_table->field[fieldNum]->flags;
@@ -700,6 +711,9 @@ public:
700
711
  m_validCursor = false;
701
712
  }
702
713
  }
714
+ void setKeyValues(const std::vector<std::string>& values, int keypart,
715
+ const std::string* inValue = NULL);
716
+
703
717
 
704
718
  };
705
719