transactd 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +37 -4
- data/bin/common/tdclc_32_1_2.dll +0 -0
- data/bin/common/tdclc_64_1_2.dll +0 -0
- data/build/common/transactd_cl_common.cmake +0 -1
- data/build/common/transactd_common.cmake +26 -6
- data/build/swig/php/generate.cmake.in +58 -0
- data/build/swig/php/generate.cmd.in +41 -0
- data/build/swig/php/php.swg +155 -0
- data/build/swig/ruby/ruby.swg +38 -0
- data/build/swig/tdcl.i +133 -3
- data/build/tdclc/CMakeLists.txt +4 -1
- data/build/tdclc/tdclc_32.cbproj +1 -1
- data/build/tdclc/tdclc_64.cbproj +1 -1
- data/build/tdclcpp/CMakeLists.txt +1 -1
- data/build/tdclcpp/tdclcpp_bcb_32.cbproj +1 -4
- data/build/tdclcpp/tdclcpp_bcb_64.cbproj +0 -3
- data/build/tdclrb/CMakeLists.txt +1 -1
- data/build/tdclrb/GEM_VERSION +2 -2
- data/source/bzs/db/engine/mysql/IReadRecords.h +1 -1
- data/source/bzs/db/engine/mysql/bookmark.h +3 -3
- data/source/bzs/db/engine/mysql/database.cpp +95 -19
- data/source/bzs/db/engine/mysql/database.h +6 -6
- data/source/bzs/db/engine/mysql/mysqlInternal.h +43 -1
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +10 -8
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +1 -1
- data/source/bzs/db/protocol/tdap/btrDate.h +2 -2
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +15 -8
- data/source/bzs/db/protocol/tdap/client/dbDef.h +2 -2
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +4 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +0 -5
- data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +0 -4
- data/source/bzs/db/protocol/tdap/client/filter.cpp +0 -484
- data/source/bzs/db/protocol/tdap/client/filter.h +696 -84
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +13 -3
- data/source/bzs/db/protocol/tdap/client/nsTable.h +12 -6
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +2 -1
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +1 -0
- data/source/bzs/db/protocol/tdap/client/table.cpp +519 -75
- data/source/bzs/db/protocol/tdap/client/table.h +49 -7
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +145 -124
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +39 -0
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +872 -0
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +8 -8
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +7 -9
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +406 -195
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +64 -13
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +2 -1
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +35 -3
- data/source/bzs/db/protocol/tdap/tdapSchema.h +11 -3
- data/source/bzs/db/protocol/tdap/tdapcapi.h +63 -53
- data/source/bzs/env/crosscompile.h +8 -3
- data/source/bzs/example/connection_pool_c.cpp +1 -7
- data/source/bzs/example/useORM.cpp +585 -0
- data/source/bzs/rtl/exception.h +6 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +12 -7
- data/source/bzs/test/tdclphp/transactd_Test.php +1845 -0
- data/source/bzs/test/tdclphp/transactd_blob_Test.php +325 -0
- data/source/bzs/test/tdclphp/transactd_datetime_Test.php +183 -0
- data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +212 -0
- data/source/bzs/test/tdclrb/transactd_blob_spec.rb +332 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +256 -1
- data/source/bzs/test/trdclengn/test_blob.cpp +327 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +485 -5
- data/source/global/tdclatl/QueryBase.cpp +231 -0
- data/source/global/tdclatl/QueryBase.h +96 -0
- data/source/global/tdclatl/Table.cpp +24 -0
- data/source/global/tdclatl/Table.h +2 -1
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/tdclatl.idl +88 -2
- metadata +16 -3
- data/bin/common/tdclc_32_1_1.dll +0 -0
- data/bin/common/tdclc_64_1_1.dll +0 -0
data/build/tdclc/tdclc_32.cbproj
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
<Defines>BOOST_ALL_NO_LIB;TRANSACTD;$(Defines)</Defines>
|
28
28
|
<BRCC_CompilerToUse>rc</BRCC_CompilerToUse>
|
29
29
|
<BRCC_IncludePath>$(BDSINCLUDE)\windows\sdk;$(BRCC_IncludePath)</BRCC_IncludePath>
|
30
|
-
<DllSuffix>
|
30
|
+
<DllSuffix>_1_2</DllSuffix>
|
31
31
|
<DynamicRTL>false</DynamicRTL>
|
32
32
|
<BPILibOutputDir>..\..\lib</BPILibOutputDir>
|
33
33
|
<BCC_PCHUsage>None</BCC_PCHUsage>
|
data/build/tdclc/tdclc_64.cbproj
CHANGED
@@ -44,7 +44,7 @@
|
|
44
44
|
<Defines>BOOST_ALL_NO_LIB;TRANSACTD;$(Defines)</Defines>
|
45
45
|
<BRCC_CompilerToUse>rc</BRCC_CompilerToUse>
|
46
46
|
<BRCC_IncludePath>$(BDSINCLUDE)\windows\sdk;$(BRCC_IncludePath)</BRCC_IncludePath>
|
47
|
-
<DllSuffix>
|
47
|
+
<DllSuffix>_1_2</DllSuffix>
|
48
48
|
<DynamicRTL>false</DynamicRTL>
|
49
49
|
<BPILibOutputDir>..\..\lib</BPILibOutputDir>
|
50
50
|
<BCC_PCHUsage>None</BCC_PCHUsage>
|
@@ -104,7 +104,7 @@ add_library(${this_target} SHARED ${${this_target}_SOURCE_FILES})
|
|
104
104
|
# ==========================================================
|
105
105
|
# add link / include
|
106
106
|
# ==========================================================
|
107
|
-
transactd_link_boost_libraries("chrono;
|
107
|
+
transactd_link_boost_libraries("filesystem;thread;chrono;system")
|
108
108
|
if(CAN_LINK_ICONV)
|
109
109
|
target_link_libraries(${this_target} iconv)
|
110
110
|
endif()
|
@@ -59,7 +59,7 @@
|
|
59
59
|
<BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
|
60
60
|
<BCC_ExtendedErrorInfo>true</BCC_ExtendedErrorInfo>
|
61
61
|
<TD_VER_MAJOR>1</TD_VER_MAJOR>
|
62
|
-
<TD_VER_MINOR>
|
62
|
+
<TD_VER_MINOR>2</TD_VER_MINOR>
|
63
63
|
<DllSuffix>$(TD_VER_MAJOR)_$(TD_VER_MINOR)</DllSuffix>
|
64
64
|
</PropertyGroup>
|
65
65
|
<PropertyGroup Condition="'$(Cfg_1)'!=''">
|
@@ -123,9 +123,6 @@
|
|
123
123
|
<CppCompile Include="..\..\source\bzs\db\protocol\tdap\client\fileDDF.cpp">
|
124
124
|
<BuildOrder>8</BuildOrder>
|
125
125
|
</CppCompile>
|
126
|
-
<CppCompile Include="..\..\source\bzs\db\protocol\tdap\client\filter.cpp">
|
127
|
-
<BuildOrder>9</BuildOrder>
|
128
|
-
</CppCompile>
|
129
126
|
<CppCompile Include="..\..\source\bzs\db\protocol\tdap\client\indexDDF.cpp">
|
130
127
|
<BuildOrder>10</BuildOrder>
|
131
128
|
</CppCompile>
|
@@ -178,9 +178,6 @@
|
|
178
178
|
<CppCompile Include="..\..\source\bzs\db\protocol\tdap\client\fileDDF.cpp">
|
179
179
|
<BuildOrder>8</BuildOrder>
|
180
180
|
</CppCompile>
|
181
|
-
<CppCompile Include="..\..\source\bzs\db\protocol\tdap\client\filter.cpp">
|
182
|
-
<BuildOrder>9</BuildOrder>
|
183
|
-
</CppCompile>
|
184
181
|
<CppCompile Include="..\..\source\bzs\db\protocol\tdap\client\indexDDF.cpp">
|
185
182
|
<BuildOrder>10</BuildOrder>
|
186
183
|
</CppCompile>
|
data/build/tdclrb/CMakeLists.txt
CHANGED
@@ -178,7 +178,7 @@ endif()
|
|
178
178
|
# add link / include
|
179
179
|
# ==========================================================
|
180
180
|
if(MINGW)
|
181
|
-
transactd_link_boost_libraries("timer;chrono;
|
181
|
+
transactd_link_boost_libraries("timer;filesystem;thread;chrono;system")
|
182
182
|
else()
|
183
183
|
transactd_link_boost_libraries("timer")
|
184
184
|
endif()
|
data/build/tdclrb/GEM_VERSION
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
TDVER_RUBYGEM_VER_MAJOR 1
|
2
|
-
TDVER_RUBYGEM_VER_MINOR
|
3
|
-
TDVER_RUBYGEM_VER_RELEASE
|
2
|
+
TDVER_RUBYGEM_VER_MINOR 2
|
3
|
+
TDVER_RUBYGEM_VER_RELEASE 0
|
@@ -39,7 +39,7 @@ class IReadRecordsHandler
|
|
39
39
|
public:
|
40
40
|
virtual ~IReadRecordsHandler(){};
|
41
41
|
virtual int match(bool typeNext) const=0;
|
42
|
-
virtual short write(const unsigned char* bookmark, unsigned int bmlen)=0;
|
42
|
+
virtual short write(const unsigned char* bookmark, unsigned int bmlen, short stat=0)=0;
|
43
43
|
virtual unsigned short rejectCount() = 0;
|
44
44
|
virtual unsigned short maxRows() = 0;
|
45
45
|
};
|
@@ -135,9 +135,9 @@ class bookmarks
|
|
135
135
|
THROW_BZS_ERROR_WITH_CODEMSG(STATUS_INVALID_BOOKMARK ,"invalid bookmark.");
|
136
136
|
void* tmp;
|
137
137
|
if (m_ptr == NULL)
|
138
|
-
tmp = (unsigned char*)
|
138
|
+
tmp = (unsigned char*)td_malloc(count*m_refLen, 0);
|
139
139
|
else
|
140
|
-
tmp =
|
140
|
+
tmp = td_realloc(m_ptr, count*m_refLen, 0);
|
141
141
|
if (tmp)
|
142
142
|
m_ptr = (unsigned char*)tmp;
|
143
143
|
else
|
@@ -153,7 +153,7 @@ public:
|
|
153
153
|
|
154
154
|
~bookmarks()
|
155
155
|
{
|
156
|
-
|
156
|
+
td_free(m_ptr);
|
157
157
|
}
|
158
158
|
|
159
159
|
/** get integer bookmark pointer by raw ref pointer
|
@@ -370,7 +370,7 @@ bool database::endSnapshot()
|
|
370
370
|
/** Metadata lock, a table name is case-sensitive
|
371
371
|
* However, in actual opening, it is not distinguished at Windows.
|
372
372
|
*/
|
373
|
-
TABLE* database::doOpenTable(const std::string& name, short mode)
|
373
|
+
TABLE* database::doOpenTable(const std::string& name, short mode, const char* ownerName)
|
374
374
|
{
|
375
375
|
TABLE_LIST tables;
|
376
376
|
m_thd->variables.lock_wait_timeout = OPEN_TABLE_TIMEOUT_SEC;
|
@@ -388,6 +388,23 @@ TABLE* database::doOpenTable(const std::string& name, short mode)
|
|
388
388
|
m_stat = STATUS_CANNOT_LOCK_TABLE;
|
389
389
|
THROW_BZS_ERROR_WITH_CODEMSG(m_stat, name.c_str());
|
390
390
|
}
|
391
|
+
|
392
|
+
//Check owner name
|
393
|
+
if (ownerName && ownerName[0])
|
394
|
+
{
|
395
|
+
const char* p = tables.table->s->comment.str;
|
396
|
+
if ((p[0] == '%') && (p[1] =='@') && (p[2] =='%'))
|
397
|
+
{
|
398
|
+
int readNoNeed = p[3] - '0';
|
399
|
+
if ((mode == TD_OPEN_READONLY) && readNoNeed)
|
400
|
+
;
|
401
|
+
else if (strcmp(p + 4, ownerName))
|
402
|
+
{
|
403
|
+
m_stat = STATUS_INVALID_OWNERNAME;
|
404
|
+
return NULL;
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}
|
391
408
|
|
392
409
|
tables.table->use_all_columns();
|
393
410
|
tables.table->open_by_handler = 1;
|
@@ -399,15 +416,20 @@ TABLE* database::doOpenTable(const std::string& name, short mode)
|
|
399
416
|
return tables.table;
|
400
417
|
}
|
401
418
|
|
402
|
-
table* database::openTable(const std::string& name, short mode)
|
419
|
+
table* database::openTable(const std::string& name, short mode, const char* ownerName)
|
403
420
|
{
|
404
421
|
if (existsTable(name))
|
405
422
|
{
|
406
423
|
tableRef.addref(m_dbname, name);//addef first then table open.
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
424
|
+
TABLE* t = doOpenTable(name, mode, ownerName);
|
425
|
+
if (t)
|
426
|
+
{
|
427
|
+
boost::shared_ptr<table> tb(new table(t , *this, name, mode, (int)m_tables.size()));
|
428
|
+
m_tables.push_back(tb);
|
429
|
+
m_stat = STATUS_SUCCESS;
|
430
|
+
return tb.get();
|
431
|
+
}
|
432
|
+
return NULL;
|
411
433
|
}
|
412
434
|
m_stat = STATUS_TABLE_NOTOPEN;
|
413
435
|
THROW_BZS_ERROR_WITH_CODEMSG(m_stat, name.c_str());
|
@@ -459,7 +481,7 @@ void database::reopen()
|
|
459
481
|
{
|
460
482
|
if (m_tables[i] && (m_tables[i]->m_table==NULL))
|
461
483
|
{
|
462
|
-
TABLE* table = doOpenTable(m_tables[i]->m_name.c_str(), m_tables[i]->m_mode);
|
484
|
+
TABLE* table = doOpenTable(m_tables[i]->m_name.c_str(), m_tables[i]->m_mode, NULL);
|
463
485
|
if (table)
|
464
486
|
m_tables[i]->resetInternalTable(table);
|
465
487
|
else
|
@@ -628,7 +650,7 @@ bool table::setNonKey(bool scan)
|
|
628
650
|
return true;
|
629
651
|
}
|
630
652
|
|
631
|
-
bool table::setKeyNum(char num)
|
653
|
+
bool table::setKeyNum(char num, bool sorted)
|
632
654
|
{
|
633
655
|
if ((m_keyNum != num) || ((m_keyNum >= 0)&& (m_table->file->inited == handler::NONE)))
|
634
656
|
{
|
@@ -637,7 +659,7 @@ bool table::setKeyNum(char num)
|
|
637
659
|
if(keynumCheck(num))
|
638
660
|
{
|
639
661
|
m_keyNum = num;
|
640
|
-
m_table->file->ha_index_init(m_keyNum,
|
662
|
+
m_table->file->ha_index_init(m_keyNum, sorted);
|
641
663
|
return true;
|
642
664
|
}
|
643
665
|
else
|
@@ -727,6 +749,9 @@ void table::setKeyValuesPacked(const uchar* ptr, int size)
|
|
727
749
|
|
728
750
|
uint table::keyPackCopy(uchar* ptr)
|
729
751
|
{
|
752
|
+
//if nokey and getbookmark operation then keynum = -2
|
753
|
+
if (m_keyNum < 0) return 0;
|
754
|
+
|
730
755
|
KEY& key = m_table->key_info[m_keyNum];
|
731
756
|
if ((key.flags & HA_NULL_PART_KEY) || (key.flags & HA_VAR_LENGTH_KEY))
|
732
757
|
{
|
@@ -790,6 +815,8 @@ inline bool isNull(Field* fd)
|
|
790
815
|
|
791
816
|
return (len==0);
|
792
817
|
}
|
818
|
+
else if (isBlobType(fd->type()))
|
819
|
+
return (0==blob_len(fd));
|
793
820
|
else
|
794
821
|
{
|
795
822
|
unsigned int k=0;
|
@@ -1334,18 +1361,21 @@ void table::stepPrev()
|
|
1334
1361
|
|
1335
1362
|
void table::readRecords(IReadRecordsHandler* hdr, bool includeCurrent, int type)
|
1336
1363
|
{
|
1337
|
-
if ((m_table->file->inited
|
1364
|
+
if ((m_table->file->inited == handler::NONE) || !m_cursor)
|
1338
1365
|
{
|
1339
1366
|
m_stat = STATUS_NO_CURRENT;
|
1340
1367
|
return;
|
1341
1368
|
}
|
1342
1369
|
m_nonNcc = false;
|
1343
1370
|
int reject = (hdr->rejectCount()==0)?4096:hdr->rejectCount();
|
1371
|
+
if (reject==0xFFFF)
|
1372
|
+
reject = -1;
|
1344
1373
|
int rows = hdr->maxRows();
|
1345
1374
|
|
1346
1375
|
//Is a current position read or not?
|
1347
1376
|
bool read = !includeCurrent;
|
1348
1377
|
bool unlock = (!m_db.inSnapshot() && !m_db.inTransaction()) || (m_db.inTransaction() && (m_db.transactionType()== 0));
|
1378
|
+
bool forword = (type == READ_RECORD_GETNEXT) || (type == READ_RECORD_STEPNEXT);
|
1349
1379
|
while((reject!=0) && (rows!=0))
|
1350
1380
|
{
|
1351
1381
|
if (read)
|
@@ -1361,6 +1391,13 @@ void table::readRecords(IReadRecordsHandler* hdr, bool includeCurrent, int type)
|
|
1361
1391
|
m_stat = m_table->file->ha_index_next(m_table->record[0]);
|
1362
1392
|
else if (type == READ_RECORD_GETPREV)
|
1363
1393
|
m_stat = m_table->file->ha_index_prev(m_table->record[0]);
|
1394
|
+
else if (type == READ_RECORD_STEPNEXT)
|
1395
|
+
m_stat = m_table->file->ha_rnd_next(m_table->record[0]);
|
1396
|
+
else if (type == READ_RECORD_STEPPREV)
|
1397
|
+
{
|
1398
|
+
m_stat = STATUS_NOSUPPORT_OP;
|
1399
|
+
return;
|
1400
|
+
}
|
1364
1401
|
m_cursor = m_validCursor = (m_stat == 0);
|
1365
1402
|
}else
|
1366
1403
|
read = true;
|
@@ -1368,7 +1405,7 @@ void table::readRecords(IReadRecordsHandler* hdr, bool includeCurrent, int type)
|
|
1368
1405
|
|
1369
1406
|
if (m_stat)
|
1370
1407
|
break;
|
1371
|
-
int ret = hdr->match(
|
1408
|
+
int ret = hdr->match(forword);
|
1372
1409
|
if (ret == REC_MACTH)
|
1373
1410
|
{
|
1374
1411
|
m_stat = hdr->write(position(), posPtrLen());
|
@@ -1417,7 +1454,7 @@ void table::movePos(const uchar* pos, char keyNum, bool sureRawValue)
|
|
1417
1454
|
unlockRow();
|
1418
1455
|
m_stat = m_table->file->ha_rnd_pos(m_table->record[0], (uchar*)rawPos);
|
1419
1456
|
m_cursor = (m_stat == 0);
|
1420
|
-
if (keyNum==-1)
|
1457
|
+
if ((keyNum==-1)||(keyNum==-64))
|
1421
1458
|
return ;
|
1422
1459
|
if (m_stat==0)
|
1423
1460
|
{
|
@@ -1456,6 +1493,8 @@ uint table::posPtrLen()const
|
|
1456
1493
|
|
1457
1494
|
ha_rows table::recordCount(bool estimate)
|
1458
1495
|
{
|
1496
|
+
if ((m_table->file->ha_table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0)
|
1497
|
+
return m_table->file->records();
|
1459
1498
|
if (estimate)
|
1460
1499
|
{ //Since the answer of innodb is random, 1 returns also 0.
|
1461
1500
|
//Since it is important, in the case of 1
|
@@ -1466,16 +1505,45 @@ ha_rows table::recordCount(bool estimate)
|
|
1466
1505
|
return rows;
|
1467
1506
|
}
|
1468
1507
|
uint n = 0;
|
1469
|
-
m_table->read_set= &m_table->tmp_set;
|
1508
|
+
m_table->read_set = &m_table->tmp_set;
|
1509
|
+
m_table->write_set = &m_table->tmp_set;
|
1470
1510
|
bitmap_clear_all(m_table->read_set);
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1511
|
+
//bitmap_clear_all(m_table->write_set);
|
1512
|
+
|
1513
|
+
char keynum = m_keyNum;
|
1514
|
+
int inited = m_table->file->inited;
|
1515
|
+
m_table->file->ha_index_or_rnd_end();
|
1516
|
+
|
1517
|
+
m_table->file->extra(HA_EXTRA_KEYREAD);
|
1518
|
+
if (setKeyNum((char)0, false/*sorted*/))
|
1474
1519
|
{
|
1475
|
-
|
1520
|
+
m_stat = m_table->file->ha_index_first(m_table->record[0]);
|
1521
|
+
while (m_stat == 0)
|
1522
|
+
{
|
1523
|
+
n++;
|
1524
|
+
m_stat = m_table->file->ha_index_next(m_table->record[0]);
|
1525
|
+
}
|
1526
|
+
m_table->file->extra(HA_EXTRA_NO_KEYREAD);
|
1527
|
+
|
1528
|
+
//restore index init
|
1529
|
+
if ((inited == (int)handler::INDEX) && (m_keyNum != keynum))
|
1530
|
+
setKeyNum(keynum);
|
1531
|
+
else if((inited == (int)handler::RND))
|
1532
|
+
setNonKey(true/*scan*/);
|
1533
|
+
}
|
1534
|
+
else
|
1535
|
+
{
|
1536
|
+
setNonKey(true/*scan*/);
|
1476
1537
|
m_stat = m_table->file->ha_rnd_next(m_table->record[0]);
|
1538
|
+
while (m_stat == 0)
|
1539
|
+
{
|
1540
|
+
n++;
|
1541
|
+
m_stat = m_table->file->ha_rnd_next(m_table->record[0]);
|
1542
|
+
}
|
1477
1543
|
}
|
1544
|
+
m_table->file->extra(HA_EXTRA_NO_KEYREAD);
|
1478
1545
|
m_table->read_set = &m_table->s->all_set;
|
1546
|
+
m_table->write_set = &m_table->s->all_set;
|
1479
1547
|
return n;
|
1480
1548
|
}
|
1481
1549
|
|
@@ -1570,7 +1638,7 @@ void table::setFiledNullFlags()
|
|
1570
1638
|
|
1571
1639
|
__int64 table::insert(bool ncc)
|
1572
1640
|
{
|
1573
|
-
if (!cp_is_write_lock(m_table->file))
|
1641
|
+
if ((m_mode==TD_OPEN_READONLY) || !cp_is_write_lock(m_table->file))
|
1574
1642
|
{
|
1575
1643
|
m_stat = STATUS_INVALID_LOCKTYPE;
|
1576
1644
|
return 0;
|
@@ -1609,6 +1677,7 @@ __int64 table::insert(bool ncc)
|
|
1609
1677
|
|
1610
1678
|
void table::beginUpdate(char keyNum)
|
1611
1679
|
{
|
1680
|
+
m_stat = 0;
|
1612
1681
|
m_table->file->try_semi_consistent_read(1);
|
1613
1682
|
beginDel();
|
1614
1683
|
if (m_stat==0)
|
@@ -1624,6 +1693,11 @@ void table::beginUpdate(char keyNum)
|
|
1624
1693
|
|
1625
1694
|
void table::beginDel()
|
1626
1695
|
{
|
1696
|
+
if ((m_mode==TD_OPEN_READONLY) || !cp_is_write_lock(m_table->file))
|
1697
|
+
{
|
1698
|
+
m_stat = STATUS_INVALID_LOCKTYPE;
|
1699
|
+
return;
|
1700
|
+
}
|
1627
1701
|
if (m_cursor)
|
1628
1702
|
{
|
1629
1703
|
m_stat = 0;
|
@@ -1641,7 +1715,9 @@ void table::beginDel()
|
|
1641
1715
|
}
|
1642
1716
|
else
|
1643
1717
|
movePos(position(true), -1, true);
|
1644
|
-
|
1718
|
+
|
1719
|
+
//Has blob fileds then ignore conflicts.
|
1720
|
+
if ((m_table->s->blob_fields==0) && cmp_record(m_table, record[1]))
|
1645
1721
|
m_stat = STATUS_CHANGE_CONFLICT;
|
1646
1722
|
|
1647
1723
|
m_cursor = m_validCursor = (m_stat == 0);
|
@@ -101,7 +101,7 @@ class database : private boost::noncopyable
|
|
101
101
|
short m_trnType;
|
102
102
|
|
103
103
|
std::vector<boost::shared_ptr<table> > m_tables;
|
104
|
-
TABLE* doOpenTable(const std::string& name, short mode);
|
104
|
+
TABLE* doOpenTable(const std::string& name, short mode, const char* ownerName);
|
105
105
|
|
106
106
|
void unUseTable(table* tb);
|
107
107
|
public:
|
@@ -111,7 +111,7 @@ public:
|
|
111
111
|
THD* thd()const{return m_thd;};
|
112
112
|
void use() const;
|
113
113
|
short clientID()const{return m_cid;}
|
114
|
-
table* openTable(const std::string& name, short mode);
|
114
|
+
table* openTable(const std::string& name, short mode, const char* ownerName);
|
115
115
|
const std::string& name()const{return m_dbname;};
|
116
116
|
table* useTable(int index, enum_sql_command cmd);
|
117
117
|
bool beginTrn(short type);
|
@@ -283,8 +283,8 @@ public:
|
|
283
283
|
return m_keyconv.keyNumByMakeOrder(num);
|
284
284
|
}
|
285
285
|
|
286
|
-
bool setKeyNum(char num);
|
287
|
-
inline void setKeyNum(const char* name){setKeyNum(keynumByName(name));};
|
286
|
+
bool setKeyNum(char num, bool sorted = true);
|
287
|
+
inline void setKeyNum(const char* name, bool sorted = true){setKeyNum(keynumByName(name), sorted);};
|
288
288
|
bool isNisKey(char num)const;
|
289
289
|
void seekKey(enum ha_rkey_function find_flag);
|
290
290
|
void getNextSame();
|
@@ -314,12 +314,12 @@ public:
|
|
314
314
|
|
315
315
|
inline void stepNextExt(IReadRecordsHandler* handler, bool includeCurrent)
|
316
316
|
{
|
317
|
-
readRecords(handler, includeCurrent,
|
317
|
+
readRecords(handler, includeCurrent, READ_RECORD_STEPNEXT);
|
318
318
|
}
|
319
319
|
|
320
320
|
inline void stepPrevExt(IReadRecordsHandler* handler, bool includeCurrent)
|
321
321
|
{
|
322
|
-
readRecords(handler, includeCurrent,
|
322
|
+
readRecords(handler, includeCurrent, READ_RECORD_STEPPREV);
|
323
323
|
}
|
324
324
|
|
325
325
|
void clearBuffer();
|
@@ -26,12 +26,15 @@
|
|
26
26
|
#ifndef MYSQL_DYNAMIC_PLUGIN
|
27
27
|
#define MYSQL_DYNAMIC_PLUGIN
|
28
28
|
#endif
|
29
|
+
|
29
30
|
#define MYSQL_SERVER 1
|
30
31
|
|
31
32
|
#ifndef HAVE_CONFIG_H
|
32
33
|
#define HAVE_CONFIG_H
|
33
34
|
#endif
|
34
35
|
|
36
|
+
#define HAVE_PSI_INTERFACE //50700
|
37
|
+
#define NO_USE_MALLOC_SERVICE_INTERFACE
|
35
38
|
|
36
39
|
#ifdef ERROR
|
37
40
|
#undef ERROR
|
@@ -44,6 +47,7 @@
|
|
44
47
|
#pragma warning(disable:4800)
|
45
48
|
#pragma warning(disable:4267)
|
46
49
|
#pragma warning(disable:4996)
|
50
|
+
#pragma warning(disable:4805)
|
47
51
|
#endif
|
48
52
|
|
49
53
|
#include <my_config.h>
|
@@ -70,9 +74,13 @@
|
|
70
74
|
#include "sql/sql_parse.h"
|
71
75
|
#include "sql/sql_table.h"
|
72
76
|
#include "sql/sql_db.h"
|
73
|
-
#include "
|
77
|
+
#include "sql_acl.h"
|
74
78
|
#include "mysqld_error.h"
|
75
79
|
|
80
|
+
#if ((MYSQL_VERSION_ID > 50700) && !defined(MARIADB_BASE_VERSION))
|
81
|
+
#include "sql/log.h"
|
82
|
+
#endif
|
83
|
+
|
76
84
|
#undef test
|
77
85
|
|
78
86
|
#undef sleep
|
@@ -84,6 +92,7 @@
|
|
84
92
|
#pragma warning(default:4996)
|
85
93
|
#pragma warning(default:4267)
|
86
94
|
#pragma warning(default:4800)
|
95
|
+
#pragma warning(default:4805)
|
87
96
|
#endif
|
88
97
|
|
89
98
|
#undef min
|
@@ -114,6 +123,10 @@
|
|
114
123
|
#define MDL_SHARED_UPGRADABLE MDL_SHARED_WRITE
|
115
124
|
#define cp_get_sql_error() stmt_da->sql_errno()
|
116
125
|
#define cp_isOk() stmt_da->is_ok()
|
126
|
+
#elif ((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION))
|
127
|
+
#define cp_get_sql_error() get_stmt_da()->mysql_errno()
|
128
|
+
#define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
|
129
|
+
#define cp_isOk() get_stmt_da()->is_ok()
|
117
130
|
#else
|
118
131
|
#define cp_get_sql_error() get_stmt_da()->sql_errno()
|
119
132
|
#define cp_isOk() get_stmt_da()->is_ok()
|
@@ -167,5 +180,34 @@
|
|
167
180
|
#define ha_index_read_map index_read_map
|
168
181
|
#endif
|
169
182
|
|
183
|
+
/* memory management */
|
184
|
+
#if ((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION))
|
185
|
+
#define td_malloc(A, B) my_malloc(PSI_NOT_INSTRUMENTED, A, B)
|
186
|
+
#define td_realloc(A, B, C) my_realloc(PSI_NOT_INSTRUMENTED, A, B, C)
|
187
|
+
#define td_strdup(A, B) my_strdup(PSI_NOT_INSTRUMENTED, A, B)
|
188
|
+
#define td_free(A) my_free(A)
|
189
|
+
|
190
|
+
/* On Windows,
|
191
|
+
"operator delete()" function is implemented in mysqld.
|
192
|
+
But "operator new" operation implement in transactd.dll.
|
193
|
+
Therefore, memory managers differ.*/
|
194
|
+
#ifdef _WIN32
|
195
|
+
inline void releaseTHD(THD* thd)
|
196
|
+
{
|
197
|
+
thd->~THD();
|
198
|
+
operator delete((void*)thd);
|
199
|
+
}
|
200
|
+
#else
|
201
|
+
inline void releaseTHD(THD* thd){delete thd;}
|
202
|
+
#endif
|
203
|
+
#else
|
204
|
+
#define td_malloc(A, B) my_malloc(A, B)
|
205
|
+
#define td_realloc(A, B, C) my_realloc(A, B, C)
|
206
|
+
#define td_strdup(A, B) my_strdup(A, B)
|
207
|
+
#define td_free(A) my_free(A)
|
208
|
+
inline void releaseTHD(THD* thd){delete thd;}
|
209
|
+
#endif
|
210
|
+
|
211
|
+
|
170
212
|
|
171
213
|
#endif //MYSQLINTERNAL_H
|
@@ -51,25 +51,26 @@ inline void setStackaddr(char* v)
|
|
51
51
|
#endif
|
52
52
|
}
|
53
53
|
|
54
|
+
|
54
55
|
void* operator new(size_t t)
|
55
56
|
{
|
56
|
-
return
|
57
|
+
return td_malloc(t, MY_WME);
|
57
58
|
}
|
58
59
|
|
59
60
|
void operator delete(void* p)
|
60
61
|
{
|
61
|
-
|
62
|
+
td_free(p);
|
62
63
|
}
|
63
64
|
|
64
65
|
void* operator new[](size_t t)
|
65
66
|
{
|
66
|
-
return
|
67
|
+
return td_malloc(t, MY_WME);
|
67
68
|
}
|
68
69
|
|
69
70
|
void operator delete[](void* p)
|
70
71
|
{
|
71
|
-
|
72
|
-
}
|
72
|
+
td_free(p);
|
73
|
+
}
|
73
74
|
|
74
75
|
void initThread(THD* thd )
|
75
76
|
{
|
@@ -121,8 +122,8 @@ THD* buildTHD()
|
|
121
122
|
sprintf_s(tmp, 256,"set innodb_lock_wait_timeout=%d;", g_lock_wait_timeout);
|
122
123
|
dispatch_command(COM_QUERY, thd, tmp, (uint)strlen(tmp));
|
123
124
|
|
124
|
-
|
125
|
-
thd->db =
|
125
|
+
td_free(thd->db);
|
126
|
+
thd->db = td_strdup("bizstation", MYF(0));
|
126
127
|
if(thd->variables.sql_log_bin)
|
127
128
|
thd->set_current_stmt_binlog_format_row();
|
128
129
|
return thd;
|
@@ -165,6 +166,7 @@ void deleteThdForThread(THD* thd)
|
|
165
166
|
cp_thd_release_resources(thd);
|
166
167
|
cp_remove_global_thread(thd);
|
167
168
|
mysql_mutex_unlock(&LOCK_thread_count);
|
168
|
-
delete thd;
|
169
169
|
|
170
|
+
releaseTHD(thd);
|
171
|
+
|
170
172
|
}
|
@@ -282,7 +282,7 @@ int dbExecuter::commandExec(std::vector<request>& requests, char* result, size_t
|
|
282
282
|
{
|
283
283
|
checkNewHandle(req.handle);
|
284
284
|
database* db = getDatabase(req.db.name, 0/*cid*/);
|
285
|
-
m_tb = db->openTable(req.table.name, req.table.openMode);
|
285
|
+
m_tb = db->openTable(req.table.name, req.table.openMode, NULL);
|
286
286
|
addHandle(getDatabaseID(0/*cid*/), m_tb->id(), req.handle);
|
287
287
|
m_tb = getTable(req.handle);
|
288
288
|
m_tb->setUseFieldList(req.table.fields);
|
@@ -122,10 +122,10 @@ public:
|
|
122
122
|
btrTimeStamp(btrDate d, btrTime t);
|
123
123
|
#ifdef _WIN32
|
124
124
|
explicit btrTimeStamp(const wchar_t* p);
|
125
|
-
wchar_t* toString(wchar_t*
|
125
|
+
wchar_t* toString(wchar_t* retbuf);
|
126
126
|
void fromString(const wchar_t* p);
|
127
127
|
#endif
|
128
|
-
char* toString(char*
|
128
|
+
char* toString(char* retbuf);
|
129
129
|
void fromString(const char* p);
|
130
130
|
|
131
131
|
};
|
@@ -201,7 +201,7 @@ void dbdef::setCodePage(tabledef* td)
|
|
201
201
|
}
|
202
202
|
}
|
203
203
|
|
204
|
-
void dbdef::updateTableDef(short TableIndex)
|
204
|
+
void dbdef::updateTableDef(short TableIndex, bool forPsqlDdf)
|
205
205
|
{
|
206
206
|
m_stat = STATUS_SUCCESS;
|
207
207
|
tabledef* td = tableDefs(TableIndex);
|
@@ -292,7 +292,7 @@ void dbdef::updateTableDef(short TableIndex)
|
|
292
292
|
return;
|
293
293
|
}
|
294
294
|
if (m_impl->deftype == TYPE_SCHEMA_DDF)
|
295
|
-
saveDDF(TableIndex, 3);
|
295
|
+
saveDDF(TableIndex, 3, forPsqlDdf);
|
296
296
|
else
|
297
297
|
{
|
298
298
|
moveById(td->id);
|
@@ -831,6 +831,7 @@ void dbdef::getFileSpec(fileSpec* fs, short TableIndex)
|
|
831
831
|
ks->keyFlag.all = KeyDef->segments[j].flags.all;
|
832
832
|
ks->keyCount = 0;
|
833
833
|
ks->keyType = TableDef->fieldDefs[FieldNum].type;
|
834
|
+
|
834
835
|
if ((ks->keyType == ft_autoinc) && (KeyDef->segmentCount > 1))
|
835
836
|
ks->keyType = 1;
|
836
837
|
if (ks->keyFlag.bit3 == true)
|
@@ -1051,9 +1052,10 @@ uint_td dbdef::fieldValidLength(eFieldQuery query, uchar_td FieldType)
|
|
1051
1052
|
maxlen = 8;
|
1052
1053
|
defaultlen = 2;
|
1053
1054
|
break;
|
1055
|
+
case ft_autoIncUnsigned:
|
1054
1056
|
case ft_autoinc: minlen = 2;
|
1055
|
-
maxlen =
|
1056
|
-
defaultlen =
|
1057
|
+
maxlen = 8;
|
1058
|
+
defaultlen = 4;
|
1057
1059
|
break;
|
1058
1060
|
case ft_bit: minlen = 1;
|
1059
1061
|
maxlen = 1;
|
@@ -1101,9 +1103,9 @@ bool dbdef::validLen(uchar_td FieldType, uint_td FieldLen)
|
|
1101
1103
|
return false;
|
1102
1104
|
|
1103
1105
|
}
|
1104
|
-
else if (FieldType == ft_autoinc)
|
1106
|
+
else if ((FieldType == ft_autoinc) || (FieldType == ft_autoIncUnsigned))
|
1105
1107
|
{
|
1106
|
-
if ((FieldLen == 2) || (FieldLen == 4))
|
1108
|
+
if ((FieldLen == 2) || (FieldLen == 4)|| (FieldLen == 8))
|
1107
1109
|
return true;
|
1108
1110
|
else
|
1109
1111
|
return false;
|
@@ -1202,7 +1204,7 @@ void dbdef::createDDF(const _TCHAR* fullpath)
|
|
1202
1204
|
|
1203
1205
|
}
|
1204
1206
|
|
1205
|
-
void dbdef::saveDDF(short TableIndex, short opration)
|
1207
|
+
void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
1206
1208
|
{
|
1207
1209
|
ushort_td chOpen = 0;
|
1208
1210
|
short Mode = 0;
|
@@ -1269,7 +1271,10 @@ void dbdef::saveDDF(short TableIndex, short opration)
|
|
1269
1271
|
tb->seek();
|
1270
1272
|
strcpy(tb->tablename, TableDef->tableNameA());
|
1271
1273
|
strcpy(tb->filename, TableDef->fileNameA());
|
1272
|
-
|
1274
|
+
if (forPsqlDdf)
|
1275
|
+
tb->flag = 0;//PSQL are reading flags from table files.
|
1276
|
+
else
|
1277
|
+
tb->flag = TableDef->flags.all;
|
1273
1278
|
if (tb->stat() == STATUS_SUCCESS)
|
1274
1279
|
{
|
1275
1280
|
if (opration == 4)
|
@@ -1303,6 +1308,8 @@ void dbdef::saveDDF(short TableIndex, short opration)
|
|
1303
1308
|
fd->fileid = tb->id;
|
1304
1309
|
strcpy(fd->name, FieldDef->nameA());
|
1305
1310
|
fd->type = FieldDef->type;
|
1311
|
+
if (forPsqlDdf && (fd->type == ft_logical))
|
1312
|
+
fd->type = ft_uinteger;
|
1306
1313
|
fd->pos = (ushort_td)(pos - 1);
|
1307
1314
|
fd->len = FieldDef->len;
|
1308
1315
|
pos += FieldDef->len;
|
@@ -55,7 +55,7 @@ class AGRPACK dbdef : private nstable
|
|
55
55
|
bool isPassKey(uchar_td FieldType);
|
56
56
|
void openDdf(const _TCHAR* dir, short Mode, const _TCHAR* OwnerName);
|
57
57
|
void createDDF(const _TCHAR* fullpath);
|
58
|
-
void saveDDF(short tableIndex, short opration);
|
58
|
+
void saveDDF(short tableIndex, short opration, bool forPsqlDdf=true);
|
59
59
|
ushort_td getDDFNewTableIndex();
|
60
60
|
ushort_td getDDFNewFieldIndex();
|
61
61
|
int totalDefLength(short tableIndex);
|
@@ -94,7 +94,7 @@ public:
|
|
94
94
|
|
95
95
|
inline short_td stat() const {return m_stat;}
|
96
96
|
|
97
|
-
void updateTableDef(short tableIndex);
|
97
|
+
void updateTableDef(short tableIndex, bool forPsqlDdf=true);
|
98
98
|
fielddef* insertField(short tableIndex, short insertIndex);
|
99
99
|
void deleteField(short tableIndex, short deleteIndex);
|
100
100
|
keydef* insertKey(short tableIndex, short insertIndex);
|