transactd 3.0.0 → 3.1.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/bin/common/tdclc_32_3_1.dll +0 -0
  3. data/bin/common/tdclc_64_3_1.dll +0 -0
  4. data/build/common/transactd.rc.in +1 -1
  5. data/build/swig/ruby/tdclrb_wrap.cpp +219 -15
  6. data/build/swig/tdcl.i +26 -0
  7. data/build/tdclc/tdclc.cbproj +1 -1
  8. data/build/tdclc/tdclc.rc +5 -5
  9. data/build/tdclcpp/tdclcpp.rc +5 -5
  10. data/build/tdclcpp/tdclcpp_bc.cbproj +1 -1
  11. data/build/tdclrb/tdclrb.rc +5 -5
  12. data/source/bzs/db/engine/mysql/database.cpp +131 -29
  13. data/source/bzs/db/engine/mysql/database.h +8 -6
  14. data/source/bzs/db/engine/mysql/dbManager.cpp +30 -12
  15. data/source/bzs/db/engine/mysql/dbManager.h +1 -1
  16. data/source/bzs/db/engine/mysql/mysqlInternal.h +251 -24
  17. data/source/bzs/db/engine/mysql/mysqlThd.cpp +2 -3
  18. data/source/bzs/db/protocol/tdap/client/bulkInsert.h +2 -2
  19. data/source/bzs/db/protocol/tdap/client/client.h +4 -3
  20. data/source/bzs/db/protocol/tdap/client/connMgr.h +1 -1
  21. data/source/bzs/db/protocol/tdap/client/database.cpp +195 -91
  22. data/source/bzs/db/protocol/tdap/client/database.h +6 -6
  23. data/source/bzs/db/protocol/tdap/client/databaseManager.h +9 -3
  24. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +31 -25
  25. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +4 -2
  26. data/source/bzs/db/protocol/tdap/client/field.cpp +6 -16
  27. data/source/bzs/db/protocol/tdap/client/filter.h +28 -9
  28. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +14 -4
  29. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +20 -2
  30. data/source/bzs/db/protocol/tdap/client/pooledDatabaseManager.h +5 -2
  31. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +2 -1
  32. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +19 -16
  33. data/source/bzs/db/protocol/tdap/client/table.cpp +2 -1
  34. data/source/bzs/db/protocol/tdap/client/table.h +1 -1
  35. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +13 -9
  36. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +68 -21
  37. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +3 -7
  38. data/source/bzs/db/protocol/tdap/tdapSchema.h +9 -1
  39. data/source/bzs/db/protocol/tdap/tdapcapi.h +11 -3
  40. data/source/bzs/db/protocol/tdap/uri.h +3 -1
  41. data/source/bzs/env/crosscompile.h +17 -3
  42. data/source/bzs/test/tdclatl/test_v3.js +60 -2
  43. data/source/bzs/test/tdclphp/transactd_Test.php +8 -0
  44. data/source/bzs/test/tdclphp/transactd_blob_Test.php +11 -3
  45. data/source/bzs/test/tdclphp/transactd_v3_Test.php +32 -8
  46. data/source/bzs/test/tdclrb/bench_tdclcpp.rb +7 -7
  47. data/source/bzs/test/tdclrb/transactd_spec.rb +22 -1
  48. data/source/bzs/test/tdclrb/transactd_v3_spec.rb +29 -3
  49. data/source/bzs/test/trdclengn/testField.h +34 -0
  50. data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +7 -0
  51. data/source/bzs/test/trdclengn/test_trdclengn.cpp +7 -8
  52. data/source/global/tdclatl/Database.cpp +34 -10
  53. data/source/global/tdclatl/Database.h +5 -5
  54. data/source/global/tdclatl/PooledDbManager.cpp +20 -3
  55. data/source/global/tdclatl/PooledDbManager.h +2 -2
  56. data/source/global/tdclatl/_IDatabaseEvents_CP.h +5 -4
  57. data/source/global/tdclatl/tdclatl.idl +157 -119
  58. metadata +4 -4
  59. data/bin/common/tdclc_32_3_0.dll +0 -0
  60. data/bin/common/tdclc_64_3_0.dll +0 -0
