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.
- checksums.yaml +4 -4
- data/bin/common/tdclc_32_3_1.dll +0 -0
- data/bin/common/tdclc_64_3_1.dll +0 -0
- data/build/common/transactd.rc.in +1 -1
- data/build/swig/ruby/tdclrb_wrap.cpp +219 -15
- data/build/swig/tdcl.i +26 -0
- data/build/tdclc/tdclc.cbproj +1 -1
- data/build/tdclc/tdclc.rc +5 -5
- data/build/tdclcpp/tdclcpp.rc +5 -5
- data/build/tdclcpp/tdclcpp_bc.cbproj +1 -1
- data/build/tdclrb/tdclrb.rc +5 -5
- data/source/bzs/db/engine/mysql/database.cpp +131 -29
- data/source/bzs/db/engine/mysql/database.h +8 -6
- data/source/bzs/db/engine/mysql/dbManager.cpp +30 -12
- data/source/bzs/db/engine/mysql/dbManager.h +1 -1
- data/source/bzs/db/engine/mysql/mysqlInternal.h +251 -24
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +2 -3
- data/source/bzs/db/protocol/tdap/client/bulkInsert.h +2 -2
- data/source/bzs/db/protocol/tdap/client/client.h +4 -3
- data/source/bzs/db/protocol/tdap/client/connMgr.h +1 -1
- data/source/bzs/db/protocol/tdap/client/database.cpp +195 -91
- data/source/bzs/db/protocol/tdap/client/database.h +6 -6
- data/source/bzs/db/protocol/tdap/client/databaseManager.h +9 -3
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +31 -25
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +4 -2
- data/source/bzs/db/protocol/tdap/client/field.cpp +6 -16
- data/source/bzs/db/protocol/tdap/client/filter.h +28 -9
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +14 -4
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +20 -2
- data/source/bzs/db/protocol/tdap/client/pooledDatabaseManager.h +5 -2
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +2 -1
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +19 -16
- data/source/bzs/db/protocol/tdap/client/table.cpp +2 -1
- data/source/bzs/db/protocol/tdap/client/table.h +1 -1
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +13 -9
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +68 -21
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +3 -7
- data/source/bzs/db/protocol/tdap/tdapSchema.h +9 -1
- data/source/bzs/db/protocol/tdap/tdapcapi.h +11 -3
- data/source/bzs/db/protocol/tdap/uri.h +3 -1
- data/source/bzs/env/crosscompile.h +17 -3
- data/source/bzs/test/tdclatl/test_v3.js +60 -2
- data/source/bzs/test/tdclphp/transactd_Test.php +8 -0
- data/source/bzs/test/tdclphp/transactd_blob_Test.php +11 -3
- data/source/bzs/test/tdclphp/transactd_v3_Test.php +32 -8
- data/source/bzs/test/tdclrb/bench_tdclcpp.rb +7 -7
- data/source/bzs/test/tdclrb/transactd_spec.rb +22 -1
- data/source/bzs/test/tdclrb/transactd_v3_spec.rb +29 -3
- data/source/bzs/test/trdclengn/testField.h +34 -0
- data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +7 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +7 -8
- data/source/global/tdclatl/Database.cpp +34 -10
- data/source/global/tdclatl/Database.h +5 -5
- data/source/global/tdclatl/PooledDbManager.cpp +20 -3
- data/source/global/tdclatl/PooledDbManager.h +2 -2
- data/source/global/tdclatl/_IDatabaseEvents_CP.h +5 -4
- data/source/global/tdclatl/tdclatl.idl +157 -119
- metadata +4 -4
- data/bin/common/tdclc_32_3_0.dll +0 -0
- data/bin/common/tdclc_64_3_0.dll +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
/* =================================================================
|
2
|
-
Copyright (C) 2012
|
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
|
@@ -43,7 +43,7 @@ namespace mysql
|
|
43
43
|
using namespace std;
|
44
44
|
|
45
45
|
#define KEYLEN_ALLCOPY 0
|
46
|
-
|
46
|
+
|
47
47
|
|
48
48
|
#if (MODE_READ_ONLY != TD_OPEN_READONLY)
|
49
49
|
#error "MODE_READ_ONLY != TD_OPEN_READONLY"
|
@@ -269,12 +269,26 @@ unsigned char* database::getUserSha1Passwd(const char* host, const char* user,
|
|
269
269
|
return retPtr;
|
270
270
|
}
|
271
271
|
|
272
|
+
bool setGrant(THD* thd, const char* host, const char* user, const char* db)
|
273
|
+
{
|
274
|
+
return (acl_getroot(cp_security_ctx(thd), cp_strdup(user, MYF(0)),
|
275
|
+
cp_strdup(host, MYF(0)), cp_strdup(host, MYF(0)), (char*)db)) == false;
|
276
|
+
}
|
272
277
|
|
278
|
+
bool copyGrant(THD* thd, THD* thdSrc, const char* db)
|
279
|
+
{
|
280
|
+
Security_context* sctx = cp_security_ctx(thdSrc);
|
281
|
+
if (sctx->cp_master_accsess() == (ulong)~NO_ACCESS)
|
282
|
+
{
|
283
|
+
cp_security_ctx(thd)->skip_grants();
|
284
|
+
return true;
|
285
|
+
}
|
286
|
+
return setGrant(thd, sctx->cp_priv_host(), sctx->cp_priv_user(), db);
|
287
|
+
}
|
273
288
|
// true ok false fail
|
274
289
|
bool database::setGrant(const char* host, const char* user)
|
275
290
|
{
|
276
|
-
bool ret = (
|
277
|
-
cp_strdup(host, MYF(0)), cp_strdup(host, MYF(0)), (char*)m_dbname.c_str())) == false;
|
291
|
+
bool ret = mysql::setGrant(m_thd, host, user, m_dbname.c_str());
|
278
292
|
if (ret)
|
279
293
|
check_access(m_thd, SELECT_ACL, m_dbname.c_str(), &m_privilege, NULL, false, true);
|
280
294
|
|
@@ -317,23 +331,23 @@ void database::use() const
|
|
317
331
|
|
318
332
|
void database::prebuildIsoratinMode()
|
319
333
|
{
|
320
|
-
|
321
|
-
if (m_inTransaction)
|
322
|
-
{
|
323
|
-
m_thd->tx_isolation = m_iso;
|
324
|
-
m_thd->in_lock_tables = 1;// WITH LOCK
|
325
|
-
}
|
326
|
-
else if(m_inSnapshot)
|
334
|
+
if (m_thd->lock == 0)
|
327
335
|
{
|
328
|
-
|
329
|
-
|
330
|
-
m_thd->in_lock_tables = 1;// WITH LOCK
|
336
|
+
cp_thd_set_read_only(m_thd, m_inSnapshot != 0);
|
337
|
+
if (m_inTransaction)
|
331
338
|
m_thd->tx_isolation = m_iso;
|
332
|
-
|
333
|
-
|
339
|
+
else if(m_inSnapshot)
|
340
|
+
{
|
341
|
+
if (m_iso)
|
342
|
+
m_thd->tx_isolation = m_iso;
|
343
|
+
else
|
344
|
+
m_thd->tx_isolation = ISO_REPEATABLE_READ;
|
345
|
+
}
|
346
|
+
else
|
347
|
+
m_thd->tx_isolation = (enum_tx_isolation)m_thd->variables.tx_isolation;
|
334
348
|
}
|
335
|
-
|
336
|
-
m_thd->
|
349
|
+
if (m_inTransaction || (m_inSnapshot && m_iso))
|
350
|
+
m_thd->in_lock_tables = 1;// WITH LOCK
|
337
351
|
}
|
338
352
|
|
339
353
|
void database::prebuildExclusieLockMode(table* tb)
|
@@ -499,9 +513,7 @@ table* database::useTable(int index, enum_sql_command cmd, rowLockMode* lck)
|
|
499
513
|
|
500
514
|
checkACL(cmd);
|
501
515
|
prebuildLocktype(tb, cmd, lck);
|
502
|
-
|
503
|
-
if (m_thd->lock == 0)
|
504
|
-
prebuildIsoratinMode();
|
516
|
+
prebuildIsoratinMode();
|
505
517
|
|
506
518
|
if (tb->isExclusveMode())
|
507
519
|
prebuildExclusieLockMode(tb);
|
@@ -630,6 +642,7 @@ bool database::beginTrn(short type, enum_tx_isolation iso)
|
|
630
642
|
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_ALREADY_INSNAPSHOT, "Snapshot is already beginning.");
|
631
643
|
|
632
644
|
bool ret = false;
|
645
|
+
m_stat = STATUS_SUCCESS;
|
633
646
|
if (m_inTransaction == 0)
|
634
647
|
{
|
635
648
|
m_trnType = type;
|
@@ -656,6 +669,7 @@ bool database::beginTrn(short type, enum_tx_isolation iso)
|
|
656
669
|
|
657
670
|
bool database::commitTrn()
|
658
671
|
{
|
672
|
+
m_stat = STATUS_SUCCESS;
|
659
673
|
if (m_inTransaction > 0)
|
660
674
|
{
|
661
675
|
--m_inTransaction;
|
@@ -667,6 +681,7 @@ bool database::commitTrn()
|
|
667
681
|
|
668
682
|
bool database::abortTrn()
|
669
683
|
{
|
684
|
+
m_stat = STATUS_SUCCESS;
|
670
685
|
if (m_inTransaction > 0)
|
671
686
|
{
|
672
687
|
--m_inTransaction;
|
@@ -676,12 +691,77 @@ bool database::abortTrn()
|
|
676
691
|
return (m_inTransaction == 0);
|
677
692
|
}
|
678
693
|
|
679
|
-
|
694
|
+
void database::useAllTables()
|
695
|
+
{
|
696
|
+
for (int i = 0; i < (int)m_tables.size(); ++i)
|
697
|
+
{
|
698
|
+
if (m_tables[i])
|
699
|
+
useTable(i, SQLCOM_SELECT, NULL);
|
700
|
+
}
|
701
|
+
}
|
702
|
+
|
703
|
+
// See USE_BINLOG_GTID and USE_BINLOG_VAR in mysqlInternal.h
|
704
|
+
#ifdef NOTUSE_BINLOG_VAR
|
705
|
+
// Windows MySQL can not use mysql_bin_log variable
|
706
|
+
inline short getBinlogPos(THD* currentThd, binlogPos* bpos)
|
707
|
+
{
|
708
|
+
short result = 0;
|
709
|
+
THD* thd = createThdForThread();
|
710
|
+
attachThd(thd);
|
711
|
+
copyGrant(thd, currentThd, NULL);
|
712
|
+
masterStatus p(thd, bpos);
|
713
|
+
cp_query_command(thd, "show master status");
|
714
|
+
if (thd->is_error())
|
715
|
+
result = thd->cp_get_sql_error();
|
716
|
+
deleteThdForThread(thd);
|
717
|
+
attachThd(currentThd);
|
718
|
+
return result;
|
719
|
+
}
|
720
|
+
#endif
|
721
|
+
|
722
|
+
#ifdef USE_BINLOG_GTID
|
723
|
+
inline short getBinlogPos(THD* currentThd, binlogPos* bpos)
|
724
|
+
{
|
725
|
+
if (mysql_bin_log.is_open())
|
726
|
+
{
|
727
|
+
rpl_gtid gtid;
|
728
|
+
bpos->type = REPL_POSTYPE_MARIA_GTID;
|
729
|
+
if (mysql_bin_log.lookup_domain_in_binlog_state(currentThd->variables.gtid_domain_id, >id))
|
730
|
+
{
|
731
|
+
sprintf_s(bpos->gtid, GTID_SIZE, "%u-%u-%llu", gtid.domain_id, gtid.server_id, gtid.seq_no);
|
732
|
+
size_t dir_len = dirname_length(mysql_bin_log.get_log_fname());
|
733
|
+
strncpy(bpos->filename, mysql_bin_log.get_log_fname() + dir_len, BINLOGNAME_SIZE);
|
734
|
+
bpos->pos = my_b_tell(mysql_bin_log.get_log_file());
|
735
|
+
bpos->filename[BINLOGNAME_SIZE-1] = 0x00;
|
736
|
+
}
|
737
|
+
}
|
738
|
+
return 0;
|
739
|
+
}
|
740
|
+
#endif
|
741
|
+
|
742
|
+
#ifdef USE_BINLOG_VAR
|
743
|
+
// Linux MySQL can access to the mysql_bin_log variable
|
744
|
+
inline short getBinlogPos(THD* , binlogPos* bpos)
|
745
|
+
{
|
746
|
+
if (mysql_bin_log.is_open())
|
747
|
+
{
|
748
|
+
size_t dir_len = dirname_length(mysql_bin_log.get_log_fname());
|
749
|
+
strncpy(bpos->filename, mysql_bin_log.get_log_fname() + dir_len, BINLOGNAME_SIZE);
|
750
|
+
bpos->pos = my_b_tell(mysql_bin_log.get_log_file());
|
751
|
+
bpos->filename[BINLOGNAME_SIZE-1] = 0x00;
|
752
|
+
bpos->type = REPL_POSTYPE_POS;
|
753
|
+
}
|
754
|
+
return 0;
|
755
|
+
}
|
756
|
+
#endif //USE_BINLOG_VAR
|
757
|
+
|
758
|
+
bool database::beginSnapshot(enum_tx_isolation iso, binlogPos* bpos)
|
680
759
|
{
|
681
760
|
if (m_inTransaction)
|
682
761
|
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_ALREADY_INTRANSACTION, "Transaction is already beginning.");
|
683
|
-
|
762
|
+
|
684
763
|
bool ret = false;
|
764
|
+
m_stat = STATUS_SUCCESS;
|
685
765
|
if (m_inSnapshot == 0)
|
686
766
|
{
|
687
767
|
m_iso = iso;
|
@@ -690,11 +770,27 @@ bool database::beginSnapshot(enum_tx_isolation iso)
|
|
690
770
|
ret = true;
|
691
771
|
}
|
692
772
|
++m_inSnapshot;
|
773
|
+
if (m_inSnapshot==1)
|
774
|
+
{
|
775
|
+
if (bpos)
|
776
|
+
{
|
777
|
+
safe_commit_lock commit(m_thd);
|
778
|
+
if (!commit.lock()) return false;
|
779
|
+
#ifndef NOTUSE_BINLOG_VAR
|
780
|
+
safe_mysql_mutex_lock lck(mysql_bin_log.get_log_lock());
|
781
|
+
#endif
|
782
|
+
m_stat = getBinlogPos(m_thd, bpos);
|
783
|
+
if (m_stat) return false;
|
784
|
+
useAllTables(); // execute scope in safe_commit_lock
|
785
|
+
}else
|
786
|
+
useAllTables();
|
787
|
+
}
|
693
788
|
return ret;
|
694
789
|
}
|
695
790
|
|
696
791
|
bool database::endSnapshot()
|
697
792
|
{
|
793
|
+
m_stat = STATUS_SUCCESS;
|
698
794
|
if (m_inSnapshot > 0)
|
699
795
|
{
|
700
796
|
--m_inSnapshot;
|
@@ -822,6 +918,8 @@ int tableUseCount(const std::vector<boost::shared_ptr<table> >& tables,
|
|
822
918
|
|
823
919
|
void database::closeTable(table* tb)
|
824
920
|
{
|
921
|
+
if (m_inSnapshot)
|
922
|
+
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_ALREADY_INSNAPSHOT, "Snapshot is already beginning.");
|
825
923
|
for (int i = (int)m_tables.size() - 1; i >= 0; i--)
|
826
924
|
{
|
827
925
|
if (m_tables[i] && (m_tables[i].get() == tb))
|
@@ -882,14 +980,16 @@ void database::closeForReopen()
|
|
882
980
|
m_usingExclusive = 0;
|
883
981
|
}
|
884
982
|
|
885
|
-
void database::reopen()
|
983
|
+
void database::reopen(bool forceReadonly)
|
886
984
|
{
|
887
985
|
for (size_t i = 0; i < m_tables.size(); i++)
|
888
986
|
{
|
889
987
|
if (m_tables[i] && (m_tables[i]->m_table == NULL))
|
890
988
|
{
|
989
|
+
if (forceReadonly)
|
990
|
+
m_tables[i]->m_mode = TD_OPEN_READONLY;
|
891
991
|
TABLE* table = doOpenTable(m_tables[i]->m_name.c_str(),
|
892
|
-
|
992
|
+
m_tables[i]->m_mode, NULL);
|
893
993
|
if (table)
|
894
994
|
m_tables[i]->resetInternalTable(table);
|
895
995
|
else
|
@@ -1050,6 +1150,7 @@ void table::resetInternalTable(TABLE* table)
|
|
1050
1150
|
m_changed = false;
|
1051
1151
|
m_validCursor = false;
|
1052
1152
|
m_nounlock = false;
|
1153
|
+
m_keyconv.setKey(m_table->key_info);
|
1053
1154
|
}
|
1054
1155
|
}
|
1055
1156
|
|
@@ -2325,7 +2426,7 @@ __int64 table::insert(bool ncc)
|
|
2325
2426
|
/* Do not change to m_changed = false */
|
2326
2427
|
m_changed = true;
|
2327
2428
|
}
|
2328
|
-
m_nounlock = setCursorStaus();
|
2429
|
+
m_nounlock = setCursorStaus(true);
|
2329
2430
|
return autoincValue;
|
2330
2431
|
}
|
2331
2432
|
|
@@ -2426,7 +2527,7 @@ void table::update(bool ncc)
|
|
2426
2527
|
++m_updCount;
|
2427
2528
|
m_changed = true;
|
2428
2529
|
}
|
2429
|
-
m_nounlock = setCursorStaus();
|
2530
|
+
m_nounlock = setCursorStaus(true);
|
2430
2531
|
}
|
2431
2532
|
}
|
2432
2533
|
}
|
@@ -2515,8 +2616,9 @@ void table::endBulkInsert()
|
|
2515
2616
|
{
|
2516
2617
|
if (m_bulkInserting)
|
2517
2618
|
{
|
2518
|
-
|
2519
|
-
|
2619
|
+
if (m_keyNum >= 0 && m_keyNum < (char)m_table->s->keys)
|
2620
|
+
key_copy(&m_keybuf[0], m_table->record[0], &m_table->key_info[(int)m_keyNum],
|
2621
|
+
KEYLEN_ALLCOPY);
|
2520
2622
|
m_bulkInserting = false;
|
2521
2623
|
m_table->file->ha_release_auto_increment();
|
2522
2624
|
m_table->file->ha_end_bulk_insert();
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#ifndef BZS_DB_ENGINE_MYSQL_DATABASE_H
|
2
2
|
#define BZS_DB_ENGINE_MYSQL_DATABASE_H
|
3
3
|
/* =================================================================
|
4
|
-
Copyright (C) 2012
|
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
|
@@ -69,7 +69,7 @@ namespace mysql
|
|
69
69
|
#define MODE_EXCLUSIVE -4
|
70
70
|
#define MODE_READ_EXCLUSIVE -6
|
71
71
|
|
72
|
-
|
72
|
+
#define OPEN_TABLE_TIMEOUT_SEC 2
|
73
73
|
/** bookmark size
|
74
74
|
* btreive API is MAX 4 byte
|
75
75
|
*/
|
@@ -133,6 +133,7 @@ private:
|
|
133
133
|
void changeIntentionLock(table* tb, thr_lock_type lock_type);
|
134
134
|
void checkACL(enum_sql_command cmd);
|
135
135
|
void releaseTable(size_t index);
|
136
|
+
void useAllTables();
|
136
137
|
public:
|
137
138
|
|
138
139
|
|
@@ -165,7 +166,7 @@ public:
|
|
165
166
|
return m_tables;
|
166
167
|
}
|
167
168
|
|
168
|
-
bool beginSnapshot(enum_tx_isolation iso);
|
169
|
+
bool beginSnapshot(enum_tx_isolation iso, struct binlogPos* bpos);
|
169
170
|
bool endSnapshot();
|
170
171
|
table* openTable(const std::string& name, short mode,
|
171
172
|
const char* ownerName);
|
@@ -178,7 +179,7 @@ public:
|
|
178
179
|
void closeTable(table* tb);
|
179
180
|
void unUseTables(bool rollback);
|
180
181
|
void closeForReopen();
|
181
|
-
void reopen();
|
182
|
+
void reopen(bool forceReadonly = false);
|
182
183
|
void cleanTable();
|
183
184
|
|
184
185
|
inline bool canUnlockRow() const
|
@@ -332,11 +333,12 @@ class table : private boost::noncopyable
|
|
332
333
|
void setKeyValues(const uchar* ptr, int size);
|
333
334
|
void setBlobFieldPointer(const bzs::db::blobHeader* hd);
|
334
335
|
|
335
|
-
inline bool setCursorStaus()
|
336
|
+
inline bool setCursorStaus(bool noCount = false)
|
336
337
|
{
|
337
338
|
if (m_stat == 0)
|
338
339
|
{
|
339
|
-
|
340
|
+
if (!noCount)
|
341
|
+
++m_readCount;
|
340
342
|
m_validCursor = true;
|
341
343
|
m_cursor = true;
|
342
344
|
}else
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* =================================================================
|
2
|
-
Copyright (C) 2012 2013 BizStation Corp All rights reserved.
|
2
|
+
Copyright (C) 2012 2013 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
|
@@ -32,6 +32,8 @@ namespace engine
|
|
32
32
|
namespace mysql
|
33
33
|
{
|
34
34
|
|
35
|
+
#define STATUS_ALREADY_INSNAPSHOT 204
|
36
|
+
#define STATUS_ALREADY_INTRANSACTION 205
|
35
37
|
|
36
38
|
class smartDbsReopen
|
37
39
|
{
|
@@ -44,8 +46,12 @@ public:
|
|
44
46
|
{
|
45
47
|
for (size_t i = 0; i < m_dbs.size(); i++)
|
46
48
|
{
|
47
|
-
if (m_dbs[i])
|
49
|
+
if (m_dbs[i] && m_dbs[i]->thd() == m_thd)
|
48
50
|
{
|
51
|
+
if (m_dbs[i]->inSnapshot())
|
52
|
+
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_ALREADY_INSNAPSHOT, "Allready in snapshot.");
|
53
|
+
else if (m_dbs[i]->inTransaction())
|
54
|
+
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_ALREADY_INTRANSACTION, "Allready in transaction.");
|
49
55
|
m_dbs[i]->use();
|
50
56
|
m_dbs[i]->unUseTables(false);
|
51
57
|
m_dbs[i]->closeForReopen();
|
@@ -58,7 +64,7 @@ public:
|
|
58
64
|
{
|
59
65
|
for (size_t i = 0; i < m_dbs.size(); i++)
|
60
66
|
{
|
61
|
-
if (m_dbs[i])
|
67
|
+
if (m_dbs[i] && m_dbs[i]->thd() == m_thd)
|
62
68
|
{
|
63
69
|
if (removeName != m_dbs[i]->name())
|
64
70
|
{
|
@@ -222,11 +228,9 @@ int dbManager::addHandle(int dbid, int tableid, int assignid)
|
|
222
228
|
int dbManager::ddl_execSql(THD* thd, const std::string& sql_stmt)
|
223
229
|
{
|
224
230
|
smartDbsReopen reopen(thd, m_dbs);
|
225
|
-
|
231
|
+
thd->variables.lock_wait_timeout = OPEN_TABLE_TIMEOUT_SEC;
|
226
232
|
thd->clear_error();
|
227
233
|
int result = cp_query_command(thd, (char*)sql_stmt.c_str());
|
228
|
-
//if (!thd->cp_isOk())
|
229
|
-
// result = 1;
|
230
234
|
if (thd->is_error())
|
231
235
|
result = errorCode(thd->cp_get_sql_error());
|
232
236
|
cp_lex_clear(thd); // reset values for insert
|
@@ -240,18 +244,32 @@ int dbManager::ddl_createDataBase(THD* thd, const std::string& dbname)
|
|
240
244
|
}
|
241
245
|
|
242
246
|
int dbManager::ddl_dropDataBase(THD* thd, const std::string& dbname,
|
243
|
-
const std::string& dbSqlname)
|
247
|
+
const std::string& dbSqlname, short cid)
|
244
248
|
{
|
245
249
|
std::string cmd = "drop database `" + dbSqlname + "`";
|
246
250
|
smartDbsReopen::removeName = dbname;
|
247
251
|
int ret = ddl_execSql(thd, cmd);
|
248
252
|
smartDbsReopen::removeName = "";
|
249
253
|
boost::mutex::scoped_lock lck(m_mutex);
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
254
|
+
if (ret == 0)
|
255
|
+
{
|
256
|
+
int index = -1;
|
257
|
+
for (int i = (int)m_dbs.size() - 1; i >= 0; i--)
|
258
|
+
{
|
259
|
+
if (m_dbs[i] != NULL && (m_dbs[i]->clientID() == cid))
|
260
|
+
{
|
261
|
+
index = i;
|
262
|
+
break;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
if (index != -1)
|
266
|
+
{
|
267
|
+
m_dbs[index].reset();
|
268
|
+
for (int i = (int)m_handles.size() - 1; i >= 0; i--)
|
269
|
+
if (m_handles[i].db == index)
|
270
|
+
m_handles.erase(m_handles.begin() + i);
|
271
|
+
}
|
272
|
+
}
|
255
273
|
return ret;
|
256
274
|
}
|
257
275
|
|
@@ -76,7 +76,7 @@ protected:
|
|
76
76
|
int ddl_execSql(THD* thd, const std::string& sql_stmt);
|
77
77
|
int ddl_createDataBase(THD* thd, const std::string& dbname);
|
78
78
|
int ddl_dropDataBase(THD* thd, const std::string& dbname,
|
79
|
-
|
79
|
+
const std::string& dbSqlname, short cid);
|
80
80
|
int ddl_useDataBase(THD* thd, const std::string& dbSqlname);
|
81
81
|
int ddl_dropTable(database* db, const std::string& tbname,
|
82
82
|
const std::string& sqldbname,
|