@@ -1,7 +1,7 @@
1
1
  #ifndef BZS_DB_ENGINE_MYSQL_MYSQLINTERNAL_H
2
2
  #define BZS_DB_ENGINE_MYSQL_MYSQLINTERNAL_H
3
3
  /* =================================================================
4
- Copyright (C) 2012 2013 BizStation Corp All rights reserved.
4
+ Copyright (C) 2012-2016 BizStation Corp All rights reserved.
5
5
 
6
6
  This program is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU General Public License
@@ -109,7 +109,11 @@ extern "C" {
109
109
 
110
110
  /* mysql.user password field index */
111
111
  #ifndef MYSQL_USER_FIELD_PASSWORD
112
- #define MYSQL_USER_FIELD_PASSWORD 2
112
+ # if ((MYSQL_VERSION_ID > 50700) && !defined(MARIADB_BASE_VERSION))
113
+ # define MYSQL_USER_FIELD_PASSWORD 40
114
+ # else
115
+ # define MYSQL_USER_FIELD_PASSWORD 2
116
+ # endif
113
117
  #endif
114
118
 
115
119
  #undef test
@@ -154,15 +158,27 @@ extern "C" {
154
158
  #define cp_get_sql_error() stmt_da->sql_errno()
155
159
  #define cp_isOk() stmt_da->is_ok()
156
160
  #define cp_set_overwrite_status(A) stmt_da->can_overwrite_status = A
161
+ #define cp_reset_diagnostics_area() stmt_da->reset_diagnostics_area()
162
+ #define cp_master_accsess() master_access
163
+ #define cp_priv_host() priv_host
164
+ #define cp_priv_user() priv_user
157
165
  #elif((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION)) // MySQL 5.7
158
166
  #define cp_get_sql_error() get_stmt_da()->mysql_errno()
159
167
  #define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
160
168
  #define cp_isOk() get_stmt_da()->is_ok()
161
169
  #define cp_set_overwrite_status(A) get_stmt_da()->set_overwrite_status(A)
170
+ #define cp_reset_diagnostics_area() get_stmt_da()->reset_diagnostics_area()
171
+ #define cp_master_accsess() master_access()
172
+ #define cp_priv_host() host().str
173
+ #define cp_priv_user() user().str
162
174
  #else // MySQL 5.6 Mariadb 10.0
163
175
  #define cp_get_sql_error() get_stmt_da()->sql_errno()
164
176
  #define cp_isOk() get_stmt_da()->is_ok()
165
177
  #define cp_set_overwrite_status(A) get_stmt_da()->set_overwrite_status(A)
178
+ #define cp_reset_diagnostics_area() get_stmt_da()->reset_diagnostics_area()
179
+ #define cp_master_accsess() master_access
180
+ #define cp_priv_host() priv_host
181
+ #define cp_priv_user() priv_user
166
182
 
167
183
  #endif
168
184
 
@@ -258,7 +274,6 @@ inline void cp_evaluate_insert_default_function(Field* fd)
258
274
 
259
275
  inline void cp_evaluate_update_default_function(Field* fd)
260
276
  {
261
-
262
277
  #if (MYSQL_VERSION_ID > 50600)
263
278
  Field* ft = fd;
264
279
  #else
@@ -268,16 +283,13 @@ inline void cp_evaluate_update_default_function(Field* fd)
268
283
  ft->set_time();
269
284
  }
270
285
 
271
-
272
286
  inline unsigned char* cp_null_ptr(Field* fd, unsigned char* /*record*/)
273
287
  {
274
288
  return (unsigned char*)fd->null_ptr;
275
289
  }
276
-
277
290
 
278
291
  #else
279
292
 
280
-
281
293
  inline void cp_thd_release_resources(THD* thd)
282
294
  {
283
295
  thd->release_resources();
@@ -411,7 +423,6 @@ inline void cp_set_db(THD* thd, char* p)
411
423
  thd->set_db(to_lex_cstring(p));
412
424
  }
413
425
 
414
-
415
426
  inline THD* cp_thread_get_THR_THD()
416
427
  {
417
428
  return my_thread_get_THR_THD();
@@ -519,23 +530,6 @@ inline int cp_thread_set_THR_THD(THD* thd)
519
530
  my_pthread_setspecific_ptr(THR_THD, thd);
520
531
  return 0;
521
532
  }
522
- /*
523
- inline void cp_set_transaction_duration_for_all_locks(THD* thd)
524
- {
525
- thd->mdl_context.set_transaction_duration_for_all_locks();
526
- }
527
-
528
- inline void cp_set_mdl_request_types(TABLE_LIST& tables, short mode)
529
- {
530
- tables.mdl_request.set_type(MDL_SHARED_READ);
531
- tables.mdl_request.duration = MDL_EXPLICIT;
532
- }
533
-
534
- inline void cp_open_error_release(THD* thd, TABLE_LIST& tables)
535
- {
536
- thd->mdl_context.release_lock(tables.mdl_request.ticket);
537
- }
538
- */
539
533
 
540
534
  inline void cp_set_transaction_duration_for_all_locks(THD* thd)
541
535
  {
@@ -625,4 +619,237 @@ inline void cp_setup_rpl_bitmap(TABLE* table){};
625
619
 
626
620
  #endif
627
621
 
622
+
623
+ class safe_mysql_mutex_lock
624
+ {
625
+ mysql_mutex_t *m_lock;
626
+ public:
627
+ safe_mysql_mutex_lock(mysql_mutex_t *lock): m_lock(lock)
628
+ {
629
+ if (m_lock)
630
+ mysql_mutex_lock(m_lock);
631
+ }
632
+ ~safe_mysql_mutex_lock()
633
+ {
634
+ if (m_lock)
635
+ mysql_mutex_unlock(m_lock);
636
+ }
637
+ };
638
+
639
+
640
+ // REPL_POS_TYPE
641
+ #include <bzs/env/compiler.h>
642
+ pragma_pack1;
643
+ #define BINLOGNAME_SIZE 119
644
+ #define GTID_SIZE 64
645
+
646
+ struct binlogPos
647
+ {
648
+ my_off_t pos;
649
+ char type;
650
+ char filename[BINLOGNAME_SIZE];
651
+ char gtid[GTID_SIZE];
652
+ };
653
+ pragma_pop;
654
+ #define REPL_POSTYPE_MARIA_GTID 1 // see tdapapi.h
655
+ #define REPL_POSTYPE_POS 2 // see tdapapi.h
656
+
657
+
658
+ #if (MYSQL_VERSION_ID > 100000)
659
+ # define USE_BINLOG_GTID 1 // like 0-1-50
660
+ #elif (!defined(_WIN32) || MYSQL_VERSION_ID > 50700 || MYSQL_VERSION_ID < 50600) // Linux or MySQL 5.5 5.7
661
+ # define USE_BINLOG_VAR 1
662
+ # if (!defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID > 50600)
663
+ # include "sql/binlog.h"
664
+ # endif
665
+
666
+ #else // MySQL 5.6 on windows
667
+ // On windows MySQL 5.6 can not access mysql_bin_log variable
668
+ # define NOTUSE_BINLOG_VAR 1
669
+
670
+ #if (MYSQL_VERSION_ID > 50700)
671
+ # define Protocol_mysql Protocol
672
+ # include "sql/rpl_master.h"
673
+ # define CP_PROTOCOL PROTOCOL_PLUGIN
674
+ #else
675
+ # define Protocol_mysql Protocol
676
+ # define CP_PROTOCOL PROTOCOL_BINARY
677
+ #endif //(MYSQL_VERSION_ID > 50700)
678
+
679
+ class dummyProtocol : public Protocol_mysql
680
+ {
681
+ THD* m_thd;
682
+ public:
683
+ #if (MYSQL_VERSION_ID > 50700)
684
+ inline dummyProtocol(THD *thd_arg) : Protocol_mysql()
685
+ {
686
+ m_thd = thd_arg;
687
+ thd_arg->set_protocol(this);
688
+ }
689
+ inline virtual ~dummyProtocol(){}
690
+ #else
691
+ inline dummyProtocol(THD *thd_arg) : Protocol_mysql(thd_arg)
692
+ {
693
+ thd_arg->protocol = this;
694
+ }
695
+ inline virtual ~dummyProtocol(){}
696
+ #endif
697
+ bool send_result_set_metadata(List<Item> *list, uint flags){return false;}
698
+ virtual bool write(){return false;};
699
+ virtual void prepare_for_resend(){}
700
+ virtual bool store_null(){return false;}
701
+ virtual bool store_tiny(longlong from){return false;}
702
+ virtual bool store_short(longlong from){return false;}
703
+ virtual bool store_long(longlong from){return false;}
704
+ virtual bool store_longlong(longlong from, bool unsigned_flag){return false;}
705
+ virtual bool store_decimal(const my_decimal *){return false;}
706
+ virtual bool store(const char *from, size_t length,
707
+ const CHARSET_INFO *fromcs,
708
+ const CHARSET_INFO *tocs){return false;}
709
+ virtual bool store(float from, uint32 decimals, String *buffer){return false;}
710
+ virtual bool store(double from, uint32 decimals, String *buffer){return false;}
711
+ virtual bool store(MYSQL_TIME *time, uint precision){return false;}
712
+ virtual bool store_date(MYSQL_TIME *time){return false;}
713
+ virtual bool store_time(MYSQL_TIME *time, uint precision){return false;}
714
+ virtual bool store(Field *field){return false;}
715
+ virtual bool send_out_parameters(List<Item_param> *sp_params){return false;}
716
+ virtual Protocol::enum_protocol_type type(void){ return CP_PROTOCOL; };
717
+ #ifdef MARIADB_BASE_VERSION //Mariadb 5.5
718
+ virtual bool store(MYSQL_TIME *time, int decimals){return false;}
719
+ virtual bool store_time(MYSQL_TIME *time, int decimals){ return false;}
720
+ #elif (MYSQL_VERSION_ID < 50600) // MySQL 5.5
721
+ virtual bool store_time(MYSQL_TIME *time){return true;};
722
+ virtual bool store(MYSQL_TIME *time){return true;}
723
+ virtual bool store(const char *from, size_t length,
724
+ CHARSET_INFO *fromcs, CHARSET_INFO *tocs){return false;}
725
+ #elif (MYSQL_VERSION_ID > 50700) // MySQL 5.7
726
+ bool store_decimal(const my_decimal *, uint, uint){ return true; }
727
+ bool store(Proto_field *){ return true; }
728
+ void start_row(){}
729
+ int read_packet(void){ return 0; }
730
+ int get_command(COM_DATA *, enum_server_command *){ return m_thd->lex->sql_command; }
731
+ enum_vio_type connection_type(void){ return VIO_TYPE_PLUGIN; }
732
+ ulong get_client_capabilities(void){ return 0; }
733
+ bool has_client_capability(unsigned long){ return false; }
734
+ bool connection_alive(void){ return false; }
735
+ bool end_row(void){ return false; }
736
+ void abort_row(void){}
737
+ void end_partial_result_set(void){}
738
+ int shutdown(bool){ return 0; }
739
+ SSL_handle get_ssl(void){ return NULL; }
740
+ uint get_rw_status(void){ return 0; }
741
+ bool get_compression(void){ return false; }
742
+ bool start_result_metadata(uint, uint, const CHARSET_INFO *){ return false; }
743
+ bool send_field_metadata(Send_field *, const CHARSET_INFO *){ return false; }
744
+ bool end_result_metadata(void){ return false; }
745
+ bool send_ok(uint, uint, ulonglong, ulonglong, const char *){ return false; }
746
+ bool send_eof(uint, uint){ return false; }
747
+ bool send_error(uint, const char *, const char *){ return false; }
748
+ #endif
749
+ };
750
+
751
+ class masterStatus : public dummyProtocol
752
+ {
753
+ binlogPos* m_bpos;
754
+ bool m_writed;
755
+ public:
756
+ inline masterStatus(THD *thd_arg, binlogPos* bpos) :
757
+ dummyProtocol(thd_arg), m_bpos(bpos), m_writed(false) {}
758
+ bool store_longlong(longlong from, bool unsigned_flag)
759
+ {
760
+ m_bpos->pos = (ulonglong)from;
761
+ m_bpos->type = REPL_POSTYPE_POS;
762
+ return false;
763
+ }
764
+
765
+ #if (MYSQL_VERSION_ID < 50600 || defined(MARIADB_BASE_VERSION)) // MySQL 5.5
766
+ bool store(const char *from, size_t length, CHARSET_INFO *cs)
767
+ {
768
+ if (!m_writed)
769
+ {
770
+ strncpy(m_bpos->filename, from, BINLOGNAME_SIZE);
771
+ m_writed = true;
772
+ }
773
+ return false;
774
+ }
775
+ #else
776
+ bool store(const char *from, size_t length,
777
+ const CHARSET_INFO *cs)
778
+ {
779
+ if (!m_writed)
780
+ {
781
+ strncpy(m_bpos->filename, from, BINLOGNAME_SIZE);
782
+ m_writed = true;
783
+ }
784
+ return false;
785
+ }
786
+ #endif
787
+ };
788
+
789
+ #endif // NOTUSE_BINLOG_VAR
790
+
791
+ class safe_commit_lock
792
+ {
793
+ THD* m_thd;
794
+ MDL_ticket* m_commits_lock;
795
+ public:
796
+ safe_commit_lock(THD* thd): m_thd(thd), m_commits_lock(NULL){}
797
+ bool lock()
798
+ {
799
+ if (m_thd)
800
+ {
801
+ MDL_request mdl_request;
802
+ #if ((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION))
803
+ mdl_request.init_with_source(MDL_key::COMMIT, "", "", MDL_SHARED, MDL_EXPLICIT, __FILE__, __LINE__);
804
+ #else
805
+ mdl_request.init(MDL_key::COMMIT, "", "", MDL_SHARED, MDL_EXPLICIT);
806
+ #endif
807
+ if (m_thd->mdl_context.acquire_lock(&mdl_request,
808
+ m_thd->variables.lock_wait_timeout))
809
+ return false;
810
+ m_commits_lock = mdl_request.ticket;
811
+ }
812
+ return true;
813
+ }
814
+ ~safe_commit_lock()
815
+ {
816
+ if (m_commits_lock)
817
+ {
818
+ m_thd->mdl_context.release_lock(m_commits_lock);
819
+ m_commits_lock= NULL;
820
+ }
821
+ }
822
+ };
823
+
824
+ /*
825
+ class safe_global_read_lock
826
+ {
827
+ THD* m_thd;
828
+ public:
829
+ safe_global_read_lock(THD* thd): m_thd(thd){}
830
+ bool lock()
831
+ {
832
+ if (m_thd->global_read_lock.lock_global_read_lock(m_thd))
833
+ {
834
+ m_thd = NULL;
835
+ return false;
836
+ }
837
+ #ifdef NOTUSE_BINLOG_VAR
838
+ close_cached_tables(NULL, NULL, FALSE , 50000000L);
839
+ if (m_thd->global_read_lock.make_global_read_lock_block_commit(m_thd))
840
+ {
841
+ m_thd->global_read_lock.unlock_global_read_lock(m_thd);
842
+ m_thd = NULL;
843
+ return false;
844
+ }
845
+ #endif
846
+ return true;
847
+ }
848
+ ~safe_global_read_lock()
849
+ {
850
+ if (m_thd)
851
+ m_thd->global_read_lock.unlock_global_read_lock(m_thd);
852
+ }
853
+ };*/
854
+
628
855
  #endif // BZS_DB_ENGINE_MYSQL_MYSQLINTERNAL_H
@@ -1,5 +1,5 @@
1
1
  /* =================================================================
2
- Copyright (C) 2012 2013 BizStation Corp All rights reserved.
2
+ Copyright (C) 2012-2016 BizStation Corp All rights reserved.
3
3
 
4
4
  This program is free software; you can redistribute it and/or
5
5
  modify it under the terms of the GNU General Public License
@@ -101,10 +101,9 @@ void endThread()
101
101
 
102
102
  void waitForServerStart()
103
103
  {
104
- mysql_mutex_lock(&LOCK_server_started);
104
+ safe_mysql_mutex_lock lck(&LOCK_server_started);
105
105
  while (!mysqld_server_started)
106
106
  mysql_cond_wait(&COND_server_started, &LOCK_server_started);
107
- mysql_mutex_unlock(&LOCK_server_started);
108
107
  }
109
108
 
110
109
  int getTransactdIsolation()
@@ -1,7 +1,7 @@
1
1
  #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_BULKINSERT_H
2
2
  #define BZS_DB_PROTOCOL_TDAP_CLIENT_BULKINSERT_H
3
3
  /*=================================================================
4
- Copyright (C) 2000-2013 BizStation Corp All rights reserved.
4
+ Copyright (C) 2000-2016 BizStation Corp All rights reserved.
5
5
 
6
6
  This program is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU General Public License
@@ -51,7 +51,7 @@ public:
51
51
  m_buflen = BULKBUFSIZE;
52
52
  }
53
53
 
54
- ~bulkInsert() { delete[] m_buf; }
54
+ ~bulkInsert() { delete [] m_buf; }
55
55
 
56
56
  char* reallocBuffer(char* buf, int oldsize, int newSize)
57
57
  {
@@ -314,7 +314,7 @@ public:
314
314
  m_req.datalen = &m_tmplen;
315
315
  }
316
316
 
317
- inline void getSqlCreate()
317
+ inline void getSqlCreate(int charsetIndex = -1)
318
318
  {
319
319
  if (!ver())
320
320
  {
@@ -324,9 +324,10 @@ public:
324
324
  _TCHAR tmp[MAX_PATH*2]={0};
325
325
  stripAuth((const char*)m_req.keybuf, tmp, MAX_PATH);
326
326
  std::string name = getTableName(tmp);
327
- int charsetIndexServer = getServerCharsetIndex();
327
+ if (charsetIndex == -1)
328
+ charsetIndex = getServerCharsetIndex();
328
329
  std::string sql = sqlBuilder::sqlCreateTable(name.c_str(), (tabledef*)m_req.data,
329
- charsetIndexServer, ver());
330
+ charsetIndex, ver());
330
331
  uint_td datalen = *m_req.datalen;
331
332
  *m_req.datalen = (uint_td)(sql.size() + 1);
332
333
  if (datalen <= sql.size())
@@ -36,7 +36,7 @@ namespace client
36
36
  class database;
37
37
  #pragma warning(disable : 4251)
38
38
 
39
- class DLLLIB connMgr : private nstable
39
+ class /*DLLLIB*/ connMgr : private nstable
40
40
  {
41
41
  public:
42
42
  typedef bzs::db::transactd::connection::record record;