Merge lp:~paul-mccullagh/maria/maria-pbxt-rc3 into lp:~maria-captains/maria/5.1-converting
- maria-pbxt-rc3
- Merge into 5.1-converting
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Kristian Nielsen | ||||
Approved revision: | not available | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~paul-mccullagh/maria/maria-pbxt-rc3 | ||||
Merge into: | lp:~maria-captains/maria/5.1-converting | ||||
Diff against target: |
5759 lines (+2595/-366) 47 files modified
sql/handler.cc (+9/-1) storage/pbxt/ChangeLog (+52/-0) storage/pbxt/src/Makefile.am (+2/-2) storage/pbxt/src/backup_xt.cc (+802/-0) storage/pbxt/src/backup_xt.h (+34/-0) storage/pbxt/src/cache_xt.cc (+7/-3) storage/pbxt/src/cache_xt.h (+1/-1) storage/pbxt/src/database_xt.cc (+14/-0) storage/pbxt/src/database_xt.h (+8/-0) storage/pbxt/src/datadic_xt.cc (+1/-6) storage/pbxt/src/datalog_xt.cc (+4/-4) storage/pbxt/src/discover_xt.cc (+301/-15) storage/pbxt/src/filesys_xt.cc (+3/-5) storage/pbxt/src/filesys_xt.h (+1/-1) storage/pbxt/src/ha_pbxt.cc (+526/-119) storage/pbxt/src/ha_pbxt.h (+26/-9) storage/pbxt/src/ha_xtsys.h (+2/-1) storage/pbxt/src/heap_xt.cc (+1/-1) storage/pbxt/src/index_xt.cc (+18/-7) storage/pbxt/src/lock_xt.cc (+1/-1) storage/pbxt/src/locklist_xt.h (+7/-2) storage/pbxt/src/memory_xt.cc (+2/-3) storage/pbxt/src/myxt_xt.cc (+164/-29) storage/pbxt/src/myxt_xt.h (+4/-0) storage/pbxt/src/pbms.h (+12/-12) storage/pbxt/src/pbms_enabled.cc (+11/-12) storage/pbxt/src/pbms_enabled.h (+0/-7) storage/pbxt/src/pthread_xt.cc (+2/-2) storage/pbxt/src/restart_xt.cc (+119/-49) storage/pbxt/src/restart_xt.h (+13/-1) storage/pbxt/src/strutil_xt.cc (+10/-4) storage/pbxt/src/systab_xt.cc (+2/-2) storage/pbxt/src/tabcache_xt.cc (+3/-1) storage/pbxt/src/tabcache_xt.h (+1/-1) storage/pbxt/src/table_xt.cc (+85/-20) storage/pbxt/src/table_xt.h (+3/-2) storage/pbxt/src/thread_xt.cc (+16/-1) storage/pbxt/src/thread_xt.h (+4/-1) storage/pbxt/src/util_xt.cc (+17/-0) storage/pbxt/src/util_xt.h (+1/-0) storage/pbxt/src/xaction_xt.cc (+169/-6) storage/pbxt/src/xaction_xt.h (+29/-1) storage/pbxt/src/xactlog_xt.cc (+48/-23) storage/pbxt/src/xactlog_xt.h (+12/-2) storage/pbxt/src/xt_config.h (+15/-2) storage/pbxt/src/xt_defs.h (+30/-7) storage/pbxt/src/xt_errno.h (+3/-0) |
||||
To merge this branch: | bzr merge lp:~paul-mccullagh/maria/maria-pbxt-rc3 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kristian Nielsen | Approve | ||
Paul McCullagh | Pending | ||
Review via email: mp+15934@code.launchpad.net |
This proposal supersedes a proposal from 2009-12-01.
Commit message
Description of the change
Paul McCullagh (paul-mccullagh) wrote : Posted in a previous version of this proposal | # |
Paul McCullagh (paul-mccullagh) wrote : Posted in a previous version of this proposal | # |
This patch changes MariaDB code in one case:
File handler.cc, Line 1591
DBUG_ASSERT(
This line has been commented out, because the assertions fails now that PBXT supports XA.
Although this assertion implies that not everything will work, I have not found any problem with the stability of MySQL due to the addition of PBXT XA.
PBXT XA can be disabled by setting pbxt_support_xa=0, it is enabled by default.
Paul McCullagh (paul-mccullagh) wrote : Posted in a previous version of this proposal | # |
I have made 2 changes:
1. I have improved the bug fix in RN291 (bug #489088). The problem was: [Warning] Plugin 'PBXT' will be forced to shutdown. The bug fix caused a crash under certain circumstances. This has been fixed.
2. I have def'd out the following code (changed ifndef to ifdef):
#ifndef WILL_BE_
/*
for now, only InnoDB supports 2pc. It means we can always safely
rollback all pending transactions, without risking inconsistent data
*/
DBUG_
tc_heuristic_
info.
#endif
Paul McCullagh (paul-mccullagh) wrote : | # |
I have made 2 changes to the original proposal:
1. I have improved the bug fix in RN291 (bug #489088). The problem was: [Warning] Plugin 'PBXT' will be forced to shutdown. The bug fix caused a crash under certain circumstances. This has been fixed.
2. I have def'd out the following code (changed ifndef to ifdef):
#ifndef WILL_BE_
/*
for now, only InnoDB supports 2pc. It means we can always safely
rollback all pending transactions, without risking inconsistent data
*/
DBUG_
tc_heuristic_
info.
#endif
Kristian Nielsen (knielsen) wrote : | # |
Merged into lp:maria.
We are still working on solving the test failure in pbxt.join_nested. But I realised that this failure was introduced when we merged MySQL 5.1.41, not with this merge. So there was no reason to delay this merge. Thanks for your work!
Paul McCullagh (paul-mccullagh) wrote : | # |
Hi Kristian,
We will also check this out as soon as the merge is complete. We have
just completed testing with MySQL 5.1.41, and have all tests running.
@Vlad: did we have any fixes for pbxt.join_nested during our testing
of RC4 and 5.1.41?
Best regards,
Paul
On Dec 21, 2009, at 10:44 AM, Kristian Nielsen wrote:
> Review: Approve
> Merged into lp:maria.
>
> We are still working on solving the test failure in
> pbxt.join_nested. But I realised that this failure was introduced
> when we merged MySQL 5.1.41, not with this merge. So there was no
> reason to delay this merge. Thanks for your work!
>
> --
> https:/
> rc3/+merge/15934
> You are the owner of lp:~paul-mccullagh/maria/maria-pbxt-rc3.
--
Paul McCullagh
PrimeBase Technologies
www.primebase.org
www.blobstreami
pbxt.blogspot.com
Preview Diff
1 | === modified file 'sql/handler.cc' | |||
2 | --- sql/handler.cc 2009-12-03 11:19:05 +0000 | |||
3 | +++ sql/handler.cc 2009-12-10 11:57:20 +0000 | |||
4 | @@ -1584,7 +1584,15 @@ | |||
5 | 1584 | if (info.commit_list) | 1584 | if (info.commit_list) |
6 | 1585 | sql_print_information("Starting crash recovery..."); | 1585 | sql_print_information("Starting crash recovery..."); |
7 | 1586 | 1586 | ||
9 | 1587 | #ifndef WILL_BE_DELETED_LATER | 1587 | /* With PBXT 1.0.09 2 engines now support XA. According to Sergei, this |
10 | 1588 | code below should therefore be removed. The code below | ||
11 | 1589 | handles the case when the engines report prepared transactions, | ||
12 | 1590 | but the binlogs are missing or have no recovery information. | ||
13 | 1591 | In this case the tc_heuristic_recover variable determines whether | ||
14 | 1592 | prepared transcations should be committed or rolled back. | ||
15 | 1593 | If there is only one engine, then rollback is safe. | ||
16 | 1594 | */ | ||
17 | 1595 | #ifdef WILL_BE_DELETED_LATER | ||
18 | 1588 | /* | 1596 | /* |
19 | 1589 | for now, only InnoDB supports 2pc. It means we can always safely | 1597 | for now, only InnoDB supports 2pc. It means we can always safely |
20 | 1590 | rollback all pending transactions, without risking inconsistent data | 1598 | rollback all pending transactions, without risking inconsistent data |
21 | 1591 | 1599 | ||
22 | === modified file 'storage/pbxt/ChangeLog' | |||
23 | --- storage/pbxt/ChangeLog 2009-09-03 06:15:03 +0000 | |||
24 | +++ storage/pbxt/ChangeLog 2009-12-10 11:57:20 +0000 | |||
25 | @@ -1,6 +1,58 @@ | |||
26 | 1 | PBXT Release Notes | 1 | PBXT Release Notes |
27 | 2 | ================== | 2 | ================== |
28 | 3 | 3 | ||
29 | 4 | ------- 1.0.09f RC3 - 2009-11-30 | ||
30 | 5 | |||
31 | 6 | RN291: Fixed bug #489088: On shutdown MySQL reports: [Warning] Plugin 'PBXT' will be forced to shutdown. | ||
32 | 7 | |||
33 | 8 | RN290: Fixed bug #345524: pbxt does not compile on 64 bit windows. Currently atomic operations are not supported on this platform. | ||
34 | 9 | |||
35 | 10 | RN286: Fixed a bug introduced in RN281, which could cause an index scan to hang. The original change was to prevent a warning in Valgrind. | ||
36 | 11 | |||
37 | 12 | RN285: Merged changes required to compile with Drizzle. | ||
38 | 13 | |||
39 | 14 | RN284: Fixed bug that cause the error "[ERROR] Invalid (old?) table or database name 'mysqld.1'", when running temp_table.test under MariaDB (thanks to Monty for his initial bug fix). Added a fix for partition table names as well. | ||
40 | 15 | |||
41 | 16 | RN283: Added win_inttypes.h to the distribution. This file is only required for the Windows build. | ||
42 | 17 | |||
43 | 18 | RN282: Fixed bug #451101: jump or move depends on uninitialised value in myxt_get_key_length | ||
44 | 19 | |||
45 | 20 | RN281: Fixed bug #451080: Uninitialised memory write in XTDatabaseLog::xlog_append | ||
46 | 21 | |||
47 | 22 | RN280: Fixed bug #451085: jump or move depends on uninitialised value in my_type_to_string | ||
48 | 23 | |||
49 | 24 | RN279: Fixed bug #441000: xtstat crashes with segmentation fault on startup if max_pbxt_threads exceeded. | ||
50 | 25 | |||
51 | 26 | ------- 1.0.09e RC3 - 2009-11-20 | ||
52 | 27 | |||
53 | 28 | RN278: Fixed compile error with MySQL 5.1.41. | ||
54 | 29 | |||
55 | 30 | ------- 1.0.09d RC3 - 2009-09-30 | ||
56 | 31 | |||
57 | 32 | RN277: Added r/o flag to pbxt_max_threads server variable (this fix is related to bug #430637) | ||
58 | 33 | |||
59 | 34 | RN276: Added test case for replication on tables w/o PKs (see bug #430716) | ||
60 | 35 | |||
61 | 36 | RN275: Fixed bug #430600: 'Failed to read auto-increment value from storage engine' error. | ||
62 | 37 | |||
63 | 38 | RN274: Fixed bug #431240: This report is public edit xtstat fails if no PBXT table has been created. xtstat now accepts --database=information_schema or --database=pbxt. Depending on this setting PBXT will either use the information_schema.pbxt_statistics or the pbxt.statistics table. If information_schema is used, then the statistics are displayed even when no PBXT table exists. Recovery activity is also displayed, unless pbxt_support_xa=1, in which case MySQL will wait for PBXT recovery to complete before allowing connections. | ||
64 | 39 | |||
65 | 40 | RN273: Fixed bug #430633: XA_RBDEADLOCK is not returned on XA END after the transacting ended with a deadlock. | ||
66 | 41 | |||
67 | 42 | RN272: Fixed bug #430596: Backup/restore does not work well even on a basic PBXT table with auto-increment. | ||
68 | 43 | |||
69 | 44 | ------- 1.0.09c RC3 - 2009-09-16 | ||
70 | 45 | |||
71 | 46 | RN271: Windows build update: now you can simply put the pbxt directory under <mysql-root>/storage and build the PBXT engine as a part of the source tree. The engine will be linked statically. Be sure to specify the WITH_PBXT_STORAGE_ENGINE option when running win\configure.js | ||
72 | 47 | |||
73 | 48 | RN270: Correctly disabled PBMS so that this version now compiles under Windows. If PBMS_ENABLED is defined, PBXT will not compile under Windows becaause of a getpid() call in pbms.h. | ||
74 | 49 | |||
75 | 50 | ------- 1.0.09 RC3 - 2009-09-09 | ||
76 | 51 | |||
77 | 52 | RN269: Implemented online backup. A native online backup driver now performs BACKUP and RESTORE DATABASE operations for PBXT. NOTE: This feature is only supported by MySQL 6.0.9 or later. | ||
78 | 53 | |||
79 | 54 | RN268: Implemented XA support. PBXT now supports all XA related MySQL statements. The variable pbxt_support_xa determines if XA support is enabled. Note: due to MySQL bug #47134, enabling XA support could lead to a crash. | ||
80 | 55 | |||
81 | 4 | ------- 1.0.08d RC2 - 2009-09-02 | 56 | ------- 1.0.08d RC2 - 2009-09-02 |
82 | 5 | 57 | ||
83 | 6 | RN267: Fixed a bug that caused MySQL to crash on shutdown, after an incorrect command line parameter was given. The crash occurred because the background recovery task was not cleaned up before the PBXT engine was de-initialized. | 58 | RN267: Fixed a bug that caused MySQL to crash on shutdown, after an incorrect command line parameter was given. The crash occurred because the background recovery task was not cleaned up before the PBXT engine was de-initialized. |
84 | 7 | 59 | ||
85 | === modified file 'storage/pbxt/src/Makefile.am' | |||
86 | --- storage/pbxt/src/Makefile.am 2009-10-07 07:40:56 +0000 | |||
87 | +++ storage/pbxt/src/Makefile.am 2009-12-10 11:57:20 +0000 | |||
88 | @@ -22,7 +22,7 @@ | |||
89 | 22 | pbms_enabled.h sortedlist_xt.h strutil_xt.h \ | 22 | pbms_enabled.h sortedlist_xt.h strutil_xt.h \ |
90 | 23 | tabcache_xt.h table_xt.h trace_xt.h thread_xt.h \ | 23 | tabcache_xt.h table_xt.h trace_xt.h thread_xt.h \ |
91 | 24 | util_xt.h xaction_xt.h xactlog_xt.h lock_xt.h \ | 24 | util_xt.h xaction_xt.h xactlog_xt.h lock_xt.h \ |
93 | 25 | systab_xt.h ha_xtsys.h discover_xt.h \ | 25 | systab_xt.h ha_xtsys.h discover_xt.h backup_xt.h \ |
94 | 26 | pbms.h xt_config.h xt_defs.h xt_errno.h locklist_xt.h | 26 | pbms.h xt_config.h xt_defs.h xt_errno.h locklist_xt.h |
95 | 27 | EXTRA_LTLIBRARIES = libpbxt.la | 27 | EXTRA_LTLIBRARIES = libpbxt.la |
96 | 28 | 28 | ||
97 | @@ -32,7 +32,7 @@ | |||
98 | 32 | memory_xt.cc myxt_xt.cc pthread_xt.cc restart_xt.cc \ | 32 | memory_xt.cc myxt_xt.cc pthread_xt.cc restart_xt.cc \ |
99 | 33 | sortedlist_xt.cc strutil_xt.cc \ | 33 | sortedlist_xt.cc strutil_xt.cc \ |
100 | 34 | tabcache_xt.cc table_xt.cc trace_xt.cc thread_xt.cc \ | 34 | tabcache_xt.cc table_xt.cc trace_xt.cc thread_xt.cc \ |
102 | 35 | systab_xt.cc ha_xtsys.cc discover_xt.cc \ | 35 | systab_xt.cc ha_xtsys.cc discover_xt.cc backup_xt.cc \ |
103 | 36 | util_xt.cc xaction_xt.cc xactlog_xt.cc lock_xt.cc locklist_xt.cc | 36 | util_xt.cc xaction_xt.cc xactlog_xt.cc lock_xt.cc locklist_xt.cc |
104 | 37 | 37 | ||
105 | 38 | libpbxt_la_LDFLAGS = -module | 38 | libpbxt_la_LDFLAGS = -module |
106 | 39 | 39 | ||
107 | === added file 'storage/pbxt/src/backup_xt.cc' | |||
108 | --- storage/pbxt/src/backup_xt.cc 1970-01-01 00:00:00 +0000 | |||
109 | +++ storage/pbxt/src/backup_xt.cc 2009-12-10 11:57:20 +0000 | |||
110 | @@ -0,0 +1,802 @@ | |||
111 | 1 | /* Copyright (c) 2009 PrimeBase Technologies GmbH | ||
112 | 2 | * | ||
113 | 3 | * PrimeBase XT | ||
114 | 4 | * | ||
115 | 5 | * This program is free software; you can redistribute it and/or modify | ||
116 | 6 | * it under the terms of the GNU General Public License as published by | ||
117 | 7 | * the Free Software Foundation; either version 2 of the License, or | ||
118 | 8 | * (at your option) any later version. | ||
119 | 9 | * | ||
120 | 10 | * This program is distributed in the hope that it will be useful, | ||
121 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
122 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
123 | 13 | * GNU General Public License for more details. | ||
124 | 14 | * | ||
125 | 15 | * You should have received a copy of the GNU General Public License | ||
126 | 16 | * along with this program; if not, write to the Free Software | ||
127 | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
128 | 18 | * | ||
129 | 19 | * 2009-09-07 Paul McCullagh | ||
130 | 20 | * | ||
131 | 21 | * H&G2JCtL | ||
132 | 22 | */ | ||
133 | 23 | |||
134 | 24 | #include "xt_config.h" | ||
135 | 25 | |||
136 | 26 | #ifdef MYSQL_SUPPORTS_BACKUP | ||
137 | 27 | |||
138 | 28 | #include <string.h> | ||
139 | 29 | #include <stdio.h> | ||
140 | 30 | #include <stdlib.h> | ||
141 | 31 | #include <time.h> | ||
142 | 32 | #include <ctype.h> | ||
143 | 33 | |||
144 | 34 | #include "mysql_priv.h" | ||
145 | 35 | #include <backup/api_types.h> | ||
146 | 36 | #include <backup/backup_engine.h> | ||
147 | 37 | #include <backup/backup_aux.h> // for build_table_list() | ||
148 | 38 | #include <hash.h> | ||
149 | 39 | |||
150 | 40 | #include "ha_pbxt.h" | ||
151 | 41 | |||
152 | 42 | #include "backup_xt.h" | ||
153 | 43 | #include "pthread_xt.h" | ||
154 | 44 | #include "filesys_xt.h" | ||
155 | 45 | #include "database_xt.h" | ||
156 | 46 | #include "strutil_xt.h" | ||
157 | 47 | #include "memory_xt.h" | ||
158 | 48 | #include "trace_xt.h" | ||
159 | 49 | #include "myxt_xt.h" | ||
160 | 50 | |||
161 | 51 | #ifdef OK | ||
162 | 52 | #undef OK | ||
163 | 53 | #endif | ||
164 | 54 | |||
165 | 55 | #ifdef byte | ||
166 | 56 | #undef byte | ||
167 | 57 | #endif | ||
168 | 58 | |||
169 | 59 | #ifdef DEBUG | ||
170 | 60 | //#define TRACE_BACKUP_CALLS | ||
171 | 61 | //#define TEST_SMALL_BLOCK 100000 | ||
172 | 62 | #endif | ||
173 | 63 | |||
174 | 64 | using backup::byte; | ||
175 | 65 | using backup::result_t; | ||
176 | 66 | using backup::version_t; | ||
177 | 67 | using backup::Table_list; | ||
178 | 68 | using backup::Table_ref; | ||
179 | 69 | using backup::Buffer; | ||
180 | 70 | |||
181 | 71 | #ifdef TRACE_BACKUP_CALLS | ||
182 | 72 | #define XT_TRACE_CALL() ha_trace_function(__FUNC__, NULL) | ||
183 | 73 | #else | ||
184 | 74 | #define XT_TRACE_CALL() | ||
185 | 75 | #endif | ||
186 | 76 | |||
187 | 77 | #define XT_RESTORE_BATCH_SIZE 10000 | ||
188 | 78 | |||
189 | 79 | #define BUP_STATE_BEFORE_LOCK 0 | ||
190 | 80 | #define BUP_STATE_AFTER_LOCK 1 | ||
191 | 81 | |||
192 | 82 | #define BUP_STANDARD_VAR_RECORD 1 | ||
193 | 83 | #define BUP_RECORD_BLOCK_4_START 2 // Part of a record, with a 4 byte total length, and 4 byte data length | ||
194 | 84 | #define BUP_RECORD_BLOCK_4 3 // Part of a record, with a 4 byte length | ||
195 | 85 | #define BUP_RECORD_BLOCK_4_END 4 // Last part of a record with a 4 byte length | ||
196 | 86 | |||
197 | 87 | /* | ||
198 | 88 | * ----------------------------------------------------------------------- | ||
199 | 89 | * UTILITIES | ||
200 | 90 | */ | ||
201 | 91 | |||
202 | 92 | #ifdef TRACE_BACKUP_CALLS | ||
203 | 93 | static void ha_trace_function(const char *function, char *table) | ||
204 | 94 | { | ||
205 | 95 | char func_buf[50], *ptr; | ||
206 | 96 | XTThreadPtr thread = xt_get_self(); | ||
207 | 97 | |||
208 | 98 | if ((ptr = strchr(function, '('))) { | ||
209 | 99 | ptr--; | ||
210 | 100 | while (ptr > function) { | ||
211 | 101 | if (!(isalnum(*ptr) || *ptr == '_')) | ||
212 | 102 | break; | ||
213 | 103 | ptr--; | ||
214 | 104 | } | ||
215 | 105 | ptr++; | ||
216 | 106 | xt_strcpy(50, func_buf, ptr); | ||
217 | 107 | if ((ptr = strchr(func_buf, '('))) | ||
218 | 108 | *ptr = 0; | ||
219 | 109 | } | ||
220 | 110 | else | ||
221 | 111 | xt_strcpy(50, func_buf, function); | ||
222 | 112 | if (table) | ||
223 | 113 | printf("%s %s (%s)\n", thread ? thread->t_name : "-unknown-", func_buf, table); | ||
224 | 114 | else | ||
225 | 115 | printf("%s %s\n", thread ? thread->t_name : "-unknown-", func_buf); | ||
226 | 116 | } | ||
227 | 117 | #endif | ||
228 | 118 | |||
229 | 119 | /* | ||
230 | 120 | * ----------------------------------------------------------------------- | ||
231 | 121 | * BACKUP DRIVER | ||
232 | 122 | */ | ||
233 | 123 | |||
234 | 124 | class PBXTBackupDriver: public Backup_driver | ||
235 | 125 | { | ||
236 | 126 | public: | ||
237 | 127 | PBXTBackupDriver(const Table_list &); | ||
238 | 128 | virtual ~PBXTBackupDriver(); | ||
239 | 129 | |||
240 | 130 | virtual size_t size(); | ||
241 | 131 | virtual size_t init_size(); | ||
242 | 132 | virtual result_t begin(const size_t); | ||
243 | 133 | virtual result_t end(); | ||
244 | 134 | virtual result_t get_data(Buffer &); | ||
245 | 135 | virtual result_t prelock(); | ||
246 | 136 | virtual result_t lock(); | ||
247 | 137 | virtual result_t unlock(); | ||
248 | 138 | virtual result_t cancel(); | ||
249 | 139 | virtual void free(); | ||
250 | 140 | void lock_tables_TL_READ_NO_INSERT(); | ||
251 | 141 | |||
252 | 142 | private: | ||
253 | 143 | XTThreadPtr bd_thread; | ||
254 | 144 | int bd_state; | ||
255 | 145 | u_int bd_table_no; | ||
256 | 146 | XTOpenTablePtr bd_ot; | ||
257 | 147 | xtWord1 *bd_row_buf; | ||
258 | 148 | |||
259 | 149 | /* Non-zero if we last returned only part of | ||
260 | 150 | * a row. | ||
261 | 151 | */ | ||
262 | 152 | xtWord1 *db_write_block(xtWord1 *buffer, xtWord1 bup_type, size_t *size, xtWord4 row_len); | ||
263 | 153 | xtWord1 *db_write_block(xtWord1 *buffer, xtWord1 bup_type, size_t *size, xtWord4 total_len, xtWord4 row_len); | ||
264 | 154 | |||
265 | 155 | xtWord4 bd_row_offset; | ||
266 | 156 | xtWord4 bd_row_size; | ||
267 | 157 | }; | ||
268 | 158 | |||
269 | 159 | |||
270 | 160 | PBXTBackupDriver::PBXTBackupDriver(const Table_list &tables): | ||
271 | 161 | Backup_driver(tables), | ||
272 | 162 | bd_state(BUP_STATE_BEFORE_LOCK), | ||
273 | 163 | bd_table_no(0), | ||
274 | 164 | bd_ot(NULL), | ||
275 | 165 | bd_row_buf(NULL), | ||
276 | 166 | bd_row_offset(0), | ||
277 | 167 | bd_row_size(0) | ||
278 | 168 | { | ||
279 | 169 | } | ||
280 | 170 | |||
281 | 171 | PBXTBackupDriver::~PBXTBackupDriver() | ||
282 | 172 | { | ||
283 | 173 | } | ||
284 | 174 | |||
285 | 175 | /** Estimates total size of backup. @todo improve it */ | ||
286 | 176 | size_t PBXTBackupDriver::size() | ||
287 | 177 | { | ||
288 | 178 | XT_TRACE_CALL(); | ||
289 | 179 | return UNKNOWN_SIZE; | ||
290 | 180 | } | ||
291 | 181 | |||
292 | 182 | /** Estimates size of backup before lock. @todo improve it */ | ||
293 | 183 | size_t PBXTBackupDriver::init_size() | ||
294 | 184 | { | ||
295 | 185 | XT_TRACE_CALL(); | ||
296 | 186 | return 0; | ||
297 | 187 | } | ||
298 | 188 | |||
299 | 189 | result_t PBXTBackupDriver::begin(const size_t) | ||
300 | 190 | { | ||
301 | 191 | THD *thd = current_thd; | ||
302 | 192 | XTExceptionRec e; | ||
303 | 193 | |||
304 | 194 | XT_TRACE_CALL(); | ||
305 | 195 | |||
306 | 196 | if (!(bd_thread = xt_ha_set_current_thread(thd, &e))) { | ||
307 | 197 | xt_log_exception(NULL, &e, XT_LOG_DEFAULT); | ||
308 | 198 | return backup::ERROR; | ||
309 | 199 | } | ||
310 | 200 | |||
311 | 201 | return backup::OK; | ||
312 | 202 | } | ||
313 | 203 | |||
314 | 204 | result_t PBXTBackupDriver::end() | ||
315 | 205 | { | ||
316 | 206 | XT_TRACE_CALL(); | ||
317 | 207 | if (bd_ot) { | ||
318 | 208 | xt_tab_seq_exit(bd_ot); | ||
319 | 209 | xt_db_return_table_to_pool_ns(bd_ot); | ||
320 | 210 | bd_ot = NULL; | ||
321 | 211 | } | ||
322 | 212 | if (bd_thread->st_xact_data) { | ||
323 | 213 | if (!xt_xn_commit(bd_thread)) | ||
324 | 214 | return backup::ERROR; | ||
325 | 215 | } | ||
326 | 216 | return backup::OK; | ||
327 | 217 | } | ||
328 | 218 | |||
329 | 219 | xtWord1 *PBXTBackupDriver::db_write_block(xtWord1 *buffer, xtWord1 bup_type, size_t *ret_size, xtWord4 row_len) | ||
330 | 220 | { | ||
331 | 221 | register size_t size = *ret_size; | ||
332 | 222 | |||
333 | 223 | *buffer = bup_type; // Record type identifier. | ||
334 | 224 | buffer++; | ||
335 | 225 | size--; | ||
336 | 226 | memcpy(buffer, bd_ot->ot_row_wbuffer, row_len); | ||
337 | 227 | buffer += row_len; | ||
338 | 228 | size -= row_len; | ||
339 | 229 | *ret_size = size; | ||
340 | 230 | return buffer; | ||
341 | 231 | } | ||
342 | 232 | |||
343 | 233 | xtWord1 *PBXTBackupDriver::db_write_block(xtWord1 *buffer, xtWord1 bup_type, size_t *ret_size, xtWord4 total_len, xtWord4 row_len) | ||
344 | 234 | { | ||
345 | 235 | register size_t size = *ret_size; | ||
346 | 236 | |||
347 | 237 | *buffer = bup_type; // Record type identifier. | ||
348 | 238 | buffer++; | ||
349 | 239 | size--; | ||
350 | 240 | if (bup_type == BUP_RECORD_BLOCK_4_START) { | ||
351 | 241 | XT_SET_DISK_4(buffer, total_len); | ||
352 | 242 | buffer += 4; | ||
353 | 243 | size -= 4; | ||
354 | 244 | } | ||
355 | 245 | XT_SET_DISK_4(buffer, row_len); | ||
356 | 246 | buffer += 4; | ||
357 | 247 | size -= 4; | ||
358 | 248 | memcpy(buffer, bd_ot->ot_row_wbuffer+bd_row_offset, row_len); | ||
359 | 249 | buffer += row_len; | ||
360 | 250 | size -= row_len; | ||
361 | 251 | bd_row_size -= row_len; | ||
362 | 252 | bd_row_offset += row_len; | ||
363 | 253 | *ret_size = size; | ||
364 | 254 | return buffer; | ||
365 | 255 | } | ||
366 | 256 | |||
367 | 257 | result_t PBXTBackupDriver::get_data(Buffer &buf) | ||
368 | 258 | { | ||
369 | 259 | xtBool eof = FALSE; | ||
370 | 260 | size_t size; | ||
371 | 261 | xtWord4 row_len; | ||
372 | 262 | xtWord1 *buffer; | ||
373 | 263 | |||
374 | 264 | XT_TRACE_CALL(); | ||
375 | 265 | |||
376 | 266 | if (bd_state == BUP_STATE_BEFORE_LOCK) { | ||
377 | 267 | buf.table_num = 0; | ||
378 | 268 | buf.size = 0; | ||
379 | 269 | buf.last = FALSE; | ||
380 | 270 | return backup::READY; | ||
381 | 271 | } | ||
382 | 272 | |||
383 | 273 | /* Open the backup table: */ | ||
384 | 274 | if (!bd_ot) { | ||
385 | 275 | XTThreadPtr self = bd_thread; | ||
386 | 276 | XTTableHPtr tab; | ||
387 | 277 | char path[PATH_MAX]; | ||
388 | 278 | |||
389 | 279 | if (bd_table_no == m_tables.count()) { | ||
390 | 280 | buf.size = 0; | ||
391 | 281 | buf.table_num = 0; | ||
392 | 282 | buf.last = TRUE; | ||
393 | 283 | return backup::DONE; | ||
394 | 284 | } | ||
395 | 285 | |||
396 | 286 | m_tables[bd_table_no].internal_name(path, sizeof(path)); | ||
397 | 287 | bd_table_no++; | ||
398 | 288 | try_(a) { | ||
399 | 289 | xt_ha_open_database_of_table(self, (XTPathStrPtr) path); | ||
400 | 290 | tab = xt_use_table(self, (XTPathStrPtr) path, FALSE, FALSE, NULL); | ||
401 | 291 | pushr_(xt_heap_release, tab); | ||
402 | 292 | if (!(bd_ot = xt_db_open_table_using_tab(tab, bd_thread))) | ||
403 | 293 | xt_throw(self); | ||
404 | 294 | freer_(); // xt_heap_release(tab) | ||
405 | 295 | |||
406 | 296 | /* Prepare the seqential scan: */ | ||
407 | 297 | xt_tab_seq_exit(bd_ot); | ||
408 | 298 | if (!xt_tab_seq_init(bd_ot)) | ||
409 | 299 | xt_throw(self); | ||
410 | 300 | |||
411 | 301 | if (bd_row_buf) { | ||
412 | 302 | xt_free(self, bd_row_buf); | ||
413 | 303 | bd_row_buf = NULL; | ||
414 | 304 | } | ||
415 | 305 | bd_row_buf = (xtWord1 *) xt_malloc(self, bd_ot->ot_table->tab_dic.dic_mysql_buf_size); | ||
416 | 306 | bd_ot->ot_cols_req = bd_ot->ot_table->tab_dic.dic_no_of_cols; | ||
417 | 307 | } | ||
418 | 308 | catch_(a) { | ||
419 | 309 | ; | ||
420 | 310 | } | ||
421 | 311 | cont_(a); | ||
422 | 312 | |||
423 | 313 | if (!bd_ot) | ||
424 | 314 | goto failed; | ||
425 | 315 | } | ||
426 | 316 | |||
427 | 317 | buf.table_num = bd_table_no; | ||
428 | 318 | #ifdef TEST_SMALL_BLOCK | ||
429 | 319 | buf.size = TEST_SMALL_BLOCK; | ||
430 | 320 | #endif | ||
431 | 321 | size = buf.size; | ||
432 | 322 | buffer = (xtWord1 *) buf.data; | ||
433 | 323 | ASSERT_NS(size > 9); | ||
434 | 324 | |||
435 | 325 | /* First check of a record was partically written | ||
436 | 326 | * last time. | ||
437 | 327 | */ | ||
438 | 328 | write_row: | ||
439 | 329 | if (bd_row_size > 0) { | ||
440 | 330 | row_len = bd_row_size; | ||
441 | 331 | if (bd_row_offset == 0) { | ||
442 | 332 | if (row_len+1 > size) { | ||
443 | 333 | ASSERT_NS(size > 9); | ||
444 | 334 | row_len = size - 9; | ||
445 | 335 | buffer = db_write_block(buffer, BUP_RECORD_BLOCK_4_START, &size, bd_row_size, row_len); | ||
446 | 336 | goto done; | ||
447 | 337 | } | ||
448 | 338 | buffer = db_write_block(buffer, BUP_STANDARD_VAR_RECORD, &size, row_len); | ||
449 | 339 | bd_row_size = 0; | ||
450 | 340 | } | ||
451 | 341 | else { | ||
452 | 342 | if (row_len+5 > size) { | ||
453 | 343 | row_len = size - 5; | ||
454 | 344 | buffer = db_write_block(buffer, BUP_RECORD_BLOCK_4, &size, 0, row_len); | ||
455 | 345 | goto done; | ||
456 | 346 | } | ||
457 | 347 | buffer = db_write_block(buffer, BUP_RECORD_BLOCK_4_END, &size, 0, row_len); | ||
458 | 348 | } | ||
459 | 349 | } | ||
460 | 350 | |||
461 | 351 | /* Now continue with the sequential scan. */ | ||
462 | 352 | while (size > 1) { | ||
463 | 353 | if (!xt_tab_seq_next(bd_ot, bd_row_buf, &eof)) | ||
464 | 354 | goto failed; | ||
465 | 355 | if (eof) { | ||
466 | 356 | /* We will go the next table, on the next call. */ | ||
467 | 357 | xt_tab_seq_exit(bd_ot); | ||
468 | 358 | xt_db_return_table_to_pool_ns(bd_ot); | ||
469 | 359 | bd_ot = NULL; | ||
470 | 360 | break; | ||
471 | 361 | } | ||
472 | 362 | if (!(row_len = myxt_store_row_data(bd_ot, 0, (char *) bd_row_buf))) | ||
473 | 363 | goto failed; | ||
474 | 364 | if (row_len+1 > size) { | ||
475 | 365 | /* Does not fit: */ | ||
476 | 366 | bd_row_offset = 0; | ||
477 | 367 | bd_row_size = row_len; | ||
478 | 368 | /* Only add part of the row, if there is still | ||
479 | 369 | * quite a bit of space left: | ||
480 | 370 | */ | ||
481 | 371 | if (size >= (32 * 1024)) | ||
482 | 372 | goto write_row; | ||
483 | 373 | break; | ||
484 | 374 | } | ||
485 | 375 | buffer = db_write_block(buffer, BUP_STANDARD_VAR_RECORD, &size, row_len); | ||
486 | 376 | } | ||
487 | 377 | |||
488 | 378 | done: | ||
489 | 379 | buf.size = buf.size - size; | ||
490 | 380 | /* This indicates wnd of data for a table! */ | ||
491 | 381 | buf.last = eof; | ||
492 | 382 | |||
493 | 383 | return backup::OK; | ||
494 | 384 | |||
495 | 385 | failed: | ||
496 | 386 | xt_log_and_clear_exception(bd_thread); | ||
497 | 387 | return backup::ERROR; | ||
498 | 388 | } | ||
499 | 389 | |||
500 | 390 | result_t PBXTBackupDriver::prelock() | ||
501 | 391 | { | ||
502 | 392 | XT_TRACE_CALL(); | ||
503 | 393 | return backup::READY; | ||
504 | 394 | } | ||
505 | 395 | |||
506 | 396 | result_t PBXTBackupDriver::lock() | ||
507 | 397 | { | ||
508 | 398 | XT_TRACE_CALL(); | ||
509 | 399 | bd_thread->st_xact_mode = XT_XACT_COMMITTED_READ; | ||
510 | 400 | bd_thread->st_ignore_fkeys = FALSE; | ||
511 | 401 | bd_thread->st_auto_commit = FALSE; | ||
512 | 402 | bd_thread->st_table_trans = FALSE; | ||
513 | 403 | bd_thread->st_abort_trans = FALSE; | ||
514 | 404 | bd_thread->st_stat_ended = FALSE; | ||
515 | 405 | bd_thread->st_stat_trans = FALSE; | ||
516 | 406 | bd_thread->st_is_update = FALSE; | ||
517 | 407 | if (!xt_xn_begin(bd_thread)) | ||
518 | 408 | return backup::ERROR; | ||
519 | 409 | bd_state = BUP_STATE_AFTER_LOCK; | ||
520 | 410 | return backup::OK; | ||
521 | 411 | } | ||
522 | 412 | |||
523 | 413 | result_t PBXTBackupDriver::unlock() | ||
524 | 414 | { | ||
525 | 415 | XT_TRACE_CALL(); | ||
526 | 416 | return backup::OK; | ||
527 | 417 | } | ||
528 | 418 | |||
529 | 419 | result_t PBXTBackupDriver::cancel() | ||
530 | 420 | { | ||
531 | 421 | XT_TRACE_CALL(); | ||
532 | 422 | return backup::OK; // free() will be called and suffice | ||
533 | 423 | } | ||
534 | 424 | |||
535 | 425 | void PBXTBackupDriver::free() | ||
536 | 426 | { | ||
537 | 427 | XT_TRACE_CALL(); | ||
538 | 428 | if (bd_ot) { | ||
539 | 429 | xt_tab_seq_exit(bd_ot); | ||
540 | 430 | xt_db_return_table_to_pool_ns(bd_ot); | ||
541 | 431 | bd_ot = NULL; | ||
542 | 432 | } | ||
543 | 433 | if (bd_row_buf) { | ||
544 | 434 | xt_free_ns(bd_row_buf); | ||
545 | 435 | bd_row_buf = NULL; | ||
546 | 436 | } | ||
547 | 437 | if (bd_thread->st_xact_data) | ||
548 | 438 | xt_xn_rollback(bd_thread); | ||
549 | 439 | delete this; | ||
550 | 440 | } | ||
551 | 441 | |||
552 | 442 | void PBXTBackupDriver::lock_tables_TL_READ_NO_INSERT() | ||
553 | 443 | { | ||
554 | 444 | XT_TRACE_CALL(); | ||
555 | 445 | } | ||
556 | 446 | |||
557 | 447 | /* | ||
558 | 448 | * ----------------------------------------------------------------------- | ||
559 | 449 | * BACKUP DRIVER | ||
560 | 450 | */ | ||
561 | 451 | |||
562 | 452 | class PBXTRestoreDriver: public Restore_driver | ||
563 | 453 | { | ||
564 | 454 | public: | ||
565 | 455 | PBXTRestoreDriver(const Table_list &tables); | ||
566 | 456 | virtual ~PBXTRestoreDriver(); | ||
567 | 457 | |||
568 | 458 | virtual result_t begin(const size_t); | ||
569 | 459 | virtual result_t end(); | ||
570 | 460 | virtual result_t send_data(Buffer &buf); | ||
571 | 461 | virtual result_t cancel(); | ||
572 | 462 | virtual void free(); | ||
573 | 463 | |||
574 | 464 | private: | ||
575 | 465 | XTThreadPtr rd_thread; | ||
576 | 466 | u_int rd_table_no; | ||
577 | 467 | XTOpenTablePtr rd_ot; | ||
578 | 468 | STRUCT_TABLE *rd_my_table; | ||
579 | 469 | xtWord1 *rb_row_buf; | ||
580 | 470 | u_int rb_col_cnt; | ||
581 | 471 | u_int rb_insert_count; | ||
582 | 472 | |||
583 | 473 | /* Long rows are accumulated here: */ | ||
584 | 474 | xtWord4 rb_row_len; | ||
585 | 475 | xtWord4 rb_data_size; | ||
586 | 476 | xtWord1 *rb_row_data; | ||
587 | 477 | }; | ||
588 | 478 | |||
589 | 479 | PBXTRestoreDriver::PBXTRestoreDriver(const Table_list &tables): | ||
590 | 480 | Restore_driver(tables), | ||
591 | 481 | rd_thread(NULL), | ||
592 | 482 | rd_table_no(0), | ||
593 | 483 | rd_ot(NULL), | ||
594 | 484 | rb_row_buf(NULL), | ||
595 | 485 | rb_row_len(0), | ||
596 | 486 | rb_data_size(0), | ||
597 | 487 | rb_row_data(NULL) | ||
598 | 488 | { | ||
599 | 489 | } | ||
600 | 490 | |||
601 | 491 | PBXTRestoreDriver::~PBXTRestoreDriver() | ||
602 | 492 | { | ||
603 | 493 | } | ||
604 | 494 | |||
605 | 495 | result_t PBXTRestoreDriver::begin(const size_t) | ||
606 | 496 | { | ||
607 | 497 | THD *thd = current_thd; | ||
608 | 498 | XTExceptionRec e; | ||
609 | 499 | |||
610 | 500 | XT_TRACE_CALL(); | ||
611 | 501 | |||
612 | 502 | if (!(rd_thread = xt_ha_set_current_thread(thd, &e))) { | ||
613 | 503 | xt_log_exception(NULL, &e, XT_LOG_DEFAULT); | ||
614 | 504 | return backup::ERROR; | ||
615 | 505 | } | ||
616 | 506 | |||
617 | 507 | return backup::OK; | ||
618 | 508 | } | ||
619 | 509 | |||
620 | 510 | result_t PBXTRestoreDriver::end() | ||
621 | 511 | { | ||
622 | 512 | XT_TRACE_CALL(); | ||
623 | 513 | if (rd_ot) { | ||
624 | 514 | xt_db_return_table_to_pool_ns(rd_ot); | ||
625 | 515 | rd_ot = NULL; | ||
626 | 516 | } | ||
627 | 517 | //if (rb_row_buf) { | ||
628 | 518 | // xt_free_ns(rb_row_buf); | ||
629 | 519 | // rb_row_buf = NULL; | ||
630 | 520 | //} | ||
631 | 521 | if (rb_row_data) { | ||
632 | 522 | xt_free_ns(rb_row_data); | ||
633 | 523 | rb_row_data = NULL; | ||
634 | 524 | } | ||
635 | 525 | if (rd_thread->st_xact_data) { | ||
636 | 526 | if (!xt_xn_commit(rd_thread)) | ||
637 | 527 | return backup::ERROR; | ||
638 | 528 | } | ||
639 | 529 | return backup::OK; | ||
640 | 530 | } | ||
641 | 531 | |||
642 | 532 | |||
643 | 533 | result_t PBXTRestoreDriver::send_data(Buffer &buf) | ||
644 | 534 | { | ||
645 | 535 | size_t size; | ||
646 | 536 | xtWord1 type; | ||
647 | 537 | xtWord1 *buffer; | ||
648 | 538 | xtWord4 row_len; | ||
649 | 539 | xtWord1 *rec_data; | ||
650 | 540 | |||
651 | 541 | XT_TRACE_CALL(); | ||
652 | 542 | |||
653 | 543 | if (buf.table_num != rd_table_no) { | ||
654 | 544 | XTThreadPtr self = rd_thread; | ||
655 | 545 | XTTableHPtr tab; | ||
656 | 546 | char path[PATH_MAX]; | ||
657 | 547 | |||
658 | 548 | if (rd_ot) { | ||
659 | 549 | xt_db_return_table_to_pool_ns(rd_ot); | ||
660 | 550 | rd_ot = NULL; | ||
661 | 551 | } | ||
662 | 552 | |||
663 | 553 | if (rd_thread->st_xact_data) { | ||
664 | 554 | if (!xt_xn_commit(rd_thread)) | ||
665 | 555 | goto failed; | ||
666 | 556 | } | ||
667 | 557 | if (!xt_xn_begin(rd_thread)) | ||
668 | 558 | goto failed; | ||
669 | 559 | rb_insert_count = 0; | ||
670 | 560 | |||
671 | 561 | rd_table_no = buf.table_num; | ||
672 | 562 | m_tables[rd_table_no-1].internal_name(path, sizeof(path)); | ||
673 | 563 | try_(a) { | ||
674 | 564 | xt_ha_open_database_of_table(self, (XTPathStrPtr) path); | ||
675 | 565 | tab = xt_use_table(self, (XTPathStrPtr) path, FALSE, FALSE, NULL); | ||
676 | 566 | pushr_(xt_heap_release, tab); | ||
677 | 567 | if (!(rd_ot = xt_db_open_table_using_tab(tab, rd_thread))) | ||
678 | 568 | xt_throw(self); | ||
679 | 569 | freer_(); // xt_heap_release(tab) | ||
680 | 570 | |||
681 | 571 | rd_my_table = rd_ot->ot_table->tab_dic.dic_my_table; | ||
682 | 572 | if (rd_my_table->found_next_number_field) { | ||
683 | 573 | rd_my_table->in_use = current_thd; | ||
684 | 574 | rd_my_table->next_number_field = rd_my_table->found_next_number_field; | ||
685 | 575 | rd_my_table->mark_columns_used_by_index_no_reset(rd_my_table->s->next_number_index, rd_my_table->read_set); | ||
686 | 576 | } | ||
687 | 577 | |||
688 | 578 | /* This is safe because only one thread can restore a table at | ||
689 | 579 | * a time! | ||
690 | 580 | */ | ||
691 | 581 | rb_row_buf = (xtWord1 *) rd_my_table->record[0]; | ||
692 | 582 | //if (rb_row_buf) { | ||
693 | 583 | // xt_free(self, rb_row_buf); | ||
694 | 584 | // rb_row_buf = NULL; | ||
695 | 585 | //} | ||
696 | 586 | //rb_row_buf = (xtWord1 *) xt_malloc(self, rd_ot->ot_table->tab_dic.dic_mysql_buf_size); | ||
697 | 587 | |||
698 | 588 | rb_col_cnt = rd_ot->ot_table->tab_dic.dic_no_of_cols; | ||
699 | 589 | |||
700 | 590 | } | ||
701 | 591 | catch_(a) { | ||
702 | 592 | ; | ||
703 | 593 | } | ||
704 | 594 | cont_(a); | ||
705 | 595 | |||
706 | 596 | if (!rd_ot) | ||
707 | 597 | goto failed; | ||
708 | 598 | } | ||
709 | 599 | |||
710 | 600 | buffer = (xtWord1 *) buf.data; | ||
711 | 601 | size = buf.size; | ||
712 | 602 | |||
713 | 603 | while (size > 0) { | ||
714 | 604 | type = *buffer; | ||
715 | 605 | switch (type) { | ||
716 | 606 | case BUP_STANDARD_VAR_RECORD: | ||
717 | 607 | rec_data = buffer + 1; | ||
718 | 608 | break; | ||
719 | 609 | case BUP_RECORD_BLOCK_4_START: | ||
720 | 610 | buffer++; | ||
721 | 611 | row_len = XT_GET_DISK_4(buffer); | ||
722 | 612 | buffer += 4; | ||
723 | 613 | if (rb_data_size < row_len) { | ||
724 | 614 | if (!xt_realloc_ns((void **) &rb_row_data, row_len)) | ||
725 | 615 | goto failed; | ||
726 | 616 | rb_data_size = row_len; | ||
727 | 617 | } | ||
728 | 618 | row_len = XT_GET_DISK_4(buffer); | ||
729 | 619 | buffer += 4; | ||
730 | 620 | ASSERT_NS(row_len <= rb_data_size); | ||
731 | 621 | if (row_len > rb_data_size) { | ||
732 | 622 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_BACKUP_FORMAT); | ||
733 | 623 | goto failed; | ||
734 | 624 | } | ||
735 | 625 | memcpy(rb_row_data, buffer, row_len); | ||
736 | 626 | rb_row_len = row_len; | ||
737 | 627 | buffer += row_len; | ||
738 | 628 | if (row_len + 9 > size) { | ||
739 | 629 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_BACKUP_FORMAT); | ||
740 | 630 | goto failed; | ||
741 | 631 | } | ||
742 | 632 | size -= row_len + 9; | ||
743 | 633 | continue; | ||
744 | 634 | case BUP_RECORD_BLOCK_4: | ||
745 | 635 | buffer++; | ||
746 | 636 | row_len = XT_GET_DISK_4(buffer); | ||
747 | 637 | buffer += 4; | ||
748 | 638 | ASSERT_NS(rb_row_len + row_len <= rb_data_size); | ||
749 | 639 | if (rb_row_len + row_len > rb_data_size) { | ||
750 | 640 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_BACKUP_FORMAT); | ||
751 | 641 | goto failed; | ||
752 | 642 | } | ||
753 | 643 | memcpy(rb_row_data + rb_row_len, buffer, row_len); | ||
754 | 644 | rb_row_len += row_len; | ||
755 | 645 | buffer += row_len; | ||
756 | 646 | if (row_len + 5 > size) { | ||
757 | 647 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_BACKUP_FORMAT); | ||
758 | 648 | goto failed; | ||
759 | 649 | } | ||
760 | 650 | size -= row_len + 5; | ||
761 | 651 | continue; | ||
762 | 652 | case BUP_RECORD_BLOCK_4_END: | ||
763 | 653 | buffer++; | ||
764 | 654 | row_len = XT_GET_DISK_4(buffer); | ||
765 | 655 | buffer += 4; | ||
766 | 656 | ASSERT_NS(rb_row_len + row_len <= rb_data_size); | ||
767 | 657 | if (rb_row_len + row_len > rb_data_size) { | ||
768 | 658 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_BACKUP_FORMAT); | ||
769 | 659 | goto failed; | ||
770 | 660 | } | ||
771 | 661 | memcpy(rb_row_data + rb_row_len, buffer, row_len); | ||
772 | 662 | buffer += row_len; | ||
773 | 663 | if (row_len + 5 > size) { | ||
774 | 664 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_BACKUP_FORMAT); | ||
775 | 665 | goto failed; | ||
776 | 666 | } | ||
777 | 667 | size -= row_len + 5; | ||
778 | 668 | rec_data = rb_row_data; | ||
779 | 669 | break; | ||
780 | 670 | default: | ||
781 | 671 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_BACKUP_FORMAT); | ||
782 | 672 | goto failed; | ||
783 | 673 | } | ||
784 | 674 | |||
785 | 675 | if (!(row_len = myxt_load_row_data(rd_ot, rec_data, rb_row_buf, rb_col_cnt))) | ||
786 | 676 | goto failed; | ||
787 | 677 | |||
788 | 678 | if (rd_ot->ot_table->tab_dic.dic_my_table->found_next_number_field) | ||
789 | 679 | ha_set_auto_increment(rd_ot, rd_ot->ot_table->tab_dic.dic_my_table->found_next_number_field); | ||
790 | 680 | |||
791 | 681 | if (!xt_tab_new_record(rd_ot, rb_row_buf)) | ||
792 | 682 | goto failed; | ||
793 | 683 | |||
794 | 684 | if (type == BUP_STANDARD_VAR_RECORD) { | ||
795 | 685 | buffer += row_len+1; | ||
796 | 686 | if (row_len + 1 > size) { | ||
797 | 687 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_BACKUP_FORMAT); | ||
798 | 688 | goto failed; | ||
799 | 689 | } | ||
800 | 690 | size -= row_len + 1; | ||
801 | 691 | } | ||
802 | 692 | |||
803 | 693 | rb_insert_count++; | ||
804 | 694 | if (rb_insert_count == XT_RESTORE_BATCH_SIZE) { | ||
805 | 695 | if (!xt_xn_commit(rd_thread)) | ||
806 | 696 | goto failed; | ||
807 | 697 | if (!xt_xn_begin(rd_thread)) | ||
808 | 698 | goto failed; | ||
809 | 699 | rb_insert_count = 0; | ||
810 | 700 | } | ||
811 | 701 | } | ||
812 | 702 | |||
813 | 703 | return backup::OK; | ||
814 | 704 | |||
815 | 705 | failed: | ||
816 | 706 | xt_log_and_clear_exception(rd_thread); | ||
817 | 707 | return backup::ERROR; | ||
818 | 708 | } | ||
819 | 709 | |||
820 | 710 | |||
821 | 711 | result_t PBXTRestoreDriver::cancel() | ||
822 | 712 | { | ||
823 | 713 | XT_TRACE_CALL(); | ||
824 | 714 | /* Nothing to do in cancel(); free() will suffice */ | ||
825 | 715 | return backup::OK; | ||
826 | 716 | } | ||
827 | 717 | |||
828 | 718 | void PBXTRestoreDriver::free() | ||
829 | 719 | { | ||
830 | 720 | XT_TRACE_CALL(); | ||
831 | 721 | if (rd_ot) { | ||
832 | 722 | xt_db_return_table_to_pool_ns(rd_ot); | ||
833 | 723 | rd_ot = NULL; | ||
834 | 724 | } | ||
835 | 725 | //if (rb_row_buf) { | ||
836 | 726 | // xt_free_ns(rb_row_buf); | ||
837 | 727 | // rb_row_buf = NULL; | ||
838 | 728 | //} | ||
839 | 729 | if (rb_row_data) { | ||
840 | 730 | xt_free_ns(rb_row_data); | ||
841 | 731 | rb_row_data = NULL; | ||
842 | 732 | } | ||
843 | 733 | if (rd_thread->st_xact_data) | ||
844 | 734 | xt_xn_rollback(rd_thread); | ||
845 | 735 | delete this; | ||
846 | 736 | } | ||
847 | 737 | |||
848 | 738 | /* | ||
849 | 739 | * ----------------------------------------------------------------------- | ||
850 | 740 | * BACKUP ENGINE FACTORY | ||
851 | 741 | */ | ||
852 | 742 | |||
853 | 743 | #define PBXT_BACKUP_VERSION 1 | ||
854 | 744 | |||
855 | 745 | |||
856 | 746 | class PBXTBackupEngine: public Backup_engine | ||
857 | 747 | { | ||
858 | 748 | public: | ||
859 | 749 | PBXTBackupEngine() { }; | ||
860 | 750 | |||
861 | 751 | virtual version_t version() const { | ||
862 | 752 | return PBXT_BACKUP_VERSION; | ||
863 | 753 | }; | ||
864 | 754 | |||
865 | 755 | virtual result_t get_backup(const uint32, const Table_list &, Backup_driver* &); | ||
866 | 756 | |||
867 | 757 | virtual result_t get_restore(const version_t, const uint32, const Table_list &,Restore_driver* &); | ||
868 | 758 | |||
869 | 759 | virtual void free() | ||
870 | 760 | { | ||
871 | 761 | delete this; | ||
872 | 762 | } | ||
873 | 763 | }; | ||
874 | 764 | |||
875 | 765 | result_t PBXTBackupEngine::get_backup(const u_int count, const Table_list &tables, Backup_driver* &drv) | ||
876 | 766 | { | ||
877 | 767 | PBXTBackupDriver *ptr = new PBXTBackupDriver(tables); | ||
878 | 768 | |||
879 | 769 | if (!ptr) | ||
880 | 770 | return backup::ERROR; | ||
881 | 771 | drv = ptr; | ||
882 | 772 | return backup::OK; | ||
883 | 773 | } | ||
884 | 774 | |||
885 | 775 | result_t PBXTBackupEngine::get_restore(const version_t ver, const uint32, | ||
886 | 776 | const Table_list &tables, Restore_driver* &drv) | ||
887 | 777 | { | ||
888 | 778 | if (ver > PBXT_BACKUP_VERSION) | ||
889 | 779 | { | ||
890 | 780 | return backup::ERROR; | ||
891 | 781 | } | ||
892 | 782 | |||
893 | 783 | PBXTRestoreDriver *ptr = new PBXTRestoreDriver(tables); | ||
894 | 784 | |||
895 | 785 | if (!ptr) | ||
896 | 786 | return backup::ERROR; | ||
897 | 787 | drv = (Restore_driver *) ptr; | ||
898 | 788 | return backup::OK; | ||
899 | 789 | } | ||
900 | 790 | |||
901 | 791 | |||
902 | 792 | Backup_result_t pbxt_backup_engine(handlerton *self, Backup_engine* &be) | ||
903 | 793 | { | ||
904 | 794 | be = new PBXTBackupEngine(); | ||
905 | 795 | |||
906 | 796 | if (!be) | ||
907 | 797 | return backup::ERROR; | ||
908 | 798 | |||
909 | 799 | return backup::OK; | ||
910 | 800 | } | ||
911 | 801 | |||
912 | 802 | #endif | ||
913 | 0 | 803 | ||
914 | === added file 'storage/pbxt/src/backup_xt.h' | |||
915 | --- storage/pbxt/src/backup_xt.h 1970-01-01 00:00:00 +0000 | |||
916 | +++ storage/pbxt/src/backup_xt.h 2009-12-10 11:57:20 +0000 | |||
917 | @@ -0,0 +1,34 @@ | |||
918 | 1 | /* Copyright (c) 2009 PrimeBase Technologies GmbH | ||
919 | 2 | * | ||
920 | 3 | * PrimeBase XT | ||
921 | 4 | * | ||
922 | 5 | * This program is free software; you can redistribute it and/or modify | ||
923 | 6 | * it under the terms of the GNU General Public License as published by | ||
924 | 7 | * the Free Software Foundation; either version 2 of the License, or | ||
925 | 8 | * (at your option) any later version. | ||
926 | 9 | * | ||
927 | 10 | * This program is distributed in the hope that it will be useful, | ||
928 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
929 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
930 | 13 | * GNU General Public License for more details. | ||
931 | 14 | * | ||
932 | 15 | * You should have received a copy of the GNU General Public License | ||
933 | 16 | * along with this program; if not, write to the Free Software | ||
934 | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
935 | 18 | * | ||
936 | 19 | * 2009-09-07 Paul McCullagh | ||
937 | 20 | * | ||
938 | 21 | * H&G2JCtL | ||
939 | 22 | */ | ||
940 | 23 | |||
941 | 24 | #ifndef __backup_xt_h__ | ||
942 | 25 | #define __backup_xt_h__ | ||
943 | 26 | |||
944 | 27 | #include "xt_defs.h" | ||
945 | 28 | |||
946 | 29 | #ifdef MYSQL_SUPPORTS_BACKUP | ||
947 | 30 | |||
948 | 31 | Backup_result_t pbxt_backup_engine(handlerton *self, Backup_engine* &be); | ||
949 | 32 | |||
950 | 33 | #endif | ||
951 | 34 | #endif | ||
952 | 0 | 35 | ||
953 | === modified file 'storage/pbxt/src/cache_xt.cc' | |||
954 | --- storage/pbxt/src/cache_xt.cc 2009-10-30 18:50:56 +0000 | |||
955 | +++ storage/pbxt/src/cache_xt.cc 2009-12-10 11:57:20 +0000 | |||
956 | @@ -73,7 +73,7 @@ | |||
957 | 73 | #define IDX_CAC_UNLOCK(i, o) xt_xsmutex_unlock(&(i)->cs_lock, (o)->t_id) | 73 | #define IDX_CAC_UNLOCK(i, o) xt_xsmutex_unlock(&(i)->cs_lock, (o)->t_id) |
958 | 74 | #elif defined(IDX_CAC_USE_PTHREAD_RW) | 74 | #elif defined(IDX_CAC_USE_PTHREAD_RW) |
959 | 75 | #define IDX_CAC_LOCK_TYPE xt_rwlock_type | 75 | #define IDX_CAC_LOCK_TYPE xt_rwlock_type |
961 | 76 | #define IDX_CAC_INIT_LOCK(s, i) xt_init_rwlock(s, &(i)->cs_lock) | 76 | #define IDX_CAC_INIT_LOCK(s, i) xt_init_rwlock_with_autoname(s, &(i)->cs_lock) |
962 | 77 | #define IDX_CAC_FREE_LOCK(s, i) xt_free_rwlock(&(i)->cs_lock) | 77 | #define IDX_CAC_FREE_LOCK(s, i) xt_free_rwlock(&(i)->cs_lock) |
963 | 78 | #define IDX_CAC_READ_LOCK(i, o) xt_slock_rwlock_ns(&(i)->cs_lock) | 78 | #define IDX_CAC_READ_LOCK(i, o) xt_slock_rwlock_ns(&(i)->cs_lock) |
964 | 79 | #define IDX_CAC_WRITE_LOCK(i, o) xt_xlock_rwlock_ns(&(i)->cs_lock) | 79 | #define IDX_CAC_WRITE_LOCK(i, o) xt_xlock_rwlock_ns(&(i)->cs_lock) |
965 | @@ -94,8 +94,12 @@ | |||
966 | 94 | #define IDX_CAC_UNLOCK(i, s) xt_spinxslock_unlock(&(i)->cs_lock, (s)->t_id) | 94 | #define IDX_CAC_UNLOCK(i, s) xt_spinxslock_unlock(&(i)->cs_lock, (s)->t_id) |
967 | 95 | #endif | 95 | #endif |
968 | 96 | 96 | ||
969 | 97 | #ifdef XT_NO_ATOMICS | ||
970 | 98 | #define ID_HANDLE_USE_PTHREAD_RW | ||
971 | 99 | #else | ||
972 | 97 | #define ID_HANDLE_USE_SPINLOCK | 100 | #define ID_HANDLE_USE_SPINLOCK |
973 | 98 | //#define ID_HANDLE_USE_PTHREAD_RW | 101 | //#define ID_HANDLE_USE_PTHREAD_RW |
974 | 102 | #endif | ||
975 | 99 | 103 | ||
976 | 100 | #if defined(ID_HANDLE_USE_PTHREAD_RW) | 104 | #if defined(ID_HANDLE_USE_PTHREAD_RW) |
977 | 101 | #define ID_HANDLE_LOCK_TYPE xt_mutex_type | 105 | #define ID_HANDLE_LOCK_TYPE xt_mutex_type |
978 | @@ -374,7 +378,7 @@ | |||
979 | 374 | { | 378 | { |
980 | 375 | DcHandleSlotPtr hs; | 379 | DcHandleSlotPtr hs; |
981 | 376 | XTIndBlockPtr block = NULL; | 380 | XTIndBlockPtr block = NULL; |
983 | 377 | u_int hash_idx = 0; | 381 | u_int hash_idx = 0; |
984 | 378 | DcSegmentPtr seg = NULL; | 382 | DcSegmentPtr seg = NULL; |
985 | 379 | XTIndBlockPtr xblock; | 383 | XTIndBlockPtr xblock; |
986 | 380 | 384 | ||
987 | @@ -1379,7 +1383,7 @@ | |||
988 | 1379 | ASSERT_NS(iref->ir_xlock == 2); | 1383 | ASSERT_NS(iref->ir_xlock == 2); |
989 | 1380 | #endif | 1384 | #endif |
990 | 1381 | if (!(block = ind_cac_fetch(ot, ind, address, &seg, TRUE))) | 1385 | if (!(block = ind_cac_fetch(ot, ind, address, &seg, TRUE))) |
992 | 1382 | return 0; | 1386 | return FAILED; |
993 | 1383 | 1387 | ||
994 | 1384 | branch_size = XT_GET_DISK_2(((XTIdxBranchDPtr) block->cb_data)->tb_size_2); | 1388 | branch_size = XT_GET_DISK_2(((XTIdxBranchDPtr) block->cb_data)->tb_size_2); |
995 | 1385 | if (XT_GET_INDEX_BLOCK_LEN(branch_size) < 2 || XT_GET_INDEX_BLOCK_LEN(branch_size) > XT_INDEX_PAGE_SIZE) { | 1389 | if (XT_GET_INDEX_BLOCK_LEN(branch_size) < 2 || XT_GET_INDEX_BLOCK_LEN(branch_size) > XT_INDEX_PAGE_SIZE) { |
996 | 1386 | 1390 | ||
997 | === modified file 'storage/pbxt/src/cache_xt.h' | |||
998 | --- storage/pbxt/src/cache_xt.h 2009-08-17 11:12:36 +0000 | |||
999 | +++ storage/pbxt/src/cache_xt.h 2009-12-10 11:57:20 +0000 | |||
1000 | @@ -62,7 +62,7 @@ | |||
1001 | 62 | #define XT_IPAGE_UNLOCK(i, x) xt_atomicrwlock_unlock(i, x) | 62 | #define XT_IPAGE_UNLOCK(i, x) xt_atomicrwlock_unlock(i, x) |
1002 | 63 | #elif defined(XT_IPAGE_USE_PTHREAD_RW) | 63 | #elif defined(XT_IPAGE_USE_PTHREAD_RW) |
1003 | 64 | #define XT_IPAGE_LOCK_TYPE xt_rwlock_type | 64 | #define XT_IPAGE_LOCK_TYPE xt_rwlock_type |
1005 | 65 | #define XT_IPAGE_INIT_LOCK(s, i) xt_init_rwlock(s, i) | 65 | #define XT_IPAGE_INIT_LOCK(s, i) xt_init_rwlock_with_autoname(s, i) |
1006 | 66 | #define XT_IPAGE_FREE_LOCK(s, i) xt_free_rwlock(i) | 66 | #define XT_IPAGE_FREE_LOCK(s, i) xt_free_rwlock(i) |
1007 | 67 | #define XT_IPAGE_READ_LOCK(i) xt_slock_rwlock_ns(i) | 67 | #define XT_IPAGE_READ_LOCK(i) xt_slock_rwlock_ns(i) |
1008 | 68 | #define XT_IPAGE_WRITE_LOCK(i, s) xt_xlock_rwlock_ns(i) | 68 | #define XT_IPAGE_WRITE_LOCK(i, s) xt_xlock_rwlock_ns(i) |
1009 | 69 | 69 | ||
1010 | === modified file 'storage/pbxt/src/database_xt.cc' | |||
1011 | --- storage/pbxt/src/database_xt.cc 2009-08-17 11:12:36 +0000 | |||
1012 | +++ storage/pbxt/src/database_xt.cc 2009-12-10 11:57:20 +0000 | |||
1013 | @@ -54,6 +54,8 @@ | |||
1014 | 54 | * GLOBALS | 54 | * GLOBALS |
1015 | 55 | */ | 55 | */ |
1016 | 56 | 56 | ||
1017 | 57 | xtPublic XTDatabaseHPtr pbxt_database = NULL; // The global open database | ||
1018 | 58 | |||
1019 | 57 | xtPublic xtLogOffset xt_db_log_file_threshold; | 59 | xtPublic xtLogOffset xt_db_log_file_threshold; |
1020 | 58 | xtPublic size_t xt_db_log_buffer_size; | 60 | xtPublic size_t xt_db_log_buffer_size; |
1021 | 59 | xtPublic size_t xt_db_transaction_buffer_size; | 61 | xtPublic size_t xt_db_transaction_buffer_size; |
1022 | @@ -505,6 +507,15 @@ | |||
1023 | 505 | * all index entries that are not visible have | 507 | * all index entries that are not visible have |
1024 | 506 | * been removed. | 508 | * been removed. |
1025 | 507 | * | 509 | * |
1026 | 510 | * REASON WHY WE SET ROWID ON RECOVERY: | ||
1027 | 511 | * The row ID is set on recovery because the | ||
1028 | 512 | * change to the index may be lost after a crash. | ||
1029 | 513 | * The change to the index is done by the sweeper, and | ||
1030 | 514 | * there is no record of this change in the log. | ||
1031 | 515 | * The sweeper will not "re-sweep" all transations | ||
1032 | 516 | * that are recovered. As a result, this upadte | ||
1033 | 517 | * of the index by the sweeper may be lost. | ||
1034 | 518 | * | ||
1035 | 508 | * {OPEN-DB-SWEEPER-WAIT} | 519 | * {OPEN-DB-SWEEPER-WAIT} |
1036 | 509 | * This has been moved to after the release of the open | 520 | * This has been moved to after the release of the open |
1037 | 510 | * database lock because: | 521 | * database lock because: |
1038 | @@ -518,9 +529,12 @@ | |||
1039 | 518 | * - To open the database it needs the open database | 529 | * - To open the database it needs the open database |
1040 | 519 | * lock. | 530 | * lock. |
1041 | 520 | */ | 531 | */ |
1042 | 532 | /* | ||
1043 | 533 | * This has been moved, see: {WAIT-FOR-SW-AFTER-RECOV} | ||
1044 | 521 | pushr_(xt_heap_release, db); | 534 | pushr_(xt_heap_release, db); |
1045 | 522 | xt_wait_for_sweeper(self, db, 0); | 535 | xt_wait_for_sweeper(self, db, 0); |
1046 | 523 | popr_(); | 536 | popr_(); |
1047 | 537 | */ | ||
1048 | 524 | 538 | ||
1049 | 525 | return db; | 539 | return db; |
1050 | 526 | } | 540 | } |
1051 | 527 | 541 | ||
1052 | === modified file 'storage/pbxt/src/database_xt.h' | |||
1053 | --- storage/pbxt/src/database_xt.h 2009-04-02 10:03:14 +0000 | |||
1054 | +++ storage/pbxt/src/database_xt.h 2009-12-10 11:57:20 +0000 | |||
1055 | @@ -105,6 +105,8 @@ | |||
1056 | 105 | #define XT_THREAD_IDLE 1 | 105 | #define XT_THREAD_IDLE 1 |
1057 | 106 | #define XT_THREAD_INERR 2 | 106 | #define XT_THREAD_INERR 2 |
1058 | 107 | 107 | ||
1059 | 108 | #define XT_XA_HASH_TAB_SIZE 223 | ||
1060 | 109 | |||
1061 | 108 | typedef struct XTDatabase : public XTHeap { | 110 | typedef struct XTDatabase : public XTHeap { |
1062 | 109 | char *db_name; /* The name of the database, last component of the path! */ | 111 | char *db_name; /* The name of the database, last component of the path! */ |
1063 | 110 | char *db_main_path; | 112 | char *db_main_path; |
1064 | @@ -131,6 +133,9 @@ | |||
1065 | 131 | u_int db_stat_sweep_waits; /* STATISTICS: count the sweeper waits. */ | 133 | u_int db_stat_sweep_waits; /* STATISTICS: count the sweeper waits. */ |
1066 | 132 | XTDatabaseLogRec db_xlog; /* The transaction log for this database. */ | 134 | XTDatabaseLogRec db_xlog; /* The transaction log for this database. */ |
1067 | 133 | XTXactRestartRec db_restart; /* Database recovery stuff. */ | 135 | XTXactRestartRec db_restart; /* Database recovery stuff. */ |
1068 | 136 | xt_mutex_type db_xn_xa_lock; | ||
1069 | 137 | XTXactPreparePtr db_xn_xa_table[XT_XA_HASH_TAB_SIZE]; | ||
1070 | 138 | XTSortedListPtr db_xn_xa_list; /* The "wait-for" list, of transactions waiting for other transactions. */ | ||
1071 | 134 | 139 | ||
1072 | 135 | XTSortedListPtr db_xn_wait_for; /* The "wait-for" list, of transactions waiting for other transactions. */ | 140 | XTSortedListPtr db_xn_wait_for; /* The "wait-for" list, of transactions waiting for other transactions. */ |
1073 | 136 | u_int db_xn_call_start; /* Start of the post wait calls. */ | 141 | u_int db_xn_call_start; /* Start of the post wait calls. */ |
1074 | @@ -198,6 +203,7 @@ | |||
1075 | 198 | 203 | ||
1076 | 199 | void xt_add_pbxt_file(size_t size, char *path, const char *file); | 204 | void xt_add_pbxt_file(size_t size, char *path, const char *file); |
1077 | 200 | void xt_add_location_file(size_t size, char *path); | 205 | void xt_add_location_file(size_t size, char *path); |
1078 | 206 | void xt_add_pbxt_dir(size_t size, char *path); | ||
1079 | 201 | void xt_add_system_dir(size_t size, char *path); | 207 | void xt_add_system_dir(size_t size, char *path); |
1080 | 202 | void xt_add_data_dir(size_t size, char *path); | 208 | void xt_add_data_dir(size_t size, char *path); |
1081 | 203 | 209 | ||
1082 | @@ -244,4 +250,6 @@ | |||
1083 | 244 | } | 250 | } |
1084 | 245 | } | 251 | } |
1085 | 246 | 252 | ||
1086 | 253 | extern XTDatabaseHPtr pbxt_database; // The global open database | ||
1087 | 254 | |||
1088 | 247 | #endif | 255 | #endif |
1089 | 248 | 256 | ||
1090 | === modified file 'storage/pbxt/src/datadic_xt.cc' | |||
1091 | --- storage/pbxt/src/datadic_xt.cc 2009-08-18 07:46:53 +0000 | |||
1092 | +++ storage/pbxt/src/datadic_xt.cc 2009-12-10 11:57:20 +0000 | |||
1093 | @@ -35,7 +35,7 @@ | |||
1094 | 35 | 35 | ||
1095 | 36 | #ifdef DEBUG | 36 | #ifdef DEBUG |
1096 | 37 | #ifdef DRIZZLED | 37 | #ifdef DRIZZLED |
1098 | 38 | #include <drizzled/common_includes.h> | 38 | //#include <drizzled/common_includes.h> |
1099 | 39 | #else | 39 | #else |
1100 | 40 | #include "mysql_priv.h" | 40 | #include "mysql_priv.h" |
1101 | 41 | #endif | 41 | #endif |
1102 | @@ -437,11 +437,6 @@ | |||
1103 | 437 | XTToken *nextToken(XTThreadPtr self, c_char *keyword, XTToken *tk); | 437 | XTToken *nextToken(XTThreadPtr self, c_char *keyword, XTToken *tk); |
1104 | 438 | }; | 438 | }; |
1105 | 439 | 439 | ||
1106 | 440 | void ri_free_token(XTThreadPtr XT_UNUSED(self), XTToken *tk) | ||
1107 | 441 | { | ||
1108 | 442 | delete tk; | ||
1109 | 443 | } | ||
1110 | 444 | |||
1111 | 445 | XTToken *XTTokenizer::newToken(XTThreadPtr self, u_int type, char *start, char *end) | 440 | XTToken *XTTokenizer::newToken(XTThreadPtr self, u_int type, char *start, char *end) |
1112 | 446 | { | 441 | { |
1113 | 447 | if (!tkn_current) { | 442 | if (!tkn_current) { |
1114 | 448 | 443 | ||
1115 | === modified file 'storage/pbxt/src/datalog_xt.cc' | |||
1116 | --- storage/pbxt/src/datalog_xt.cc 2009-09-04 07:29:34 +0000 | |||
1117 | +++ storage/pbxt/src/datalog_xt.cc 2009-12-10 11:57:20 +0000 | |||
1118 | @@ -410,7 +410,7 @@ | |||
1119 | 410 | ASSERT_NS(seq_read.sl_log_eof == seq_read.sl_rec_log_offset); | 410 | ASSERT_NS(seq_read.sl_log_eof == seq_read.sl_rec_log_offset); |
1120 | 411 | data_log->dlf_log_eof = seq_read.sl_rec_log_offset; | 411 | data_log->dlf_log_eof = seq_read.sl_rec_log_offset; |
1121 | 412 | 412 | ||
1123 | 413 | if ((size_t) data_log->dlf_log_eof < sizeof(XTXactLogHeaderDRec)) { | 413 | if (data_log->dlf_log_eof < (off_t) sizeof(XTXactLogHeaderDRec)) { |
1124 | 414 | data_log->dlf_log_eof = sizeof(XTXactLogHeaderDRec); | 414 | data_log->dlf_log_eof = sizeof(XTXactLogHeaderDRec); |
1125 | 415 | if (!dl_create_log_header(data_log, seq_read.sl_log_file, self)) | 415 | if (!dl_create_log_header(data_log, seq_read.sl_log_file, self)) |
1126 | 416 | xt_throw(self); | 416 | xt_throw(self); |
1127 | @@ -1162,7 +1162,7 @@ | |||
1128 | 1162 | /* When I use 'thread' instead of 'self', this means | 1162 | /* When I use 'thread' instead of 'self', this means |
1129 | 1163 | * that I will not throw an error. | 1163 | * that I will not throw an error. |
1130 | 1164 | */ | 1164 | */ |
1132 | 1165 | xtBool XTDataLogBuffer::dlb_get_log_offset(xtLogID *log_id, xtLogOffset *out_offset, size_t req_size, struct XTThread *thread) | 1165 | xtBool XTDataLogBuffer::dlb_get_log_offset(xtLogID *log_id, xtLogOffset *out_offset, size_t XT_UNUSED(req_size), struct XTThread *thread) |
1133 | 1166 | { | 1166 | { |
1134 | 1167 | /* Note, I am allowing a log to grow beyond the threshold. | 1167 | /* Note, I am allowing a log to grow beyond the threshold. |
1135 | 1168 | * The amount depends on the maximum extended record size. | 1168 | * The amount depends on the maximum extended record size. |
1136 | @@ -1757,7 +1757,7 @@ | |||
1137 | 1757 | freer_(); // xt_unlock_mutex(&db->db_co_dlog_lock) | 1757 | freer_(); // xt_unlock_mutex(&db->db_co_dlog_lock) |
1138 | 1758 | 1758 | ||
1139 | 1759 | /* Flush the transaction log. */ | 1759 | /* Flush the transaction log. */ |
1141 | 1760 | if (!xt_xlog_flush_log(self)) | 1760 | if (!xt_xlog_flush_log(db, self)) |
1142 | 1761 | xt_throw(self); | 1761 | xt_throw(self); |
1143 | 1762 | 1762 | ||
1144 | 1763 | xt_lock_mutex_ns(&db->db_datalogs.dlc_head_lock); | 1763 | xt_lock_mutex_ns(&db->db_datalogs.dlc_head_lock); |
1145 | @@ -1891,7 +1891,7 @@ | |||
1146 | 1891 | freer_(); // xt_unlock_mutex(&db->db_co_dlog_lock) | 1891 | freer_(); // xt_unlock_mutex(&db->db_co_dlog_lock) |
1147 | 1892 | 1892 | ||
1148 | 1893 | /* Flush the transaction log. */ | 1893 | /* Flush the transaction log. */ |
1150 | 1894 | if (!xt_xlog_flush_log(self)) | 1894 | if (!xt_xlog_flush_log(db, self)) |
1151 | 1895 | xt_throw(self); | 1895 | xt_throw(self); |
1152 | 1896 | 1896 | ||
1153 | 1897 | /* Save state in source log header. */ | 1897 | /* Save state in source log header. */ |
1154 | 1898 | 1898 | ||
1155 | === modified file 'storage/pbxt/src/discover_xt.cc' | |||
1156 | --- storage/pbxt/src/discover_xt.cc 2009-12-03 11:19:05 +0000 | |||
1157 | +++ storage/pbxt/src/discover_xt.cc 2009-12-10 11:57:20 +0000 | |||
1158 | @@ -31,6 +31,9 @@ | |||
1159 | 31 | #include <drizzled/session.h> | 31 | #include <drizzled/session.h> |
1160 | 32 | #include <drizzled/server_includes.h> | 32 | #include <drizzled/server_includes.h> |
1161 | 33 | #include <drizzled/sql_base.h> | 33 | #include <drizzled/sql_base.h> |
1162 | 34 | #include <drizzled/statement/alter_table.h> | ||
1163 | 35 | #include <algorithm> | ||
1164 | 36 | #include <sstream> | ||
1165 | 34 | #endif | 37 | #endif |
1166 | 35 | 38 | ||
1167 | 36 | #include "strutil_xt.h" | 39 | #include "strutil_xt.h" |
1168 | @@ -39,18 +42,273 @@ | |||
1169 | 39 | #include "ha_xtsys.h" | 42 | #include "ha_xtsys.h" |
1170 | 40 | 43 | ||
1171 | 41 | #ifndef DRIZZLED | 44 | #ifndef DRIZZLED |
1173 | 42 | #if MYSQL_VERSION_ID > 60005 | 45 | #if MYSQL_VERSION_ID >= 50404 |
1174 | 43 | #define DOT_STR(x) x.str | 46 | #define DOT_STR(x) x.str |
1175 | 44 | #else | 47 | #else |
1176 | 45 | #define DOT_STR(x) x | 48 | #define DOT_STR(x) x |
1177 | 46 | #endif | 49 | #endif |
1178 | 47 | #endif | 50 | #endif |
1179 | 48 | 51 | ||
1181 | 49 | #ifndef DRIZZLED | 52 | //#ifndef DRIZZLED |
1182 | 50 | #define LOCK_OPEN_HACK_REQUIRED | 53 | #define LOCK_OPEN_HACK_REQUIRED |
1184 | 51 | #endif // DRIZZLED | 54 | //#endif // DRIZZLED |
1185 | 52 | 55 | ||
1186 | 53 | #ifdef LOCK_OPEN_HACK_REQUIRED | 56 | #ifdef LOCK_OPEN_HACK_REQUIRED |
1187 | 57 | #ifdef DRIZZLED | ||
1188 | 58 | |||
1189 | 59 | using namespace drizzled; | ||
1190 | 60 | using namespace std; | ||
1191 | 61 | |||
1192 | 62 | #define mysql_create_table_no_lock hacked_mysql_create_table_no_lock | ||
1193 | 63 | |||
1194 | 64 | namespace drizzled { | ||
1195 | 65 | |||
1196 | 66 | int rea_create_table(Session *session, const char *path, | ||
1197 | 67 | const char *db, const char *table_name, | ||
1198 | 68 | message::Table *table_proto, | ||
1199 | 69 | HA_CREATE_INFO *create_info, | ||
1200 | 70 | List<CreateField> &create_field, | ||
1201 | 71 | uint32_t key_count,KEY *key_info); | ||
1202 | 72 | } | ||
1203 | 73 | |||
1204 | 74 | static uint32_t build_tmptable_filename(Session* session, | ||
1205 | 75 | char *buff, size_t bufflen) | ||
1206 | 76 | { | ||
1207 | 77 | uint32_t length; | ||
1208 | 78 | ostringstream path_str, post_tmpdir_str; | ||
1209 | 79 | string tmp; | ||
1210 | 80 | |||
1211 | 81 | path_str << drizzle_tmpdir; | ||
1212 | 82 | post_tmpdir_str << "/" << TMP_FILE_PREFIX << current_pid; | ||
1213 | 83 | post_tmpdir_str << session->thread_id << session->tmp_table++; | ||
1214 | 84 | tmp= post_tmpdir_str.str(); | ||
1215 | 85 | |||
1216 | 86 | transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower); | ||
1217 | 87 | |||
1218 | 88 | path_str << tmp; | ||
1219 | 89 | |||
1220 | 90 | if (bufflen < path_str.str().length()) | ||
1221 | 91 | length= 0; | ||
1222 | 92 | else | ||
1223 | 93 | length= unpack_filename(buff, path_str.str().c_str()); | ||
1224 | 94 | |||
1225 | 95 | return length; | ||
1226 | 96 | } | ||
1227 | 97 | |||
1228 | 98 | static bool mysql_create_table_no_lock(Session *session, | ||
1229 | 99 | const char *db, const char *table_name, | ||
1230 | 100 | HA_CREATE_INFO *create_info, | ||
1231 | 101 | message::Table *table_proto, | ||
1232 | 102 | AlterInfo *alter_info, | ||
1233 | 103 | bool internal_tmp_table, | ||
1234 | 104 | uint32_t select_field_count) | ||
1235 | 105 | { | ||
1236 | 106 | char path[FN_REFLEN]; | ||
1237 | 107 | uint32_t path_length; | ||
1238 | 108 | uint db_options, key_count; | ||
1239 | 109 | KEY *key_info_buffer; | ||
1240 | 110 | Cursor *file; | ||
1241 | 111 | bool error= true; | ||
1242 | 112 | /* Check for duplicate fields and check type of table to create */ | ||
1243 | 113 | if (!alter_info->create_list.elements) | ||
1244 | 114 | { | ||
1245 | 115 | my_message(ER_TABLE_MUST_HAVE_COLUMNS, ER(ER_TABLE_MUST_HAVE_COLUMNS), | ||
1246 | 116 | MYF(0)); | ||
1247 | 117 | return true; | ||
1248 | 118 | } | ||
1249 | 119 | assert(strcmp(table_name,table_proto->name().c_str())==0); | ||
1250 | 120 | if (check_engine(session, table_name, create_info)) | ||
1251 | 121 | return true; | ||
1252 | 122 | db_options= create_info->table_options; | ||
1253 | 123 | if (create_info->row_type == ROW_TYPE_DYNAMIC) | ||
1254 | 124 | db_options|=HA_OPTION_PACK_RECORD; | ||
1255 | 125 | |||
1256 | 126 | /*if (!(file= create_info->db_type->getCursor((TableShare*) 0, session->mem_root))) | ||
1257 | 127 | { | ||
1258 | 128 | my_error(ER_OUTOFMEMORY, MYF(0), sizeof(Cursor)); | ||
1259 | 129 | return true; | ||
1260 | 130 | }*/ | ||
1261 | 131 | |||
1262 | 132 | /* PMC - Done to avoid getting the partition handler by mistake! */ | ||
1263 | 133 | if (!(file= new (session->mem_root) ha_xtsys(pbxt_hton, NULL))) | ||
1264 | 134 | { | ||
1265 | 135 | my_error(ER_OUTOFMEMORY, MYF(0), sizeof(Cursor)); | ||
1266 | 136 | return true; | ||
1267 | 137 | } | ||
1268 | 138 | |||
1269 | 139 | set_table_default_charset(create_info, (char*) db); | ||
1270 | 140 | |||
1271 | 141 | if (mysql_prepare_create_table(session, | ||
1272 | 142 | create_info, | ||
1273 | 143 | table_proto, | ||
1274 | 144 | alter_info, | ||
1275 | 145 | internal_tmp_table, | ||
1276 | 146 | &db_options, file, | ||
1277 | 147 | &key_info_buffer, &key_count, | ||
1278 | 148 | select_field_count)) | ||
1279 | 149 | goto err; | ||
1280 | 150 | |||
1281 | 151 | /* Check if table exists */ | ||
1282 | 152 | if (create_info->options & HA_LEX_CREATE_TMP_TABLE) | ||
1283 | 153 | { | ||
1284 | 154 | path_length= build_tmptable_filename(session, path, sizeof(path)); | ||
1285 | 155 | } | ||
1286 | 156 | else | ||
1287 | 157 | { | ||
1288 | 158 | #ifdef FN_DEVCHAR | ||
1289 | 159 | /* check if the table name contains FN_DEVCHAR when defined */ | ||
1290 | 160 | if (strchr(table_name, FN_DEVCHAR)) | ||
1291 | 161 | { | ||
1292 | 162 | my_error(ER_WRONG_TABLE_NAME, MYF(0), table_name); | ||
1293 | 163 | return true; | ||
1294 | 164 | } | ||
1295 | 165 | #endif | ||
1296 | 166 | path_length= build_table_filename(path, sizeof(path), db, table_name, internal_tmp_table); | ||
1297 | 167 | } | ||
1298 | 168 | |||
1299 | 169 | /* Check if table already exists */ | ||
1300 | 170 | if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) && | ||
1301 | 171 | session->find_temporary_table(db, table_name)) | ||
1302 | 172 | { | ||
1303 | 173 | if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) | ||
1304 | 174 | { | ||
1305 | 175 | create_info->table_existed= 1; // Mark that table existed | ||
1306 | 176 | push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE, | ||
1307 | 177 | ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), | ||
1308 | 178 | table_name); | ||
1309 | 179 | error= 0; | ||
1310 | 180 | goto err; | ||
1311 | 181 | } | ||
1312 | 182 | my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name); | ||
1313 | 183 | goto err; | ||
1314 | 184 | } | ||
1315 | 185 | |||
1316 | 186 | //pthread_mutex_lock(&LOCK_open); /* CREATE TABLE (some confussion on naming, double check) */ | ||
1317 | 187 | if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) | ||
1318 | 188 | { | ||
1319 | 189 | if (plugin::StorageEngine::getTableDefinition(*session, | ||
1320 | 190 | path, | ||
1321 | 191 | db, | ||
1322 | 192 | table_name, | ||
1323 | 193 | internal_tmp_table) == EEXIST) | ||
1324 | 194 | { | ||
1325 | 195 | if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) | ||
1326 | 196 | { | ||
1327 | 197 | error= false; | ||
1328 | 198 | push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE, | ||
1329 | 199 | ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), | ||
1330 | 200 | table_name); | ||
1331 | 201 | create_info->table_existed= 1; // Mark that table existed | ||
1332 | 202 | } | ||
1333 | 203 | else | ||
1334 | 204 | my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); | ||
1335 | 205 | |||
1336 | 206 | goto unlock_and_end; | ||
1337 | 207 | } | ||
1338 | 208 | /* | ||
1339 | 209 | * We don't assert here, but check the result, because the table could be | ||
1340 | 210 | * in the table definition cache and in the same time the .frm could be | ||
1341 | 211 | * missing from the disk, in case of manual intervention which deletes | ||
1342 | 212 | * the .frm file. The user has to use FLUSH TABLES; to clear the cache. | ||
1343 | 213 | * Then she could create the table. This case is pretty obscure and | ||
1344 | 214 | * therefore we don't introduce a new error message only for it. | ||
1345 | 215 | * */ | ||
1346 | 216 | if (TableShare::getShare(db, table_name)) | ||
1347 | 217 | { | ||
1348 | 218 | my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name); | ||
1349 | 219 | goto unlock_and_end; | ||
1350 | 220 | } | ||
1351 | 221 | } | ||
1352 | 222 | /* | ||
1353 | 223 | * Check that table with given name does not already | ||
1354 | 224 | * exist in any storage engine. In such a case it should | ||
1355 | 225 | * be discovered and the error ER_TABLE_EXISTS_ERROR be returned | ||
1356 | 226 | * unless user specified CREATE TABLE IF EXISTS | ||
1357 | 227 | * The LOCK_open mutex has been locked to make sure no | ||
1358 | 228 | * one else is attempting to discover the table. Since | ||
1359 | 229 | * it's not on disk as a frm file, no one could be using it! | ||
1360 | 230 | * */ | ||
1361 | 231 | if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE)) | ||
1362 | 232 | { | ||
1363 | 233 | bool create_if_not_exists = | ||
1364 | 234 | create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS; | ||
1365 | 235 | |||
1366 | 236 | char table_path[FN_REFLEN]; | ||
1367 | 237 | uint32_t table_path_length; | ||
1368 | 238 | |||
1369 | 239 | table_path_length= build_table_filename(table_path, sizeof(table_path), | ||
1370 | 240 | db, table_name, false); | ||
1371 | 241 | |||
1372 | 242 | int retcode= plugin::StorageEngine::getTableDefinition(*session, | ||
1373 | 243 | table_path, | ||
1374 | 244 | db, | ||
1375 | 245 | table_name, | ||
1376 | 246 | false); | ||
1377 | 247 | switch (retcode) | ||
1378 | 248 | { | ||
1379 | 249 | case ENOENT: | ||
1380 | 250 | /* Normal case, no table exists. we can go and create it */ | ||
1381 | 251 | break; | ||
1382 | 252 | case EEXIST: | ||
1383 | 253 | if (create_if_not_exists) | ||
1384 | 254 | { | ||
1385 | 255 | error= false; | ||
1386 | 256 | push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE, | ||
1387 | 257 | ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), | ||
1388 | 258 | table_name); | ||
1389 | 259 | create_info->table_existed= 1; // Mark that table existed | ||
1390 | 260 | goto unlock_and_end; | ||
1391 | 261 | } | ||
1392 | 262 | my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); | ||
1393 | 263 | goto unlock_and_end; | ||
1394 | 264 | default: | ||
1395 | 265 | my_error(retcode, MYF(0),table_name); | ||
1396 | 266 | goto unlock_and_end; | ||
1397 | 267 | } | ||
1398 | 268 | } | ||
1399 | 269 | |||
1400 | 270 | session->set_proc_info("creating table"); | ||
1401 | 271 | create_info->table_existed= 0; // Mark that table is created | ||
1402 | 272 | |||
1403 | 273 | create_info->table_options=db_options; | ||
1404 | 274 | |||
1405 | 275 | if (rea_create_table(session, path, db, table_name, | ||
1406 | 276 | table_proto, | ||
1407 | 277 | create_info, alter_info->create_list, | ||
1408 | 278 | key_count, key_info_buffer)) | ||
1409 | 279 | goto unlock_and_end; | ||
1410 | 280 | |||
1411 | 281 | if (create_info->options & HA_LEX_CREATE_TMP_TABLE) | ||
1412 | 282 | { | ||
1413 | 283 | /* Open table and put in temporary table list */ | ||
1414 | 284 | if (!(session->open_temporary_table(path, db, table_name, 1, OTM_OPEN))) | ||
1415 | 285 | { | ||
1416 | 286 | (void) session->rm_temporary_table(create_info->db_type, path); | ||
1417 | 287 | goto unlock_and_end; | ||
1418 | 288 | } | ||
1419 | 289 | } | ||
1420 | 290 | |||
1421 | 291 | /* | ||
1422 | 292 | * Don't write statement if: | ||
1423 | 293 | * - It is an internal temporary table, | ||
1424 | 294 | * - Row-based logging is used and it we are creating a temporary table, or | ||
1425 | 295 | * - The binary log is not open. | ||
1426 | 296 | * Otherwise, the statement shall be binlogged. | ||
1427 | 297 | * */ | ||
1428 | 298 | if (!internal_tmp_table && | ||
1429 | 299 | ((!(create_info->options & HA_LEX_CREATE_TMP_TABLE)))) | ||
1430 | 300 | write_bin_log(session, session->query, session->query_length); | ||
1431 | 301 | error= false; | ||
1432 | 302 | unlock_and_end: | ||
1433 | 303 | //pthread_mutex_unlock(&LOCK_open); | ||
1434 | 304 | |||
1435 | 305 | err: | ||
1436 | 306 | session->set_proc_info("After create"); | ||
1437 | 307 | delete file; | ||
1438 | 308 | return(error); | ||
1439 | 309 | } | ||
1440 | 310 | |||
1441 | 311 | #else // MySQL case | ||
1442 | 54 | /////////////////////////////// | 312 | /////////////////////////////// |
1443 | 55 | /* | 313 | /* |
1444 | 56 | * Unfortunately I cannot use the standard mysql_create_table_no_lock() because it will lock "LOCK_open" | 314 | * Unfortunately I cannot use the standard mysql_create_table_no_lock() because it will lock "LOCK_open" |
1445 | @@ -1229,13 +1487,13 @@ | |||
1446 | 1229 | if (create_info->options & HA_LEX_CREATE_TMP_TABLE) | 1487 | if (create_info->options & HA_LEX_CREATE_TMP_TABLE) |
1447 | 1230 | { | 1488 | { |
1448 | 1231 | /* Open table and put in temporary table list */ | 1489 | /* Open table and put in temporary table list */ |
1450 | 1232 | #if MYSQL_VERSION_ID > 60005 | 1490 | #if MYSQL_VERSION_ID >= 50404 |
1451 | 1233 | if (!(open_temporary_table(thd, path, db, table_name, 1, OTM_OPEN))) | 1491 | if (!(open_temporary_table(thd, path, db, table_name, 1, OTM_OPEN))) |
1452 | 1234 | #else | 1492 | #else |
1453 | 1235 | if (!(open_temporary_table(thd, path, db, table_name, 1))) | 1493 | if (!(open_temporary_table(thd, path, db, table_name, 1))) |
1454 | 1236 | #endif | 1494 | #endif |
1455 | 1237 | { | 1495 | { |
1457 | 1238 | #if MYSQL_VERSION_ID > 60005 | 1496 | #if MYSQL_VERSION_ID >= 50404 |
1458 | 1239 | (void) rm_temporary_table(create_info->db_type, path, false); | 1497 | (void) rm_temporary_table(create_info->db_type, path, false); |
1459 | 1240 | #else | 1498 | #else |
1460 | 1241 | (void) rm_temporary_table(create_info->db_type, path); | 1499 | (void) rm_temporary_table(create_info->db_type, path); |
1461 | @@ -1252,11 +1510,25 @@ | |||
1462 | 1252 | - The binary log is not open. | 1510 | - The binary log is not open. |
1463 | 1253 | Otherwise, the statement shall be binlogged. | 1511 | Otherwise, the statement shall be binlogged. |
1464 | 1254 | */ | 1512 | */ |
1465 | 1513 | /* PBXT 1.0.09e | ||
1466 | 1514 | * Firstly we had a compile problem with MySQL 5.1.42 and | ||
1467 | 1515 | * the write_bin_log() call below: | ||
1468 | 1516 | * discover_xt.cc:1259: error: argument of type 'char* (Statement::)()' does not match 'const char*' | ||
1469 | 1517 | * | ||
1470 | 1518 | * And secondly, we should no write the BINLOG anyway because this is | ||
1471 | 1519 | * an internal PBXT system table. | ||
1472 | 1520 | * | ||
1473 | 1521 | * So I am just commenting out the code altogether. | ||
1474 | 1255 | if (!internal_tmp_table && | 1522 | if (!internal_tmp_table && |
1475 | 1256 | (!thd->current_stmt_binlog_row_based || | 1523 | (!thd->current_stmt_binlog_row_based || |
1476 | 1257 | (thd->current_stmt_binlog_row_based && | 1524 | (thd->current_stmt_binlog_row_based && |
1477 | 1258 | !(create_info->options & HA_LEX_CREATE_TMP_TABLE)))) | 1525 | !(create_info->options & HA_LEX_CREATE_TMP_TABLE)))) |
1478 | 1526 | <<<<<<< TREE | ||
1479 | 1259 | write_bin_log(thd, TRUE, thd->query(), thd->query_length()); | 1527 | write_bin_log(thd, TRUE, thd->query(), thd->query_length()); |
1480 | 1528 | ======= | ||
1481 | 1529 | write_bin_log(thd, TRUE, thd->query, thd->query_length); | ||
1482 | 1530 | */ | ||
1483 | 1531 | >>>>>>> MERGE-SOURCE | ||
1484 | 1260 | error= FALSE; | 1532 | error= FALSE; |
1485 | 1261 | unlock_and_end: | 1533 | unlock_and_end: |
1486 | 1262 | pthread_mutex_unlock(&LOCK_open); | 1534 | pthread_mutex_unlock(&LOCK_open); |
1487 | @@ -1279,37 +1551,51 @@ | |||
1488 | 1279 | ////// END OF CUT AND PASTES FROM sql_table.cc //////// | 1551 | ////// END OF CUT AND PASTES FROM sql_table.cc //////// |
1489 | 1280 | //////////////////////////////////////////////////////// | 1552 | //////////////////////////////////////////////////////// |
1490 | 1281 | 1553 | ||
1491 | 1554 | #endif // DRIZZLED | ||
1492 | 1282 | #endif // LOCK_OPEN_HACK_REQUIRED | 1555 | #endif // LOCK_OPEN_HACK_REQUIRED |
1493 | 1283 | 1556 | ||
1494 | 1284 | //------------------------------ | 1557 | //------------------------------ |
1495 | 1285 | int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char *name, DT_FIELD_INFO *info, DT_KEY_INFO *XT_UNUSED(keys), xtBool skip_existing) | 1558 | int xt_create_table_frm(handlerton *hton, THD* thd, const char *db, const char *name, DT_FIELD_INFO *info, DT_KEY_INFO *XT_UNUSED(keys), xtBool skip_existing) |
1496 | 1286 | { | 1559 | { |
1497 | 1287 | #ifdef DRIZZLED | 1560 | #ifdef DRIZZLED |
1499 | 1288 | drizzled::message::Table table_proto; | 1561 | #define MYLEX_CREATE_INFO create_info |
1500 | 1562 | #else | ||
1501 | 1563 | #define MYLEX_CREATE_INFO mylex.create_info | ||
1502 | 1564 | #endif | ||
1503 | 1565 | |||
1504 | 1566 | #ifdef DRIZZLED | ||
1505 | 1567 | drizzled::statement::AlterTable *stmt = new drizzled::statement::AlterTable(thd); | ||
1506 | 1568 | HA_CREATE_INFO create_info; | ||
1507 | 1569 | //AlterInfo alter_info; | ||
1508 | 1570 | drizzled::message::Table table_proto; | ||
1509 | 1289 | 1571 | ||
1510 | 1290 | static const char *ext = ".dfe"; | 1572 | static const char *ext = ".dfe"; |
1511 | 1291 | static const int ext_len = 4; | 1573 | static const int ext_len = 4; |
1512 | 1574 | |||
1513 | 1575 | table_proto.mutable_engine()->mutable_name()->assign("PBXT"); | ||
1514 | 1292 | #else | 1576 | #else |
1515 | 1293 | static const char *ext = ".frm"; | 1577 | static const char *ext = ".frm"; |
1516 | 1294 | static const int ext_len = 4; | 1578 | static const int ext_len = 4; |
1517 | 1295 | #endif | 1579 | #endif |
1518 | 1296 | int err = 1; | 1580 | int err = 1; |
1519 | 1297 | //HA_CREATE_INFO create_info = {0}; | ||
1520 | 1298 | //Alter_info alter_info; | ||
1521 | 1299 | char field_length_buffer[12], *field_length_ptr; | 1581 | char field_length_buffer[12], *field_length_ptr; |
1522 | 1300 | LEX *save_lex= thd->lex, mylex; | 1582 | LEX *save_lex= thd->lex, mylex; |
1525 | 1301 | 1583 | ||
1526 | 1302 | memset(&mylex.create_info, 0, sizeof(HA_CREATE_INFO)); | 1584 | memset(&MYLEX_CREATE_INFO, 0, sizeof(HA_CREATE_INFO)); |
1527 | 1303 | 1585 | ||
1528 | 1304 | thd->lex = &mylex; | 1586 | thd->lex = &mylex; |
1530 | 1305 | lex_start(thd); | 1587 | lex_start(thd); |
1531 | 1588 | #ifdef DRIZZLED | ||
1532 | 1589 | mylex.statement = stmt; | ||
1533 | 1590 | #endif | ||
1534 | 1306 | 1591 | ||
1535 | 1307 | /* setup the create info */ | 1592 | /* setup the create info */ |
1537 | 1308 | mylex.create_info.db_type = hton; | 1593 | MYLEX_CREATE_INFO.db_type = hton; |
1538 | 1594 | |||
1539 | 1309 | #ifndef DRIZZLED | 1595 | #ifndef DRIZZLED |
1540 | 1310 | mylex.create_info.frm_only = 1; | 1596 | mylex.create_info.frm_only = 1; |
1541 | 1311 | #endif | 1597 | #endif |
1543 | 1312 | mylex.create_info.default_table_charset = system_charset_info; | 1598 | MYLEX_CREATE_INFO.default_table_charset = system_charset_info; |
1544 | 1313 | 1599 | ||
1545 | 1314 | /* setup the column info. */ | 1600 | /* setup the column info. */ |
1546 | 1315 | while (info->field_name) { | 1601 | while (info->field_name) { |
1547 | @@ -1335,7 +1621,7 @@ | |||
1548 | 1335 | #else | 1621 | #else |
1549 | 1336 | if (add_field_to_list(thd, &field_name, info->field_type, field_length_ptr, info->field_decimal_length, | 1622 | if (add_field_to_list(thd, &field_name, info->field_type, field_length_ptr, info->field_decimal_length, |
1550 | 1337 | info->field_flags, | 1623 | info->field_flags, |
1552 | 1338 | #if MYSQL_VERSION_ID > 60005 | 1624 | #if MYSQL_VERSION_ID >= 50404 |
1553 | 1339 | HA_SM_DISK, | 1625 | HA_SM_DISK, |
1554 | 1340 | COLUMN_FORMAT_TYPE_FIXED, | 1626 | COLUMN_FORMAT_TYPE_FIXED, |
1555 | 1341 | #endif | 1627 | #endif |
1556 | @@ -1369,7 +1655,7 @@ | |||
1557 | 1369 | table_proto.set_name(name); | 1655 | table_proto.set_name(name); |
1558 | 1370 | table_proto.set_type(drizzled::message::Table::STANDARD); | 1656 | table_proto.set_type(drizzled::message::Table::STANDARD); |
1559 | 1371 | 1657 | ||
1561 | 1372 | if (mysql_create_table_no_lock(thd, db, name, &mylex.create_info, &table_proto, &mylex.alter_info, 1, 0, false)) | 1658 | if (mysql_create_table_no_lock(thd, db, name, &create_info, &table_proto, &stmt->alter_info, 1, 0)) |
1562 | 1373 | goto error; | 1659 | goto error; |
1563 | 1374 | #else | 1660 | #else |
1564 | 1375 | if (mysql_create_table_no_lock(thd, db, name, &mylex.create_info, &mylex.alter_info, 1, 0)) | 1661 | if (mysql_create_table_no_lock(thd, db, name, &mylex.create_info, &mylex.alter_info, 1, 0)) |
1565 | 1376 | 1662 | ||
1566 | === modified file 'storage/pbxt/src/filesys_xt.cc' | |||
1567 | --- storage/pbxt/src/filesys_xt.cc 2009-09-03 06:15:03 +0000 | |||
1568 | +++ storage/pbxt/src/filesys_xt.cc 2009-12-10 11:57:20 +0000 | |||
1569 | @@ -56,6 +56,8 @@ | |||
1570 | 56 | //#define DEBUG_TRACE_FILES | 56 | //#define DEBUG_TRACE_FILES |
1571 | 57 | //#define INJECT_WRITE_REMAP_ERROR | 57 | //#define INJECT_WRITE_REMAP_ERROR |
1572 | 58 | /* This is required to make testing on the Mac faster: */ | 58 | /* This is required to make testing on the Mac faster: */ |
1573 | 59 | /* It turns of full file sync. */ | ||
1574 | 60 | #define DEBUG_FAST_MAC | ||
1575 | 59 | #endif | 61 | #endif |
1576 | 60 | 62 | ||
1577 | 61 | #ifdef DEBUG_TRACE_FILES | 63 | #ifdef DEBUG_TRACE_FILES |
1578 | @@ -63,10 +65,6 @@ | |||
1579 | 63 | #define PRINTF xt_trace | 65 | #define PRINTF xt_trace |
1580 | 64 | #endif | 66 | #endif |
1581 | 65 | 67 | ||
1582 | 66 | #if defined(XT_MAC) && defined(F_FULLFSYNC) | ||
1583 | 67 | #undef F_FULLFSYNC | ||
1584 | 68 | #endif | ||
1585 | 69 | |||
1586 | 70 | #ifdef INJECT_WRITE_REMAP_ERROR | 68 | #ifdef INJECT_WRITE_REMAP_ERROR |
1587 | 71 | #define INJECT_REMAP_FILE_SIZE 1000000 | 69 | #define INJECT_REMAP_FILE_SIZE 1000000 |
1588 | 72 | #define INJECT_REMAP_FILE_TYPE "xtd" | 70 | #define INJECT_REMAP_FILE_TYPE "xtd" |
1589 | @@ -883,7 +881,7 @@ | |||
1590 | 883 | * fsync didn't really flush index pages to disk. fcntl(F_FULLFSYNC) is considered more effective | 881 | * fsync didn't really flush index pages to disk. fcntl(F_FULLFSYNC) is considered more effective |
1591 | 884 | * in such case. | 882 | * in such case. |
1592 | 885 | */ | 883 | */ |
1594 | 886 | #ifdef F_FULLFSYNC | 884 | #if defined(F_FULLFSYNC) && !defined(DEBUG_FAST_MAC) |
1595 | 887 | if (fcntl(of->of_filedes, F_FULLFSYNC, 0) == -1) { | 885 | if (fcntl(of->of_filedes, F_FULLFSYNC, 0) == -1) { |
1596 | 888 | xt_register_ferrno(XT_REG_CONTEXT, errno, xt_file_path(of)); | 886 | xt_register_ferrno(XT_REG_CONTEXT, errno, xt_file_path(of)); |
1597 | 889 | goto failed; | 887 | goto failed; |
1598 | 890 | 888 | ||
1599 | === modified file 'storage/pbxt/src/filesys_xt.h' | |||
1600 | --- storage/pbxt/src/filesys_xt.h 2009-08-17 11:12:36 +0000 | |||
1601 | +++ storage/pbxt/src/filesys_xt.h 2009-12-10 11:57:20 +0000 | |||
1602 | @@ -102,7 +102,7 @@ | |||
1603 | 102 | #define FILE_MAP_UNLOCK(i, o) xt_xsmutex_unlock(i, o) | 102 | #define FILE_MAP_UNLOCK(i, o) xt_xsmutex_unlock(i, o) |
1604 | 103 | #elif defined(FILE_MAP_USE_PTHREAD_RW) | 103 | #elif defined(FILE_MAP_USE_PTHREAD_RW) |
1605 | 104 | #define FILE_MAP_LOCK_TYPE xt_rwlock_type | 104 | #define FILE_MAP_LOCK_TYPE xt_rwlock_type |
1607 | 105 | #define FILE_MAP_INIT_LOCK(s, i) xt_init_rwlock(s, i) | 105 | #define FILE_MAP_INIT_LOCK(s, i) xt_init_rwlock_with_autoname(s, i) |
1608 | 106 | #define FILE_MAP_FREE_LOCK(s, i) xt_free_rwlock(i) | 106 | #define FILE_MAP_FREE_LOCK(s, i) xt_free_rwlock(i) |
1609 | 107 | #define FILE_MAP_READ_LOCK(i, o) xt_slock_rwlock_ns(i) | 107 | #define FILE_MAP_READ_LOCK(i, o) xt_slock_rwlock_ns(i) |
1610 | 108 | #define FILE_MAP_WRITE_LOCK(i, o) xt_xlock_rwlock_ns(i) | 108 | #define FILE_MAP_WRITE_LOCK(i, o) xt_xlock_rwlock_ns(i) |
1611 | 109 | 109 | ||
1612 | === modified file 'storage/pbxt/src/ha_pbxt.cc' | |||
1613 | --- storage/pbxt/src/ha_pbxt.cc 2009-09-03 06:15:03 +0000 | |||
1614 | +++ storage/pbxt/src/ha_pbxt.cc 2009-12-10 11:57:20 +0000 | |||
1615 | @@ -35,6 +35,7 @@ | |||
1616 | 35 | 35 | ||
1617 | 36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
1618 | 37 | #include <time.h> | 37 | #include <time.h> |
1619 | 38 | #include <ctype.h> | ||
1620 | 38 | 39 | ||
1621 | 39 | #ifdef DRIZZLED | 40 | #ifdef DRIZZLED |
1622 | 40 | #include <drizzled/common.h> | 41 | #include <drizzled/common.h> |
1623 | @@ -42,14 +43,21 @@ | |||
1624 | 42 | #include <mysys/my_alloc.h> | 43 | #include <mysys/my_alloc.h> |
1625 | 43 | #include <mysys/hash.h> | 44 | #include <mysys/hash.h> |
1626 | 44 | #include <drizzled/field.h> | 45 | #include <drizzled/field.h> |
1628 | 45 | #include <drizzled/current_session.h> | 46 | #include <drizzled/session.h> |
1629 | 46 | #include <drizzled/data_home.h> | 47 | #include <drizzled/data_home.h> |
1630 | 47 | #include <drizzled/error.h> | 48 | #include <drizzled/error.h> |
1631 | 48 | #include <drizzled/table.h> | 49 | #include <drizzled/table.h> |
1632 | 49 | #include <drizzled/field/timestamp.h> | 50 | #include <drizzled/field/timestamp.h> |
1633 | 50 | #include <drizzled/server_includes.h> | 51 | #include <drizzled/server_includes.h> |
1634 | 52 | #include <drizzled/plugin/info_schema_table.h> | ||
1635 | 51 | extern "C" char **session_query(Session *session); | 53 | extern "C" char **session_query(Session *session); |
1636 | 52 | #define my_strdup(a,b) strdup(a) | 54 | #define my_strdup(a,b) strdup(a) |
1637 | 55 | |||
1638 | 56 | using drizzled::plugin::Registry; | ||
1639 | 57 | using drizzled::plugin::ColumnInfo; | ||
1640 | 58 | using drizzled::plugin::InfoSchemaTable; | ||
1641 | 59 | using drizzled::plugin::InfoSchemaMethods; | ||
1642 | 60 | |||
1643 | 53 | #else | 61 | #else |
1644 | 54 | #include "mysql_priv.h" | 62 | #include "mysql_priv.h" |
1645 | 55 | #include <mysql/plugin.h> | 63 | #include <mysql/plugin.h> |
1646 | @@ -71,7 +79,7 @@ | |||
1647 | 71 | #include "tabcache_xt.h" | 79 | #include "tabcache_xt.h" |
1648 | 72 | #include "systab_xt.h" | 80 | #include "systab_xt.h" |
1649 | 73 | #include "xaction_xt.h" | 81 | #include "xaction_xt.h" |
1651 | 74 | #include "restart_xt.h" | 82 | #include "backup_xt.h" |
1652 | 75 | 83 | ||
1653 | 76 | #ifdef DEBUG | 84 | #ifdef DEBUG |
1654 | 77 | //#define XT_USE_SYS_PAR_DEBUG_SIZES | 85 | //#define XT_USE_SYS_PAR_DEBUG_SIZES |
1655 | @@ -101,6 +109,10 @@ | |||
1656 | 101 | static int pbxt_close_connection(handlerton *hton, THD* thd); | 109 | static int pbxt_close_connection(handlerton *hton, THD* thd); |
1657 | 102 | static int pbxt_commit(handlerton *hton, THD *thd, bool all); | 110 | static int pbxt_commit(handlerton *hton, THD *thd, bool all); |
1658 | 103 | static int pbxt_rollback(handlerton *hton, THD *thd, bool all); | 111 | static int pbxt_rollback(handlerton *hton, THD *thd, bool all); |
1659 | 112 | static int pbxt_prepare(handlerton *hton, THD *thd, bool all); | ||
1660 | 113 | static int pbxt_recover(handlerton *hton, XID *xid_list, uint len); | ||
1661 | 114 | static int pbxt_commit_by_xid(handlerton *hton, XID *xid); | ||
1662 | 115 | static int pbxt_rollback_by_xid(handlerton *hton, XID *xid); | ||
1663 | 104 | #endif | 116 | #endif |
1664 | 105 | static void ha_aquire_exclusive_use(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine); | 117 | static void ha_aquire_exclusive_use(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine); |
1665 | 106 | static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share); | 118 | static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share); |
1666 | @@ -123,7 +135,9 @@ | |||
1667 | 123 | #ifdef PBXT_HANDLER_TRACE | 135 | #ifdef PBXT_HANDLER_TRACE |
1668 | 124 | #define PBXT_ALLOW_PRINTING | 136 | #define PBXT_ALLOW_PRINTING |
1669 | 125 | 137 | ||
1671 | 126 | #define XT_TRACE_CALL() do { XTThreadPtr s = xt_get_self(); printf("%s %s\n", s ? s->t_name : "-unknown-", __FUNC__); } while (0) | 138 | #define XT_TRACE_CALL() ha_trace_function(__FUNC__, NULL) |
1672 | 139 | #define XT_TRACE_METHOD() ha_trace_function(__FUNC__, pb_share->sh_table_path->ps_path) | ||
1673 | 140 | |||
1674 | 127 | #ifdef PBXT_TRACE_RETURN | 141 | #ifdef PBXT_TRACE_RETURN |
1675 | 128 | #define XT_RETURN(x) do { printf("%d\n", (int) (x)); return (x); } while (0) | 142 | #define XT_RETURN(x) do { printf("%d\n", (int) (x)); return (x); } while (0) |
1676 | 129 | #define XT_RETURN_VOID do { printf("out\n"); return; } while (0) | 143 | #define XT_RETURN_VOID do { printf("out\n"); return; } while (0) |
1677 | @@ -135,6 +149,7 @@ | |||
1678 | 135 | #else | 149 | #else |
1679 | 136 | 150 | ||
1680 | 137 | #define XT_TRACE_CALL() | 151 | #define XT_TRACE_CALL() |
1681 | 152 | #define XT_TRACE_METHOD() | ||
1682 | 138 | #define XT_RETURN(x) return (x) | 153 | #define XT_RETURN(x) return (x) |
1683 | 139 | #define XT_RETURN_VOID return | 154 | #define XT_RETURN_VOID return |
1684 | 140 | 155 | ||
1685 | @@ -165,10 +180,10 @@ | |||
1686 | 165 | xtBool pbxt_crash_debug = FALSE; | 180 | xtBool pbxt_crash_debug = FALSE; |
1687 | 166 | #endif | 181 | #endif |
1688 | 167 | 182 | ||
1689 | 183 | |||
1690 | 168 | /* Variables for pbxt share methods */ | 184 | /* Variables for pbxt share methods */ |
1691 | 169 | static xt_mutex_type pbxt_database_mutex; // Prevent a database from being opened while it is being dropped | 185 | static xt_mutex_type pbxt_database_mutex; // Prevent a database from being opened while it is being dropped |
1692 | 170 | static XTHashTabPtr pbxt_share_tables; // Hash used to track open tables | 186 | static XTHashTabPtr pbxt_share_tables; // Hash used to track open tables |
1693 | 171 | XTDatabaseHPtr pbxt_database = NULL; // The global open database | ||
1694 | 172 | static char *pbxt_index_cache_size; | 187 | static char *pbxt_index_cache_size; |
1695 | 173 | static char *pbxt_record_cache_size; | 188 | static char *pbxt_record_cache_size; |
1696 | 174 | static char *pbxt_log_cache_size; | 189 | static char *pbxt_log_cache_size; |
1697 | @@ -180,6 +195,12 @@ | |||
1698 | 180 | static char *pbxt_data_file_grow_size; | 195 | static char *pbxt_data_file_grow_size; |
1699 | 181 | static char *pbxt_row_file_grow_size; | 196 | static char *pbxt_row_file_grow_size; |
1700 | 182 | static int pbxt_max_threads; | 197 | static int pbxt_max_threads; |
1701 | 198 | static my_bool pbxt_support_xa; | ||
1702 | 199 | |||
1703 | 200 | #ifndef DRIZZLED | ||
1704 | 201 | // drizzle complains it's not used | ||
1705 | 202 | static XTXactEnumXARec pbxt_xa_enum; | ||
1706 | 203 | #endif | ||
1707 | 183 | 204 | ||
1708 | 184 | #ifdef DEBUG | 205 | #ifdef DEBUG |
1709 | 185 | #define XT_SHARE_LOCK_WAIT 5000 | 206 | #define XT_SHARE_LOCK_WAIT 5000 |
1710 | @@ -259,6 +280,33 @@ | |||
1711 | 259 | //#define XT_AUTO_INCREMENT_DEF 1 | 280 | //#define XT_AUTO_INCREMENT_DEF 1 |
1712 | 260 | #endif | 281 | #endif |
1713 | 261 | 282 | ||
1714 | 283 | #ifdef PBXT_HANDLER_TRACE | ||
1715 | 284 | static void ha_trace_function(const char *function, char *table) | ||
1716 | 285 | { | ||
1717 | 286 | char func_buf[50], *ptr; | ||
1718 | 287 | XTThreadPtr thread = xt_get_self(); | ||
1719 | 288 | |||
1720 | 289 | if ((ptr = strchr(function, '('))) { | ||
1721 | 290 | ptr--; | ||
1722 | 291 | while (ptr > function) { | ||
1723 | 292 | if (!(isalnum(*ptr) || *ptr == '_')) | ||
1724 | 293 | break; | ||
1725 | 294 | ptr--; | ||
1726 | 295 | } | ||
1727 | 296 | ptr++; | ||
1728 | 297 | xt_strcpy(50, func_buf, ptr); | ||
1729 | 298 | if ((ptr = strchr(func_buf, '('))) | ||
1730 | 299 | *ptr = 0; | ||
1731 | 300 | } | ||
1732 | 301 | else | ||
1733 | 302 | xt_strcpy(50, func_buf, function); | ||
1734 | 303 | if (table) | ||
1735 | 304 | printf("%s %s (%s)\n", thread ? thread->t_name : "-unknown-", func_buf, table); | ||
1736 | 305 | else | ||
1737 | 306 | printf("%s %s\n", thread ? thread->t_name : "-unknown-", func_buf); | ||
1738 | 307 | } | ||
1739 | 308 | #endif | ||
1740 | 309 | |||
1741 | 262 | /* | 310 | /* |
1742 | 263 | * ----------------------------------------------------------------------- | 311 | * ----------------------------------------------------------------------- |
1743 | 264 | * SHARED TABLE DATA | 312 | * SHARED TABLE DATA |
1744 | @@ -584,6 +632,9 @@ | |||
1745 | 584 | /* The first bit is 1. */ | 632 | /* The first bit is 1. */ |
1746 | 585 | static u_int ha_get_max_bit(MX_BITMAP *map) | 633 | static u_int ha_get_max_bit(MX_BITMAP *map) |
1747 | 586 | { | 634 | { |
1748 | 635 | #ifdef DRIZZLED | ||
1749 | 636 | return map->getFirstSet(); | ||
1750 | 637 | #else | ||
1751 | 587 | my_bitmap_map *data_ptr = map->bitmap; | 638 | my_bitmap_map *data_ptr = map->bitmap; |
1752 | 588 | my_bitmap_map *end_ptr = map->last_word_ptr; | 639 | my_bitmap_map *end_ptr = map->last_word_ptr; |
1753 | 589 | my_bitmap_map b; | 640 | my_bitmap_map b; |
1754 | @@ -612,6 +663,7 @@ | |||
1755 | 612 | cnt -= 32; | 663 | cnt -= 32; |
1756 | 613 | } | 664 | } |
1757 | 614 | return 0; | 665 | return 0; |
1758 | 666 | #endif | ||
1759 | 615 | } | 667 | } |
1760 | 616 | 668 | ||
1761 | 617 | /* | 669 | /* |
1762 | @@ -684,9 +736,10 @@ | |||
1763 | 684 | return(-1); // Unknown error | 736 | return(-1); // Unknown error |
1764 | 685 | } | 737 | } |
1765 | 686 | 738 | ||
1767 | 687 | xtPublic int xt_ha_pbxt_thread_error_for_mysql(THD *XT_UNUSED(thd), const XTThreadPtr self, int ignore_dup_key) | 739 | xtPublic int xt_ha_pbxt_thread_error_for_mysql(THD *thd, const XTThreadPtr self, int ignore_dup_key) |
1768 | 688 | { | 740 | { |
1770 | 689 | int xt_err = self->t_exception.e_xt_err; | 741 | int xt_err = self->t_exception.e_xt_err; |
1771 | 742 | xtBool dup_key = FALSE; | ||
1772 | 690 | 743 | ||
1773 | 691 | XT_PRINT2(self, "xt_ha_pbxt_thread_error_for_mysql xt_err=%d auto commit=%d\n", (int) xt_err, (int) self->st_auto_commit); | 744 | XT_PRINT2(self, "xt_ha_pbxt_thread_error_for_mysql xt_err=%d auto commit=%d\n", (int) xt_err, (int) self->st_auto_commit); |
1774 | 692 | switch (xt_err) { | 745 | switch (xt_err) { |
1775 | @@ -725,6 +778,7 @@ | |||
1776 | 725 | /* If we are in auto-commit mode (and we are not ignoring | 778 | /* If we are in auto-commit mode (and we are not ignoring |
1777 | 726 | * duplicate keys) then rollback the transaction automatically. | 779 | * duplicate keys) then rollback the transaction automatically. |
1778 | 727 | */ | 780 | */ |
1779 | 781 | dup_key = TRUE; | ||
1780 | 728 | if (!ignore_dup_key && self->st_auto_commit) | 782 | if (!ignore_dup_key && self->st_auto_commit) |
1781 | 729 | goto abort_transaction; | 783 | goto abort_transaction; |
1782 | 730 | break; | 784 | break; |
1783 | @@ -790,26 +844,20 @@ | |||
1784 | 790 | /* Locks are held on tables. | 844 | /* Locks are held on tables. |
1785 | 791 | * Only rollback after locks are released. | 845 | * Only rollback after locks are released. |
1786 | 792 | */ | 846 | */ |
1788 | 793 | self->st_auto_commit = TRUE; | 847 | /* I do not think this is required, because |
1789 | 848 | * I tell mysql to rollback below, | ||
1790 | 849 | * besides it is a hack! | ||
1791 | 850 | self->st_auto_commit = TRUE; | ||
1792 | 851 | */ | ||
1793 | 794 | self->st_abort_trans = TRUE; | 852 | self->st_abort_trans = TRUE; |
1794 | 795 | } | 853 | } |
1810 | 796 | #ifdef xxxx | 854 | /* Only tell MySQL to rollback if we automatically rollback. |
1811 | 797 | /* DBUG_ASSERT(thd->transaction.stmt.ha_list == NULL || | 855 | * Note: calling this with (thd, FALSE), cause sp.test to fail. |
1812 | 798 | trans == &thd->transaction.stmt); in handler.cc now | 856 | */ |
1813 | 799 | * fails, and I don't know if this function can be called anymore! */ | 857 | if (!dup_key) { |
1814 | 800 | /* Cause any other DBs to do a rollback as well... */ | 858 | if (thd) |
1815 | 801 | if (thd) { | 859 | thd_mark_transaction_to_rollback(thd, TRUE); |
1801 | 802 | /* | ||
1802 | 803 | * GOTCHA: | ||
1803 | 804 | * This is a BUG in MySQL. I cannot rollback a transaction if | ||
1804 | 805 | * pb_mysql_thd->in_sub_stmt! But I must....?! | ||
1805 | 806 | */ | ||
1806 | 807 | #ifdef MYSQL_SERVER | ||
1807 | 808 | if (!thd->in_sub_stmt) | ||
1808 | 809 | ha_rollback(thd); | ||
1809 | 810 | #endif | ||
1816 | 811 | } | 860 | } |
1817 | 812 | #endif | ||
1818 | 813 | } | 861 | } |
1819 | 814 | break; | 862 | break; |
1820 | 815 | } | 863 | } |
1821 | @@ -908,7 +956,11 @@ | |||
1822 | 908 | xt_db_data_file_grow_size = (size_t) data_file_grow_size; | 956 | xt_db_data_file_grow_size = (size_t) data_file_grow_size; |
1823 | 909 | xt_db_row_file_grow_size = (size_t) row_file_grow_size; | 957 | xt_db_row_file_grow_size = (size_t) row_file_grow_size; |
1824 | 910 | 958 | ||
1825 | 959 | #ifdef DRIZZLED | ||
1826 | 960 | pbxt_ignore_case = TRUE; | ||
1827 | 961 | #else | ||
1828 | 911 | pbxt_ignore_case = lower_case_table_names != 0; | 962 | pbxt_ignore_case = lower_case_table_names != 0; |
1829 | 963 | #endif | ||
1830 | 912 | if (pbxt_ignore_case) | 964 | if (pbxt_ignore_case) |
1831 | 913 | pbxt_share_tables = xt_new_hashtable(self, ha_hash_comp_ci, ha_hash_ci, ha_hash_free, TRUE, FALSE); | 965 | pbxt_share_tables = xt_new_hashtable(self, ha_hash_comp_ci, ha_hash_ci, ha_hash_free, TRUE, FALSE); |
1832 | 914 | else | 966 | else |
1833 | @@ -968,7 +1020,7 @@ | |||
1834 | 968 | */ | 1020 | */ |
1835 | 969 | static void ha_exit(XTThreadPtr self) | 1021 | static void ha_exit(XTThreadPtr self) |
1836 | 970 | { | 1022 | { |
1838 | 971 | xt_xres_wait_for_recovery(self); | 1023 | xt_xres_terminate_recovery(self); |
1839 | 972 | 1024 | ||
1840 | 973 | /* Wrap things up... */ | 1025 | /* Wrap things up... */ |
1841 | 974 | xt_unuse_database(self, self); /* Just in case the main thread has a database in use (for testing)? */ | 1026 | xt_unuse_database(self, self); /* Just in case the main thread has a database in use (for testing)? */ |
1842 | @@ -1024,7 +1076,7 @@ | |||
1843 | 1024 | cont_(a); | 1076 | cont_(a); |
1844 | 1025 | 1077 | ||
1845 | 1026 | if (!not_ok) { | 1078 | if (!not_ok) { |
1847 | 1027 | if (stat_print(thd, "PBXT", 4, "", 0, strbuf.sb_cstring, strbuf.sb_len)) | 1079 | if (stat_print(thd, "PBXT", 4, "", 0, strbuf.sb_cstring, (uint) strbuf.sb_len)) |
1848 | 1028 | not_ok = TRUE; | 1080 | not_ok = TRUE; |
1849 | 1029 | } | 1081 | } |
1850 | 1030 | xt_sb_set_size(self, &strbuf, 0); | 1082 | xt_sb_set_size(self, &strbuf, 0); |
1851 | @@ -1038,14 +1090,14 @@ | |||
1852 | 1038 | * return 1 on error, else 0. | 1090 | * return 1 on error, else 0. |
1853 | 1039 | */ | 1091 | */ |
1854 | 1040 | #ifdef DRIZZLED | 1092 | #ifdef DRIZZLED |
1856 | 1041 | static int pbxt_init(PluginRegistry ®istry) | 1093 | static int pbxt_init(Registry ®istry) |
1857 | 1042 | #else | 1094 | #else |
1858 | 1043 | static int pbxt_init(void *p) | 1095 | static int pbxt_init(void *p) |
1859 | 1044 | #endif | 1096 | #endif |
1860 | 1045 | { | 1097 | { |
1861 | 1046 | int init_err = 0; | 1098 | int init_err = 0; |
1862 | 1047 | 1099 | ||
1864 | 1048 | XT_TRACE_CALL(); | 1100 | XT_PRINT0(NULL, "pbxt_init\n"); |
1865 | 1049 | 1101 | ||
1866 | 1050 | if (sizeof(xtWordPS) != sizeof(void *)) { | 1102 | if (sizeof(xtWordPS) != sizeof(void *)) { |
1867 | 1051 | printf("PBXT: This won't work, I require that sizeof(xtWordPS) == sizeof(void *)!\n"); | 1103 | printf("PBXT: This won't work, I require that sizeof(xtWordPS) == sizeof(void *)!\n"); |
1868 | @@ -1076,11 +1128,27 @@ | |||
1869 | 1076 | pbxt_hton->close_connection = pbxt_close_connection; /* close_connection, cleanup thread related data. */ | 1128 | pbxt_hton->close_connection = pbxt_close_connection; /* close_connection, cleanup thread related data. */ |
1870 | 1077 | pbxt_hton->commit = pbxt_commit; /* commit */ | 1129 | pbxt_hton->commit = pbxt_commit; /* commit */ |
1871 | 1078 | pbxt_hton->rollback = pbxt_rollback; /* rollback */ | 1130 | pbxt_hton->rollback = pbxt_rollback; /* rollback */ |
1872 | 1131 | if (pbxt_support_xa) { | ||
1873 | 1132 | pbxt_hton->prepare = pbxt_prepare; | ||
1874 | 1133 | pbxt_hton->recover = pbxt_recover; | ||
1875 | 1134 | pbxt_hton->commit_by_xid = pbxt_commit_by_xid; | ||
1876 | 1135 | pbxt_hton->rollback_by_xid = pbxt_rollback_by_xid; | ||
1877 | 1136 | } | ||
1878 | 1137 | else { | ||
1879 | 1138 | pbxt_hton->prepare = NULL; | ||
1880 | 1139 | pbxt_hton->recover = NULL; | ||
1881 | 1140 | pbxt_hton->commit_by_xid = NULL; | ||
1882 | 1141 | pbxt_hton->rollback_by_xid = NULL; | ||
1883 | 1142 | } | ||
1884 | 1079 | pbxt_hton->create = pbxt_create_handler; /* Create a new handler */ | 1143 | pbxt_hton->create = pbxt_create_handler; /* Create a new handler */ |
1885 | 1080 | pbxt_hton->drop_database = pbxt_drop_database; /* Drop a database */ | 1144 | pbxt_hton->drop_database = pbxt_drop_database; /* Drop a database */ |
1886 | 1081 | pbxt_hton->panic = pbxt_panic; /* Panic call */ | 1145 | pbxt_hton->panic = pbxt_panic; /* Panic call */ |
1887 | 1082 | pbxt_hton->show_status = pbxt_show_status; | 1146 | pbxt_hton->show_status = pbxt_show_status; |
1888 | 1083 | pbxt_hton->flags = HTON_NO_FLAGS; /* HTON_CAN_RECREATE - Without this flags TRUNCATE uses delete_all_rows() */ | 1147 | pbxt_hton->flags = HTON_NO_FLAGS; /* HTON_CAN_RECREATE - Without this flags TRUNCATE uses delete_all_rows() */ |
1889 | 1148 | pbxt_hton->slot = (uint)-1; /* assign invald value, so we know when it's inited later */ | ||
1890 | 1149 | #if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP) | ||
1891 | 1150 | pbxt_hton->get_backup_engine = pbxt_backup_engine; | ||
1892 | 1151 | #endif | ||
1893 | 1084 | #endif | 1152 | #endif |
1894 | 1085 | if (!xt_init_logging()) /* Initialize logging */ | 1153 | if (!xt_init_logging()) /* Initialize logging */ |
1895 | 1086 | goto error_1; | 1154 | goto error_1; |
1896 | @@ -1160,8 +1228,10 @@ | |||
1897 | 1160 | * Only real problem, 2 threads try to load the same | 1228 | * Only real problem, 2 threads try to load the same |
1898 | 1161 | * plugin at the same time. | 1229 | * plugin at the same time. |
1899 | 1162 | */ | 1230 | */ |
1900 | 1231 | #if MYSQL_VERSION_ID < 60014 | ||
1901 | 1163 | myxt_mutex_unlock(&LOCK_plugin); | 1232 | myxt_mutex_unlock(&LOCK_plugin); |
1902 | 1164 | #endif | 1233 | #endif |
1903 | 1234 | #endif | ||
1904 | 1165 | 1235 | ||
1905 | 1166 | /* Can't do this here yet, because I need a THD! */ | 1236 | /* Can't do this here yet, because I need a THD! */ |
1906 | 1167 | try_(b) { | 1237 | try_(b) { |
1907 | @@ -1195,8 +1265,10 @@ | |||
1908 | 1195 | if (thd) | 1265 | if (thd) |
1909 | 1196 | myxt_destroy_thread(thd, FALSE); | 1266 | myxt_destroy_thread(thd, FALSE); |
1910 | 1197 | #ifndef DRIZZLED | 1267 | #ifndef DRIZZLED |
1911 | 1268 | #if MYSQL_VERSION_ID < 60014 | ||
1912 | 1198 | myxt_mutex_lock(&LOCK_plugin); | 1269 | myxt_mutex_lock(&LOCK_plugin); |
1913 | 1199 | #endif | 1270 | #endif |
1914 | 1271 | #endif | ||
1915 | 1200 | } | 1272 | } |
1916 | 1201 | #endif | 1273 | #endif |
1917 | 1202 | } | 1274 | } |
1918 | @@ -1262,7 +1334,7 @@ | |||
1919 | 1262 | } | 1334 | } |
1920 | 1263 | 1335 | ||
1921 | 1264 | #ifdef DRIZZLED | 1336 | #ifdef DRIZZLED |
1923 | 1265 | static int pbxt_end(PluginRegistry ®istry) | 1337 | static int pbxt_end(Registry ®istry) |
1924 | 1266 | #else | 1338 | #else |
1925 | 1267 | static int pbxt_end(void *) | 1339 | static int pbxt_end(void *) |
1926 | 1268 | #endif | 1340 | #endif |
1927 | @@ -1378,7 +1450,7 @@ | |||
1928 | 1378 | * transaction (!all && !self->st_auto_commit). | 1450 | * transaction (!all && !self->st_auto_commit). |
1929 | 1379 | */ | 1451 | */ |
1930 | 1380 | if (all || self->st_auto_commit) { | 1452 | if (all || self->st_auto_commit) { |
1932 | 1381 | XT_PRINT0(self, "xt_xn_commit\n"); | 1453 | XT_PRINT0(self, "xt_xn_commit in pbxt_commit\n"); |
1933 | 1382 | 1454 | ||
1934 | 1383 | if (!xt_xn_commit(self)) | 1455 | if (!xt_xn_commit(self)) |
1935 | 1384 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); | 1456 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); |
1936 | @@ -1402,7 +1474,7 @@ | |||
1937 | 1402 | XTThreadPtr self; | 1474 | XTThreadPtr self; |
1938 | 1403 | 1475 | ||
1939 | 1404 | if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) { | 1476 | if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) { |
1941 | 1405 | XT_PRINT1(self, "pbxt_rollback all=%d\n", all); | 1477 | XT_PRINT1(self, "pbxt_rollback all=%d in pbxt_commit\n", all); |
1942 | 1406 | 1478 | ||
1943 | 1407 | if (self->st_xact_data) { | 1479 | if (self->st_xact_data) { |
1944 | 1408 | /* There are no table locks, rollback immediately in all cases | 1480 | /* There are no table locks, rollback immediately in all cases |
1945 | @@ -1431,7 +1503,7 @@ | |||
1946 | 1431 | } | 1503 | } |
1947 | 1432 | 1504 | ||
1948 | 1433 | #ifdef DRIZZLED | 1505 | #ifdef DRIZZLED |
1950 | 1434 | handler *PBXTStorageEngine::create(TABLE_SHARE *table, MEM_ROOT *mem_root) | 1506 | Cursor *PBXTStorageEngine::create(TABLE_SHARE *table, MEM_ROOT *mem_root) |
1951 | 1435 | { | 1507 | { |
1952 | 1436 | PBXTStorageEngine * const hton = this; | 1508 | PBXTStorageEngine * const hton = this; |
1953 | 1437 | #else | 1509 | #else |
1954 | @@ -1446,6 +1518,182 @@ | |||
1955 | 1446 | 1518 | ||
1956 | 1447 | /* | 1519 | /* |
1957 | 1448 | * ----------------------------------------------------------------------- | 1520 | * ----------------------------------------------------------------------- |
1958 | 1521 | * 2-PHASE COMMIT | ||
1959 | 1522 | * | ||
1960 | 1523 | */ | ||
1961 | 1524 | |||
1962 | 1525 | #ifndef DRIZZLED | ||
1963 | 1526 | |||
1964 | 1527 | static int pbxt_prepare(handlerton *hton, THD *thd, bool all) | ||
1965 | 1528 | { | ||
1966 | 1529 | int err = 0; | ||
1967 | 1530 | XTThreadPtr self; | ||
1968 | 1531 | |||
1969 | 1532 | XT_TRACE_CALL(); | ||
1970 | 1533 | if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) { | ||
1971 | 1534 | XT_PRINT1(self, "pbxt_commit all=%d\n", all); | ||
1972 | 1535 | |||
1973 | 1536 | if (self->st_xact_data) { | ||
1974 | 1537 | /* There are no table locks, commit immediately in all cases | ||
1975 | 1538 | * except when this is a statement commit with an explicit | ||
1976 | 1539 | * transaction (!all && !self->st_auto_commit). | ||
1977 | 1540 | */ | ||
1978 | 1541 | if (all) { | ||
1979 | 1542 | XID xid; | ||
1980 | 1543 | |||
1981 | 1544 | XT_PRINT0(self, "xt_xn_prepare in pbxt_prepare\n"); | ||
1982 | 1545 | thd_get_xid(thd, (MYSQL_XID*) &xid); | ||
1983 | 1546 | |||
1984 | 1547 | if (!xt_xn_prepare(xid.length(), (xtWord1 *) &xid, self)) | ||
1985 | 1548 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); | ||
1986 | 1549 | } | ||
1987 | 1550 | } | ||
1988 | 1551 | } | ||
1989 | 1552 | return err; | ||
1990 | 1553 | } | ||
1991 | 1554 | |||
1992 | 1555 | static XTThreadPtr ha_temp_open_global_database(handlerton *hton, THD **ret_thd, int *temp_thread, char *thread_name, int *err) | ||
1993 | 1556 | { | ||
1994 | 1557 | THD *thd; | ||
1995 | 1558 | XTThreadPtr self = NULL; | ||
1996 | 1559 | |||
1997 | 1560 | *temp_thread = 0; | ||
1998 | 1561 | if ((thd = current_thd)) | ||
1999 | 1562 | self = (XTThreadPtr) *thd_ha_data(thd, hton); | ||
2000 | 1563 | else { | ||
2001 | 1564 | //thd = (THD *) myxt_create_thread(); | ||
2002 | 1565 | //*temp_thread |= 2; | ||
2003 | 1566 | } | ||
2004 | 1567 | |||
2005 | 1568 | if (!self) { | ||
2006 | 1569 | XTExceptionRec e; | ||
2007 | 1570 | |||
2008 | 1571 | if (!(self = xt_create_thread(thread_name, FALSE, TRUE, &e))) { | ||
2009 | 1572 | *err = xt_ha_pbxt_to_mysql_error(e.e_xt_err); | ||
2010 | 1573 | xt_log_exception(NULL, &e, XT_LOG_DEFAULT); | ||
2011 | 1574 | return NULL; | ||
2012 | 1575 | } | ||
2013 | 1576 | *temp_thread |= 1; | ||
2014 | 1577 | } | ||
2015 | 1578 | |||
2016 | 1579 | xt_xres_wait_for_recovery(self, XT_RECOVER_DONE); | ||
2017 | 1580 | |||
2018 | 1581 | try_(a) { | ||
2019 | 1582 | xt_open_database(self, mysql_real_data_home, TRUE); | ||
2020 | 1583 | } | ||
2021 | 1584 | catch_(a) { | ||
2022 | 1585 | *err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); | ||
2023 | 1586 | if ((*temp_thread & 1)) | ||
2024 | 1587 | xt_free_thread(self); | ||
2025 | 1588 | if (*temp_thread & 2) | ||
2026 | 1589 | myxt_destroy_thread(thd, FALSE); | ||
2027 | 1590 | self = NULL; | ||
2028 | 1591 | } | ||
2029 | 1592 | cont_(a); | ||
2030 | 1593 | |||
2031 | 1594 | *ret_thd = thd; | ||
2032 | 1595 | return self; | ||
2033 | 1596 | } | ||
2034 | 1597 | |||
2035 | 1598 | static void ha_temp_close_database(XTThreadPtr self, THD *thd, int temp_thread) | ||
2036 | 1599 | { | ||
2037 | 1600 | xt_unuse_database(self, self); | ||
2038 | 1601 | if (temp_thread & 1) | ||
2039 | 1602 | xt_free_thread(self); | ||
2040 | 1603 | if (temp_thread & 2) | ||
2041 | 1604 | myxt_destroy_thread(thd, TRUE); | ||
2042 | 1605 | } | ||
2043 | 1606 | |||
2044 | 1607 | /* Return all prepared transactions, found during recovery. | ||
2045 | 1608 | * This function returns a count. If len is returned, the | ||
2046 | 1609 | * function will be called again. | ||
2047 | 1610 | */ | ||
2048 | 1611 | static int pbxt_recover(handlerton *hton, XID *xid_list, uint len) | ||
2049 | 1612 | { | ||
2050 | 1613 | xtBool temp_thread; | ||
2051 | 1614 | XTThreadPtr self; | ||
2052 | 1615 | XTDatabaseHPtr db; | ||
2053 | 1616 | uint count = 0; | ||
2054 | 1617 | XTXactPreparePtr xap; | ||
2055 | 1618 | int err; | ||
2056 | 1619 | THD *thd; | ||
2057 | 1620 | |||
2058 | 1621 | if (!(self = ha_temp_open_global_database(hton, &thd, &temp_thread, "TempForRecover", &err))) | ||
2059 | 1622 | return 0; | ||
2060 | 1623 | |||
2061 | 1624 | db = self->st_database; | ||
2062 | 1625 | |||
2063 | 1626 | for (count=0; count<len; count++) { | ||
2064 | 1627 | xap = xt_xn_enum_xa_data(db, &pbxt_xa_enum); | ||
2065 | 1628 | if (!xap) | ||
2066 | 1629 | break; | ||
2067 | 1630 | memcpy(&xid_list[count], xap->xp_xa_data, xap->xp_data_len); | ||
2068 | 1631 | } | ||
2069 | 1632 | |||
2070 | 1633 | ha_temp_close_database(self, thd, temp_thread); | ||
2071 | 1634 | return (int) count; | ||
2072 | 1635 | } | ||
2073 | 1636 | |||
2074 | 1637 | static int pbxt_commit_by_xid(handlerton *hton, XID *xid) | ||
2075 | 1638 | { | ||
2076 | 1639 | xtBool temp_thread; | ||
2077 | 1640 | XTThreadPtr self; | ||
2078 | 1641 | XTDatabaseHPtr db; | ||
2079 | 1642 | int err = 0; | ||
2080 | 1643 | XTXactPreparePtr xap; | ||
2081 | 1644 | THD *thd; | ||
2082 | 1645 | |||
2083 | 1646 | XT_TRACE_CALL(); | ||
2084 | 1647 | |||
2085 | 1648 | if (!(self = ha_temp_open_global_database(hton, &thd, &temp_thread, "TempForCommitXA", &err))) | ||
2086 | 1649 | return err; | ||
2087 | 1650 | db = self->st_database; | ||
2088 | 1651 | |||
2089 | 1652 | if ((xap = xt_xn_find_xa_data(db, xid->length(), (xtWord1 *) xid, TRUE, self))) { | ||
2090 | 1653 | if ((self->st_xact_data = xt_xn_get_xact(db, xap->xp_xact_id, self))) { | ||
2091 | 1654 | self->st_xact_data->xd_flags &= ~XT_XN_XAC_PREPARED; // Prepared transactions cannot be swept! | ||
2092 | 1655 | if (!xt_xn_commit(self)) | ||
2093 | 1656 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); | ||
2094 | 1657 | } | ||
2095 | 1658 | xt_xn_delete_xa_data(db, xap, TRUE, self); | ||
2096 | 1659 | } | ||
2097 | 1660 | |||
2098 | 1661 | ha_temp_close_database(self, thd, temp_thread); | ||
2099 | 1662 | return 0; | ||
2100 | 1663 | } | ||
2101 | 1664 | |||
2102 | 1665 | static int pbxt_rollback_by_xid(handlerton *hton, XID *xid) | ||
2103 | 1666 | { | ||
2104 | 1667 | int temp_thread; | ||
2105 | 1668 | XTThreadPtr self; | ||
2106 | 1669 | XTDatabaseHPtr db; | ||
2107 | 1670 | int err = 0; | ||
2108 | 1671 | XTXactPreparePtr xap; | ||
2109 | 1672 | THD *thd; | ||
2110 | 1673 | |||
2111 | 1674 | XT_TRACE_CALL(); | ||
2112 | 1675 | |||
2113 | 1676 | if (!(self = ha_temp_open_global_database(hton, &thd, &temp_thread, "TempForRollbackXA", &err))) | ||
2114 | 1677 | return err; | ||
2115 | 1678 | db = self->st_database; | ||
2116 | 1679 | |||
2117 | 1680 | if ((xap = xt_xn_find_xa_data(db, xid->length(), (xtWord1 *) xid, TRUE, self))) { | ||
2118 | 1681 | if ((self->st_xact_data = xt_xn_get_xact(db, xap->xp_xact_id, self))) { | ||
2119 | 1682 | self->st_xact_data->xd_flags &= ~XT_XN_XAC_PREPARED; // Prepared transactions cannot be swept! | ||
2120 | 1683 | if (!xt_xn_rollback(self)) | ||
2121 | 1684 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); | ||
2122 | 1685 | } | ||
2123 | 1686 | xt_xn_delete_xa_data(db, xap, TRUE, self); | ||
2124 | 1687 | } | ||
2125 | 1688 | |||
2126 | 1689 | ha_temp_close_database(self, thd, temp_thread); | ||
2127 | 1690 | return 0; | ||
2128 | 1691 | } | ||
2129 | 1692 | |||
2130 | 1693 | #endif | ||
2131 | 1694 | |||
2132 | 1695 | /* | ||
2133 | 1696 | * ----------------------------------------------------------------------- | ||
2134 | 1449 | * HANDLER LOCKING FUNCTIONS | 1697 | * HANDLER LOCKING FUNCTIONS |
2135 | 1450 | * | 1698 | * |
2136 | 1451 | * These functions are used get a lock on all handles of a particular table. | 1699 | * These functions are used get a lock on all handles of a particular table. |
2137 | @@ -1497,7 +1745,7 @@ | |||
2138 | 1497 | ha_pbxt *handler; | 1745 | ha_pbxt *handler; |
2139 | 1498 | time_t end_time = time(NULL) + XT_SHARE_LOCK_TIMEOUT / 1000; | 1746 | time_t end_time = time(NULL) + XT_SHARE_LOCK_TIMEOUT / 1000; |
2140 | 1499 | 1747 | ||
2142 | 1500 | XT_PRINT1(self, "ha_aquire_exclusive_use %s PBXT X lock\n", share->sh_table_path->ps_path); | 1748 | XT_PRINT1(self, "ha_aquire_exclusive_use (%s) PBXT X lock\n", share->sh_table_path->ps_path); |
2143 | 1501 | /* GOTCHA: It is possible to hang here, if you hold | 1749 | /* GOTCHA: It is possible to hang here, if you hold |
2144 | 1502 | * onto the sh_ex_mutex lock, before we really | 1750 | * onto the sh_ex_mutex lock, before we really |
2145 | 1503 | * have the exclusive lock (i.e. before all | 1751 | * have the exclusive lock (i.e. before all |
2146 | @@ -1578,7 +1826,7 @@ | |||
2147 | 1578 | static void ha_release_exclusive_use(XTThreadPtr XT_UNUSED(self), XTSharePtr share) | 1826 | static void ha_release_exclusive_use(XTThreadPtr XT_UNUSED(self), XTSharePtr share) |
2148 | 1579 | #endif | 1827 | #endif |
2149 | 1580 | { | 1828 | { |
2151 | 1581 | XT_PRINT1(self, "ha_release_exclusive_use %s PBXT X UNLOCK\n", share->sh_table_path->ps_path); | 1829 | XT_PRINT1(self, "ha_release_exclusive_use (%s) PBXT X UNLOCK\n", share->sh_table_path->ps_path); |
2152 | 1582 | xt_lock_mutex_ns((xt_mutex_type *) share->sh_ex_mutex); | 1830 | xt_lock_mutex_ns((xt_mutex_type *) share->sh_ex_mutex); |
2153 | 1583 | share->sh_table_lock = FALSE; | 1831 | share->sh_table_lock = FALSE; |
2154 | 1584 | xt_broadcast_cond_ns((xt_cond_type *) share->sh_ex_cond); | 1832 | xt_broadcast_cond_ns((xt_cond_type *) share->sh_ex_cond); |
2155 | @@ -1589,7 +1837,7 @@ | |||
2156 | 1589 | { | 1837 | { |
2157 | 1590 | time_t end_time = time(NULL) + XT_SHARE_LOCK_TIMEOUT / 1000; | 1838 | time_t end_time = time(NULL) + XT_SHARE_LOCK_TIMEOUT / 1000; |
2158 | 1591 | 1839 | ||
2160 | 1592 | XT_PRINT1(xt_get_self(), "ha_wait_for_shared_use %s share lock wait...\n", share->sh_table_path->ps_path); | 1840 | XT_PRINT1(xt_get_self(), "ha_wait_for_shared_use (%s) share lock wait...\n", share->sh_table_path->ps_path); |
2161 | 1593 | mine->pb_ex_in_use = 0; | 1841 | mine->pb_ex_in_use = 0; |
2162 | 1594 | xt_lock_mutex_ns((xt_mutex_type *) share->sh_ex_mutex); | 1842 | xt_lock_mutex_ns((xt_mutex_type *) share->sh_ex_mutex); |
2163 | 1595 | while (share->sh_table_lock) { | 1843 | while (share->sh_table_lock) { |
2164 | @@ -1667,14 +1915,38 @@ | |||
2165 | 1667 | * | 1915 | * |
2166 | 1668 | */ | 1916 | */ |
2167 | 1669 | 1917 | ||
2169 | 1670 | int pbxt_statistics_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) | 1918 | static int pbxt_statistics_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) |
2170 | 1671 | { | 1919 | { |
2172 | 1672 | XTThreadPtr self; | 1920 | XTThreadPtr self = NULL; |
2173 | 1673 | int err = 0; | 1921 | int err = 0; |
2174 | 1674 | 1922 | ||
2175 | 1923 | if (!pbxt_hton) { | ||
2176 | 1924 | /* Can't do if PBXT is not loaded! */ | ||
2177 | 1925 | XTExceptionRec e; | ||
2178 | 1926 | |||
2179 | 1927 | xt_exception_xterr(&e, XT_CONTEXT, XT_ERR_PBXT_NOT_INSTALLED); | ||
2180 | 1928 | xt_log_exception(NULL, &e, XT_LOG_DEFAULT); | ||
2181 | 1929 | /* Just return an empty set: */ | ||
2182 | 1930 | return 0; | ||
2183 | 1931 | } | ||
2184 | 1932 | |||
2185 | 1675 | if (!(self = ha_set_current_thread(thd, &err))) | 1933 | if (!(self = ha_set_current_thread(thd, &err))) |
2186 | 1676 | return xt_ha_pbxt_to_mysql_error(err); | 1934 | return xt_ha_pbxt_to_mysql_error(err); |
2187 | 1935 | |||
2188 | 1936 | |||
2189 | 1677 | try_(a) { | 1937 | try_(a) { |
2190 | 1938 | /* If the thread has no open database, and the global | ||
2191 | 1939 | * database is already open, then open | ||
2192 | 1940 | * the database. Otherwise the statement will be | ||
2193 | 1941 | * executed without an open database, which means | ||
2194 | 1942 | * that the related statistics will be missing. | ||
2195 | 1943 | * | ||
2196 | 1944 | * This includes all background threads. | ||
2197 | 1945 | */ | ||
2198 | 1946 | if (!self->st_database && pbxt_database) { | ||
2199 | 1947 | xt_ha_open_database_of_table(self, (XTPathStrPtr) NULL); | ||
2200 | 1948 | } | ||
2201 | 1949 | |||
2202 | 1678 | err = myxt_statistics_fill_table(self, thd, tables, cond, system_charset_info); | 1950 | err = myxt_statistics_fill_table(self, thd, tables, cond, system_charset_info); |
2203 | 1679 | } | 1951 | } |
2204 | 1680 | catch_(a) { | 1952 | catch_(a) { |
2205 | @@ -1684,6 +1956,24 @@ | |||
2206 | 1684 | return err; | 1956 | return err; |
2207 | 1685 | } | 1957 | } |
2208 | 1686 | 1958 | ||
2209 | 1959 | #ifdef DRIZZLED | ||
2210 | 1960 | ColumnInfo pbxt_statistics_fields_info[]= | ||
2211 | 1961 | { | ||
2212 | 1962 | ColumnInfo("ID", 4, MYSQL_TYPE_LONG, 0, 0, "The ID of the statistic", SKIP_OPEN_TABLE), | ||
2213 | 1963 | ColumnInfo("Name", 40, MYSQL_TYPE_STRING, 0, 0, "The name of the statistic", SKIP_OPEN_TABLE), | ||
2214 | 1964 | ColumnInfo("Value", 8, MYSQL_TYPE_LONGLONG, 0, 0, "The accumulated value", SKIP_OPEN_TABLE), | ||
2215 | 1965 | ColumnInfo() | ||
2216 | 1966 | }; | ||
2217 | 1967 | |||
2218 | 1968 | class PBXTStatisticsMethods : public InfoSchemaMethods | ||
2219 | 1969 | { | ||
2220 | 1970 | public: | ||
2221 | 1971 | int fillTable(Session *session, TableList *tables, COND *cond) | ||
2222 | 1972 | { | ||
2223 | 1973 | return pbxt_statistics_fill_table(session, tables, cond); | ||
2224 | 1974 | } | ||
2225 | 1975 | }; | ||
2226 | 1976 | #else | ||
2227 | 1687 | ST_FIELD_INFO pbxt_statistics_fields_info[]= | 1977 | ST_FIELD_INFO pbxt_statistics_fields_info[]= |
2228 | 1688 | { | 1978 | { |
2229 | 1689 | { "ID", 4, MYSQL_TYPE_LONG, 0, 0, "The ID of the statistic", SKIP_OPEN_TABLE}, | 1979 | { "ID", 4, MYSQL_TYPE_LONG, 0, 0, "The ID of the statistic", SKIP_OPEN_TABLE}, |
2230 | @@ -1691,24 +1981,28 @@ | |||
2231 | 1691 | { "Value", 8, MYSQL_TYPE_LONGLONG, 0, 0, "The accumulated value", SKIP_OPEN_TABLE}, | 1981 | { "Value", 8, MYSQL_TYPE_LONGLONG, 0, 0, "The accumulated value", SKIP_OPEN_TABLE}, |
2232 | 1692 | { 0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} | 1982 | { 0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} |
2233 | 1693 | }; | 1983 | }; |
2234 | 1984 | #endif | ||
2235 | 1694 | 1985 | ||
2236 | 1695 | #ifdef DRIZZLED | 1986 | #ifdef DRIZZLED |
2237 | 1696 | static InfoSchemaTable *pbxt_statistics_table; | 1987 | static InfoSchemaTable *pbxt_statistics_table; |
2240 | 1697 | 1988 | static PBXTStatisticsMethods pbxt_statistics_methods; | |
2241 | 1698 | int pbxt_init_statitics(PluginRegistry ®istry) | 1989 | static int pbxt_init_statistics(Registry ®istry) |
2242 | 1699 | #else | 1990 | #else |
2244 | 1700 | int pbxt_init_statitics(void *p) | 1991 | static int pbxt_init_statistics(void *p) |
2245 | 1701 | #endif | 1992 | #endif |
2246 | 1702 | { | 1993 | { |
2247 | 1703 | #ifdef DRIZZLED | 1994 | #ifdef DRIZZLED |
2250 | 1704 | pbxt_statistics_table = (InfoSchemaTable *)xt_calloc_ns(sizeof(InfoSchemaTable)); | 1995 | //pbxt_statistics_table = (InfoSchemaTable *)xt_calloc_ns(sizeof(InfoSchemaTable)); |
2251 | 1705 | pbxt_statistics_table->table_name= "PBXT_STATISTICS"; | 1996 | //pbxt_statistics_table->table_name= "PBXT_STATISTICS"; |
2252 | 1997 | pbxt_statistics_table = new InfoSchemaTable("PBXT_STATISTICS"); | ||
2253 | 1998 | pbxt_statistics_table->setColumnInfo(pbxt_statistics_fields_info); | ||
2254 | 1999 | pbxt_statistics_table->setInfoSchemaMethods(&pbxt_statistics_methods); | ||
2255 | 1706 | registry.add(pbxt_statistics_table); | 2000 | registry.add(pbxt_statistics_table); |
2256 | 1707 | #else | 2001 | #else |
2257 | 1708 | ST_SCHEMA_TABLE *pbxt_statistics_table = (ST_SCHEMA_TABLE *) p; | 2002 | ST_SCHEMA_TABLE *pbxt_statistics_table = (ST_SCHEMA_TABLE *) p; |
2258 | 1709 | #endif | ||
2259 | 1710 | pbxt_statistics_table->fields_info = pbxt_statistics_fields_info; | 2003 | pbxt_statistics_table->fields_info = pbxt_statistics_fields_info; |
2260 | 1711 | pbxt_statistics_table->fill_table = pbxt_statistics_fill_table; | 2004 | pbxt_statistics_table->fill_table = pbxt_statistics_fill_table; |
2261 | 2005 | #endif | ||
2262 | 1712 | 2006 | ||
2263 | 1713 | #if defined(XT_WIN) && defined(XT_COREDUMP) | 2007 | #if defined(XT_WIN) && defined(XT_COREDUMP) |
2264 | 1714 | void register_crash_filter(); | 2008 | void register_crash_filter(); |
2265 | @@ -1721,14 +2015,14 @@ | |||
2266 | 1721 | } | 2015 | } |
2267 | 1722 | 2016 | ||
2268 | 1723 | #ifdef DRIZZLED | 2017 | #ifdef DRIZZLED |
2270 | 1724 | int pbxt_exit_statitics(PluginRegistry ®istry) | 2018 | static int pbxt_exit_statistics(Registry ®istry) |
2271 | 1725 | #else | 2019 | #else |
2273 | 1726 | int pbxt_exit_statitics(void *XT_UNUSED(p)) | 2020 | static int pbxt_exit_statistics(void *XT_UNUSED(p)) |
2274 | 1727 | #endif | 2021 | #endif |
2275 | 1728 | { | 2022 | { |
2276 | 1729 | #ifdef DRIZZLED | 2023 | #ifdef DRIZZLED |
2277 | 1730 | registry.remove(pbxt_statistics_table); | 2024 | registry.remove(pbxt_statistics_table); |
2279 | 1731 | xt_free_ns(pbxt_statistics_table); | 2025 | delete pbxt_statistics_table; |
2280 | 1732 | #endif | 2026 | #endif |
2281 | 1733 | return(0); | 2027 | return(0); |
2282 | 1734 | } | 2028 | } |
2283 | @@ -1758,7 +2052,11 @@ | |||
2284 | 1758 | * exist for the storage engine. This is also used by the default rename_table and | 2052 | * exist for the storage engine. This is also used by the default rename_table and |
2285 | 1759 | * delete_table method in handler.cc. | 2053 | * delete_table method in handler.cc. |
2286 | 1760 | */ | 2054 | */ |
2287 | 2055 | #ifdef DRIZZLED | ||
2288 | 2056 | const char **PBXTStorageEngine::bas_ext() const | ||
2289 | 2057 | #else | ||
2290 | 1761 | const char **ha_pbxt::bas_ext() const | 2058 | const char **ha_pbxt::bas_ext() const |
2291 | 2059 | #endif | ||
2292 | 1762 | { | 2060 | { |
2293 | 1763 | return pbxt_extensions; | 2061 | return pbxt_extensions; |
2294 | 1764 | } | 2062 | } |
2295 | @@ -1800,11 +2098,13 @@ | |||
2296 | 1800 | * purposes! | 2098 | * purposes! |
2297 | 1801 | HA_NOT_EXACT_COUNT | | 2099 | HA_NOT_EXACT_COUNT | |
2298 | 1802 | */ | 2100 | */ |
2299 | 2101 | #ifndef DRIZZLED | ||
2300 | 1803 | /* | 2102 | /* |
2301 | 1804 | * This basically means we have a file with the name of | 2103 | * This basically means we have a file with the name of |
2302 | 1805 | * database table (which we do). | 2104 | * database table (which we do). |
2303 | 1806 | */ | 2105 | */ |
2304 | 1807 | HA_FILE_BASED | | 2106 | HA_FILE_BASED | |
2305 | 2107 | #endif | ||
2306 | 1808 | /* | 2108 | /* |
2307 | 1809 | * Not sure what this does (but MyISAM and InnoDB have it)?! | 2109 | * Not sure what this does (but MyISAM and InnoDB have it)?! |
2308 | 1810 | * Could it mean that we support the handler functions. | 2110 | * Could it mean that we support the handler functions. |
2309 | @@ -1971,7 +2271,7 @@ | |||
2310 | 1971 | if (!(self = ha_set_current_thread(thd, &err))) | 2271 | if (!(self = ha_set_current_thread(thd, &err))) |
2311 | 1972 | return xt_ha_pbxt_to_mysql_error(err); | 2272 | return xt_ha_pbxt_to_mysql_error(err); |
2312 | 1973 | 2273 | ||
2314 | 1974 | XT_PRINT1(self, "ha_pbxt::open %s\n", table_path); | 2274 | XT_PRINT1(self, "open (%s)\n", table_path); |
2315 | 1975 | 2275 | ||
2316 | 1976 | pb_ex_in_use = 1; | 2276 | pb_ex_in_use = 1; |
2317 | 1977 | try_(a) { | 2277 | try_(a) { |
2318 | @@ -2049,7 +2349,7 @@ | |||
2319 | 2049 | } | 2349 | } |
2320 | 2050 | } | 2350 | } |
2321 | 2051 | 2351 | ||
2323 | 2052 | XT_PRINT1(self, "ha_pbxt::close %s\n", pb_share && pb_share->sh_table_path->ps_path ? pb_share->sh_table_path->ps_path : "unknown"); | 2352 | XT_PRINT1(self, "close (%s)\n", pb_share && pb_share->sh_table_path->ps_path ? pb_share->sh_table_path->ps_path : "unknown"); |
2324 | 2053 | 2353 | ||
2325 | 2054 | if (self) { | 2354 | if (self) { |
2326 | 2055 | try_(a) { | 2355 | try_(a) { |
2327 | @@ -2125,9 +2425,10 @@ | |||
2328 | 2125 | if (!TS(table)->next_number_key_offset) { | 2425 | if (!TS(table)->next_number_key_offset) { |
2329 | 2126 | // Autoincrement at key-start | 2426 | // Autoincrement at key-start |
2330 | 2127 | err = index_last(table->record[1]); | 2427 | err = index_last(table->record[1]); |
2332 | 2128 | if (!err) | 2428 | if (!err && !table->next_number_field->is_null(TS(table)->rec_buff_length)) { |
2333 | 2129 | /* {PRE-INC} */ | 2429 | /* {PRE-INC} */ |
2334 | 2130 | nr = (xtWord8) table->next_number_field->val_int_offset(TS(table)->rec_buff_length); | 2430 | nr = (xtWord8) table->next_number_field->val_int_offset(TS(table)->rec_buff_length); |
2335 | 2431 | } | ||
2336 | 2131 | } | 2432 | } |
2337 | 2132 | else { | 2433 | else { |
2338 | 2133 | /* Do an index scan to find the largest value! */ | 2434 | /* Do an index scan to find the largest value! */ |
2339 | @@ -2180,8 +2481,10 @@ | |||
2340 | 2180 | table->next_number_field = tmp_fie; | 2481 | table->next_number_field = tmp_fie; |
2341 | 2181 | table->in_use = tmp_thd; | 2482 | table->in_use = tmp_thd; |
2342 | 2182 | 2483 | ||
2344 | 2183 | if (xn_started) | 2484 | if (xn_started) { |
2345 | 2485 | XT_PRINT0(self, "xt_xn_commit in init_auto_increment\n"); | ||
2346 | 2184 | xt_xn_commit(self); | 2486 | xt_xn_commit(self); |
2347 | 2487 | } | ||
2348 | 2185 | } | 2488 | } |
2349 | 2186 | xt_spinlock_unlock(&tab->tab_ainc_lock); | 2489 | xt_spinlock_unlock(&tab->tab_ainc_lock); |
2350 | 2187 | } | 2490 | } |
2351 | @@ -2228,13 +2531,13 @@ | |||
2352 | 2228 | * insert into t1 values (-1); | 2531 | * insert into t1 values (-1); |
2353 | 2229 | * insert into t1 values (NULL); | 2532 | * insert into t1 values (NULL); |
2354 | 2230 | */ | 2533 | */ |
2356 | 2231 | void ha_pbxt::set_auto_increment(Field *nr) | 2534 | xtPublic void ha_set_auto_increment(XTOpenTablePtr ot, Field *nr) |
2357 | 2232 | { | 2535 | { |
2358 | 2233 | register XTTableHPtr tab; | 2536 | register XTTableHPtr tab; |
2359 | 2234 | MX_ULONGLONG_T nr_int_val; | 2537 | MX_ULONGLONG_T nr_int_val; |
2360 | 2235 | 2538 | ||
2361 | 2236 | nr_int_val = nr->val_int(); | 2539 | nr_int_val = nr->val_int(); |
2363 | 2237 | tab = pb_open_tab->ot_table; | 2540 | tab = ot->ot_table; |
2364 | 2238 | 2541 | ||
2365 | 2239 | if (nr->cmp((const unsigned char *)&tab->tab_auto_inc) > 0) { | 2542 | if (nr->cmp((const unsigned char *)&tab->tab_auto_inc) > 0) { |
2366 | 2240 | xt_spinlock_lock(&tab->tab_ainc_lock); | 2543 | xt_spinlock_lock(&tab->tab_ainc_lock); |
2367 | @@ -2260,9 +2563,9 @@ | |||
2368 | 2260 | #else | 2563 | #else |
2369 | 2261 | tab->tab_dic.dic_min_auto_inc = nr_int_val + 100; | 2564 | tab->tab_dic.dic_min_auto_inc = nr_int_val + 100; |
2370 | 2262 | #endif | 2565 | #endif |
2374 | 2263 | pb_open_tab->ot_thread = xt_get_self(); | 2566 | ot->ot_thread = xt_get_self(); |
2375 | 2264 | if (!xt_tab_write_min_auto_inc(pb_open_tab)) | 2567 | if (!xt_tab_write_min_auto_inc(ot)) |
2376 | 2265 | xt_log_and_clear_exception(pb_open_tab->ot_thread); | 2568 | xt_log_and_clear_exception(ot->ot_thread); |
2377 | 2266 | } | 2569 | } |
2378 | 2267 | } | 2570 | } |
2379 | 2268 | } | 2571 | } |
2380 | @@ -2305,7 +2608,7 @@ | |||
2381 | 2305 | 2608 | ||
2382 | 2306 | ASSERT_NS(pb_ex_in_use); | 2609 | ASSERT_NS(pb_ex_in_use); |
2383 | 2307 | 2610 | ||
2385 | 2308 | XT_PRINT1(pb_open_tab->ot_thread, "ha_pbxt::write_row %s\n", pb_share->sh_table_path->ps_path); | 2611 | XT_PRINT1(pb_open_tab->ot_thread, "write_row (%s)\n", pb_share->sh_table_path->ps_path); |
2386 | 2309 | XT_DISABLED_TRACE(("INSERT tx=%d val=%d\n", (int) pb_open_tab->ot_thread->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(&buf[1]))); | 2612 | XT_DISABLED_TRACE(("INSERT tx=%d val=%d\n", (int) pb_open_tab->ot_thread->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(&buf[1]))); |
2387 | 2310 | //statistic_increment(ha_write_count,&LOCK_status); | 2613 | //statistic_increment(ha_write_count,&LOCK_status); |
2388 | 2311 | #ifdef PBMS_ENABLED | 2614 | #ifdef PBMS_ENABLED |
2389 | @@ -2350,7 +2653,7 @@ | |||
2390 | 2350 | err = update_err; | 2653 | err = update_err; |
2391 | 2351 | goto done; | 2654 | goto done; |
2392 | 2352 | } | 2655 | } |
2394 | 2353 | set_auto_increment(table->next_number_field); | 2656 | ha_set_auto_increment(pb_open_tab, table->next_number_field); |
2395 | 2354 | } | 2657 | } |
2396 | 2355 | 2658 | ||
2397 | 2356 | if (!xt_tab_new_record(pb_open_tab, (xtWord1 *) buf)) { | 2659 | if (!xt_tab_new_record(pb_open_tab, (xtWord1 *) buf)) { |
2398 | @@ -2423,7 +2726,7 @@ | |||
2399 | 2423 | 2726 | ||
2400 | 2424 | ASSERT_NS(pb_ex_in_use); | 2727 | ASSERT_NS(pb_ex_in_use); |
2401 | 2425 | 2728 | ||
2403 | 2426 | XT_PRINT1(self, "ha_pbxt::update_row %s\n", pb_share->sh_table_path->ps_path); | 2729 | XT_PRINT1(self, "update_row (%s)\n", pb_share->sh_table_path->ps_path); |
2404 | 2427 | XT_DISABLED_TRACE(("UPDATE tx=%d val=%d\n", (int) self->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(&new_data[1]))); | 2730 | XT_DISABLED_TRACE(("UPDATE tx=%d val=%d\n", (int) self->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(&new_data[1]))); |
2405 | 2428 | //statistic_increment(ha_update_count,&LOCK_status); | 2731 | //statistic_increment(ha_update_count,&LOCK_status); |
2406 | 2429 | 2732 | ||
2407 | @@ -2472,7 +2775,7 @@ | |||
2408 | 2472 | 2775 | ||
2409 | 2473 | old_map = mx_tmp_use_all_columns(table, table->read_set); | 2776 | old_map = mx_tmp_use_all_columns(table, table->read_set); |
2410 | 2474 | nr = table->found_next_number_field->val_int(); | 2777 | nr = table->found_next_number_field->val_int(); |
2412 | 2475 | set_auto_increment(table->found_next_number_field); | 2778 | ha_set_auto_increment(pb_open_tab, table->found_next_number_field); |
2413 | 2476 | mx_tmp_restore_column_map(table, old_map); | 2779 | mx_tmp_restore_column_map(table, old_map); |
2414 | 2477 | } | 2780 | } |
2415 | 2478 | 2781 | ||
2416 | @@ -2504,7 +2807,7 @@ | |||
2417 | 2504 | 2807 | ||
2418 | 2505 | ASSERT_NS(pb_ex_in_use); | 2808 | ASSERT_NS(pb_ex_in_use); |
2419 | 2506 | 2809 | ||
2421 | 2507 | XT_PRINT1(pb_open_tab->ot_thread, "ha_pbxt::delete_row %s\n", pb_share->sh_table_path->ps_path); | 2810 | XT_PRINT1(pb_open_tab->ot_thread, "delete_row (%s)\n", pb_share->sh_table_path->ps_path); |
2422 | 2508 | XT_DISABLED_TRACE(("DELETE tx=%d val=%d\n", (int) pb_open_tab->ot_thread->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(&buf[1]))); | 2811 | XT_DISABLED_TRACE(("DELETE tx=%d val=%d\n", (int) pb_open_tab->ot_thread->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(&buf[1]))); |
2423 | 2509 | //statistic_increment(ha_delete_count,&LOCK_status); | 2812 | //statistic_increment(ha_delete_count,&LOCK_status); |
2424 | 2510 | 2813 | ||
2425 | @@ -2829,7 +3132,8 @@ | |||
2426 | 2829 | 3132 | ||
2427 | 2830 | int ha_pbxt::index_init(uint idx, bool XT_UNUSED(sorted)) | 3133 | int ha_pbxt::index_init(uint idx, bool XT_UNUSED(sorted)) |
2428 | 2831 | { | 3134 | { |
2430 | 2832 | XTIndexPtr ind; | 3135 | XTIndexPtr ind; |
2431 | 3136 | XTThreadPtr thread = pb_open_tab->ot_thread; | ||
2432 | 2833 | 3137 | ||
2433 | 2834 | /* select count(*) from smalltab_PBXT; | 3138 | /* select count(*) from smalltab_PBXT; |
2434 | 2835 | * ignores the error below, and continues to | 3139 | * ignores the error below, and continues to |
2435 | @@ -2851,6 +3155,15 @@ | |||
2436 | 2851 | 3155 | ||
2437 | 2852 | printf("index_init %s index %d cols req=%d/%d read_bits=%X write_bits=%X index_bits=%X\n", pb_open_tab->ot_table->tab_name->ps_path, (int) idx, pb_open_tab->ot_cols_req, pb_open_tab->ot_cols_req, (int) *table->read_set->bitmap, (int) *table->write_set->bitmap, (int) *ind->mi_col_map.bitmap); | 3156 | printf("index_init %s index %d cols req=%d/%d read_bits=%X write_bits=%X index_bits=%X\n", pb_open_tab->ot_table->tab_name->ps_path, (int) idx, pb_open_tab->ot_cols_req, pb_open_tab->ot_cols_req, (int) *table->read_set->bitmap, (int) *table->write_set->bitmap, (int) *ind->mi_col_map.bitmap); |
2438 | 2853 | #endif | 3157 | #endif |
2439 | 3158 | /* Start a statement based transaction as soon | ||
2440 | 3159 | * as a read is done for a modify type statement! | ||
2441 | 3160 | * Previously, this was done too late! | ||
2442 | 3161 | */ | ||
2443 | 3162 | if (!thread->st_stat_trans) { | ||
2444 | 3163 | trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); | ||
2445 | 3164 | XT_PRINT0(thread, "ha_pbxt::update_row trans_register_ha all=FALSE\n"); | ||
2446 | 3165 | thread->st_stat_trans = TRUE; | ||
2447 | 3166 | } | ||
2448 | 2854 | } | 3167 | } |
2449 | 2855 | else { | 3168 | else { |
2450 | 2856 | pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set); | 3169 | pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set); |
2451 | @@ -2901,7 +3214,7 @@ | |||
2452 | 2901 | #endif | 3214 | #endif |
2453 | 2902 | } | 3215 | } |
2454 | 2903 | 3216 | ||
2456 | 2904 | xt_xlog_check_long_writer(pb_open_tab->ot_thread); | 3217 | xt_xlog_check_long_writer(thread); |
2457 | 2905 | 3218 | ||
2458 | 2906 | pb_open_tab->ot_thread->st_statistics.st_scan_index++; | 3219 | pb_open_tab->ot_thread->st_statistics.st_scan_index++; |
2459 | 2907 | return 0; | 3220 | return 0; |
2460 | @@ -2911,7 +3224,7 @@ | |||
2461 | 2911 | { | 3224 | { |
2462 | 2912 | int err = 0; | 3225 | int err = 0; |
2463 | 2913 | 3226 | ||
2465 | 2914 | XT_TRACE_CALL(); | 3227 | XT_TRACE_METHOD(); |
2466 | 2915 | 3228 | ||
2467 | 2916 | XTThreadPtr thread = pb_open_tab->ot_thread; | 3229 | XTThreadPtr thread = pb_open_tab->ot_thread; |
2468 | 2917 | 3230 | ||
2469 | @@ -2991,7 +3304,7 @@ | |||
2470 | 2991 | 3304 | ||
2471 | 2992 | ASSERT_NS(pb_ex_in_use); | 3305 | ASSERT_NS(pb_ex_in_use); |
2472 | 2993 | 3306 | ||
2474 | 2994 | XT_PRINT1(pb_open_tab->ot_thread, "ha_pbxt::index_read_xt %s\n", pb_share->sh_table_path->ps_path); | 3307 | XT_PRINT1(pb_open_tab->ot_thread, "index_read_xt (%s)\n", pb_share->sh_table_path->ps_path); |
2475 | 2995 | XT_DISABLED_TRACE(("search tx=%d val=%d update=%d\n", (int) pb_open_tab->ot_thread->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(key), pb_modified)); | 3308 | XT_DISABLED_TRACE(("search tx=%d val=%d update=%d\n", (int) pb_open_tab->ot_thread->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(key), pb_modified)); |
2476 | 2996 | ind = (XTIndexPtr) pb_share->sh_dic_keys[idx]; | 3309 | ind = (XTIndexPtr) pb_share->sh_dic_keys[idx]; |
2477 | 2997 | 3310 | ||
2478 | @@ -3072,7 +3385,7 @@ | |||
2479 | 3072 | int err = 0; | 3385 | int err = 0; |
2480 | 3073 | XTIndexPtr ind; | 3386 | XTIndexPtr ind; |
2481 | 3074 | 3387 | ||
2483 | 3075 | XT_TRACE_CALL(); | 3388 | XT_TRACE_METHOD(); |
2484 | 3076 | //statistic_increment(ha_read_next_count,&LOCK_status); | 3389 | //statistic_increment(ha_read_next_count,&LOCK_status); |
2485 | 3077 | ASSERT_NS(pb_ex_in_use); | 3390 | ASSERT_NS(pb_ex_in_use); |
2486 | 3078 | 3391 | ||
2487 | @@ -3114,7 +3427,7 @@ | |||
2488 | 3114 | XTIndexPtr ind; | 3427 | XTIndexPtr ind; |
2489 | 3115 | XTIdxSearchKeyRec search_key; | 3428 | XTIdxSearchKeyRec search_key; |
2490 | 3116 | 3429 | ||
2492 | 3117 | XT_TRACE_CALL(); | 3430 | XT_TRACE_METHOD(); |
2493 | 3118 | //statistic_increment(ha_read_next_count,&LOCK_status); | 3431 | //statistic_increment(ha_read_next_count,&LOCK_status); |
2494 | 3119 | ASSERT_NS(pb_ex_in_use); | 3432 | ASSERT_NS(pb_ex_in_use); |
2495 | 3120 | 3433 | ||
2496 | @@ -3154,7 +3467,7 @@ | |||
2497 | 3154 | int err = 0; | 3467 | int err = 0; |
2498 | 3155 | XTIndexPtr ind; | 3468 | XTIndexPtr ind; |
2499 | 3156 | 3469 | ||
2501 | 3157 | XT_TRACE_CALL(); | 3470 | XT_TRACE_METHOD(); |
2502 | 3158 | //statistic_increment(ha_read_prev_count,&LOCK_status); | 3471 | //statistic_increment(ha_read_prev_count,&LOCK_status); |
2503 | 3159 | ASSERT_NS(pb_ex_in_use); | 3472 | ASSERT_NS(pb_ex_in_use); |
2504 | 3160 | 3473 | ||
2505 | @@ -3188,7 +3501,7 @@ | |||
2506 | 3188 | XTIndexPtr ind; | 3501 | XTIndexPtr ind; |
2507 | 3189 | XTIdxSearchKeyRec search_key; | 3502 | XTIdxSearchKeyRec search_key; |
2508 | 3190 | 3503 | ||
2510 | 3191 | XT_TRACE_CALL(); | 3504 | XT_TRACE_METHOD(); |
2511 | 3192 | //statistic_increment(ha_read_first_count,&LOCK_status); | 3505 | //statistic_increment(ha_read_first_count,&LOCK_status); |
2512 | 3193 | ASSERT_NS(pb_ex_in_use); | 3506 | ASSERT_NS(pb_ex_in_use); |
2513 | 3194 | 3507 | ||
2514 | @@ -3228,7 +3541,7 @@ | |||
2515 | 3228 | XTIndexPtr ind; | 3541 | XTIndexPtr ind; |
2516 | 3229 | XTIdxSearchKeyRec search_key; | 3542 | XTIdxSearchKeyRec search_key; |
2517 | 3230 | 3543 | ||
2519 | 3231 | XT_TRACE_CALL(); | 3544 | XT_TRACE_METHOD(); |
2520 | 3232 | //statistic_increment(ha_read_last_count,&LOCK_status); | 3545 | //statistic_increment(ha_read_last_count,&LOCK_status); |
2521 | 3233 | ASSERT_NS(pb_ex_in_use); | 3546 | ASSERT_NS(pb_ex_in_use); |
2522 | 3234 | 3547 | ||
2523 | @@ -3275,10 +3588,11 @@ | |||
2524 | 3275 | */ | 3588 | */ |
2525 | 3276 | int ha_pbxt::rnd_init(bool scan) | 3589 | int ha_pbxt::rnd_init(bool scan) |
2526 | 3277 | { | 3590 | { |
2528 | 3278 | int err = 0; | 3591 | int err = 0; |
2529 | 3592 | XTThreadPtr thread = pb_open_tab->ot_thread; | ||
2530 | 3279 | 3593 | ||
2533 | 3280 | XT_PRINT1(pb_open_tab->ot_thread, "ha_pbxt::rnd_init %s\n", pb_share->sh_table_path->ps_path); | 3594 | XT_PRINT1(thread, "rnd_init (%s)\n", pb_share->sh_table_path->ps_path); |
2534 | 3281 | XT_DISABLED_TRACE(("seq scan tx=%d\n", (int) pb_open_tab->ot_thread->st_xact_data->xd_start_xn_id)); | 3595 | XT_DISABLED_TRACE(("seq scan tx=%d\n", (int) thread->st_xact_data->xd_start_xn_id)); |
2535 | 3282 | 3596 | ||
2536 | 3283 | /* Call xt_tab_seq_exit() to make sure the resources used by the previous | 3597 | /* Call xt_tab_seq_exit() to make sure the resources used by the previous |
2537 | 3284 | * scan are freed. In particular make sure cache page ref count is decremented. | 3598 | * scan are freed. In particular make sure cache page ref count is decremented. |
2538 | @@ -3296,8 +3610,18 @@ | |||
2539 | 3296 | xt_tab_seq_exit(pb_open_tab); | 3610 | xt_tab_seq_exit(pb_open_tab); |
2540 | 3297 | 3611 | ||
2541 | 3298 | /* The number of columns required: */ | 3612 | /* The number of columns required: */ |
2543 | 3299 | if (pb_open_tab->ot_is_modify) | 3613 | if (pb_open_tab->ot_is_modify) { |
2544 | 3300 | pb_open_tab->ot_cols_req = table->read_set->MX_BIT_SIZE(); | 3614 | pb_open_tab->ot_cols_req = table->read_set->MX_BIT_SIZE(); |
2545 | 3615 | /* Start a statement based transaction as soon | ||
2546 | 3616 | * as a read is done for a modify type statement! | ||
2547 | 3617 | * Previously, this was done too late! | ||
2548 | 3618 | */ | ||
2549 | 3619 | if (!thread->st_stat_trans) { | ||
2550 | 3620 | trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); | ||
2551 | 3621 | XT_PRINT0(thread, "ha_pbxt::update_row trans_register_ha all=FALSE\n"); | ||
2552 | 3622 | thread->st_stat_trans = TRUE; | ||
2553 | 3623 | } | ||
2554 | 3624 | } | ||
2555 | 3301 | else { | 3625 | else { |
2556 | 3302 | pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set); | 3626 | pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set); |
2557 | 3303 | 3627 | ||
2558 | @@ -3322,14 +3646,14 @@ | |||
2559 | 3322 | else | 3646 | else |
2560 | 3323 | xt_tab_seq_reset(pb_open_tab); | 3647 | xt_tab_seq_reset(pb_open_tab); |
2561 | 3324 | 3648 | ||
2563 | 3325 | xt_xlog_check_long_writer(pb_open_tab->ot_thread); | 3649 | xt_xlog_check_long_writer(thread); |
2564 | 3326 | 3650 | ||
2565 | 3327 | return err; | 3651 | return err; |
2566 | 3328 | } | 3652 | } |
2567 | 3329 | 3653 | ||
2568 | 3330 | int ha_pbxt::rnd_end() | 3654 | int ha_pbxt::rnd_end() |
2569 | 3331 | { | 3655 | { |
2571 | 3332 | XT_TRACE_CALL(); | 3656 | XT_TRACE_METHOD(); |
2572 | 3333 | 3657 | ||
2573 | 3334 | /* | 3658 | /* |
2574 | 3335 | * make permanent the lock for the last scanned row | 3659 | * make permanent the lock for the last scanned row |
2575 | @@ -3358,7 +3682,7 @@ | |||
2576 | 3358 | int err = 0; | 3682 | int err = 0; |
2577 | 3359 | xtBool eof; | 3683 | xtBool eof; |
2578 | 3360 | 3684 | ||
2580 | 3361 | XT_TRACE_CALL(); | 3685 | XT_TRACE_METHOD(); |
2581 | 3362 | ASSERT_NS(pb_ex_in_use); | 3686 | ASSERT_NS(pb_ex_in_use); |
2582 | 3363 | //statistic_increment(ha_read_rnd_next_count, &LOCK_status); | 3687 | //statistic_increment(ha_read_rnd_next_count, &LOCK_status); |
2583 | 3364 | xt_xlog_check_long_writer(pb_open_tab->ot_thread); | 3688 | xt_xlog_check_long_writer(pb_open_tab->ot_thread); |
2584 | @@ -3393,7 +3717,7 @@ | |||
2585 | 3393 | */ | 3717 | */ |
2586 | 3394 | void ha_pbxt::position(const byte *XT_UNUSED(record)) | 3718 | void ha_pbxt::position(const byte *XT_UNUSED(record)) |
2587 | 3395 | { | 3719 | { |
2589 | 3396 | XT_TRACE_CALL(); | 3720 | XT_TRACE_METHOD(); |
2590 | 3397 | ASSERT_NS(pb_ex_in_use); | 3721 | ASSERT_NS(pb_ex_in_use); |
2591 | 3398 | /* | 3722 | /* |
2592 | 3399 | * I changed this from using little endian to big endian. | 3723 | * I changed this from using little endian to big endian. |
2593 | @@ -3429,10 +3753,10 @@ | |||
2594 | 3429 | { | 3753 | { |
2595 | 3430 | int err = 0; | 3754 | int err = 0; |
2596 | 3431 | 3755 | ||
2598 | 3432 | XT_TRACE_CALL(); | 3756 | XT_TRACE_METHOD(); |
2599 | 3433 | ASSERT_NS(pb_ex_in_use); | 3757 | ASSERT_NS(pb_ex_in_use); |
2600 | 3434 | //statistic_increment(ha_read_rnd_count, &LOCK_status); | 3758 | //statistic_increment(ha_read_rnd_count, &LOCK_status); |
2602 | 3435 | XT_PRINT1(pb_open_tab->ot_thread, "ha_pbxt::rnd_pos %s\n", pb_share->sh_table_path->ps_path); | 3759 | XT_PRINT1(pb_open_tab->ot_thread, "rnd_pos (%s)\n", pb_share->sh_table_path->ps_path); |
2603 | 3436 | 3760 | ||
2604 | 3437 | pb_open_tab->ot_curr_rec_id = mi_uint4korr((xtWord1 *) pos); | 3761 | pb_open_tab->ot_curr_rec_id = mi_uint4korr((xtWord1 *) pos); |
2605 | 3438 | switch (xt_tab_dirty_read_record(pb_open_tab, (xtWord1 *) buf)) { | 3762 | switch (xt_tab_dirty_read_record(pb_open_tab, (xtWord1 *) buf)) { |
2606 | @@ -3509,7 +3833,7 @@ | |||
2607 | 3509 | XTOpenTablePtr ot; | 3833 | XTOpenTablePtr ot; |
2608 | 3510 | int in_use; | 3834 | int in_use; |
2609 | 3511 | 3835 | ||
2611 | 3512 | XT_TRACE_CALL(); | 3836 | XT_TRACE_METHOD(); |
2612 | 3513 | 3837 | ||
2613 | 3514 | if (!(in_use = pb_ex_in_use)) { | 3838 | if (!(in_use = pb_ex_in_use)) { |
2614 | 3515 | pb_ex_in_use = 1; | 3839 | pb_ex_in_use = 1; |
2615 | @@ -3535,7 +3859,7 @@ | |||
2616 | 3535 | stats.index_file_length = xt_ind_node_to_offset(ot->ot_table, ot->ot_table->tab_ind_eof); | 3859 | stats.index_file_length = xt_ind_node_to_offset(ot->ot_table, ot->ot_table->tab_ind_eof); |
2617 | 3536 | stats.delete_length = ot->ot_table->tab_rec_fnum * ot->ot_rec_size; | 3860 | stats.delete_length = ot->ot_table->tab_rec_fnum * ot->ot_rec_size; |
2618 | 3537 | //check_time = info.check_time; | 3861 | //check_time = info.check_time; |
2620 | 3538 | stats.mean_rec_length = ot->ot_rec_size; | 3862 | stats.mean_rec_length = (ulong) ot->ot_rec_size; |
2621 | 3539 | } | 3863 | } |
2622 | 3540 | 3864 | ||
2623 | 3541 | if (flag & HA_STATUS_CONST) { | 3865 | if (flag & HA_STATUS_CONST) { |
2624 | @@ -3551,7 +3875,9 @@ | |||
2625 | 3551 | stats.block_size = XT_INDEX_PAGE_SIZE; | 3875 | stats.block_size = XT_INDEX_PAGE_SIZE; |
2626 | 3552 | 3876 | ||
2627 | 3553 | if (share->tmp_table == NO_TMP_TABLE) | 3877 | if (share->tmp_table == NO_TMP_TABLE) |
2629 | 3554 | #if MYSQL_VERSION_ID > 60005 | 3878 | #ifdef DRIZZLED |
2630 | 3879 | #define WHICH_MUTEX mutex | ||
2631 | 3880 | #elif MYSQL_VERSION_ID >= 50404 | ||
2632 | 3555 | #define WHICH_MUTEX LOCK_ha_data | 3881 | #define WHICH_MUTEX LOCK_ha_data |
2633 | 3556 | #else | 3882 | #else |
2634 | 3557 | #define WHICH_MUTEX mutex | 3883 | #define WHICH_MUTEX mutex |
2635 | @@ -3559,19 +3885,15 @@ | |||
2636 | 3559 | 3885 | ||
2637 | 3560 | #ifdef SAFE_MUTEX | 3886 | #ifdef SAFE_MUTEX |
2638 | 3561 | 3887 | ||
2640 | 3562 | #if MYSQL_VERSION_ID < 60000 | 3888 | #if MYSQL_VERSION_ID < 50404 |
2641 | 3563 | #if MYSQL_VERSION_ID < 50123 | 3889 | #if MYSQL_VERSION_ID < 50123 |
2642 | 3564 | safe_mutex_lock(&share->mutex,__FILE__,__LINE__); | 3890 | safe_mutex_lock(&share->mutex,__FILE__,__LINE__); |
2643 | 3565 | #else | 3891 | #else |
2644 | 3566 | safe_mutex_lock(&share->mutex,0,__FILE__,__LINE__); | 3892 | safe_mutex_lock(&share->mutex,0,__FILE__,__LINE__); |
2645 | 3567 | #endif | 3893 | #endif |
2646 | 3568 | #else | 3894 | #else |
2647 | 3569 | #if MYSQL_VERSION_ID < 60004 | ||
2648 | 3570 | safe_mutex_lock(&share->mutex,__FILE__,__LINE__); | ||
2649 | 3571 | #else | ||
2650 | 3572 | safe_mutex_lock(&share->WHICH_MUTEX,0,__FILE__,__LINE__); | 3895 | safe_mutex_lock(&share->WHICH_MUTEX,0,__FILE__,__LINE__); |
2651 | 3573 | #endif | 3896 | #endif |
2652 | 3574 | #endif | ||
2653 | 3575 | 3897 | ||
2654 | 3576 | #else // SAFE_MUTEX | 3898 | #else // SAFE_MUTEX |
2655 | 3577 | 3899 | ||
2656 | @@ -3675,7 +3997,7 @@ | |||
2657 | 3675 | { | 3997 | { |
2658 | 3676 | int err = 0; | 3998 | int err = 0; |
2659 | 3677 | 3999 | ||
2661 | 3678 | XT_PRINT2(xt_get_self(), "ha_pbxt::extra %s operation=%d\n", pb_share->sh_table_path->ps_path, operation); | 4000 | XT_PRINT2(xt_get_self(), "ha_pbxt::extra (%s) operation=%d\n", pb_share->sh_table_path->ps_path, operation); |
2662 | 3679 | 4001 | ||
2663 | 3680 | switch (operation) { | 4002 | switch (operation) { |
2664 | 3681 | case HA_EXTRA_RESET_STATE: | 4003 | case HA_EXTRA_RESET_STATE: |
2665 | @@ -3771,14 +4093,14 @@ | |||
2666 | 3771 | */ | 4093 | */ |
2667 | 3772 | int ha_pbxt::reset(void) | 4094 | int ha_pbxt::reset(void) |
2668 | 3773 | { | 4095 | { |
2670 | 3774 | XT_TRACE_CALL(); | 4096 | XT_TRACE_METHOD(); |
2671 | 3775 | extra(HA_EXTRA_RESET_STATE); | 4097 | extra(HA_EXTRA_RESET_STATE); |
2672 | 3776 | XT_RETURN(0); | 4098 | XT_RETURN(0); |
2673 | 3777 | } | 4099 | } |
2674 | 3778 | 4100 | ||
2675 | 3779 | void ha_pbxt::unlock_row() | 4101 | void ha_pbxt::unlock_row() |
2676 | 3780 | { | 4102 | { |
2678 | 3781 | XT_TRACE_CALL(); | 4103 | XT_TRACE_METHOD(); |
2679 | 3782 | if (pb_open_tab) | 4104 | if (pb_open_tab) |
2680 | 3783 | pb_open_tab->ot_table->tab_locks.xt_remove_temp_lock(pb_open_tab, FALSE); | 4105 | pb_open_tab->ot_table->tab_locks.xt_remove_temp_lock(pb_open_tab, FALSE); |
2681 | 3784 | } | 4106 | } |
2682 | @@ -3802,7 +4124,7 @@ | |||
2683 | 3802 | XTDDTable *tab_def = NULL; | 4124 | XTDDTable *tab_def = NULL; |
2684 | 3803 | char path[PATH_MAX]; | 4125 | char path[PATH_MAX]; |
2685 | 3804 | 4126 | ||
2687 | 3805 | XT_TRACE_CALL(); | 4127 | XT_TRACE_METHOD(); |
2688 | 3806 | 4128 | ||
2689 | 3807 | if (thd_sql_command(thd) != SQLCOM_TRUNCATE) { | 4129 | if (thd_sql_command(thd) != SQLCOM_TRUNCATE) { |
2690 | 3808 | /* Just like InnoDB we only handle TRUNCATE TABLE | 4130 | /* Just like InnoDB we only handle TRUNCATE TABLE |
2691 | @@ -3906,7 +4228,7 @@ | |||
2692 | 3906 | xtXactID clean_xn_id = 0; | 4228 | xtXactID clean_xn_id = 0; |
2693 | 3907 | uint cnt = 10; | 4229 | uint cnt = 10; |
2694 | 3908 | 4230 | ||
2696 | 3909 | XT_TRACE_CALL(); | 4231 | XT_TRACE_METHOD(); |
2697 | 3910 | 4232 | ||
2698 | 3911 | if (!pb_open_tab) { | 4233 | if (!pb_open_tab) { |
2699 | 3912 | if ((err = reopen())) | 4234 | if ((err = reopen())) |
2700 | @@ -4056,7 +4378,7 @@ | |||
2701 | 4056 | ASSERT_NS(pb_ex_in_use); | 4378 | ASSERT_NS(pb_ex_in_use); |
2702 | 4057 | */ | 4379 | */ |
2703 | 4058 | 4380 | ||
2705 | 4059 | XT_PRINT1(self, "ha_pbxt::EXTERNAL_LOCK %s lock_type=UNLOCK\n", pb_share->sh_table_path->ps_path); | 4381 | XT_PRINT1(self, "EXTERNAL_LOCK (%s) lock_type=UNLOCK\n", pb_share->sh_table_path->ps_path); |
2706 | 4060 | 4382 | ||
2707 | 4061 | /* Make any temporary locks on this table permanent. | 4383 | /* Make any temporary locks on this table permanent. |
2708 | 4062 | * | 4384 | * |
2709 | @@ -4189,10 +4511,9 @@ | |||
2710 | 4189 | xt_broadcast_cond_ns((xt_cond_type *) pb_share->sh_ex_cond); | 4511 | xt_broadcast_cond_ns((xt_cond_type *) pb_share->sh_ex_cond); |
2711 | 4190 | } | 4512 | } |
2712 | 4191 | else { | 4513 | else { |
2714 | 4192 | XT_PRINT2(self, "ha_pbxt::EXTERNAL_LOCK %s lock_type=%d\n", pb_share->sh_table_path->ps_path, lock_type); | 4514 | XT_PRINT2(self, "ha_pbxt::EXTERNAL_LOCK (%s) lock_type=%d\n", pb_share->sh_table_path->ps_path, lock_type); |
2715 | 4193 | 4515 | ||
2716 | 4194 | if (pb_lock_table) { | 4516 | if (pb_lock_table) { |
2717 | 4195 | |||
2718 | 4196 | pb_ex_in_use = 1; | 4517 | pb_ex_in_use = 1; |
2719 | 4197 | try_(a) { | 4518 | try_(a) { |
2720 | 4198 | if (!pb_table_locked) | 4519 | if (!pb_table_locked) |
2721 | @@ -4243,14 +4564,18 @@ | |||
2722 | 4243 | if ((pb_open_tab->ot_for_update = (lock_type == F_WRLCK))) { | 4564 | if ((pb_open_tab->ot_for_update = (lock_type == F_WRLCK))) { |
2723 | 4244 | switch ((int) thd_sql_command(thd)) { | 4565 | switch ((int) thd_sql_command(thd)) { |
2724 | 4245 | case SQLCOM_DELETE: | 4566 | case SQLCOM_DELETE: |
2725 | 4567 | #ifndef DRIZZLED | ||
2726 | 4246 | case SQLCOM_DELETE_MULTI: | 4568 | case SQLCOM_DELETE_MULTI: |
2727 | 4569 | #endif | ||
2728 | 4247 | /* turn DELETE IGNORE into normal DELETE. The IGNORE option causes problems because | 4570 | /* turn DELETE IGNORE into normal DELETE. The IGNORE option causes problems because |
2729 | 4248 | * when a record is deleted we add an xlog record which we cannot "rollback" later | 4571 | * when a record is deleted we add an xlog record which we cannot "rollback" later |
2730 | 4249 | * when we find that an FK-constraint has failed. | 4572 | * when we find that an FK-constraint has failed. |
2731 | 4250 | */ | 4573 | */ |
2732 | 4251 | thd->lex->ignore = false; | 4574 | thd->lex->ignore = false; |
2733 | 4252 | case SQLCOM_UPDATE: | 4575 | case SQLCOM_UPDATE: |
2734 | 4576 | #ifndef DRIZZLED | ||
2735 | 4253 | case SQLCOM_UPDATE_MULTI: | 4577 | case SQLCOM_UPDATE_MULTI: |
2736 | 4578 | #endif | ||
2737 | 4254 | case SQLCOM_REPLACE: | 4579 | case SQLCOM_REPLACE: |
2738 | 4255 | case SQLCOM_REPLACE_SELECT: | 4580 | case SQLCOM_REPLACE_SELECT: |
2739 | 4256 | case SQLCOM_INSERT: | 4581 | case SQLCOM_INSERT: |
2740 | @@ -4265,7 +4590,9 @@ | |||
2741 | 4265 | case SQLCOM_DROP_TABLE: | 4590 | case SQLCOM_DROP_TABLE: |
2742 | 4266 | case SQLCOM_DROP_INDEX: | 4591 | case SQLCOM_DROP_INDEX: |
2743 | 4267 | case SQLCOM_LOAD: | 4592 | case SQLCOM_LOAD: |
2744 | 4593 | #ifndef DRIZZLED | ||
2745 | 4268 | case SQLCOM_REPAIR: | 4594 | case SQLCOM_REPAIR: |
2746 | 4595 | #endif | ||
2747 | 4269 | case SQLCOM_OPTIMIZE: | 4596 | case SQLCOM_OPTIMIZE: |
2748 | 4270 | self->st_stat_modify = TRUE; | 4597 | self->st_stat_modify = TRUE; |
2749 | 4271 | break; | 4598 | break; |
2750 | @@ -4316,11 +4643,16 @@ | |||
2751 | 4316 | self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ; | 4643 | self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ; |
2752 | 4317 | self->st_ignore_fkeys = (thd_test_options(thd,OPTION_NO_FOREIGN_KEY_CHECKS)) != 0; | 4644 | self->st_ignore_fkeys = (thd_test_options(thd,OPTION_NO_FOREIGN_KEY_CHECKS)) != 0; |
2753 | 4318 | self->st_auto_commit = (thd_test_options(thd, (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0; | 4645 | self->st_auto_commit = (thd_test_options(thd, (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0; |
2754 | 4646 | #ifdef DRIZZLED | ||
2755 | 4647 | self->st_table_trans = FALSE; | ||
2756 | 4648 | #else | ||
2757 | 4319 | self->st_table_trans = thd_sql_command(thd) == SQLCOM_LOCK_TABLES; | 4649 | self->st_table_trans = thd_sql_command(thd) == SQLCOM_LOCK_TABLES; |
2758 | 4650 | #endif | ||
2759 | 4320 | self->st_abort_trans = FALSE; | 4651 | self->st_abort_trans = FALSE; |
2760 | 4321 | self->st_stat_ended = FALSE; | 4652 | self->st_stat_ended = FALSE; |
2761 | 4322 | self->st_stat_trans = FALSE; | 4653 | self->st_stat_trans = FALSE; |
2762 | 4323 | XT_PRINT0(self, "xt_xn_begin\n"); | 4654 | XT_PRINT0(self, "xt_xn_begin\n"); |
2763 | 4655 | xt_xres_wait_for_recovery(self, XT_RECOVER_SWEPT); | ||
2764 | 4324 | if (!xt_xn_begin(self)) { | 4656 | if (!xt_xn_begin(self)) { |
2765 | 4325 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key); | 4657 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key); |
2766 | 4326 | pb_ex_in_use = 0; | 4658 | pb_ex_in_use = 0; |
2767 | @@ -4404,7 +4736,7 @@ | |||
2768 | 4404 | if (!(self = ha_set_current_thread(thd, &err))) | 4736 | if (!(self = ha_set_current_thread(thd, &err))) |
2769 | 4405 | return xt_ha_pbxt_to_mysql_error(err); | 4737 | return xt_ha_pbxt_to_mysql_error(err); |
2770 | 4406 | 4738 | ||
2772 | 4407 | XT_PRINT2(self, "ha_pbxt::start_stmt %s lock_type=%d\n", pb_share->sh_table_path->ps_path, (int) lock_type); | 4739 | XT_PRINT2(self, "ha_pbxt::start_stmt (%s) lock_type=%d\n", pb_share->sh_table_path->ps_path, (int) lock_type); |
2773 | 4408 | 4740 | ||
2774 | 4409 | if (!pb_open_tab) { | 4741 | if (!pb_open_tab) { |
2775 | 4410 | if ((err = reopen())) | 4742 | if ((err = reopen())) |
2776 | @@ -4430,12 +4762,12 @@ | |||
2777 | 4430 | /* This section handles "auto-commit"... */ | 4762 | /* This section handles "auto-commit"... */ |
2778 | 4431 | if (self->st_xact_data && self->st_auto_commit && self->st_table_trans) { | 4763 | if (self->st_xact_data && self->st_auto_commit && self->st_table_trans) { |
2779 | 4432 | if (self->st_abort_trans) { | 4764 | if (self->st_abort_trans) { |
2781 | 4433 | XT_PRINT0(self, "xt_xn_rollback\n"); | 4765 | XT_PRINT0(self, "xt_xn_rollback in start_stmt\n"); |
2782 | 4434 | if (!xt_xn_rollback(self)) | 4766 | if (!xt_xn_rollback(self)) |
2783 | 4435 | err = xt_ha_pbxt_thread_error_for_mysql(pb_mysql_thd, self, pb_ignore_dup_key); | 4767 | err = xt_ha_pbxt_thread_error_for_mysql(pb_mysql_thd, self, pb_ignore_dup_key); |
2784 | 4436 | } | 4768 | } |
2785 | 4437 | else { | 4769 | else { |
2787 | 4438 | XT_PRINT0(self, "xt_xn_commit\n"); | 4770 | XT_PRINT0(self, "xt_xn_commit in start_stmt\n"); |
2788 | 4439 | if (!xt_xn_commit(self)) | 4771 | if (!xt_xn_commit(self)) |
2789 | 4440 | err = xt_ha_pbxt_thread_error_for_mysql(pb_mysql_thd, self, pb_ignore_dup_key); | 4772 | err = xt_ha_pbxt_thread_error_for_mysql(pb_mysql_thd, self, pb_ignore_dup_key); |
2790 | 4441 | } | 4773 | } |
2791 | @@ -4466,9 +4798,11 @@ | |||
2792 | 4466 | if (pb_open_tab->ot_for_update) { | 4798 | if (pb_open_tab->ot_for_update) { |
2793 | 4467 | switch ((int) thd_sql_command(thd)) { | 4799 | switch ((int) thd_sql_command(thd)) { |
2794 | 4468 | case SQLCOM_UPDATE: | 4800 | case SQLCOM_UPDATE: |
2795 | 4801 | case SQLCOM_DELETE: | ||
2796 | 4802 | #ifndef DRIZZLED | ||
2797 | 4469 | case SQLCOM_UPDATE_MULTI: | 4803 | case SQLCOM_UPDATE_MULTI: |
2798 | 4470 | case SQLCOM_DELETE: | ||
2799 | 4471 | case SQLCOM_DELETE_MULTI: | 4804 | case SQLCOM_DELETE_MULTI: |
2800 | 4805 | #endif | ||
2801 | 4472 | case SQLCOM_REPLACE: | 4806 | case SQLCOM_REPLACE: |
2802 | 4473 | case SQLCOM_REPLACE_SELECT: | 4807 | case SQLCOM_REPLACE_SELECT: |
2803 | 4474 | case SQLCOM_INSERT: | 4808 | case SQLCOM_INSERT: |
2804 | @@ -4483,14 +4817,15 @@ | |||
2805 | 4483 | case SQLCOM_DROP_TABLE: | 4817 | case SQLCOM_DROP_TABLE: |
2806 | 4484 | case SQLCOM_DROP_INDEX: | 4818 | case SQLCOM_DROP_INDEX: |
2807 | 4485 | case SQLCOM_LOAD: | 4819 | case SQLCOM_LOAD: |
2808 | 4820 | #ifndef DRIZZLED | ||
2809 | 4486 | case SQLCOM_REPAIR: | 4821 | case SQLCOM_REPAIR: |
2810 | 4822 | #endif | ||
2811 | 4487 | case SQLCOM_OPTIMIZE: | 4823 | case SQLCOM_OPTIMIZE: |
2812 | 4488 | self->st_stat_modify = TRUE; | 4824 | self->st_stat_modify = TRUE; |
2813 | 4489 | break; | 4825 | break; |
2814 | 4490 | } | 4826 | } |
2815 | 4491 | } | 4827 | } |
2816 | 4492 | 4828 | ||
2817 | 4493 | |||
2818 | 4494 | /* (***) This is required at this level! | 4829 | /* (***) This is required at this level! |
2819 | 4495 | * No matter how often it is called, it is still the start of a | 4830 | * No matter how often it is called, it is still the start of a |
2820 | 4496 | * statement. We need to make sure statements that are NOT mistaken | 4831 | * statement. We need to make sure statements that are NOT mistaken |
2821 | @@ -4516,6 +4851,7 @@ | |||
2822 | 4516 | self->st_stat_ended = FALSE; | 4851 | self->st_stat_ended = FALSE; |
2823 | 4517 | self->st_stat_trans = FALSE; | 4852 | self->st_stat_trans = FALSE; |
2824 | 4518 | XT_PRINT0(self, "xt_xn_begin\n"); | 4853 | XT_PRINT0(self, "xt_xn_begin\n"); |
2825 | 4854 | xt_xres_wait_for_recovery(self, XT_RECOVER_SWEPT); | ||
2826 | 4519 | if (!xt_xn_begin(self)) { | 4855 | if (!xt_xn_begin(self)) { |
2827 | 4520 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key); | 4856 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key); |
2828 | 4521 | goto complete; | 4857 | goto complete; |
2829 | @@ -4673,7 +5009,9 @@ | |||
2830 | 4673 | * | 5009 | * |
2831 | 4674 | */ | 5010 | */ |
2832 | 4675 | if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) && | 5011 | if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) && |
2833 | 5012 | #ifndef DRIZZLED | ||
2834 | 4676 | !(thd_in_lock_tables(thd) && thd_sql_command(thd) == SQLCOM_LOCK_TABLES) && | 5013 | !(thd_in_lock_tables(thd) && thd_sql_command(thd) == SQLCOM_LOCK_TABLES) && |
2835 | 5014 | #endif | ||
2836 | 4677 | !thd_tablespace_op(thd) && | 5015 | !thd_tablespace_op(thd) && |
2837 | 4678 | thd_sql_command(thd) != SQLCOM_TRUNCATE && | 5016 | thd_sql_command(thd) != SQLCOM_TRUNCATE && |
2838 | 4679 | thd_sql_command(thd) != SQLCOM_OPTIMIZE && | 5017 | thd_sql_command(thd) != SQLCOM_OPTIMIZE && |
2839 | @@ -4691,22 +5029,23 @@ | |||
2840 | 4691 | 5029 | ||
2841 | 4692 | * Stewart: removed SQLCOM_CALL, not sure of implications. | 5030 | * Stewart: removed SQLCOM_CALL, not sure of implications. |
2842 | 4693 | */ | 5031 | */ |
2845 | 4694 | if (lock_type == TL_READ_NO_INSERT && | 5032 | if (lock_type == TL_READ_NO_INSERT |
2844 | 4695 | (!thd_in_lock_tables(thd) | ||
2846 | 4696 | #ifndef DRIZZLED | 5033 | #ifndef DRIZZLED |
2847 | 5034 | && (!thd_in_lock_tables(thd) | ||
2848 | 4697 | || thd_sql_command(thd) == SQLCOM_CALL | 5035 | || thd_sql_command(thd) == SQLCOM_CALL |
2849 | 5036 | ) | ||
2850 | 4698 | #endif | 5037 | #endif |
2852 | 4699 | )) | 5038 | ) |
2853 | 4700 | { | 5039 | { |
2854 | 4701 | lock_type = TL_READ; | 5040 | lock_type = TL_READ; |
2855 | 4702 | } | 5041 | } |
2856 | 4703 | 5042 | ||
2858 | 4704 | XT_PRINT3(xt_get_self(), "ha_pbxt::store_lock %s %d->%d\n", pb_share->sh_table_path->ps_path, pb_lock.type, lock_type); | 5043 | XT_PRINT3(xt_get_self(), "store_lock (%s) %d->%d\n", pb_share->sh_table_path->ps_path, pb_lock.type, lock_type); |
2859 | 4705 | pb_lock.type = lock_type; | 5044 | pb_lock.type = lock_type; |
2860 | 4706 | } | 5045 | } |
2861 | 4707 | #ifdef PBXT_HANDLER_TRACE | 5046 | #ifdef PBXT_HANDLER_TRACE |
2862 | 4708 | else { | 5047 | else { |
2864 | 4709 | XT_PRINT3(xt_get_self(), "ha_pbxt::store_lock %s %d->%d (ignore/unlock)\n", pb_share->sh_table_path->ps_path, lock_type, lock_type); | 5048 | XT_PRINT3(xt_get_self(), "store_lock (%s) %d->%d (ignore/unlock)\n", pb_share->sh_table_path->ps_path, lock_type, lock_type); |
2865 | 4710 | } | 5049 | } |
2866 | 4711 | #endif | 5050 | #endif |
2867 | 4712 | *to++= &pb_lock; | 5051 | *to++= &pb_lock; |
2868 | @@ -4723,15 +5062,23 @@ | |||
2869 | 4723 | * during create if the table_flag HA_DROP_BEFORE_CREATE was specified for | 5062 | * during create if the table_flag HA_DROP_BEFORE_CREATE was specified for |
2870 | 4724 | * the storage engine. | 5063 | * the storage engine. |
2871 | 4725 | */ | 5064 | */ |
2872 | 5065 | #ifdef DRIZZLED | ||
2873 | 5066 | int PBXTStorageEngine::doDropTable(Session &, std::string table_path_str) | ||
2874 | 5067 | #else | ||
2875 | 4726 | int ha_pbxt::delete_table(const char *table_path) | 5068 | int ha_pbxt::delete_table(const char *table_path) |
2876 | 5069 | #endif | ||
2877 | 4727 | { | 5070 | { |
2878 | 4728 | THD *thd = current_thd; | 5071 | THD *thd = current_thd; |
2879 | 4729 | int err = 0; | 5072 | int err = 0; |
2880 | 4730 | XTThreadPtr self = NULL; | 5073 | XTThreadPtr self = NULL; |
2881 | 4731 | XTSharePtr share; | 5074 | XTSharePtr share; |
2882 | 4732 | 5075 | ||
2883 | 5076 | #ifdef DRIZZLED | ||
2884 | 5077 | const char *table_path = table_path_str.c_str(); | ||
2885 | 5078 | #endif | ||
2886 | 5079 | |||
2887 | 4733 | STAT_TRACE(self, *thd_query(thd)); | 5080 | STAT_TRACE(self, *thd_query(thd)); |
2889 | 4734 | XT_PRINT1(self, "ha_pbxt::delete_table %s\n", table_path); | 5081 | XT_PRINT1(self, "delete_table (%s)\n", table_path); |
2890 | 4735 | 5082 | ||
2891 | 4736 | if (XTSystemTableShare::isSystemTable(table_path)) | 5083 | if (XTSystemTableShare::isSystemTable(table_path)) |
2892 | 4737 | return delete_system_table(table_path); | 5084 | return delete_system_table(table_path); |
2893 | @@ -4795,7 +5142,7 @@ | |||
2894 | 4795 | #endif | 5142 | #endif |
2895 | 4796 | } | 5143 | } |
2896 | 4797 | catch_(a) { | 5144 | catch_(a) { |
2898 | 4798 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key); | 5145 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); |
2899 | 4799 | #ifdef DRIZZLED | 5146 | #ifdef DRIZZLED |
2900 | 4800 | if (err == HA_ERR_NO_SUCH_TABLE) | 5147 | if (err == HA_ERR_NO_SUCH_TABLE) |
2901 | 4801 | err = ENOENT; | 5148 | err = ENOENT; |
2902 | @@ -4819,7 +5166,11 @@ | |||
2903 | 4819 | return err; | 5166 | return err; |
2904 | 4820 | } | 5167 | } |
2905 | 4821 | 5168 | ||
2906 | 5169 | #ifdef DRIZZLED | ||
2907 | 5170 | int PBXTStorageEngine::delete_system_table(const char *table_path) | ||
2908 | 5171 | #else | ||
2909 | 4822 | int ha_pbxt::delete_system_table(const char *table_path) | 5172 | int ha_pbxt::delete_system_table(const char *table_path) |
2910 | 5173 | #endif | ||
2911 | 4823 | { | 5174 | { |
2912 | 4824 | THD *thd = current_thd; | 5175 | THD *thd = current_thd; |
2913 | 4825 | XTExceptionRec e; | 5176 | XTExceptionRec e; |
2914 | @@ -4857,7 +5208,13 @@ | |||
2915 | 4857 | * This function can be used to move a table from one database to | 5208 | * This function can be used to move a table from one database to |
2916 | 4858 | * another. | 5209 | * another. |
2917 | 4859 | */ | 5210 | */ |
2918 | 5211 | #ifdef DRIZZLED | ||
2919 | 5212 | int PBXTStorageEngine::doRenameTable(Session *, | ||
2920 | 5213 | const char *from, | ||
2921 | 5214 | const char *to) | ||
2922 | 5215 | #else | ||
2923 | 4860 | int ha_pbxt::rename_table(const char *from, const char *to) | 5216 | int ha_pbxt::rename_table(const char *from, const char *to) |
2924 | 5217 | #endif | ||
2925 | 4861 | { | 5218 | { |
2926 | 4862 | THD *thd = current_thd; | 5219 | THD *thd = current_thd; |
2927 | 4863 | int err = 0; | 5220 | int err = 0; |
2928 | @@ -4865,15 +5222,13 @@ | |||
2929 | 4865 | XTSharePtr share; | 5222 | XTSharePtr share; |
2930 | 4866 | XTDatabaseHPtr to_db; | 5223 | XTDatabaseHPtr to_db; |
2931 | 4867 | 5224 | ||
2932 | 4868 | XT_TRACE_CALL(); | ||
2933 | 4869 | |||
2934 | 4870 | if (XTSystemTableShare::isSystemTable(from)) | 5225 | if (XTSystemTableShare::isSystemTable(from)) |
2935 | 4871 | return rename_system_table(from, to); | 5226 | return rename_system_table(from, to); |
2936 | 4872 | 5227 | ||
2937 | 4873 | if (!(self = ha_set_current_thread(thd, &err))) | 5228 | if (!(self = ha_set_current_thread(thd, &err))) |
2938 | 4874 | return xt_ha_pbxt_to_mysql_error(err); | 5229 | return xt_ha_pbxt_to_mysql_error(err); |
2939 | 4875 | 5230 | ||
2941 | 4876 | XT_PRINT2(self, "ha_pbxt::rename_table %s -> %s\n", from, to); | 5231 | XT_PRINT2(self, "rename_table (%s -> %s)\n", from, to); |
2942 | 4877 | 5232 | ||
2943 | 4878 | #ifdef PBMS_ENABLED | 5233 | #ifdef PBMS_ENABLED |
2944 | 4879 | PBMSResultRec result; | 5234 | PBMSResultRec result; |
2945 | @@ -4929,7 +5284,7 @@ | |||
2946 | 4929 | #endif | 5284 | #endif |
2947 | 4930 | } | 5285 | } |
2948 | 4931 | catch_(a) { | 5286 | catch_(a) { |
2950 | 4932 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key); | 5287 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); |
2951 | 4933 | } | 5288 | } |
2952 | 4934 | cont_(a); | 5289 | cont_(a); |
2953 | 4935 | 5290 | ||
2954 | @@ -4940,7 +5295,11 @@ | |||
2955 | 4940 | XT_RETURN(err); | 5295 | XT_RETURN(err); |
2956 | 4941 | } | 5296 | } |
2957 | 4942 | 5297 | ||
2958 | 5298 | #ifdef DRIZZLED | ||
2959 | 5299 | int PBXTStorageEngine::rename_system_table(const char *XT_UNUSED(from), const char *XT_UNUSED(to)) | ||
2960 | 5300 | #else | ||
2961 | 4943 | int ha_pbxt::rename_system_table(const char *XT_UNUSED(from), const char *XT_UNUSED(to)) | 5301 | int ha_pbxt::rename_system_table(const char *XT_UNUSED(from), const char *XT_UNUSED(to)) |
2962 | 5302 | #endif | ||
2963 | 4944 | { | 5303 | { |
2964 | 4945 | return ER_NOT_SUPPORTED_YET; | 5304 | return ER_NOT_SUPPORTED_YET; |
2965 | 4946 | } | 5305 | } |
2966 | @@ -5029,7 +5388,15 @@ | |||
2967 | 5029 | 5388 | ||
2968 | 5030 | * Called from handle.cc by ha_create_table(). | 5389 | * Called from handle.cc by ha_create_table(). |
2969 | 5031 | */ | 5390 | */ |
2970 | 5391 | #ifdef DRIZZLED | ||
2971 | 5392 | int PBXTStorageEngine::doCreateTable(Session *, | ||
2972 | 5393 | const char *table_path, | ||
2973 | 5394 | Table &table_arg, | ||
2974 | 5395 | HA_CREATE_INFO &create_info, | ||
2975 | 5396 | drizzled::message::Table &XT_UNUSED(proto)) | ||
2976 | 5397 | #else | ||
2977 | 5032 | int ha_pbxt::create(const char *table_path, TABLE *table_arg, HA_CREATE_INFO *create_info) | 5398 | int ha_pbxt::create(const char *table_path, TABLE *table_arg, HA_CREATE_INFO *create_info) |
2978 | 5399 | #endif | ||
2979 | 5033 | { | 5400 | { |
2980 | 5034 | THD *thd = current_thd; | 5401 | THD *thd = current_thd; |
2981 | 5035 | int err = 0; | 5402 | int err = 0; |
2982 | @@ -5037,37 +5404,61 @@ | |||
2983 | 5037 | XTDDTable *tab_def = NULL; | 5404 | XTDDTable *tab_def = NULL; |
2984 | 5038 | XTDictionaryRec dic; | 5405 | XTDictionaryRec dic; |
2985 | 5039 | 5406 | ||
2986 | 5407 | if ((strcmp(table_path, "./pbxt/location") == 0) || (strcmp(table_path, "./pbxt/statistics") == 0)) | ||
2987 | 5408 | return 0; | ||
2988 | 5409 | |||
2989 | 5040 | memset(&dic, 0, sizeof(dic)); | 5410 | memset(&dic, 0, sizeof(dic)); |
2990 | 5041 | 5411 | ||
2991 | 5042 | XT_TRACE_CALL(); | ||
2992 | 5043 | |||
2993 | 5044 | if (!(self = ha_set_current_thread(thd, &err))) | 5412 | if (!(self = ha_set_current_thread(thd, &err))) |
2994 | 5045 | return xt_ha_pbxt_to_mysql_error(err); | 5413 | return xt_ha_pbxt_to_mysql_error(err); |
2995 | 5414 | #ifdef DRIZZLED | ||
2996 | 5415 | XT_PRINT2(self, "create (%s) %s\n", table_path, (create_info.options & HA_LEX_CREATE_TMP_TABLE) ? "temporary" : ""); | ||
2997 | 5416 | #else | ||
2998 | 5417 | XT_PRINT2(self, "create (%s) %s\n", table_path, (create_info->options & HA_LEX_CREATE_TMP_TABLE) ? "temporary" : ""); | ||
2999 | 5418 | #endif | ||
3000 | 5046 | 5419 | ||
3001 | 5047 | STAT_TRACE(self, *thd_query(thd)); | 5420 | STAT_TRACE(self, *thd_query(thd)); |
3002 | 5048 | XT_PRINT1(self, "ha_pbxt::create %s\n", table_path); | ||
3003 | 5049 | 5421 | ||
3004 | 5050 | try_(a) { | 5422 | try_(a) { |
3005 | 5051 | xt_ha_open_database_of_table(self, (XTPathStrPtr) table_path); | 5423 | xt_ha_open_database_of_table(self, (XTPathStrPtr) table_path); |
3006 | 5052 | 5424 | ||
3007 | 5425 | #ifdef DRIZZLED | ||
3008 | 5426 | for (uint i=0; i<TS(&table_arg)->keys; i++) { | ||
3009 | 5427 | if (table_arg.key_info[i].key_length > XT_INDEX_MAX_KEY_SIZE) | ||
3010 | 5428 | xt_throw_sulxterr(XT_CONTEXT, XT_ERR_KEY_TOO_LARGE, table_arg.key_info[i].name, (u_long) XT_INDEX_MAX_KEY_SIZE); | ||
3011 | 5429 | } | ||
3012 | 5430 | #else | ||
3013 | 5053 | for (uint i=0; i<TS(table_arg)->keys; i++) { | 5431 | for (uint i=0; i<TS(table_arg)->keys; i++) { |
3014 | 5054 | if (table_arg->key_info[i].key_length > XT_INDEX_MAX_KEY_SIZE) | 5432 | if (table_arg->key_info[i].key_length > XT_INDEX_MAX_KEY_SIZE) |
3015 | 5055 | xt_throw_sulxterr(XT_CONTEXT, XT_ERR_KEY_TOO_LARGE, table_arg->key_info[i].name, (u_long) XT_INDEX_MAX_KEY_SIZE); | 5433 | xt_throw_sulxterr(XT_CONTEXT, XT_ERR_KEY_TOO_LARGE, table_arg->key_info[i].name, (u_long) XT_INDEX_MAX_KEY_SIZE); |
3016 | 5056 | } | 5434 | } |
3017 | 5435 | #endif | ||
3018 | 5057 | 5436 | ||
3019 | 5058 | /* ($) auto_increment_value will be zero if | 5437 | /* ($) auto_increment_value will be zero if |
3020 | 5059 | * AUTO_INCREMENT is not used. Otherwise | 5438 | * AUTO_INCREMENT is not used. Otherwise |
3021 | 5060 | * Query was ALTER TABLE ... AUTO_INCREMENT = x; or | 5439 | * Query was ALTER TABLE ... AUTO_INCREMENT = x; or |
3022 | 5061 | * CREATE TABLE ... AUTO_INCREMENT = x; | 5440 | * CREATE TABLE ... AUTO_INCREMENT = x; |
3023 | 5062 | */ | 5441 | */ |
3024 | 5442 | #ifdef DRIZZLED | ||
3025 | 5443 | tab_def = xt_ri_create_table(self, true, (XTPathStrPtr) table_path, *thd_query(thd), myxt_create_table_from_table(self, &table_arg)); | ||
3026 | 5444 | tab_def->checkForeignKeys(self, create_info.options & HA_LEX_CREATE_TMP_TABLE); | ||
3027 | 5445 | #else | ||
3028 | 5063 | tab_def = xt_ri_create_table(self, true, (XTPathStrPtr) table_path, *thd_query(thd), myxt_create_table_from_table(self, table_arg)); | 5446 | tab_def = xt_ri_create_table(self, true, (XTPathStrPtr) table_path, *thd_query(thd), myxt_create_table_from_table(self, table_arg)); |
3029 | 5064 | tab_def->checkForeignKeys(self, create_info->options & HA_LEX_CREATE_TMP_TABLE); | 5447 | tab_def->checkForeignKeys(self, create_info->options & HA_LEX_CREATE_TMP_TABLE); |
3030 | 5448 | #endif | ||
3031 | 5065 | 5449 | ||
3032 | 5066 | dic.dic_table = tab_def; | 5450 | dic.dic_table = tab_def; |
3033 | 5451 | #ifdef DRIZZLED | ||
3034 | 5452 | dic.dic_my_table = &table_arg; | ||
3035 | 5453 | dic.dic_tab_flags = (create_info.options & HA_LEX_CREATE_TMP_TABLE) ? XT_TAB_FLAGS_TEMP_TAB : 0; | ||
3036 | 5454 | dic.dic_min_auto_inc = (xtWord8) create_info.auto_increment_value; /* ($) */ | ||
3037 | 5455 | dic.dic_def_ave_row_size = table_arg.s->getAvgRowLength(); | ||
3038 | 5456 | #else | ||
3039 | 5067 | dic.dic_my_table = table_arg; | 5457 | dic.dic_my_table = table_arg; |
3040 | 5068 | dic.dic_tab_flags = (create_info->options & HA_LEX_CREATE_TMP_TABLE) ? XT_TAB_FLAGS_TEMP_TAB : 0; | 5458 | dic.dic_tab_flags = (create_info->options & HA_LEX_CREATE_TMP_TABLE) ? XT_TAB_FLAGS_TEMP_TAB : 0; |
3041 | 5069 | dic.dic_min_auto_inc = (xtWord8) create_info->auto_increment_value; /* ($) */ | 5459 | dic.dic_min_auto_inc = (xtWord8) create_info->auto_increment_value; /* ($) */ |
3042 | 5070 | dic.dic_def_ave_row_size = (xtWord8) table_arg->s->avg_row_length; | 5460 | dic.dic_def_ave_row_size = (xtWord8) table_arg->s->avg_row_length; |
3043 | 5461 | #endif | ||
3044 | 5071 | myxt_setup_dictionary(self, &dic); | 5462 | myxt_setup_dictionary(self, &dic); |
3045 | 5072 | 5463 | ||
3046 | 5073 | /* | 5464 | /* |
3047 | @@ -5089,7 +5480,7 @@ | |||
3048 | 5089 | if (tab_def) | 5480 | if (tab_def) |
3049 | 5090 | tab_def->finalize(self); | 5481 | tab_def->finalize(self); |
3050 | 5091 | dic.dic_table = NULL; | 5482 | dic.dic_table = NULL; |
3052 | 5092 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key); | 5483 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); |
3053 | 5093 | } | 5484 | } |
3054 | 5094 | cont_(a); | 5485 | cont_(a); |
3055 | 5095 | 5486 | ||
3056 | @@ -5161,7 +5552,7 @@ | |||
3057 | 5161 | if (!self->t_exception.e_xt_err) | 5552 | if (!self->t_exception.e_xt_err) |
3058 | 5162 | return FALSE; | 5553 | return FALSE; |
3059 | 5163 | 5554 | ||
3061 | 5164 | buf->copy(self->t_exception.e_err_msg, strlen(self->t_exception.e_err_msg), system_charset_info); | 5555 | buf->copy(self->t_exception.e_err_msg, (uint32) strlen(self->t_exception.e_err_msg), system_charset_info); |
3062 | 5165 | return TRUE; | 5556 | return TRUE; |
3063 | 5166 | } | 5557 | } |
3064 | 5167 | 5558 | ||
3065 | @@ -5421,16 +5812,31 @@ | |||
3066 | 5421 | 5812 | ||
3067 | 5422 | #ifdef DRIZZLED | 5813 | #ifdef DRIZZLED |
3068 | 5423 | static MYSQL_SYSVAR_INT(max_threads, pbxt_max_threads, | 5814 | static MYSQL_SYSVAR_INT(max_threads, pbxt_max_threads, |
3070 | 5424 | PLUGIN_VAR_OPCMDARG, | 5815 | PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY, |
3071 | 5425 | "The maximum number of threads used by PBXT", | 5816 | "The maximum number of threads used by PBXT", |
3072 | 5426 | NULL, NULL, 500, 20, 20000, 1); | 5817 | NULL, NULL, 500, 20, 20000, 1); |
3073 | 5427 | #else | 5818 | #else |
3074 | 5428 | static MYSQL_SYSVAR_INT(max_threads, pbxt_max_threads, | 5819 | static MYSQL_SYSVAR_INT(max_threads, pbxt_max_threads, |
3076 | 5429 | PLUGIN_VAR_OPCMDARG, | 5820 | PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY, |
3077 | 5430 | "The maximum number of threads used by PBXT, 0 = set according to MySQL max_connections.", | 5821 | "The maximum number of threads used by PBXT, 0 = set according to MySQL max_connections.", |
3078 | 5431 | NULL, NULL, 0, 0, 20000, 1); | 5822 | NULL, NULL, 0, 0, 20000, 1); |
3079 | 5432 | #endif | 5823 | #endif |
3080 | 5433 | 5824 | ||
3081 | 5825 | #ifndef DEBUG | ||
3082 | 5826 | static MYSQL_SYSVAR_BOOL(support_xa, pbxt_support_xa, | ||
3083 | 5827 | PLUGIN_VAR_OPCMDARG, | ||
3084 | 5828 | "Enable PBXT support for the XA two-phase commit, default is enabled", | ||
3085 | 5829 | NULL, NULL, TRUE); | ||
3086 | 5830 | #else | ||
3087 | 5831 | static MYSQL_SYSVAR_BOOL(support_xa, pbxt_support_xa, | ||
3088 | 5832 | PLUGIN_VAR_OPCMDARG, | ||
3089 | 5833 | "Enable PBXT support for the XA two-phase commit, default is disabled (due to assertion failure in MySQL)", | ||
3090 | 5834 | /* The problem is, in MySQL an assertion fails in debug mode: | ||
3091 | 5835 | * Assertion failed: (total_ha_2pc == (ulong) opt_bin_log+1), function ha_recover, file handler.cc, line 1557. | ||
3092 | 5836 | */ | ||
3093 | 5837 | NULL, NULL, FALSE); | ||
3094 | 5838 | #endif | ||
3095 | 5839 | |||
3096 | 5434 | static struct st_mysql_sys_var* pbxt_system_variables[] = { | 5840 | static struct st_mysql_sys_var* pbxt_system_variables[] = { |
3097 | 5435 | MYSQL_SYSVAR(index_cache_size), | 5841 | MYSQL_SYSVAR(index_cache_size), |
3098 | 5436 | MYSQL_SYSVAR(record_cache_size), | 5842 | MYSQL_SYSVAR(record_cache_size), |
3099 | @@ -5448,6 +5854,7 @@ | |||
3100 | 5448 | MYSQL_SYSVAR(offline_log_function), | 5854 | MYSQL_SYSVAR(offline_log_function), |
3101 | 5449 | MYSQL_SYSVAR(sweeper_priority), | 5855 | MYSQL_SYSVAR(sweeper_priority), |
3102 | 5450 | MYSQL_SYSVAR(max_threads), | 5856 | MYSQL_SYSVAR(max_threads), |
3103 | 5857 | MYSQL_SYSVAR(support_xa), | ||
3104 | 5451 | NULL | 5858 | NULL |
3105 | 5452 | }; | 5859 | }; |
3106 | 5453 | #endif | 5860 | #endif |
3107 | @@ -5494,8 +5901,8 @@ | |||
3108 | 5494 | "Paul McCullagh, PrimeBase Technologies GmbH", | 5901 | "Paul McCullagh, PrimeBase Technologies GmbH", |
3109 | 5495 | "PBXT internal system statitics", | 5902 | "PBXT internal system statitics", |
3110 | 5496 | PLUGIN_LICENSE_GPL, | 5903 | PLUGIN_LICENSE_GPL, |
3113 | 5497 | pbxt_init_statitics, /* plugin init */ | 5904 | pbxt_init_statistics, /* plugin init */ |
3114 | 5498 | pbxt_exit_statitics, /* plugin deinit */ | 5905 | pbxt_exit_statistics, /* plugin deinit */ |
3115 | 5499 | #ifndef DRIZZLED | 5906 | #ifndef DRIZZLED |
3116 | 5500 | 0x0005, | 5907 | 0x0005, |
3117 | 5501 | #endif | 5908 | #endif |
3118 | 5502 | 5909 | ||
3119 | === modified file 'storage/pbxt/src/ha_pbxt.h' | |||
3120 | --- storage/pbxt/src/ha_pbxt.h 2009-08-17 11:12:36 +0000 | |||
3121 | +++ storage/pbxt/src/ha_pbxt.h 2009-12-10 11:57:20 +0000 | |||
3122 | @@ -27,9 +27,9 @@ | |||
3123 | 27 | 27 | ||
3124 | 28 | #ifdef DRIZZLED | 28 | #ifdef DRIZZLED |
3125 | 29 | #include <drizzled/common.h> | 29 | #include <drizzled/common.h> |
3126 | 30 | #include <drizzled/handler.h> | ||
3127 | 31 | #include <drizzled/plugin/storage_engine.h> | ||
3128 | 32 | #include <mysys/thr_lock.h> | 30 | #include <mysys/thr_lock.h> |
3129 | 31 | #include <drizzled/cursor.h> | ||
3130 | 32 | |||
3131 | 33 | #else | 33 | #else |
3132 | 34 | #include "mysql_priv.h" | 34 | #include "mysql_priv.h" |
3133 | 35 | #endif | 35 | #endif |
3134 | @@ -53,17 +53,31 @@ | |||
3135 | 53 | 53 | ||
3136 | 54 | #ifdef DRIZZLED | 54 | #ifdef DRIZZLED |
3137 | 55 | 55 | ||
3139 | 56 | class PBXTStorageEngine : public StorageEngine { | 56 | class PBXTStorageEngine : public drizzled::plugin::StorageEngine |
3140 | 57 | { | ||
3141 | 58 | |||
3142 | 59 | int delete_system_table(const char *table_path); | ||
3143 | 60 | int rename_system_table(const char * from, const char * to); | ||
3144 | 61 | |||
3145 | 57 | public: | 62 | public: |
3146 | 58 | PBXTStorageEngine(std::string name_arg) | 63 | PBXTStorageEngine(std::string name_arg) |
3148 | 59 | : StorageEngine(name_arg, HTON_NO_FLAGS) {} | 64 | : drizzled::plugin::StorageEngine(name_arg, HTON_NO_FLAGS) {} |
3149 | 65 | |||
3150 | 66 | void operator delete(void *) {} | ||
3151 | 67 | void operator delete[] (void *) {} | ||
3152 | 60 | 68 | ||
3153 | 61 | /* override */ int close_connection(Session *); | 69 | /* override */ int close_connection(Session *); |
3154 | 62 | /* override */ int commit(Session *, bool); | 70 | /* override */ int commit(Session *, bool); |
3155 | 63 | /* override */ int rollback(Session *, bool); | 71 | /* override */ int rollback(Session *, bool); |
3157 | 64 | /* override */ handler *create(TABLE_SHARE *, MEM_ROOT *); | 72 | /* override */ Cursor *create(TABLE_SHARE *, MEM_ROOT *); |
3158 | 65 | /* override */ void drop_database(char *); | 73 | /* override */ void drop_database(char *); |
3159 | 66 | /* override */ bool show_status(Session *, stat_print_fn *, enum ha_stat_type); | 74 | /* override */ bool show_status(Session *, stat_print_fn *, enum ha_stat_type); |
3160 | 75 | /* override */ const char **bas_ext() const; | ||
3161 | 76 | /* override */ int doCreateTable(Session *session, const char *table_name, | ||
3162 | 77 | Table &table_arg, HA_CREATE_INFO | ||
3163 | 78 | &create_info, drizzled::message::Table &proto); | ||
3164 | 79 | /* override */ int doRenameTable(Session *, const char *from, const char *to); | ||
3165 | 80 | /* override */ int doDropTable(Session &session, std::string table_path); | ||
3166 | 67 | }; | 81 | }; |
3167 | 68 | 82 | ||
3168 | 69 | typedef PBXTStorageEngine handlerton; | 83 | typedef PBXTStorageEngine handlerton; |
3169 | @@ -139,9 +153,9 @@ | |||
3170 | 139 | * don't implement this method unless you really have indexes. | 153 | * don't implement this method unless you really have indexes. |
3171 | 140 | */ | 154 | */ |
3172 | 141 | const char *index_type(uint inx) { (void) inx; return "BTREE"; } | 155 | const char *index_type(uint inx) { (void) inx; return "BTREE"; } |
3174 | 142 | 156 | #ifndef DRIZZLED | |
3175 | 143 | const char **bas_ext() const; | 157 | const char **bas_ext() const; |
3177 | 144 | 158 | #endif | |
3178 | 145 | MX_UINT8_T table_cache_type(); | 159 | MX_UINT8_T table_cache_type(); |
3179 | 146 | 160 | ||
3180 | 147 | /* | 161 | /* |
3181 | @@ -241,11 +255,13 @@ | |||
3182 | 241 | int optimize(THD* thd, HA_CHECK_OPT* check_opt); | 255 | int optimize(THD* thd, HA_CHECK_OPT* check_opt); |
3183 | 242 | int check(THD* thd, HA_CHECK_OPT* check_opt); | 256 | int check(THD* thd, HA_CHECK_OPT* check_opt); |
3184 | 243 | ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); | 257 | ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); |
3185 | 258 | #ifndef DRIZZLED | ||
3186 | 259 | int delete_system_table(const char *table_path); | ||
3187 | 244 | int delete_table(const char *from); | 260 | int delete_table(const char *from); |
3189 | 245 | int delete_system_table(const char *table_path); | 261 | int rename_system_table(const char * from, const char * to); |
3190 | 246 | int rename_table(const char * from, const char * to); | 262 | int rename_table(const char * from, const char * to); |
3191 | 247 | int rename_system_table(const char * from, const char * to); | ||
3192 | 248 | int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); //required | 263 | int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); //required |
3193 | 264 | #endif | ||
3194 | 249 | void update_create_info(HA_CREATE_INFO *create_info); | 265 | void update_create_info(HA_CREATE_INFO *create_info); |
3195 | 250 | 266 | ||
3196 | 251 | THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); //required | 267 | THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); //required |
3197 | @@ -277,6 +293,7 @@ | |||
3198 | 277 | int xt_ha_pbxt_to_mysql_error(int xt_err); | 293 | int xt_ha_pbxt_to_mysql_error(int xt_err); |
3199 | 278 | int xt_ha_pbxt_thread_error_for_mysql(THD *thd, const XTThreadPtr self, int ignore_dup_key); | 294 | int xt_ha_pbxt_thread_error_for_mysql(THD *thd, const XTThreadPtr self, int ignore_dup_key); |
3200 | 279 | void xt_ha_all_threads_close_database(XTThreadPtr self, XTDatabase *db); | 295 | void xt_ha_all_threads_close_database(XTThreadPtr self, XTDatabase *db); |
3201 | 296 | void ha_set_auto_increment(XTOpenTablePtr ot, Field *nr); | ||
3202 | 280 | 297 | ||
3203 | 281 | /* | 298 | /* |
3204 | 282 | * These hooks are suppossed to only be used by InnoDB: | 299 | * These hooks are suppossed to only be used by InnoDB: |
3205 | 283 | 300 | ||
3206 | === modified file 'storage/pbxt/src/ha_xtsys.h' | |||
3207 | --- storage/pbxt/src/ha_xtsys.h 2009-08-17 11:12:36 +0000 | |||
3208 | +++ storage/pbxt/src/ha_xtsys.h 2009-12-10 11:57:20 +0000 | |||
3209 | @@ -30,8 +30,9 @@ | |||
3210 | 30 | 30 | ||
3211 | 31 | #ifdef DRIZZLED | 31 | #ifdef DRIZZLED |
3212 | 32 | #include <drizzled/common.h> | 32 | #include <drizzled/common.h> |
3214 | 33 | #include <drizzled/handler.h> | 33 | #include <drizzled/handler_structs.h> |
3215 | 34 | #include <drizzled/current_session.h> | 34 | #include <drizzled/current_session.h> |
3216 | 35 | #include <drizzled/cursor.h> | ||
3217 | 35 | #else | 36 | #else |
3218 | 36 | #include "mysql_priv.h" | 37 | #include "mysql_priv.h" |
3219 | 37 | #endif | 38 | #endif |
3220 | 38 | 39 | ||
3221 | === modified file 'storage/pbxt/src/heap_xt.cc' | |||
3222 | --- storage/pbxt/src/heap_xt.cc 2009-08-17 11:12:36 +0000 | |||
3223 | +++ storage/pbxt/src/heap_xt.cc 2009-12-10 11:57:20 +0000 | |||
3224 | @@ -73,7 +73,7 @@ | |||
3225 | 73 | } | 73 | } |
3226 | 74 | 74 | ||
3227 | 75 | #ifdef DEBUG_MEMORY | 75 | #ifdef DEBUG_MEMORY |
3229 | 76 | xtPublic void xt_mm_heap_reference(XTThreadPtr self, XTHeapPtr hp, u_int line, c_char *file) | 76 | xtPublic void xt_mm_heap_reference(XTThreadPtr XT_UNUSED(self), XTHeapPtr hp, u_int line, c_char *file) |
3230 | 77 | #else | 77 | #else |
3231 | 78 | xtPublic void xt_heap_reference(XTThreadPtr, XTHeapPtr hp) | 78 | xtPublic void xt_heap_reference(XTThreadPtr, XTHeapPtr hp) |
3232 | 79 | #endif | 79 | #endif |
3233 | 80 | 80 | ||
3234 | === modified file 'storage/pbxt/src/index_xt.cc' | |||
3235 | --- storage/pbxt/src/index_xt.cc 2009-08-18 07:46:53 +0000 | |||
3236 | +++ storage/pbxt/src/index_xt.cc 2009-12-10 11:57:20 +0000 | |||
3237 | @@ -829,14 +829,25 @@ | |||
3238 | 829 | 829 | ||
3239 | 830 | result->sr_item.i_item_offset += result->sr_item.i_item_size + result->sr_item.i_node_ref_size; | 830 | result->sr_item.i_item_offset += result->sr_item.i_item_size + result->sr_item.i_node_ref_size; |
3240 | 831 | bitem = branch->tb_data + result->sr_item.i_item_offset; | 831 | bitem = branch->tb_data + result->sr_item.i_item_offset; |
3243 | 832 | if (ind->mi_fix_key) | 832 | if (result->sr_item.i_item_offset < result->sr_item.i_total_size) { |
3244 | 833 | ilen = result->sr_item.i_item_size; | 833 | if (ind->mi_fix_key) |
3245 | 834 | ilen = result->sr_item.i_item_size; | ||
3246 | 835 | else { | ||
3247 | 836 | ilen = myxt_get_key_length(ind, bitem) + XT_RECORD_REF_SIZE; | ||
3248 | 837 | result->sr_item.i_item_size = ilen; | ||
3249 | 838 | } | ||
3250 | 839 | xt_get_res_record_ref(bitem + ilen - XT_RECORD_REF_SIZE, result); /* (Only valid if i_item_offset < i_total_size) */ | ||
3251 | 840 | } | ||
3252 | 834 | else { | 841 | else { |
3255 | 835 | ilen = myxt_get_key_length(ind, bitem) + XT_RECORD_REF_SIZE; | 842 | result->sr_item.i_item_size = 0; |
3256 | 836 | result->sr_item.i_item_size = ilen; | 843 | result->sr_rec_id = 0; |
3257 | 844 | result->sr_row_id = 0; | ||
3258 | 837 | } | 845 | } |
3261 | 838 | xt_get_res_record_ref(bitem + ilen - XT_RECORD_REF_SIZE, result); /* (Only valid if i_item_offset < i_total_size) */ | 846 | if (result->sr_item.i_node_ref_size) |
3262 | 839 | result->sr_branch = IDX_GET_NODE_REF(tab, bitem, result->sr_item.i_node_ref_size); | 847 | /* IDX_GET_NODE_REF() loads the branch reference to the LEFT of the item. */ |
3263 | 848 | result->sr_branch = IDX_GET_NODE_REF(tab, bitem, result->sr_item.i_node_ref_size); | ||
3264 | 849 | else | ||
3265 | 850 | result->sr_branch = 0; | ||
3266 | 840 | } | 851 | } |
3267 | 841 | 852 | ||
3268 | 842 | xtPublic void xt_prev_branch_item_fix(XTTableHPtr XT_UNUSED(tab), XTIndexPtr XT_UNUSED(ind), XTIdxBranchDPtr branch, register XTIdxResultRec *result) | 853 | xtPublic void xt_prev_branch_item_fix(XTTableHPtr XT_UNUSED(tab), XTIndexPtr XT_UNUSED(ind), XTIdxBranchDPtr branch, register XTIdxResultRec *result) |
3269 | @@ -3987,7 +3998,7 @@ | |||
3270 | 3987 | * here. | 3998 | * here. |
3271 | 3988 | */ | 3999 | */ |
3272 | 3989 | if (!(tab->tab_dic.dic_tab_flags & XT_TAB_FLAGS_TEMP_TAB)) { | 4000 | if (!(tab->tab_dic.dic_tab_flags & XT_TAB_FLAGS_TEMP_TAB)) { |
3274 | 3990 | if (!xt_xlog_flush_log(ot->ot_thread)) | 4001 | if (!xt_xlog_flush_log(tab->tab_db, ot->ot_thread)) |
3275 | 3991 | goto failed_2; | 4002 | goto failed_2; |
3276 | 3992 | if (!il->il_flush(ot)) | 4003 | if (!il->il_flush(ot)) |
3277 | 3993 | goto failed_2; | 4004 | goto failed_2; |
3278 | 3994 | 4005 | ||
3279 | === modified file 'storage/pbxt/src/lock_xt.cc' | |||
3280 | --- storage/pbxt/src/lock_xt.cc 2009-08-17 11:12:36 +0000 | |||
3281 | +++ storage/pbxt/src/lock_xt.cc 2009-12-10 11:57:20 +0000 | |||
3282 | @@ -1246,7 +1246,7 @@ | |||
3283 | 1246 | (void) self; | 1246 | (void) self; |
3284 | 1247 | spl->spl_lock = 0; | 1247 | spl->spl_lock = 0; |
3285 | 1248 | #ifdef XT_NO_ATOMICS | 1248 | #ifdef XT_NO_ATOMICS |
3287 | 1249 | xt_init_mutex(self, &spl->spl_mutex); | 1249 | xt_init_mutex_with_autoname(self, &spl->spl_mutex); |
3288 | 1250 | #endif | 1250 | #endif |
3289 | 1251 | #ifdef DEBUG | 1251 | #ifdef DEBUG |
3290 | 1252 | spl->spl_locker = 0; | 1252 | spl->spl_locker = 0; |
3291 | 1253 | 1253 | ||
3292 | === modified file 'storage/pbxt/src/locklist_xt.h' | |||
3293 | --- storage/pbxt/src/locklist_xt.h 2009-08-17 11:12:36 +0000 | |||
3294 | +++ storage/pbxt/src/locklist_xt.h 2009-12-10 11:57:20 +0000 | |||
3295 | @@ -24,11 +24,16 @@ | |||
3296 | 24 | #ifndef __xt_locklist_h__ | 24 | #ifndef __xt_locklist_h__ |
3297 | 25 | #define __xt_locklist_h__ | 25 | #define __xt_locklist_h__ |
3298 | 26 | 26 | ||
3299 | 27 | /* | ||
3300 | 28 | * XT_THREAD_LOCK_INFO and DEBUG_LOCKING code must be updated to avoid calls to xt_get_self() as it can be called before hton->slot is | ||
3301 | 29 | * assigned by MySQL which is used by xt_get_self() | ||
3302 | 30 | */ | ||
3303 | 31 | |||
3304 | 27 | #ifdef DEBUG | 32 | #ifdef DEBUG |
3306 | 28 | #define XT_THREAD_LOCK_INFO | 33 | //#define XT_THREAD_LOCK_INFO |
3307 | 29 | #ifndef XT_WIN | 34 | #ifndef XT_WIN |
3308 | 30 | /* We need DEBUG_LOCKING in order to enable pthread function wrappers */ | 35 | /* We need DEBUG_LOCKING in order to enable pthread function wrappers */ |
3310 | 31 | #define DEBUG_LOCKING | 36 | //#define DEBUG_LOCKING |
3311 | 32 | #endif | 37 | #endif |
3312 | 33 | #endif | 38 | #endif |
3313 | 34 | 39 | ||
3314 | 35 | 40 | ||
3315 | === modified file 'storage/pbxt/src/memory_xt.cc' | |||
3316 | --- storage/pbxt/src/memory_xt.cc 2009-09-03 06:15:03 +0000 | |||
3317 | +++ storage/pbxt/src/memory_xt.cc 2009-12-10 11:57:20 +0000 | |||
3318 | @@ -34,7 +34,7 @@ | |||
3319 | 34 | #include "trace_xt.h" | 34 | #include "trace_xt.h" |
3320 | 35 | 35 | ||
3321 | 36 | #ifdef DEBUG | 36 | #ifdef DEBUG |
3323 | 37 | //#define RECORD_MM | 37 | #define RECORD_MM |
3324 | 38 | #endif | 38 | #endif |
3325 | 39 | 39 | ||
3326 | 40 | #ifdef DEBUG | 40 | #ifdef DEBUG |
3327 | @@ -367,9 +367,8 @@ | |||
3328 | 367 | return(-1); | 367 | return(-1); |
3329 | 368 | } | 368 | } |
3330 | 369 | 369 | ||
3332 | 370 | static long mm_add_pointer(void *ptr, u_int id) | 370 | static long mm_add_pointer(void *ptr, u_int XT_UNUSED(id)) |
3333 | 371 | { | 371 | { |
3334 | 372 | #pragma unused(id) | ||
3335 | 373 | register int i, n, guess; | 372 | register int i, n, guess; |
3336 | 374 | 373 | ||
3337 | 375 | if (mm_nr_in_use == mm_total_allocated) { | 374 | if (mm_nr_in_use == mm_total_allocated) { |
3338 | 376 | 375 | ||
3339 | === modified file 'storage/pbxt/src/myxt_xt.cc' | |||
3340 | --- storage/pbxt/src/myxt_xt.cc 2009-09-03 06:15:03 +0000 | |||
3341 | +++ storage/pbxt/src/myxt_xt.cc 2009-12-10 11:57:20 +0000 | |||
3342 | @@ -36,7 +36,7 @@ | |||
3343 | 36 | #include <drizzled/current_session.h> | 36 | #include <drizzled/current_session.h> |
3344 | 37 | #include <drizzled/sql_lex.h> | 37 | #include <drizzled/sql_lex.h> |
3345 | 38 | #include <drizzled/session.h> | 38 | #include <drizzled/session.h> |
3347 | 39 | extern "C" struct charset_info_st *session_charset(Session *session); | 39 | //extern "C" struct charset_info_st *session_charset(Session *session); |
3348 | 40 | extern pthread_key_t THR_Session; | 40 | extern pthread_key_t THR_Session; |
3349 | 41 | #else | 41 | #else |
3350 | 42 | #include "mysql_priv.h" | 42 | #include "mysql_priv.h" |
3351 | @@ -171,7 +171,9 @@ | |||
3352 | 171 | 171 | ||
3353 | 172 | for (u_int i=0; i<ind->mi_seg_count && (int) k_length > 0; i++, old += keyseg->length, keyseg++) | 172 | for (u_int i=0; i<ind->mi_seg_count && (int) k_length > 0; i++, old += keyseg->length, keyseg++) |
3354 | 173 | { | 173 | { |
3355 | 174 | #ifndef DRIZZLED | ||
3356 | 174 | enum ha_base_keytype type = (enum ha_base_keytype) keyseg->type; | 175 | enum ha_base_keytype type = (enum ha_base_keytype) keyseg->type; |
3357 | 176 | #endif | ||
3358 | 175 | u_int length = keyseg->length < k_length ? keyseg->length : k_length; | 177 | u_int length = keyseg->length < k_length ? keyseg->length : k_length; |
3359 | 176 | u_int char_length; | 178 | u_int char_length; |
3360 | 177 | xtWord1 *pos; | 179 | xtWord1 *pos; |
3361 | @@ -192,14 +194,18 @@ | |||
3362 | 192 | pos = old; | 194 | pos = old; |
3363 | 193 | if (keyseg->flag & HA_SPACE_PACK) { | 195 | if (keyseg->flag & HA_SPACE_PACK) { |
3364 | 194 | uchar *end = pos + length; | 196 | uchar *end = pos + length; |
3365 | 197 | #ifndef DRIZZLED | ||
3366 | 195 | if (type != HA_KEYTYPE_NUM) { | 198 | if (type != HA_KEYTYPE_NUM) { |
3367 | 199 | #endif | ||
3368 | 196 | while (end > pos && end[-1] == ' ') | 200 | while (end > pos && end[-1] == ' ') |
3369 | 197 | end--; | 201 | end--; |
3370 | 202 | #ifndef DRIZZLED | ||
3371 | 198 | } | 203 | } |
3372 | 199 | else { | 204 | else { |
3373 | 200 | while (pos < end && pos[0] == ' ') | 205 | while (pos < end && pos[0] == ' ') |
3374 | 201 | pos++; | 206 | pos++; |
3375 | 202 | } | 207 | } |
3376 | 208 | #endif | ||
3377 | 203 | k_length -= length; | 209 | k_length -= length; |
3378 | 204 | length = (u_int) (end-pos); | 210 | length = (u_int) (end-pos); |
3379 | 205 | FIX_LENGTH(cs, pos, length, char_length); | 211 | FIX_LENGTH(cs, pos, length, char_length); |
3380 | @@ -276,6 +282,7 @@ | |||
3381 | 276 | char_length= ((cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length); | 282 | char_length= ((cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length); |
3382 | 277 | 283 | ||
3383 | 278 | pos = record + keyseg->start; | 284 | pos = record + keyseg->start; |
3384 | 285 | #ifndef DRIZZLED | ||
3385 | 279 | if (type == HA_KEYTYPE_BIT) | 286 | if (type == HA_KEYTYPE_BIT) |
3386 | 280 | { | 287 | { |
3387 | 281 | if (keyseg->bit_length) | 288 | if (keyseg->bit_length) |
3388 | @@ -289,17 +296,22 @@ | |||
3389 | 289 | key+= length; | 296 | key+= length; |
3390 | 290 | continue; | 297 | continue; |
3391 | 291 | } | 298 | } |
3392 | 299 | #endif | ||
3393 | 292 | if (keyseg->flag & HA_SPACE_PACK) | 300 | if (keyseg->flag & HA_SPACE_PACK) |
3394 | 293 | { | 301 | { |
3395 | 294 | end = pos + length; | 302 | end = pos + length; |
3396 | 303 | #ifndef DRIZZLED | ||
3397 | 295 | if (type != HA_KEYTYPE_NUM) { | 304 | if (type != HA_KEYTYPE_NUM) { |
3398 | 305 | #endif | ||
3399 | 296 | while (end > pos && end[-1] == ' ') | 306 | while (end > pos && end[-1] == ' ') |
3400 | 297 | end--; | 307 | end--; |
3401 | 308 | #ifndef DRIZZLED | ||
3402 | 298 | } | 309 | } |
3403 | 299 | else { | 310 | else { |
3404 | 300 | while (pos < end && pos[0] == ' ') | 311 | while (pos < end && pos[0] == ' ') |
3405 | 301 | pos++; | 312 | pos++; |
3406 | 302 | } | 313 | } |
3407 | 314 | #endif | ||
3408 | 303 | length = (u_int) (end-pos); | 315 | length = (u_int) (end-pos); |
3409 | 304 | FIX_LENGTH(cs, pos, length, char_length); | 316 | FIX_LENGTH(cs, pos, length, char_length); |
3410 | 305 | store_key_length_inc(key,char_length); | 317 | store_key_length_inc(key,char_length); |
3411 | @@ -333,6 +345,7 @@ | |||
3412 | 333 | if (keyseg->flag & HA_SWAP_KEY) | 345 | if (keyseg->flag & HA_SWAP_KEY) |
3413 | 334 | { /* Numerical column */ | 346 | { /* Numerical column */ |
3414 | 335 | #ifdef HAVE_ISNAN | 347 | #ifdef HAVE_ISNAN |
3415 | 348 | #ifndef DRIZZLED | ||
3416 | 336 | if (type == HA_KEYTYPE_FLOAT) | 349 | if (type == HA_KEYTYPE_FLOAT) |
3417 | 337 | { | 350 | { |
3418 | 338 | float nr; | 351 | float nr; |
3419 | @@ -345,7 +358,9 @@ | |||
3420 | 345 | continue; | 358 | continue; |
3421 | 346 | } | 359 | } |
3422 | 347 | } | 360 | } |
3424 | 348 | else if (type == HA_KEYTYPE_DOUBLE) { | 361 | else |
3425 | 362 | #endif | ||
3426 | 363 | if (type == HA_KEYTYPE_DOUBLE) { | ||
3427 | 349 | double nr; | 364 | double nr; |
3428 | 350 | 365 | ||
3429 | 351 | float8get(nr,pos); | 366 | float8get(nr,pos); |
3430 | @@ -414,6 +429,7 @@ | |||
3431 | 414 | char_length= ((cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length); | 429 | char_length= ((cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length); |
3432 | 415 | 430 | ||
3433 | 416 | pos = record + keyseg->start; | 431 | pos = record + keyseg->start; |
3434 | 432 | #ifndef DRIZZLED | ||
3435 | 417 | if (type == HA_KEYTYPE_BIT) | 433 | if (type == HA_KEYTYPE_BIT) |
3436 | 418 | { | 434 | { |
3437 | 419 | if (keyseg->bit_length) | 435 | if (keyseg->bit_length) |
3438 | @@ -427,17 +443,22 @@ | |||
3439 | 427 | key+= length; | 443 | key+= length; |
3440 | 428 | continue; | 444 | continue; |
3441 | 429 | } | 445 | } |
3442 | 446 | #endif | ||
3443 | 430 | if (keyseg->flag & HA_SPACE_PACK) | 447 | if (keyseg->flag & HA_SPACE_PACK) |
3444 | 431 | { | 448 | { |
3445 | 432 | end = pos + length; | 449 | end = pos + length; |
3446 | 450 | #ifndef DRIZZLED | ||
3447 | 433 | if (type != HA_KEYTYPE_NUM) { | 451 | if (type != HA_KEYTYPE_NUM) { |
3448 | 452 | #endif | ||
3449 | 434 | while (end > pos && end[-1] == ' ') | 453 | while (end > pos && end[-1] == ' ') |
3450 | 435 | end--; | 454 | end--; |
3451 | 455 | #ifndef DRIZZLED | ||
3452 | 436 | } | 456 | } |
3453 | 437 | else { | 457 | else { |
3454 | 438 | while (pos < end && pos[0] == ' ') | 458 | while (pos < end && pos[0] == ' ') |
3455 | 439 | pos++; | 459 | pos++; |
3456 | 440 | } | 460 | } |
3457 | 461 | #endif | ||
3458 | 441 | length = (u_int) (end-pos); | 462 | length = (u_int) (end-pos); |
3459 | 442 | FIX_LENGTH(cs, pos, length, char_length); | 463 | FIX_LENGTH(cs, pos, length, char_length); |
3460 | 443 | store_key_length_inc(key,char_length); | 464 | store_key_length_inc(key,char_length); |
3461 | @@ -471,6 +492,7 @@ | |||
3462 | 471 | if (keyseg->flag & HA_SWAP_KEY) | 492 | if (keyseg->flag & HA_SWAP_KEY) |
3463 | 472 | { /* Numerical column */ | 493 | { /* Numerical column */ |
3464 | 473 | #ifdef HAVE_ISNAN | 494 | #ifdef HAVE_ISNAN |
3465 | 495 | #ifndef DRIZZLED | ||
3466 | 474 | if (type == HA_KEYTYPE_FLOAT) | 496 | if (type == HA_KEYTYPE_FLOAT) |
3467 | 475 | { | 497 | { |
3468 | 476 | float nr; | 498 | float nr; |
3469 | @@ -483,7 +505,9 @@ | |||
3470 | 483 | continue; | 505 | continue; |
3471 | 484 | } | 506 | } |
3472 | 485 | } | 507 | } |
3474 | 486 | else if (type == HA_KEYTYPE_DOUBLE) { | 508 | else |
3475 | 509 | #endif | ||
3476 | 510 | if (type == HA_KEYTYPE_DOUBLE) { | ||
3477 | 487 | double nr; | 511 | double nr; |
3478 | 488 | 512 | ||
3479 | 489 | float8get(nr,pos); | 513 | float8get(nr,pos); |
3480 | @@ -622,7 +646,6 @@ | |||
3481 | 622 | case MYSQL_TYPE_SET: | 646 | case MYSQL_TYPE_SET: |
3482 | 623 | case MYSQL_TYPE_GEOMETRY: | 647 | case MYSQL_TYPE_GEOMETRY: |
3483 | 624 | #else | 648 | #else |
3484 | 625 | case DRIZZLE_TYPE_TINY: | ||
3485 | 626 | case DRIZZLE_TYPE_LONG: | 649 | case DRIZZLE_TYPE_LONG: |
3486 | 627 | case DRIZZLE_TYPE_DOUBLE: | 650 | case DRIZZLE_TYPE_DOUBLE: |
3487 | 628 | case DRIZZLE_TYPE_NULL: | 651 | case DRIZZLE_TYPE_NULL: |
3488 | @@ -740,7 +763,6 @@ | |||
3489 | 740 | case MYSQL_TYPE_SET: | 763 | case MYSQL_TYPE_SET: |
3490 | 741 | case MYSQL_TYPE_GEOMETRY: | 764 | case MYSQL_TYPE_GEOMETRY: |
3491 | 742 | #else | 765 | #else |
3492 | 743 | case DRIZZLE_TYPE_TINY: | ||
3493 | 744 | case DRIZZLE_TYPE_LONG: | 766 | case DRIZZLE_TYPE_LONG: |
3494 | 745 | case DRIZZLE_TYPE_DOUBLE: | 767 | case DRIZZLE_TYPE_DOUBLE: |
3495 | 746 | case DRIZZLE_TYPE_NULL: | 768 | case DRIZZLE_TYPE_NULL: |
3496 | @@ -825,6 +847,7 @@ | |||
3497 | 825 | } | 847 | } |
3498 | 826 | record[keyseg->null_pos] &= ~keyseg->null_bit; | 848 | record[keyseg->null_pos] &= ~keyseg->null_bit; |
3499 | 827 | } | 849 | } |
3500 | 850 | #ifndef DRIZZLED | ||
3501 | 828 | if (keyseg->type == HA_KEYTYPE_BIT) | 851 | if (keyseg->type == HA_KEYTYPE_BIT) |
3502 | 829 | { | 852 | { |
3503 | 830 | uint length = keyseg->length; | 853 | uint length = keyseg->length; |
3504 | @@ -845,6 +868,7 @@ | |||
3505 | 845 | key+= length; | 868 | key+= length; |
3506 | 846 | continue; | 869 | continue; |
3507 | 847 | } | 870 | } |
3508 | 871 | #endif | ||
3509 | 848 | if (keyseg->flag & HA_SPACE_PACK) | 872 | if (keyseg->flag & HA_SPACE_PACK) |
3510 | 849 | { | 873 | { |
3511 | 850 | uint length; | 874 | uint length; |
3512 | @@ -854,16 +878,20 @@ | |||
3513 | 854 | goto err; | 878 | goto err; |
3514 | 855 | #endif | 879 | #endif |
3515 | 856 | pos = record+keyseg->start; | 880 | pos = record+keyseg->start; |
3516 | 881 | #ifndef DRIZZLED | ||
3517 | 857 | if (keyseg->type != (int) HA_KEYTYPE_NUM) | 882 | if (keyseg->type != (int) HA_KEYTYPE_NUM) |
3518 | 858 | { | 883 | { |
3519 | 884 | #endif | ||
3520 | 859 | memcpy(pos,key,(size_t) length); | 885 | memcpy(pos,key,(size_t) length); |
3521 | 860 | bfill(pos+length,keyseg->length-length,' '); | 886 | bfill(pos+length,keyseg->length-length,' '); |
3522 | 887 | #ifndef DRIZZLED | ||
3523 | 861 | } | 888 | } |
3524 | 862 | else | 889 | else |
3525 | 863 | { | 890 | { |
3526 | 864 | bfill(pos,keyseg->length-length,' '); | 891 | bfill(pos,keyseg->length-length,' '); |
3527 | 865 | memcpy(pos+keyseg->length-length,key,(size_t) length); | 892 | memcpy(pos+keyseg->length-length,key,(size_t) length); |
3528 | 866 | } | 893 | } |
3529 | 894 | #endif | ||
3530 | 867 | key+=length; | 895 | key+=length; |
3531 | 868 | continue; | 896 | continue; |
3532 | 869 | } | 897 | } |
3533 | @@ -945,7 +973,7 @@ | |||
3534 | 945 | static int my_compare_bin(uchar *a, uint a_length, uchar *b, uint b_length, | 973 | static int my_compare_bin(uchar *a, uint a_length, uchar *b, uint b_length, |
3535 | 946 | my_bool part_key, my_bool skip_end_space) | 974 | my_bool part_key, my_bool skip_end_space) |
3536 | 947 | { | 975 | { |
3538 | 948 | uint length= min(a_length,b_length); | 976 | uint length= a_length < b_length ? a_length : b_length; |
3539 | 949 | uchar *end= a+ length; | 977 | uchar *end= a+ length; |
3540 | 950 | int flag; | 978 | int flag; |
3541 | 951 | 979 | ||
3542 | @@ -1023,6 +1051,7 @@ | |||
3543 | 1023 | get_key_pack_length(seg_len, pack_len, key_data); | 1051 | get_key_pack_length(seg_len, pack_len, key_data); |
3544 | 1024 | key_data += seg_len; | 1052 | key_data += seg_len; |
3545 | 1025 | break; | 1053 | break; |
3546 | 1054 | #ifndef DRIZZLED | ||
3547 | 1026 | case HA_KEYTYPE_NUM: { | 1055 | case HA_KEYTYPE_NUM: { |
3548 | 1027 | /* Numeric key */ | 1056 | /* Numeric key */ |
3549 | 1028 | if (keyseg->flag & HA_SPACE_PACK) | 1057 | if (keyseg->flag & HA_SPACE_PACK) |
3550 | @@ -1035,15 +1064,16 @@ | |||
3551 | 1035 | case HA_KEYTYPE_INT8: | 1064 | case HA_KEYTYPE_INT8: |
3552 | 1036 | case HA_KEYTYPE_SHORT_INT: | 1065 | case HA_KEYTYPE_SHORT_INT: |
3553 | 1037 | case HA_KEYTYPE_USHORT_INT: | 1066 | case HA_KEYTYPE_USHORT_INT: |
3554 | 1067 | case HA_KEYTYPE_INT24: | ||
3555 | 1068 | case HA_KEYTYPE_FLOAT: | ||
3556 | 1069 | case HA_KEYTYPE_BIT: | ||
3557 | 1070 | #endif | ||
3558 | 1038 | case HA_KEYTYPE_LONG_INT: | 1071 | case HA_KEYTYPE_LONG_INT: |
3559 | 1039 | case HA_KEYTYPE_ULONG_INT: | 1072 | case HA_KEYTYPE_ULONG_INT: |
3560 | 1040 | case HA_KEYTYPE_INT24: | ||
3561 | 1041 | case HA_KEYTYPE_UINT24: | 1073 | case HA_KEYTYPE_UINT24: |
3562 | 1042 | case HA_KEYTYPE_FLOAT: | ||
3563 | 1043 | case HA_KEYTYPE_DOUBLE: | 1074 | case HA_KEYTYPE_DOUBLE: |
3564 | 1044 | case HA_KEYTYPE_LONGLONG: | 1075 | case HA_KEYTYPE_LONGLONG: |
3565 | 1045 | case HA_KEYTYPE_ULONGLONG: | 1076 | case HA_KEYTYPE_ULONGLONG: |
3566 | 1046 | case HA_KEYTYPE_BIT: | ||
3567 | 1047 | key_data += keyseg->length; | 1077 | key_data += keyseg->length; |
3568 | 1048 | break; | 1078 | break; |
3569 | 1049 | case HA_KEYTYPE_END: | 1079 | case HA_KEYTYPE_END: |
3570 | @@ -1190,6 +1220,7 @@ | |||
3571 | 1190 | b += b_length; | 1220 | b += b_length; |
3572 | 1191 | break; | 1221 | break; |
3573 | 1192 | } | 1222 | } |
3574 | 1223 | #ifndef DRIZZLED | ||
3575 | 1193 | case HA_KEYTYPE_INT8: | 1224 | case HA_KEYTYPE_INT8: |
3576 | 1194 | { | 1225 | { |
3577 | 1195 | int i_1 = (int) *((signed char *) a); | 1226 | int i_1 = (int) *((signed char *) a); |
3578 | @@ -1218,6 +1249,7 @@ | |||
3579 | 1218 | b += keyseg->length; | 1249 | b += keyseg->length; |
3580 | 1219 | break; | 1250 | break; |
3581 | 1220 | } | 1251 | } |
3582 | 1252 | #endif | ||
3583 | 1221 | case HA_KEYTYPE_LONG_INT: { | 1253 | case HA_KEYTYPE_LONG_INT: { |
3584 | 1222 | int32 l_1 = sint4korr(a); | 1254 | int32 l_1 = sint4korr(a); |
3585 | 1223 | int32 l_2 = sint4korr(b); | 1255 | int32 l_2 = sint4korr(b); |
3586 | @@ -1236,6 +1268,7 @@ | |||
3587 | 1236 | b += keyseg->length; | 1268 | b += keyseg->length; |
3588 | 1237 | break; | 1269 | break; |
3589 | 1238 | } | 1270 | } |
3590 | 1271 | #ifndef DRIZZLED | ||
3591 | 1239 | case HA_KEYTYPE_INT24: { | 1272 | case HA_KEYTYPE_INT24: { |
3592 | 1240 | int32 l_1 = sint3korr(a); | 1273 | int32 l_1 = sint3korr(a); |
3593 | 1241 | int32 l_2 = sint3korr(b); | 1274 | int32 l_2 = sint3korr(b); |
3594 | @@ -1245,6 +1278,7 @@ | |||
3595 | 1245 | b += keyseg->length; | 1278 | b += keyseg->length; |
3596 | 1246 | break; | 1279 | break; |
3597 | 1247 | } | 1280 | } |
3598 | 1281 | #endif | ||
3599 | 1248 | case HA_KEYTYPE_UINT24: { | 1282 | case HA_KEYTYPE_UINT24: { |
3600 | 1249 | int32 l_1 = uint3korr(a); | 1283 | int32 l_1 = uint3korr(a); |
3601 | 1250 | int32 l_2 = uint3korr(b); | 1284 | int32 l_2 = uint3korr(b); |
3602 | @@ -1254,6 +1288,7 @@ | |||
3603 | 1254 | b += keyseg->length; | 1288 | b += keyseg->length; |
3604 | 1255 | break; | 1289 | break; |
3605 | 1256 | } | 1290 | } |
3606 | 1291 | #ifndef DRIZZLED | ||
3607 | 1257 | case HA_KEYTYPE_FLOAT: { | 1292 | case HA_KEYTYPE_FLOAT: { |
3608 | 1258 | float f_1, f_2; | 1293 | float f_1, f_2; |
3609 | 1259 | 1294 | ||
3610 | @@ -1270,6 +1305,7 @@ | |||
3611 | 1270 | b += keyseg->length; | 1305 | b += keyseg->length; |
3612 | 1271 | break; | 1306 | break; |
3613 | 1272 | } | 1307 | } |
3614 | 1308 | #endif | ||
3615 | 1273 | case HA_KEYTYPE_DOUBLE: { | 1309 | case HA_KEYTYPE_DOUBLE: { |
3616 | 1274 | double d_1, d_2; | 1310 | double d_1, d_2; |
3617 | 1275 | 1311 | ||
3618 | @@ -1286,6 +1322,7 @@ | |||
3619 | 1286 | b += keyseg->length; | 1322 | b += keyseg->length; |
3620 | 1287 | break; | 1323 | break; |
3621 | 1288 | } | 1324 | } |
3622 | 1325 | #ifndef DRIZZLED | ||
3623 | 1289 | case HA_KEYTYPE_NUM: { | 1326 | case HA_KEYTYPE_NUM: { |
3624 | 1290 | /* Numeric key */ | 1327 | /* Numeric key */ |
3625 | 1291 | if (keyseg->flag & HA_SPACE_PACK) { | 1328 | if (keyseg->flag & HA_SPACE_PACK) { |
3626 | @@ -1339,6 +1376,7 @@ | |||
3627 | 1339 | b += b_length; | 1376 | b += b_length; |
3628 | 1340 | break; | 1377 | break; |
3629 | 1341 | } | 1378 | } |
3630 | 1379 | #endif | ||
3631 | 1342 | #ifdef HAVE_LONG_LONG | 1380 | #ifdef HAVE_LONG_LONG |
3632 | 1343 | case HA_KEYTYPE_LONGLONG: { | 1381 | case HA_KEYTYPE_LONGLONG: { |
3633 | 1344 | longlong ll_a = sint8korr(a); | 1382 | longlong ll_a = sint8korr(a); |
3634 | @@ -1359,9 +1397,11 @@ | |||
3635 | 1359 | break; | 1397 | break; |
3636 | 1360 | } | 1398 | } |
3637 | 1361 | #endif | 1399 | #endif |
3638 | 1400 | #ifndef DRIZZLED | ||
3639 | 1362 | case HA_KEYTYPE_BIT: | 1401 | case HA_KEYTYPE_BIT: |
3640 | 1363 | /* TODO: What here? */ | 1402 | /* TODO: What here? */ |
3641 | 1364 | break; | 1403 | break; |
3642 | 1404 | #endif | ||
3643 | 1365 | case HA_KEYTYPE_END: /* Ready */ | 1405 | case HA_KEYTYPE_END: /* Ready */ |
3644 | 1366 | goto end; | 1406 | goto end; |
3645 | 1367 | } | 1407 | } |
3646 | @@ -1410,16 +1450,19 @@ | |||
3647 | 1410 | key_length = has_null + a_length + pack_len; | 1450 | key_length = has_null + a_length + pack_len; |
3648 | 1411 | break; | 1451 | break; |
3649 | 1412 | } | 1452 | } |
3650 | 1453 | #ifndef DRIZZLED | ||
3651 | 1413 | case HA_KEYTYPE_INT8: | 1454 | case HA_KEYTYPE_INT8: |
3652 | 1414 | case HA_KEYTYPE_SHORT_INT: | 1455 | case HA_KEYTYPE_SHORT_INT: |
3653 | 1415 | case HA_KEYTYPE_USHORT_INT: | 1456 | case HA_KEYTYPE_USHORT_INT: |
3654 | 1457 | case HA_KEYTYPE_INT24: | ||
3655 | 1458 | case HA_KEYTYPE_FLOAT: | ||
3656 | 1459 | #endif | ||
3657 | 1416 | case HA_KEYTYPE_LONG_INT: | 1460 | case HA_KEYTYPE_LONG_INT: |
3658 | 1417 | case HA_KEYTYPE_ULONG_INT: | 1461 | case HA_KEYTYPE_ULONG_INT: |
3659 | 1418 | case HA_KEYTYPE_INT24: | ||
3660 | 1419 | case HA_KEYTYPE_UINT24: | 1462 | case HA_KEYTYPE_UINT24: |
3661 | 1420 | case HA_KEYTYPE_FLOAT: | ||
3662 | 1421 | case HA_KEYTYPE_DOUBLE: | 1463 | case HA_KEYTYPE_DOUBLE: |
3663 | 1422 | break; | 1464 | break; |
3664 | 1465 | #ifndef DRIZZLED | ||
3665 | 1423 | case HA_KEYTYPE_NUM: { | 1466 | case HA_KEYTYPE_NUM: { |
3666 | 1424 | /* Numeric key */ | 1467 | /* Numeric key */ |
3667 | 1425 | if (keyseg->flag & HA_SPACE_PACK) { | 1468 | if (keyseg->flag & HA_SPACE_PACK) { |
3668 | @@ -1428,14 +1471,17 @@ | |||
3669 | 1428 | } | 1471 | } |
3670 | 1429 | break; | 1472 | break; |
3671 | 1430 | } | 1473 | } |
3672 | 1474 | #endif | ||
3673 | 1431 | #ifdef HAVE_LONG_LONG | 1475 | #ifdef HAVE_LONG_LONG |
3674 | 1432 | case HA_KEYTYPE_LONGLONG: | 1476 | case HA_KEYTYPE_LONGLONG: |
3675 | 1433 | case HA_KEYTYPE_ULONGLONG: | 1477 | case HA_KEYTYPE_ULONGLONG: |
3676 | 1434 | break; | 1478 | break; |
3677 | 1435 | #endif | 1479 | #endif |
3678 | 1480 | #ifndef DRIZZLED | ||
3679 | 1436 | case HA_KEYTYPE_BIT: | 1481 | case HA_KEYTYPE_BIT: |
3680 | 1437 | /* TODO: What here? */ | 1482 | /* TODO: What here? */ |
3681 | 1438 | break; | 1483 | break; |
3682 | 1484 | #endif | ||
3683 | 1439 | case HA_KEYTYPE_END: /* Ready */ | 1485 | case HA_KEYTYPE_END: /* Ready */ |
3684 | 1440 | break; | 1486 | break; |
3685 | 1441 | } | 1487 | } |
3686 | @@ -1486,7 +1532,7 @@ | |||
3687 | 1486 | return row_size; | 1532 | return row_size; |
3688 | 1487 | } | 1533 | } |
3689 | 1488 | 1534 | ||
3691 | 1489 | static xtWord4 mx_store_row(XTOpenTablePtr ot, xtWord4 row_size, char *rec_buff) | 1535 | xtPublic xtWord4 myxt_store_row_data(XTOpenTablePtr ot, xtWord4 row_size, char *rec_buff) |
3692 | 1490 | { | 1536 | { |
3693 | 1491 | TABLE *table = ot->ot_table->tab_dic.dic_my_table; | 1537 | TABLE *table = ot->ot_table->tab_dic.dic_my_table; |
3694 | 1492 | char *sdata; | 1538 | char *sdata; |
3695 | @@ -1614,8 +1660,9 @@ | |||
3696 | 1614 | } | 1660 | } |
3697 | 1615 | 1661 | ||
3698 | 1616 | /* Unload from PBXT variable length format to the MySQL row format. */ | 1662 | /* Unload from PBXT variable length format to the MySQL row format. */ |
3700 | 1617 | xtPublic xtBool myxt_load_row(XTOpenTablePtr ot, xtWord1 *source_buf, xtWord1 *dest_buff, u_int col_cnt) | 1663 | xtPublic xtWord4 myxt_load_row_data(XTOpenTablePtr ot, xtWord1 *source_buf, xtWord1 *dest_buff, u_int col_cnt) |
3701 | 1618 | { | 1664 | { |
3702 | 1665 | xtWord1 *input_buf = source_buf; | ||
3703 | 1619 | TABLE *table; | 1666 | TABLE *table; |
3704 | 1620 | xtWord4 len; | 1667 | xtWord4 len; |
3705 | 1621 | Field *curr_field; | 1668 | Field *curr_field; |
3706 | @@ -1624,7 +1671,7 @@ | |||
3707 | 1624 | 1671 | ||
3708 | 1625 | if (!(table = ot->ot_table->tab_dic.dic_my_table)) { | 1672 | if (!(table = ot->ot_table->tab_dic.dic_my_table)) { |
3709 | 1626 | xt_register_taberr(XT_REG_CONTEXT, XT_ERR_NO_DICTIONARY, ot->ot_table->tab_name); | 1673 | xt_register_taberr(XT_REG_CONTEXT, XT_ERR_NO_DICTIONARY, ot->ot_table->tab_name); |
3711 | 1627 | return FAILED; | 1674 | return 0; |
3712 | 1628 | } | 1675 | } |
3713 | 1629 | 1676 | ||
3714 | 1630 | /* According to the InnoDB implementation: | 1677 | /* According to the InnoDB implementation: |
3715 | @@ -1657,7 +1704,7 @@ | |||
3716 | 1657 | default: // Length byte | 1704 | default: // Length byte |
3717 | 1658 | if (*source_buf > 240) { | 1705 | if (*source_buf > 240) { |
3718 | 1659 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_RECORD_FORMAT); | 1706 | xt_register_xterr(XT_REG_CONTEXT, XT_ERR_BAD_RECORD_FORMAT); |
3720 | 1660 | return FAILED; | 1707 | return 0; |
3721 | 1661 | } | 1708 | } |
3722 | 1662 | len = *source_buf; | 1709 | len = *source_buf; |
3723 | 1663 | source_buf++; | 1710 | source_buf++; |
3724 | @@ -1671,7 +1718,12 @@ | |||
3725 | 1671 | 1718 | ||
3726 | 1672 | source_buf += len; | 1719 | source_buf += len; |
3727 | 1673 | } | 1720 | } |
3729 | 1674 | return OK; | 1721 | return (xtWord4) (source_buf - input_buf); |
3730 | 1722 | } | ||
3731 | 1723 | |||
3732 | 1724 | xtPublic xtBool myxt_load_row(XTOpenTablePtr ot, xtWord1 *source_buf, xtWord1 *dest_buff, u_int col_cnt) | ||
3733 | 1725 | { | ||
3734 | 1726 | return myxt_load_row_data(ot, source_buf, dest_buff, col_cnt) != 0; | ||
3735 | 1675 | } | 1727 | } |
3736 | 1676 | 1728 | ||
3737 | 1677 | xtPublic xtBool myxt_find_column(XTOpenTablePtr ot, u_int *col_idx, const char *col_name) | 1729 | xtPublic xtBool myxt_find_column(XTOpenTablePtr ot, u_int *col_idx, const char *col_name) |
3738 | @@ -1784,7 +1836,7 @@ | |||
3739 | 1784 | else { | 1836 | else { |
3740 | 1785 | xtWord4 row_size; | 1837 | xtWord4 row_size; |
3741 | 1786 | 1838 | ||
3743 | 1787 | if (!(row_size = mx_store_row(ot, XT_REC_EXT_HEADER_SIZE, rec_buff))) | 1839 | if (!(row_size = myxt_store_row_data(ot, XT_REC_EXT_HEADER_SIZE, rec_buff))) |
3744 | 1788 | return FAILED; | 1840 | return FAILED; |
3745 | 1789 | if (row_size - XT_REC_FIX_EXT_HEADER_DIFF <= ot->ot_rec_size) { | 1841 | if (row_size - XT_REC_FIX_EXT_HEADER_DIFF <= ot->ot_rec_size) { |
3746 | 1790 | rec_info->ri_fix_rec_buf = (XTTabRecFixDPtr) &ot->ot_row_wbuffer[XT_REC_FIX_EXT_HEADER_DIFF]; | 1842 | rec_info->ri_fix_rec_buf = (XTTabRecFixDPtr) &ot->ot_row_wbuffer[XT_REC_FIX_EXT_HEADER_DIFF]; |
3747 | @@ -1951,7 +2003,7 @@ | |||
3748 | 1951 | 2003 | ||
3749 | 1952 | #ifdef DRIZZLED | 2004 | #ifdef DRIZZLED |
3750 | 1953 | share->init(db_name, 0, name, path); | 2005 | share->init(db_name, 0, name, path); |
3752 | 1954 | if ((error = open_table_def(thd, share)) || | 2006 | if ((error = open_table_def(*thd, share)) || |
3753 | 1955 | (error = open_table_from_share(thd, share, "", 0, (uint32_t) READ_ALL, 0, table, OTM_OPEN))) | 2007 | (error = open_table_from_share(thd, share, "", 0, (uint32_t) READ_ALL, 0, table, OTM_OPEN))) |
3754 | 1956 | { | 2008 | { |
3755 | 1957 | xt_free(self, table); | 2009 | xt_free(self, table); |
3756 | @@ -1995,7 +2047,7 @@ | |||
3757 | 1995 | return NULL; | 2047 | return NULL; |
3758 | 1996 | } | 2048 | } |
3759 | 1997 | 2049 | ||
3761 | 1998 | #if MYSQL_VERSION_ID >= 60003 | 2050 | #if MYSQL_VERSION_ID >= 50404 |
3762 | 1999 | if ((error = open_table_from_share(thd, share, "", 0, (uint) READ_ALL, 0, table, OTM_OPEN))) | 2051 | if ((error = open_table_from_share(thd, share, "", 0, (uint) READ_ALL, 0, table, OTM_OPEN))) |
3763 | 2000 | #else | 2052 | #else |
3764 | 2001 | if ((error = open_table_from_share(thd, share, "", 0, (uint) READ_ALL, 0, table, FALSE))) | 2053 | if ((error = open_table_from_share(thd, share, "", 0, (uint) READ_ALL, 0, table, FALSE))) |
3765 | @@ -2145,7 +2197,10 @@ | |||
3766 | 2145 | if (options & HA_OPTION_PACK_KEYS || | 2197 | if (options & HA_OPTION_PACK_KEYS || |
3767 | 2146 | (index->flags & (HA_PACK_KEY | HA_BINARY_PACK_KEY | HA_SPACE_PACK_USED))) | 2198 | (index->flags & (HA_PACK_KEY | HA_BINARY_PACK_KEY | HA_SPACE_PACK_USED))) |
3768 | 2147 | { | 2199 | { |
3770 | 2148 | if (key_part->length > 8 && (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_NUM || | 2200 | if (key_part->length > 8 && (type == HA_KEYTYPE_TEXT || |
3771 | 2201 | #ifndef DRIZZLED | ||
3772 | 2202 | type == HA_KEYTYPE_NUM || | ||
3773 | 2203 | #endif | ||
3774 | 2149 | (type == HA_KEYTYPE_BINARY && !field->zero_pack()))) | 2204 | (type == HA_KEYTYPE_BINARY && !field->zero_pack()))) |
3775 | 2150 | { | 2205 | { |
3776 | 2151 | /* No blobs here */ | 2206 | /* No blobs here */ |
3777 | @@ -2213,8 +2268,12 @@ | |||
3778 | 2213 | else if (field->type() == MYSQL_TYPE_ENUM) { | 2268 | else if (field->type() == MYSQL_TYPE_ENUM) { |
3779 | 2214 | switch (seg->length) { | 2269 | switch (seg->length) { |
3780 | 2215 | case 2: | 2270 | case 2: |
3781 | 2271 | #ifdef DRIZZLED | ||
3782 | 2272 | ASSERT_NS(FALSE); | ||
3783 | 2273 | #else | ||
3784 | 2216 | seg->type = HA_KEYTYPE_USHORT_INT; | 2274 | seg->type = HA_KEYTYPE_USHORT_INT; |
3785 | 2217 | break; | 2275 | break; |
3786 | 2276 | #endif | ||
3787 | 2218 | case 3: | 2277 | case 3: |
3788 | 2219 | seg->type = HA_KEYTYPE_UINT24; | 2278 | seg->type = HA_KEYTYPE_UINT24; |
3789 | 2220 | break; | 2279 | break; |
3790 | @@ -2675,7 +2734,11 @@ | |||
3791 | 2675 | if (!(my_tab = my_open_table(self, db, tab_path))) | 2734 | if (!(my_tab = my_open_table(self, db, tab_path))) |
3792 | 2676 | return FAILED; | 2735 | return FAILED; |
3793 | 2677 | dic->dic_my_table = my_tab; | 2736 | dic->dic_my_table = my_tab; |
3794 | 2737 | #ifdef DRIZZLED | ||
3795 | 2738 | dic->dic_def_ave_row_size = (xtWord8) my_tab->s->getAvgRowLength(); | ||
3796 | 2739 | #else | ||
3797 | 2678 | dic->dic_def_ave_row_size = (xtWord8) my_tab->s->avg_row_length; | 2740 | dic->dic_def_ave_row_size = (xtWord8) my_tab->s->avg_row_length; |
3798 | 2741 | #endif | ||
3799 | 2679 | myxt_setup_dictionary(self, dic); | 2742 | myxt_setup_dictionary(self, dic); |
3800 | 2680 | dic->dic_keys = (XTIndexPtr *) xt_calloc(self, sizeof(XTIndexPtr) * TS(my_tab)->keys); | 2743 | dic->dic_keys = (XTIndexPtr *) xt_calloc(self, sizeof(XTIndexPtr) * TS(my_tab)->keys); |
3801 | 2681 | for (uint i=0; i<TS(my_tab)->keys; i++) | 2744 | for (uint i=0; i<TS(my_tab)->keys; i++) |
3802 | @@ -2805,8 +2868,10 @@ | |||
3803 | 2805 | 2868 | ||
3804 | 2806 | static char *my_type_to_string(XTThreadPtr self, Field *field, TABLE *XT_UNUSED(my_tab)) | 2869 | static char *my_type_to_string(XTThreadPtr self, Field *field, TABLE *XT_UNUSED(my_tab)) |
3805 | 2807 | { | 2870 | { |
3807 | 2808 | char buffer[MAX_FIELD_WIDTH + 400], *ptr; | 2871 | char buffer[MAX_FIELD_WIDTH + 400]; |
3808 | 2872 | const char *ptr; | ||
3809 | 2809 | String type((char *) buffer, sizeof(buffer), system_charset_info); | 2873 | String type((char *) buffer, sizeof(buffer), system_charset_info); |
3810 | 2874 | xtWord4 len; | ||
3811 | 2810 | 2875 | ||
3812 | 2811 | /* GOTCHA: | 2876 | /* GOTCHA: |
3813 | 2812 | * - Above sets the string length to the same as the buffer, | 2877 | * - Above sets the string length to the same as the buffer, |
3814 | @@ -2817,10 +2882,17 @@ | |||
3815 | 2817 | */ | 2882 | */ |
3816 | 2818 | type.length(0); | 2883 | type.length(0); |
3817 | 2819 | field->sql_type(type); | 2884 | field->sql_type(type); |
3819 | 2820 | ptr = type.c_ptr(); | 2885 | ptr = type.ptr(); |
3820 | 2886 | len = type.length(); | ||
3821 | 2887 | |||
3822 | 2888 | if (len >= sizeof(buffer)) | ||
3823 | 2889 | len = sizeof(buffer)-1; | ||
3824 | 2890 | |||
3825 | 2821 | if (ptr != buffer) | 2891 | if (ptr != buffer) |
3827 | 2822 | xt_strcpy(sizeof(buffer), buffer, ptr); | 2892 | xt_strcpy(sizeof(buffer), buffer, ptr); |
3828 | 2823 | 2893 | ||
3829 | 2894 | buffer[len] = 0; | ||
3830 | 2895 | |||
3831 | 2824 | if (field->has_charset()) { | 2896 | if (field->has_charset()) { |
3832 | 2825 | /* Always include the charset so that we can compare types | 2897 | /* Always include the charset so that we can compare types |
3833 | 2826 | * for FK/PK releations. | 2898 | * for FK/PK releations. |
3834 | @@ -2877,6 +2949,10 @@ | |||
3835 | 2877 | 2949 | ||
3836 | 2878 | xtPublic void myxt_static_convert_identifier(XTThreadPtr XT_UNUSED(self), MX_CHARSET_INFO *cs, char *from, char *to, size_t to_len) | 2950 | xtPublic void myxt_static_convert_identifier(XTThreadPtr XT_UNUSED(self), MX_CHARSET_INFO *cs, char *from, char *to, size_t to_len) |
3837 | 2879 | { | 2951 | { |
3838 | 2952 | #ifdef DRIZZLED | ||
3839 | 2953 | ((void *)cs); | ||
3840 | 2954 | xt_strcpy(to_len, to, from); | ||
3841 | 2955 | #else | ||
3842 | 2880 | uint errors; | 2956 | uint errors; |
3843 | 2881 | 2957 | ||
3844 | 2882 | /* | 2958 | /* |
3845 | @@ -2888,11 +2964,16 @@ | |||
3846 | 2888 | xt_strcpy(to_len, to, from); | 2964 | xt_strcpy(to_len, to, from); |
3847 | 2889 | else | 2965 | else |
3848 | 2890 | strconvert(cs, from, &my_charset_utf8_general_ci, to, to_len, &errors); | 2966 | strconvert(cs, from, &my_charset_utf8_general_ci, to, to_len, &errors); |
3849 | 2967 | #endif | ||
3850 | 2891 | } | 2968 | } |
3851 | 2892 | 2969 | ||
3852 | 2893 | // cs == current_thd->charset() | 2970 | // cs == current_thd->charset() |
3853 | 2894 | xtPublic char *myxt_convert_identifier(XTThreadPtr self, MX_CHARSET_INFO *cs, char *from) | 2971 | xtPublic char *myxt_convert_identifier(XTThreadPtr self, MX_CHARSET_INFO *cs, char *from) |
3854 | 2895 | { | 2972 | { |
3855 | 2973 | #ifdef DRIZZLED | ||
3856 | 2974 | char *to = xt_dup_string(self, from); | ||
3857 | 2975 | ((void *)cs); | ||
3858 | 2976 | #else | ||
3859 | 2896 | uint errors; | 2977 | uint errors; |
3860 | 2897 | u_int len; | 2978 | u_int len; |
3861 | 2898 | char *to; | 2979 | char *to; |
3862 | @@ -2904,6 +2985,7 @@ | |||
3863 | 2904 | to = (char *) xt_malloc(self, len); | 2985 | to = (char *) xt_malloc(self, len); |
3864 | 2905 | strconvert(cs, from, &my_charset_utf8_general_ci, to, len, &errors); | 2986 | strconvert(cs, from, &my_charset_utf8_general_ci, to, len, &errors); |
3865 | 2906 | } | 2987 | } |
3866 | 2988 | #endif | ||
3867 | 2907 | return to; | 2989 | return to; |
3868 | 2908 | } | 2990 | } |
3869 | 2909 | 2991 | ||
3870 | @@ -2954,9 +3036,9 @@ | |||
3871 | 2954 | THD *thd = current_thd; | 3036 | THD *thd = current_thd; |
3872 | 2955 | 3037 | ||
3873 | 2956 | if (thd) | 3038 | if (thd) |
3875 | 2957 | return thd_charset(thd); | 3039 | return (MX_CHARSET_INFO *)thd_charset(thd); |
3876 | 2958 | } | 3040 | } |
3878 | 2959 | return &my_charset_utf8_general_ci; | 3041 | return (MX_CHARSET_INFO *)&my_charset_utf8_general_ci; |
3879 | 2960 | } | 3042 | } |
3880 | 2961 | 3043 | ||
3881 | 2962 | xtPublic void *myxt_create_thread() | 3044 | xtPublic void *myxt_create_thread() |
3882 | @@ -3011,12 +3093,26 @@ | |||
3883 | 3011 | return NULL; | 3093 | return NULL; |
3884 | 3012 | } | 3094 | } |
3885 | 3013 | 3095 | ||
3887 | 3014 | if (!(new_thd = new THD())) { | 3096 | if (!(new_thd = new THD)) { |
3888 | 3015 | my_thread_end(); | 3097 | my_thread_end(); |
3889 | 3016 | xt_register_error(XT_REG_CONTEXT, XT_ERR_MYSQL_ERROR, 0, "Unable to create MySQL thread (THD)"); | 3098 | xt_register_error(XT_REG_CONTEXT, XT_ERR_MYSQL_ERROR, 0, "Unable to create MySQL thread (THD)"); |
3890 | 3017 | return NULL; | 3099 | return NULL; |
3891 | 3018 | } | 3100 | } |
3892 | 3019 | 3101 | ||
3893 | 3102 | /* | ||
3894 | 3103 | * If PBXT is the default storage engine, then creating any THD objects will add extra | ||
3895 | 3104 | * references to the PBXT plugin object. because the threads are created but PBXT | ||
3896 | 3105 | * this creates a self reference, and the reference count does not go to zero | ||
3897 | 3106 | * on shutdown. | ||
3898 | 3107 | * | ||
3899 | 3108 | * The server then issues a message that it is forcing shutdown of the plugin. | ||
3900 | 3109 | * | ||
3901 | 3110 | * However, the engine reference is not required by the THDs used by PBXT, so | ||
3902 | 3111 | * I just remove them here. | ||
3903 | 3112 | */ | ||
3904 | 3113 | plugin_unlock(NULL, new_thd->variables.table_plugin); | ||
3905 | 3114 | new_thd->variables.table_plugin = NULL; | ||
3906 | 3115 | |||
3907 | 3020 | new_thd->thread_stack = (char *) &new_thd; | 3116 | new_thd->thread_stack = (char *) &new_thd; |
3908 | 3021 | new_thd->store_globals(); | 3117 | new_thd->store_globals(); |
3909 | 3022 | lex_start(new_thd); | 3118 | lex_start(new_thd); |
3910 | @@ -3051,7 +3147,7 @@ | |||
3911 | 3051 | #else | 3147 | #else |
3912 | 3052 | close_thread_tables(thd); | 3148 | close_thread_tables(thd); |
3913 | 3053 | #endif | 3149 | #endif |
3915 | 3054 | 3150 | ||
3916 | 3055 | delete thd; | 3151 | delete thd; |
3917 | 3056 | 3152 | ||
3918 | 3057 | /* Remember that we don't have a THD */ | 3153 | /* Remember that we don't have a THD */ |
3919 | @@ -3128,11 +3224,12 @@ | |||
3920 | 3128 | const char *stat_name; | 3224 | const char *stat_name; |
3921 | 3129 | u_llong stat_value; | 3225 | u_llong stat_value; |
3922 | 3130 | XTStatisticsRec statistics; | 3226 | XTStatisticsRec statistics; |
3923 | 3227 | XTDatabaseHPtr db = self->st_database; | ||
3924 | 3131 | 3228 | ||
3925 | 3132 | xt_gather_statistics(&statistics); | 3229 | xt_gather_statistics(&statistics); |
3926 | 3133 | for (u_int rec_id=0; !err && rec_id<XT_STAT_CURRENT_MAX; rec_id++) { | 3230 | for (u_int rec_id=0; !err && rec_id<XT_STAT_CURRENT_MAX; rec_id++) { |
3927 | 3134 | stat_name = xt_get_stat_meta_data(rec_id)->sm_name; | 3231 | stat_name = xt_get_stat_meta_data(rec_id)->sm_name; |
3929 | 3135 | stat_value = xt_get_statistic(&statistics, self->st_database, rec_id); | 3232 | stat_value = xt_get_statistic(&statistics, db, rec_id); |
3930 | 3136 | 3233 | ||
3931 | 3137 | col=0; | 3234 | col=0; |
3932 | 3138 | mx_put_u_llong(table, col++, rec_id+1); | 3235 | mx_put_u_llong(table, col++, rec_id+1); |
3933 | @@ -3213,19 +3310,31 @@ | |||
3934 | 3213 | my_bitmap_map *buf; | 3310 | my_bitmap_map *buf; |
3935 | 3214 | uint size_in_bytes = (((n_bits) + 31) / 32) * 4; | 3311 | uint size_in_bytes = (((n_bits) + 31) / 32) * 4; |
3936 | 3215 | 3312 | ||
3938 | 3216 | buf = (my_bitmap_map *) xt_malloc(self, size_in_bytes); | 3313 | buf = (my_bitmap_map *) xt_malloc(self, size_in_bytes); |
3939 | 3314 | |||
3940 | 3315 | #ifdef DRIZZLED | ||
3941 | 3316 | map->init(buf, n_bits); | ||
3942 | 3317 | #else | ||
3943 | 3217 | map->bitmap= buf; | 3318 | map->bitmap= buf; |
3944 | 3218 | map->n_bits= n_bits; | 3319 | map->n_bits= n_bits; |
3945 | 3219 | create_last_word_mask(map); | 3320 | create_last_word_mask(map); |
3946 | 3220 | bitmap_clear_all(map); | 3321 | bitmap_clear_all(map); |
3947 | 3322 | #endif | ||
3948 | 3221 | } | 3323 | } |
3949 | 3222 | 3324 | ||
3950 | 3223 | static void myxt_bitmap_free(XTThreadPtr self, MX_BITMAP *map) | 3325 | static void myxt_bitmap_free(XTThreadPtr self, MX_BITMAP *map) |
3951 | 3224 | { | 3326 | { |
3952 | 3327 | #ifdef DRIZZLED | ||
3953 | 3328 | my_bitmap_map *buf = map->getBitmap(); | ||
3954 | 3329 | if (buf) | ||
3955 | 3330 | xt_free(self, buf); | ||
3956 | 3331 | map->setBitmap(NULL); | ||
3957 | 3332 | #else | ||
3958 | 3225 | if (map->bitmap) { | 3333 | if (map->bitmap) { |
3959 | 3226 | xt_free(self, map->bitmap); | 3334 | xt_free(self, map->bitmap); |
3960 | 3227 | map->bitmap = NULL; | 3335 | map->bitmap = NULL; |
3961 | 3228 | } | 3336 | } |
3962 | 3337 | #endif | ||
3963 | 3229 | } | 3338 | } |
3964 | 3230 | 3339 | ||
3965 | 3231 | /* | 3340 | /* |
3966 | @@ -3269,3 +3378,29 @@ | |||
3967 | 3269 | return col; | 3378 | return col; |
3968 | 3270 | } | 3379 | } |
3969 | 3271 | 3380 | ||
3970 | 3381 | /* | ||
3971 | 3382 | * ----------------------------------------------------------------------- | ||
3972 | 3383 | * utilities | ||
3973 | 3384 | */ | ||
3974 | 3385 | |||
3975 | 3386 | /* | ||
3976 | 3387 | * MySQL (not sure about Drizzle) first calls hton->init and then assigns the plugin a thread slot | ||
3977 | 3388 | * which is used by xt_get_self(). This is a problem as pbxt_init() starts a number of daemon threads | ||
3978 | 3389 | * which could try to use the slot before it is assigned. This code waits till slot is inited. | ||
3979 | 3390 | * We cannot directly check hton->slot as in some versions of MySQL it can be 0 before init which is a | ||
3980 | 3391 | * valid value. | ||
3981 | 3392 | */ | ||
3982 | 3393 | extern ulong total_ha; | ||
3983 | 3394 | |||
3984 | 3395 | xtPublic void myxt_wait_pbxt_plugin_slot_assigned(XTThread *self) | ||
3985 | 3396 | { | ||
3986 | 3397 | #ifdef DRIZZLED | ||
3987 | 3398 | static LEX_STRING plugin_name = { C_STRING_WITH_LEN("PBXT") }; | ||
3988 | 3399 | |||
3989 | 3400 | while (!self->t_quit && !Registry::singleton().find(&plugin_name)) | ||
3990 | 3401 | xt_sleep_milli_second(1); | ||
3991 | 3402 | #else | ||
3992 | 3403 | while(!self->t_quit && (pbxt_hton->slot >= total_ha)) | ||
3993 | 3404 | xt_sleep_milli_second(1); | ||
3994 | 3405 | #endif | ||
3995 | 3406 | } | ||
3996 | 3272 | 3407 | ||
3997 | === modified file 'storage/pbxt/src/myxt_xt.h' | |||
3998 | --- storage/pbxt/src/myxt_xt.h 2009-09-03 06:15:03 +0000 | |||
3999 | +++ storage/pbxt/src/myxt_xt.h 2009-12-10 11:57:20 +0000 | |||
4000 | @@ -52,8 +52,10 @@ | |||
4001 | 52 | void myxt_print_key(XTIndexPtr ind, xtWord1 *key_value); | 52 | void myxt_print_key(XTIndexPtr ind, xtWord1 *key_value); |
4002 | 53 | 53 | ||
4003 | 54 | xtWord4 myxt_store_row_length(XTOpenTablePtr ot, char *rec_buff); | 54 | xtWord4 myxt_store_row_length(XTOpenTablePtr ot, char *rec_buff); |
4004 | 55 | xtWord4 myxt_store_row_data(XTOpenTablePtr ot, xtWord4 row_size, char *rec_buff); | ||
4005 | 55 | xtBool myxt_store_row(XTOpenTablePtr ot, XTTabRecInfoPtr rec_info, char *rec_buff); | 56 | xtBool myxt_store_row(XTOpenTablePtr ot, XTTabRecInfoPtr rec_info, char *rec_buff); |
4006 | 56 | size_t myxt_load_row_length(XTOpenTablePtr ot, size_t buffer_size, xtWord1 *source_buf, u_int *ret_col_cnt); | 57 | size_t myxt_load_row_length(XTOpenTablePtr ot, size_t buffer_size, xtWord1 *source_buf, u_int *ret_col_cnt); |
4007 | 58 | xtWord4 myxt_load_row_data(XTOpenTablePtr ot, xtWord1 *source_buf, xtWord1 *dest_buff, u_int col_cnt); | ||
4008 | 57 | xtBool myxt_load_row(XTOpenTablePtr ot, xtWord1 *source_buf, xtWord1 *dest_buff, u_int col_cnt); | 59 | xtBool myxt_load_row(XTOpenTablePtr ot, xtWord1 *source_buf, xtWord1 *dest_buff, u_int col_cnt); |
4009 | 58 | xtBool myxt_find_column(XTOpenTablePtr ot, u_int *col_idx, const char *col_name); | 60 | xtBool myxt_find_column(XTOpenTablePtr ot, u_int *col_idx, const char *col_name); |
4010 | 59 | void myxt_get_column_name(XTOpenTablePtr ot, u_int col_idx, u_int len, char *col_name); | 61 | void myxt_get_column_name(XTOpenTablePtr ot, u_int col_idx, u_int len, char *col_name); |
4011 | @@ -93,4 +95,6 @@ | |||
4012 | 93 | static XTDDColumn *createFromMySQLField(XTThread *self, STRUCT_TABLE *, Field *); | 95 | static XTDDColumn *createFromMySQLField(XTThread *self, STRUCT_TABLE *, Field *); |
4013 | 94 | }; | 96 | }; |
4014 | 95 | 97 | ||
4015 | 98 | void myxt_wait_pbxt_plugin_slot_assigned(XTThread *self); | ||
4016 | 99 | |||
4017 | 96 | #endif | 100 | #endif |
4018 | 97 | 101 | ||
4019 | === modified file 'storage/pbxt/src/pbms.h' | |||
4020 | --- storage/pbxt/src/pbms.h 2009-08-18 07:46:53 +0000 | |||
4021 | +++ storage/pbxt/src/pbms.h 2009-12-10 11:57:20 +0000 | |||
4022 | @@ -344,16 +344,16 @@ | |||
4023 | 344 | int couldBeURL(char *blob_url, int size) | 344 | int couldBeURL(char *blob_url, int size) |
4024 | 345 | { | 345 | { |
4025 | 346 | if (blob_url && (size < PBMS_BLOB_URL_SIZE)) { | 346 | if (blob_url && (size < PBMS_BLOB_URL_SIZE)) { |
4036 | 347 | char buffer[PBMS_BLOB_URL_SIZE+1]; | 347 | char buffer[PBMS_BLOB_URL_SIZE+1]; |
4037 | 348 | u_int32_t db_id = 0; | 348 | unsigned long db_id = 0; |
4038 | 349 | u_int32_t tab_id = 0; | 349 | unsigned long tab_id = 0; |
4039 | 350 | u_int64_t blob_id = 0; | 350 | unsigned long long blob_id = 0; |
4040 | 351 | u_int64_t blob_ref_id = 0; | 351 | unsigned long long blob_ref_id = 0; |
4041 | 352 | u_int64_t blob_size = 0; | 352 | unsigned long long blob_size = 0; |
4042 | 353 | u_int32_t auth_code = 0; | 353 | unsigned long auth_code = 0; |
4043 | 354 | u_int32_t server_id = 0; | 354 | unsigned long server_id = 0; |
4044 | 355 | char type, junk[5]; | 355 | char type, junk[5]; |
4045 | 356 | int scanned; | 356 | int scanned; |
4046 | 357 | 357 | ||
4047 | 358 | junk[0] = 0; | 358 | junk[0] = 0; |
4048 | 359 | if (blob_url[size]) { // There is no guarantee that the URL will be null terminated. | 359 | if (blob_url[size]) { // There is no guarantee that the URL will be null terminated. |
4049 | @@ -364,12 +364,12 @@ | |||
4050 | 364 | 364 | ||
4051 | 365 | scanned = sscanf(blob_url, URL_FMT"%4s", &db_id, &type, &tab_id, &blob_id, &auth_code, &server_id, &blob_ref_id, &blob_size, junk); | 365 | scanned = sscanf(blob_url, URL_FMT"%4s", &db_id, &type, &tab_id, &blob_id, &auth_code, &server_id, &blob_ref_id, &blob_size, junk); |
4052 | 366 | if (scanned != 8) {// If junk is found at the end this will also result in an invalid URL. | 366 | if (scanned != 8) {// If junk is found at the end this will also result in an invalid URL. |
4054 | 367 | printf("Bad URL \"%s\": scanned = %d, junk: %d, %d, %d, %d\n", blob_url, scanned, junk[0], junk[1], junk[2], junk[3]); | 367 | printf("Bad URL \"%s\": scanned = %d, junk: %d, %d, %d, %d\n", blob_url, scanned, junk[0], junk[1], junk[2], junk[3]); |
4055 | 368 | return 0; | 368 | return 0; |
4056 | 369 | } | 369 | } |
4057 | 370 | 370 | ||
4058 | 371 | if (junk[0] || (type != '~' && type != '_')) { | 371 | if (junk[0] || (type != '~' && type != '_')) { |
4060 | 372 | printf("Bad URL \"%s\": scanned = %d, junk: %d, %d, %d, %d\n", blob_url, scanned, junk[0], junk[1], junk[2], junk[3]); | 372 | printf("Bad URL \"%s\": scanned = %d, junk: %d, %d, %d, %d\n", blob_url, scanned, junk[0], junk[1], junk[2], junk[3]); |
4061 | 373 | return 0; | 373 | return 0; |
4062 | 374 | } | 374 | } |
4063 | 375 | 375 | ||
4064 | 376 | 376 | ||
4065 | === modified file 'storage/pbxt/src/pbms_enabled.cc' | |||
4066 | --- storage/pbxt/src/pbms_enabled.cc 2009-10-06 15:16:01 +0000 | |||
4067 | +++ storage/pbxt/src/pbms_enabled.cc 2009-12-10 11:57:20 +0000 | |||
4068 | @@ -29,15 +29,10 @@ | |||
4069 | 29 | * | 29 | * |
4070 | 30 | */ | 30 | */ |
4071 | 31 | 31 | ||
4072 | 32 | /* | ||
4073 | 33 | The following two lines backported by psergey. Remove them when we merge from PBXT again. | ||
4074 | 34 | */ | ||
4075 | 35 | #include "xt_config.h" | 32 | #include "xt_config.h" |
4076 | 33 | |||
4077 | 36 | #ifdef PBMS_ENABLED | 34 | #ifdef PBMS_ENABLED |
4078 | 37 | 35 | ||
4079 | 38 | #define PBMS_API pbms_enabled_api | ||
4080 | 39 | |||
4081 | 40 | #include "pbms_enabled.h" | ||
4082 | 41 | #ifdef DRIZZLED | 36 | #ifdef DRIZZLED |
4083 | 42 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
4084 | 43 | #include <drizzled/common_includes.h> | 38 | #include <drizzled/common_includes.h> |
4085 | @@ -47,11 +42,15 @@ | |||
4086 | 47 | #include <mysql/plugin.h> | 42 | #include <mysql/plugin.h> |
4087 | 48 | #define session_alloc(sess, size) thd_alloc(sess, size); | 43 | #define session_alloc(sess, size) thd_alloc(sess, size); |
4088 | 49 | #define current_session current_thd | 44 | #define current_session current_thd |
4094 | 50 | #endif | 45 | #endif |
4095 | 51 | 46 | ||
4096 | 52 | #define GET_BLOB_FIELD(t, i) (Field_blob *)(t->field[t->s->blob_field[i]]) | 47 | #define GET_BLOB_FIELD(t, i) (Field_blob *)(t->field[t->s->blob_field[i]]) |
4097 | 53 | #define DB_NAME(f) (f->table->s->db.str) | 48 | #define DB_NAME(f) (f->table->s->db.str) |
4098 | 54 | #define TAB_NAME(f) (*(f->table_name)) | 49 | #define TAB_NAME(f) (*(f->table_name)) |
4099 | 50 | |||
4100 | 51 | #define PBMS_API pbms_enabled_api | ||
4101 | 52 | |||
4102 | 53 | #include "pbms_enabled.h" | ||
4103 | 55 | 54 | ||
4104 | 56 | static PBMS_API pbms_api; | 55 | static PBMS_API pbms_api; |
4105 | 57 | 56 | ||
4106 | @@ -242,4 +241,4 @@ | |||
4107 | 242 | return ; | 241 | return ; |
4108 | 243 | } | 242 | } |
4109 | 244 | 243 | ||
4110 | 245 | #endif | ||
4111 | 246 | \ No newline at end of file | 244 | \ No newline at end of file |
4112 | 245 | #endif // PBMS_ENABLED | ||
4113 | 247 | 246 | ||
4114 | === modified file 'storage/pbxt/src/pbms_enabled.h' | |||
4115 | --- storage/pbxt/src/pbms_enabled.h 2009-08-18 07:46:53 +0000 | |||
4116 | +++ storage/pbxt/src/pbms_enabled.h 2009-12-10 11:57:20 +0000 | |||
4117 | @@ -35,13 +35,6 @@ | |||
4118 | 35 | 35 | ||
4119 | 36 | #include "pbms.h" | 36 | #include "pbms.h" |
4120 | 37 | 37 | ||
4121 | 38 | #ifdef DRIZZLED | ||
4122 | 39 | #include <drizzled/server_includes.h> | ||
4123 | 40 | #define TABLE Table | ||
4124 | 41 | #else | ||
4125 | 42 | #include <mysql_priv.h> | ||
4126 | 43 | #endif | ||
4127 | 44 | |||
4128 | 45 | /* | 38 | /* |
4129 | 46 | * pbms_initialize() should be called from the engines plugIn's 'init()' function. | 39 | * pbms_initialize() should be called from the engines plugIn's 'init()' function. |
4130 | 47 | * The engine_name is the name of your engine, "PBXT" or "InnoDB" for example. | 40 | * The engine_name is the name of your engine, "PBXT" or "InnoDB" for example. |
4131 | 48 | 41 | ||
4132 | === modified file 'storage/pbxt/src/pthread_xt.cc' | |||
4133 | --- storage/pbxt/src/pthread_xt.cc 2009-08-18 07:46:53 +0000 | |||
4134 | +++ storage/pbxt/src/pthread_xt.cc 2009-12-10 11:57:20 +0000 | |||
4135 | @@ -578,8 +578,8 @@ | |||
4136 | 578 | 578 | ||
4137 | 579 | xtPublic int xt_p_mutex_destroy(xt_mutex_type *mutex) | 579 | xtPublic int xt_p_mutex_destroy(xt_mutex_type *mutex) |
4138 | 580 | { | 580 | { |
4141 | 581 | ASSERT_NS(mutex->mu_init == 12345); | 581 | //ASSERT_NS(mutex->mu_init == 12345); |
4142 | 582 | mutex->mu_init = 89898; | 582 | mutex->mu_init = 11111; |
4143 | 583 | #ifdef XT_THREAD_LOCK_INFO | 583 | #ifdef XT_THREAD_LOCK_INFO |
4144 | 584 | xt_thread_lock_info_free(&mutex->mu_lock_info); | 584 | xt_thread_lock_info_free(&mutex->mu_lock_info); |
4145 | 585 | #endif | 585 | #endif |
4146 | 586 | 586 | ||
4147 | === modified file 'storage/pbxt/src/restart_xt.cc' | |||
4148 | --- storage/pbxt/src/restart_xt.cc 2009-09-03 06:15:03 +0000 | |||
4149 | +++ storage/pbxt/src/restart_xt.cc 2009-12-10 11:57:20 +0000 | |||
4150 | @@ -34,12 +34,16 @@ | |||
4151 | 34 | 34 | ||
4152 | 35 | #include "ha_pbxt.h" | 35 | #include "ha_pbxt.h" |
4153 | 36 | 36 | ||
4154 | 37 | #ifdef DRIZZLED | ||
4155 | 38 | #include <drizzled/data_home.h> | ||
4156 | 39 | using drizzled::plugin::Registry; | ||
4157 | 40 | #endif | ||
4158 | 41 | |||
4159 | 37 | #include "xactlog_xt.h" | 42 | #include "xactlog_xt.h" |
4160 | 38 | #include "database_xt.h" | 43 | #include "database_xt.h" |
4161 | 39 | #include "util_xt.h" | 44 | #include "util_xt.h" |
4162 | 40 | #include "strutil_xt.h" | 45 | #include "strutil_xt.h" |
4163 | 41 | #include "filesys_xt.h" | 46 | #include "filesys_xt.h" |
4164 | 42 | #include "restart_xt.h" | ||
4165 | 43 | #include "myxt_xt.h" | 47 | #include "myxt_xt.h" |
4166 | 44 | #include "trace_xt.h" | 48 | #include "trace_xt.h" |
4167 | 45 | 49 | ||
4168 | @@ -57,13 +61,27 @@ | |||
4169 | 57 | //#define PRINTF xt_ftracef | 61 | //#define PRINTF xt_ftracef |
4170 | 58 | //#define PRINTF xt_trace | 62 | //#define PRINTF xt_trace |
4171 | 59 | 63 | ||
4173 | 60 | void xt_print_bytes(xtWord1 *buf, u_int len) | 64 | /* |
4174 | 65 | * ----------------------------------------------------------------------- | ||
4175 | 66 | * GLOBALS | ||
4176 | 67 | */ | ||
4177 | 68 | |||
4178 | 69 | xtPublic int pbxt_recovery_state; | ||
4179 | 70 | |||
4180 | 71 | /* | ||
4181 | 72 | * ----------------------------------------------------------------------- | ||
4182 | 73 | * UTILITIES | ||
4183 | 74 | */ | ||
4184 | 75 | |||
4185 | 76 | #ifdef TRACE_RECORD_DATA | ||
4186 | 77 | static void xt_print_bytes(xtWord1 *buf, u_int len) | ||
4187 | 61 | { | 78 | { |
4188 | 62 | for (u_int i=0; i<len; i++) { | 79 | for (u_int i=0; i<len; i++) { |
4189 | 63 | PRINTF("%02x ", (u_int) *buf); | 80 | PRINTF("%02x ", (u_int) *buf); |
4190 | 64 | buf++; | 81 | buf++; |
4191 | 65 | } | 82 | } |
4192 | 66 | } | 83 | } |
4193 | 84 | #endif | ||
4194 | 67 | 85 | ||
4195 | 68 | void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr record) | 86 | void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr record) |
4196 | 69 | { | 87 | { |
4197 | @@ -252,7 +270,7 @@ | |||
4198 | 252 | rec_type = "DELETE"; | 270 | rec_type = "DELETE"; |
4199 | 253 | break; | 271 | break; |
4200 | 254 | case XT_LOG_ENT_DELETE_FL: | 272 | case XT_LOG_ENT_DELETE_FL: |
4202 | 255 | rec_type = "DELETE-FL-BG"; | 273 | rec_type = "DELETE-FL"; |
4203 | 256 | break; | 274 | break; |
4204 | 257 | case XT_LOG_ENT_UPDATE_BG: | 275 | case XT_LOG_ENT_UPDATE_BG: |
4205 | 258 | rec_type = "UPDATE-BG"; | 276 | rec_type = "UPDATE-BG"; |
4206 | @@ -320,6 +338,11 @@ | |||
4207 | 320 | case XT_LOG_ENT_END_OF_LOG: | 338 | case XT_LOG_ENT_END_OF_LOG: |
4208 | 321 | rec_type = "END OF LOG"; | 339 | rec_type = "END OF LOG"; |
4209 | 322 | break; | 340 | break; |
4210 | 341 | case XT_LOG_ENT_PREPARE: | ||
4211 | 342 | rec_type = "PREPARE"; | ||
4212 | 343 | xn_id = XT_GET_DISK_4(record->xp.xp_xact_id_4); | ||
4213 | 344 | xn_set = TRUE; | ||
4214 | 345 | break; | ||
4215 | 323 | } | 346 | } |
4216 | 324 | 347 | ||
4217 | 325 | if (log) | 348 | if (log) |
4218 | @@ -327,6 +350,8 @@ | |||
4219 | 327 | PRINTF("%s ", rec_type); | 350 | PRINTF("%s ", rec_type); |
4220 | 328 | if (type) | 351 | if (type) |
4221 | 329 | PRINTF("op=%lu tab=%lu %s=%lu ", (u_long) op_no, (u_long) tab_id, type, (u_long) rec_id); | 352 | PRINTF("op=%lu tab=%lu %s=%lu ", (u_long) op_no, (u_long) tab_id, type, (u_long) rec_id); |
4222 | 353 | else if (tab_id) | ||
4223 | 354 | PRINTF("tab=%lu ", (u_long) tab_id); | ||
4224 | 330 | if (row_id) | 355 | if (row_id) |
4225 | 331 | PRINTF("row=%lu ", (u_long) row_id); | 356 | PRINTF("row=%lu ", (u_long) row_id); |
4226 | 332 | if (log_id) | 357 | if (log_id) |
4227 | @@ -459,6 +484,7 @@ | |||
4228 | 459 | } | 484 | } |
4229 | 460 | return OK; | 485 | return OK; |
4230 | 461 | } | 486 | } |
4231 | 487 | |||
4232 | 462 | ws->ws_tab_gone = tab_id; | 488 | ws->ws_tab_gone = tab_id; |
4233 | 463 | return FAILED; | 489 | return FAILED; |
4234 | 464 | } | 490 | } |
4235 | @@ -629,6 +655,7 @@ | |||
4236 | 629 | xtWord1 *rec_data = NULL; | 655 | xtWord1 *rec_data = NULL; |
4237 | 630 | XTTabRecFreeDPtr free_data; | 656 | XTTabRecFreeDPtr free_data; |
4238 | 631 | 657 | ||
4239 | 658 | ASSERT(ot->ot_thread == self); | ||
4240 | 632 | if (tab->tab_dic.dic_key_count == 0) | 659 | if (tab->tab_dic.dic_key_count == 0) |
4241 | 633 | check_index = FALSE; | 660 | check_index = FALSE; |
4242 | 634 | 661 | ||
4243 | @@ -1300,7 +1327,7 @@ | |||
4244 | 1300 | * These operations are applied even though operations | 1327 | * These operations are applied even though operations |
4245 | 1301 | * in sequence are missing. | 1328 | * in sequence are missing. |
4246 | 1302 | */ | 1329 | */ |
4248 | 1303 | xtBool xres_sync_operations(XTThreadPtr self, XTDatabaseHPtr db, XTWriterStatePtr ws) | 1330 | static xtBool xres_sync_operations(XTThreadPtr self, XTDatabaseHPtr db, XTWriterStatePtr ws) |
4249 | 1304 | { | 1331 | { |
4250 | 1305 | u_int edx; | 1332 | u_int edx; |
4251 | 1306 | XTTableEntryPtr te_ptr; | 1333 | XTTableEntryPtr te_ptr; |
4252 | @@ -1881,15 +1908,6 @@ | |||
4253 | 1881 | void XTXactRestart::xres_recover_progress(XTThreadPtr self, XTOpenFilePtr *of, int perc) | 1908 | void XTXactRestart::xres_recover_progress(XTThreadPtr self, XTOpenFilePtr *of, int perc) |
4254 | 1882 | { | 1909 | { |
4255 | 1883 | #ifdef XT_USE_GLOBAL_DB | 1910 | #ifdef XT_USE_GLOBAL_DB |
4256 | 1884 | if (!perc) { | ||
4257 | 1885 | char file_path[PATH_MAX]; | ||
4258 | 1886 | |||
4259 | 1887 | xt_strcpy(PATH_MAX, file_path, xres_db->db_main_path); | ||
4260 | 1888 | xt_add_pbxt_file(PATH_MAX, file_path, "recovery-progress"); | ||
4261 | 1889 | *of = xt_open_file(self, file_path, XT_FS_CREATE | XT_FS_MAKE_PATH); | ||
4262 | 1890 | xt_set_eof_file(self, *of, 0); | ||
4263 | 1891 | } | ||
4264 | 1892 | |||
4265 | 1893 | if (perc > 100) { | 1911 | if (perc > 100) { |
4266 | 1894 | char file_path[PATH_MAX]; | 1912 | char file_path[PATH_MAX]; |
4267 | 1895 | 1913 | ||
4268 | @@ -1905,6 +1923,15 @@ | |||
4269 | 1905 | else { | 1923 | else { |
4270 | 1906 | char number[40]; | 1924 | char number[40]; |
4271 | 1907 | 1925 | ||
4272 | 1926 | if (!*of) { | ||
4273 | 1927 | char file_path[PATH_MAX]; | ||
4274 | 1928 | |||
4275 | 1929 | xt_strcpy(PATH_MAX, file_path, xres_db->db_main_path); | ||
4276 | 1930 | xt_add_pbxt_file(PATH_MAX, file_path, "recovery-progress"); | ||
4277 | 1931 | *of = xt_open_file(self, file_path, XT_FS_CREATE | XT_FS_MAKE_PATH); | ||
4278 | 1932 | xt_set_eof_file(self, *of, 0); | ||
4279 | 1933 | } | ||
4280 | 1934 | |||
4281 | 1908 | sprintf(number, "%d", perc); | 1935 | sprintf(number, "%d", perc); |
4282 | 1909 | if (!xt_pwrite_file(*of, 0, strlen(number), number, &self->st_statistics.st_x, self)) | 1936 | if (!xt_pwrite_file(*of, 0, strlen(number), number, &self->st_statistics.st_x, self)) |
4283 | 1910 | xt_throw(self); | 1937 | xt_throw(self); |
4284 | @@ -1927,10 +1954,11 @@ | |||
4285 | 1927 | off_t bytes_to_read; | 1954 | off_t bytes_to_read; |
4286 | 1928 | volatile xtBool print_progress = FALSE; | 1955 | volatile xtBool print_progress = FALSE; |
4287 | 1929 | volatile off_t perc_size = 0, next_goal = 0; | 1956 | volatile off_t perc_size = 0, next_goal = 0; |
4289 | 1930 | int perc_complete = 1; | 1957 | int perc_complete = 1, perc_to_write = 1; |
4290 | 1931 | XTOpenFilePtr progress_file = NULL; | 1958 | XTOpenFilePtr progress_file = NULL; |
4291 | 1932 | xtBool min_ram_xn_id_set = FALSE; | 1959 | xtBool min_ram_xn_id_set = FALSE; |
4292 | 1933 | u_int log_count; | 1960 | u_int log_count; |
4293 | 1961 | time_t start_time; | ||
4294 | 1934 | 1962 | ||
4295 | 1935 | memset(&ws, 0, sizeof(ws)); | 1963 | memset(&ws, 0, sizeof(ws)); |
4296 | 1936 | 1964 | ||
4297 | @@ -1955,12 +1983,11 @@ | |||
4298 | 1955 | /* Don't print anything about recovering an empty database: */ | 1983 | /* Don't print anything about recovering an empty database: */ |
4299 | 1956 | if (bytes_to_read != 0) | 1984 | if (bytes_to_read != 0) |
4300 | 1957 | xt_logf(XT_NT_INFO, "PBXT: Recovering from %lu-%llu, bytes to read: %llu\n", (u_long) xres_cp_log_id, (u_llong) xres_cp_log_offset, (u_llong) bytes_to_read); | 1985 | xt_logf(XT_NT_INFO, "PBXT: Recovering from %lu-%llu, bytes to read: %llu\n", (u_long) xres_cp_log_id, (u_llong) xres_cp_log_offset, (u_llong) bytes_to_read); |
4307 | 1958 | if (bytes_to_read >= 10*1024*1024) { | 1986 | |
4308 | 1959 | print_progress = TRUE; | 1987 | print_progress = FALSE; |
4309 | 1960 | perc_size = bytes_to_read / 100; | 1988 | start_time = time(NULL); |
4310 | 1961 | next_goal = perc_size; | 1989 | perc_size = bytes_to_read / 100; |
4311 | 1962 | xres_recover_progress(self, &progress_file, 0); | 1990 | next_goal = perc_size; |
4306 | 1963 | } | ||
4312 | 1964 | 1991 | ||
4313 | 1965 | if (!db->db_xlog.xlog_seq_start(&ws.ws_seqread, xres_cp_log_id, xres_cp_log_offset, FALSE)) { | 1992 | if (!db->db_xlog.xlog_seq_start(&ws.ws_seqread, xres_cp_log_id, xres_cp_log_offset, FALSE)) { |
4314 | 1966 | ok = FALSE; | 1993 | ok = FALSE; |
4315 | @@ -1983,17 +2010,28 @@ | |||
4316 | 1983 | #ifdef PRINT_LOG_ON_RECOVERY | 2010 | #ifdef PRINT_LOG_ON_RECOVERY |
4317 | 1984 | xt_print_log_record(ws.ws_seqread.xseq_rec_log_id, ws.ws_seqread.xseq_rec_log_offset, record); | 2011 | xt_print_log_record(ws.ws_seqread.xseq_rec_log_id, ws.ws_seqread.xseq_rec_log_offset, record); |
4318 | 1985 | #endif | 2012 | #endif |
4330 | 1986 | if (print_progress && bytes_read > next_goal) { | 2013 | if (bytes_read >= next_goal) { |
4331 | 1987 | if (((perc_complete - 1) % 25) == 0) | 2014 | while (bytes_read >= next_goal) { |
4332 | 1988 | xt_logf(XT_NT_INFO, "PBXT: "); | 2015 | next_goal += perc_size; |
4333 | 1989 | if ((perc_complete % 25) == 0) | 2016 | perc_complete++; |
4334 | 1990 | xt_logf(XT_NT_INFO, "%2d\n", (int) perc_complete); | 2017 | } |
4335 | 1991 | else | 2018 | if (!print_progress) { |
4336 | 1992 | xt_logf(XT_NT_INFO, "%2d ", (int) perc_complete); | 2019 | if (time(NULL) - start_time > 2) |
4337 | 1993 | xt_log_flush(self); | 2020 | print_progress = TRUE; |
4338 | 1994 | xres_recover_progress(self, &progress_file, perc_complete); | 2021 | } |
4339 | 1995 | next_goal += perc_size; | 2022 | if (print_progress) { |
4340 | 1996 | perc_complete++; | 2023 | while (perc_to_write < perc_complete) { |
4341 | 2024 | if (((perc_to_write - 1) % 25) == 0) | ||
4342 | 2025 | xt_logf(XT_NT_INFO, "PBXT: "); | ||
4343 | 2026 | if ((perc_to_write % 25) == 0) | ||
4344 | 2027 | xt_logf(XT_NT_INFO, "%2d\n", (int) perc_to_write); | ||
4345 | 2028 | else | ||
4346 | 2029 | xt_logf(XT_NT_INFO, "%2d ", (int) perc_to_write); | ||
4347 | 2030 | xt_log_flush(self); | ||
4348 | 2031 | xres_recover_progress(self, &progress_file, perc_to_write); | ||
4349 | 2032 | perc_to_write++; | ||
4350 | 2033 | } | ||
4351 | 2034 | } | ||
4352 | 1997 | } | 2035 | } |
4353 | 1998 | switch (record->xl.xl_status_1) { | 2036 | switch (record->xl.xl_status_1) { |
4354 | 1999 | case XT_LOG_ENT_HEADER: | 2037 | case XT_LOG_ENT_HEADER: |
4355 | @@ -2053,8 +2091,11 @@ | |||
4356 | 2053 | xact->xd_end_xn_id = xn_id; | 2091 | xact->xd_end_xn_id = xn_id; |
4357 | 2054 | xact->xd_flags |= XT_XN_XAC_ENDED | XT_XN_XAC_SWEEP; | 2092 | xact->xd_flags |= XT_XN_XAC_ENDED | XT_XN_XAC_SWEEP; |
4358 | 2055 | xact->xd_flags &= ~XT_XN_XAC_RECOVERED; // We can expect an end record on cleanup! | 2093 | xact->xd_flags &= ~XT_XN_XAC_RECOVERED; // We can expect an end record on cleanup! |
4359 | 2094 | xact->xd_flags &= ~XT_XN_XAC_PREPARED; // Prepared transactions cannot be swept! | ||
4360 | 2056 | if (record->xl.xl_status_1 == XT_LOG_ENT_COMMIT) | 2095 | if (record->xl.xl_status_1 == XT_LOG_ENT_COMMIT) |
4361 | 2057 | xact->xd_flags |= XT_XN_XAC_COMMITTED; | 2096 | xact->xd_flags |= XT_XN_XAC_COMMITTED; |
4362 | 2097 | if (xt_sl_get_size(db->db_xn_xa_list) > 0) | ||
4363 | 2098 | xt_xn_delete_xa_data_by_xact(db, xn_id, self); | ||
4364 | 2058 | } | 2099 | } |
4365 | 2059 | break; | 2100 | break; |
4366 | 2060 | case XT_LOG_ENT_CLEANUP: | 2101 | case XT_LOG_ENT_CLEANUP: |
4367 | @@ -2071,6 +2112,14 @@ | |||
4368 | 2071 | rec_log_id = XT_GET_DISK_4(record->xl.xl_log_id_4); | 2112 | rec_log_id = XT_GET_DISK_4(record->xl.xl_log_id_4); |
4369 | 2072 | xt_dl_set_to_delete(self, db, rec_log_id); | 2113 | xt_dl_set_to_delete(self, db, rec_log_id); |
4370 | 2073 | break; | 2114 | break; |
4371 | 2115 | case XT_LOG_ENT_PREPARE: | ||
4372 | 2116 | xn_id = XT_GET_DISK_4(record->xp.xp_xact_id_4); | ||
4373 | 2117 | if ((xact = xt_xn_get_xact(db, xn_id, self))) { | ||
4374 | 2118 | xact->xd_flags |= XT_XN_XAC_PREPARED; | ||
4375 | 2119 | if (!xt_xn_store_xa_data(db, xn_id, record->xp.xp_xa_len_1, record->xp.xp_xa_data, self)) | ||
4376 | 2120 | xt_throw(self); | ||
4377 | 2121 | } | ||
4378 | 2122 | break; | ||
4379 | 2074 | default: | 2123 | default: |
4380 | 2075 | xt_xres_apply_in_order(self, &ws, ws.ws_seqread.xseq_rec_log_id, ws.ws_seqread.xseq_rec_log_offset, record); | 2124 | xt_xres_apply_in_order(self, &ws, ws.ws_seqread.xseq_rec_log_id, ws.ws_seqread.xseq_rec_log_offset, record); |
4381 | 2076 | break; | 2125 | break; |
4382 | @@ -2534,7 +2583,8 @@ | |||
4383 | 2534 | /* This condition means we could checkpoint: */ | 2583 | /* This condition means we could checkpoint: */ |
4384 | 2535 | if (!(xt_sl_get_size(db->db_datalogs.dlc_to_delete) == 0 && | 2584 | if (!(xt_sl_get_size(db->db_datalogs.dlc_to_delete) == 0 && |
4385 | 2536 | xt_sl_get_size(db->db_datalogs.dlc_deleted) == 0 && | 2585 | xt_sl_get_size(db->db_datalogs.dlc_deleted) == 0 && |
4387 | 2537 | xt_comp_log_pos(log_id, log_offset, db->db_restart.xres_cp_log_id, db->db_restart.xres_cp_log_offset) <= 0)) | 2586 | xt_comp_log_pos(log_id, log_offset, db->db_restart.xres_cp_log_id, db->db_restart.xres_cp_log_offset) <= 0) && |
4388 | 2587 | xt_sl_get_size(db->db_xn_xa_list) == 0) | ||
4389 | 2538 | break; | 2588 | break; |
4390 | 2539 | 2589 | ||
4391 | 2540 | xres_cp_wait_for_log_writer(self, db, 400); | 2590 | xres_cp_wait_for_log_writer(self, db, 400); |
4392 | @@ -2654,7 +2704,7 @@ | |||
4393 | 2654 | * until they are flushed. | 2704 | * until they are flushed. |
4394 | 2655 | */ | 2705 | */ |
4395 | 2656 | /* This is an alternative to the above. | 2706 | /* This is an alternative to the above. |
4397 | 2657 | if (!xt_xlog_flush_log(self)) | 2707 | if (!xt_xlog_flush_log(db, self)) |
4398 | 2658 | xt_throw(self); | 2708 | xt_throw(self); |
4399 | 2659 | */ | 2709 | */ |
4400 | 2660 | xt_lock_mutex_ns(&db->db_wr_lock); | 2710 | xt_lock_mutex_ns(&db->db_wr_lock); |
4401 | @@ -2776,6 +2826,14 @@ | |||
4402 | 2776 | size_t chk_size = 0; | 2826 | size_t chk_size = 0; |
4403 | 2777 | u_int no_of_logs = 0; | 2827 | u_int no_of_logs = 0; |
4404 | 2778 | 2828 | ||
4405 | 2829 | /* As long as we have outstanding XA transactions, we may not checkpoint! */ | ||
4406 | 2830 | if (xt_sl_get_size(db->db_xn_xa_list) > 0) { | ||
4407 | 2831 | #ifdef DEBUG | ||
4408 | 2832 | printf("Checkpoint must wait\n"); | ||
4409 | 2833 | #endif | ||
4410 | 2834 | return OK; | ||
4411 | 2835 | } | ||
4412 | 2836 | |||
4413 | 2779 | #ifdef NEVER_CHECKPOINT | 2837 | #ifdef NEVER_CHECKPOINT |
4414 | 2780 | return OK; | 2838 | return OK; |
4415 | 2781 | #endif | 2839 | #endif |
4416 | @@ -3183,7 +3241,7 @@ | |||
4417 | 3183 | * D A T A B A S E R E C O V E R Y T H R E A D | 3241 | * D A T A B A S E R E C O V E R Y T H R E A D |
4418 | 3184 | */ | 3242 | */ |
4419 | 3185 | 3243 | ||
4421 | 3186 | extern XTDatabaseHPtr pbxt_database; | 3244 | |
4422 | 3187 | static XTThreadPtr xres_recovery_thread; | 3245 | static XTThreadPtr xres_recovery_thread; |
4423 | 3188 | 3246 | ||
4424 | 3189 | static void *xn_xres_run_recovery_thread(XTThreadPtr self) | 3247 | static void *xn_xres_run_recovery_thread(XTThreadPtr self) |
4425 | @@ -3193,18 +3251,18 @@ | |||
4426 | 3193 | if (!(mysql_thread = (THD *) myxt_create_thread())) | 3251 | if (!(mysql_thread = (THD *) myxt_create_thread())) |
4427 | 3194 | xt_throw(self); | 3252 | xt_throw(self); |
4428 | 3195 | 3253 | ||
4431 | 3196 | while (!xres_recovery_thread->t_quit && !ha_resolve_by_legacy_type(mysql_thread, DB_TYPE_PBXT)) | 3254 | myxt_wait_pbxt_plugin_slot_assigned(self); |
4430 | 3197 | xt_sleep_milli_second(1); | ||
4432 | 3198 | 3255 | ||
4433 | 3199 | if (!xres_recovery_thread->t_quit) { | 3256 | if (!xres_recovery_thread->t_quit) { |
4440 | 3200 | /* {GLOBAL-DB} | 3257 | try_(a) { |
4441 | 3201 | * It can happen that something will just get in before this | 3258 | /* {GLOBAL-DB} |
4442 | 3202 | * thread and open/recover the database! | 3259 | * It can happen that something will just get in before this |
4443 | 3203 | */ | 3260 | * thread and open/recover the database! |
4444 | 3204 | if (!pbxt_database) { | 3261 | */ |
4445 | 3205 | try_(a) { | 3262 | if (!pbxt_database) { |
4446 | 3206 | xt_open_database(self, mysql_real_data_home, TRUE); | 3263 | xt_open_database(self, mysql_real_data_home, TRUE); |
4448 | 3207 | /* This can be done at the same time by a foreground thread, | 3264 | /* {GLOBAL-DB} |
4449 | 3265 | * This can be done at the same time as the recovery thread, | ||
4450 | 3208 | * strictly speaking I need a lock. | 3266 | * strictly speaking I need a lock. |
4451 | 3209 | */ | 3267 | */ |
4452 | 3210 | if (!pbxt_database) { | 3268 | if (!pbxt_database) { |
4453 | @@ -3212,11 +3270,22 @@ | |||
4454 | 3212 | xt_heap_reference(self, pbxt_database); | 3270 | xt_heap_reference(self, pbxt_database); |
4455 | 3213 | } | 3271 | } |
4456 | 3214 | } | 3272 | } |
4462 | 3215 | catch_(a) { | 3273 | else |
4463 | 3216 | xt_log_and_clear_exception(self); | 3274 | xt_use_database(self, pbxt_database, XT_FOR_USER); |
4464 | 3217 | } | 3275 | |
4465 | 3218 | cont_(a); | 3276 | pbxt_recovery_state = XT_RECOVER_DONE; |
4466 | 3219 | } | 3277 | |
4467 | 3278 | /* {WAIT-FOR-SW-AFTER-RECOV} | ||
4468 | 3279 | * Moved to here... | ||
4469 | 3280 | */ | ||
4470 | 3281 | xt_wait_for_sweeper(self, self->st_database, 0); | ||
4471 | 3282 | |||
4472 | 3283 | pbxt_recovery_state = XT_RECOVER_SWEPT; | ||
4473 | 3284 | } | ||
4474 | 3285 | catch_(a) { | ||
4475 | 3286 | xt_log_and_clear_exception(self); | ||
4476 | 3287 | } | ||
4477 | 3288 | cont_(a); | ||
4478 | 3220 | } | 3289 | } |
4479 | 3221 | 3290 | ||
4480 | 3222 | /* | 3291 | /* |
4481 | @@ -3261,11 +3330,12 @@ | |||
4482 | 3261 | sprintf(name, "DB-RECOVERY-%s", xt_last_directory_of_path(mysql_real_data_home)); | 3330 | sprintf(name, "DB-RECOVERY-%s", xt_last_directory_of_path(mysql_real_data_home)); |
4483 | 3262 | xt_remove_dir_char(name); | 3331 | xt_remove_dir_char(name); |
4484 | 3263 | 3332 | ||
4485 | 3333 | pbxt_recovery_state = XT_RECOVER_PENDING; | ||
4486 | 3264 | xres_recovery_thread = xt_create_daemon(self, name); | 3334 | xres_recovery_thread = xt_create_daemon(self, name); |
4487 | 3265 | xt_run_thread(self, xres_recovery_thread, xn_xres_run_recovery_thread); | 3335 | xt_run_thread(self, xres_recovery_thread, xn_xres_run_recovery_thread); |
4488 | 3266 | } | 3336 | } |
4489 | 3267 | 3337 | ||
4491 | 3268 | xtPublic void xt_xres_wait_for_recovery(XTThreadPtr self) | 3338 | xtPublic void xt_xres_terminate_recovery(XTThreadPtr self) |
4492 | 3269 | { | 3339 | { |
4493 | 3270 | XTThreadPtr thr_rec; | 3340 | XTThreadPtr thr_rec; |
4494 | 3271 | 3341 | ||
4495 | 3272 | 3342 | ||
4496 | === modified file 'storage/pbxt/src/restart_xt.h' | |||
4497 | --- storage/pbxt/src/restart_xt.h 2009-09-03 06:15:03 +0000 | |||
4498 | +++ storage/pbxt/src/restart_xt.h 2009-12-10 11:57:20 +0000 | |||
4499 | @@ -37,6 +37,8 @@ | |||
4500 | 37 | struct XTDatabase; | 37 | struct XTDatabase; |
4501 | 38 | struct XTTable; | 38 | struct XTTable; |
4502 | 39 | 39 | ||
4503 | 40 | extern int pbxt_recovery_state; | ||
4504 | 41 | |||
4505 | 40 | typedef struct XTWriterState { | 42 | typedef struct XTWriterState { |
4506 | 41 | struct XTDatabase *ws_db; | 43 | struct XTDatabase *ws_db; |
4507 | 42 | xtBool ws_in_recover; | 44 | xtBool ws_in_recover; |
4508 | @@ -132,6 +134,16 @@ | |||
4509 | 132 | void xt_dump_xlogs(struct XTDatabase *db, xtLogID start_log); | 134 | void xt_dump_xlogs(struct XTDatabase *db, xtLogID start_log); |
4510 | 133 | 135 | ||
4511 | 134 | void xt_xres_start_database_recovery(XTThreadPtr self); | 136 | void xt_xres_start_database_recovery(XTThreadPtr self); |
4513 | 135 | void xt_xres_wait_for_recovery(XTThreadPtr self); | 137 | void xt_xres_terminate_recovery(XTThreadPtr self); |
4514 | 138 | |||
4515 | 139 | #define XT_RECOVER_PENDING 0 | ||
4516 | 140 | #define XT_RECOVER_DONE 1 | ||
4517 | 141 | #define XT_RECOVER_SWEPT 2 | ||
4518 | 142 | |||
4519 | 143 | inline void xt_xres_wait_for_recovery(XTThreadPtr XT_UNUSED(self), int state) | ||
4520 | 144 | { | ||
4521 | 145 | while (pbxt_recovery_state < state) | ||
4522 | 146 | xt_sleep_milli_second(100); | ||
4523 | 147 | } | ||
4524 | 136 | 148 | ||
4525 | 137 | #endif | 149 | #endif |
4526 | 138 | 150 | ||
4527 | === modified file 'storage/pbxt/src/strutil_xt.cc' | |||
4528 | --- storage/pbxt/src/strutil_xt.cc 2009-10-26 11:35:42 +0000 | |||
4529 | +++ storage/pbxt/src/strutil_xt.cc 2009-12-10 11:57:20 +0000 | |||
4530 | @@ -21,8 +21,10 @@ | |||
4531 | 21 | * H&G2JCtL | 21 | * H&G2JCtL |
4532 | 22 | */ | 22 | */ |
4533 | 23 | 23 | ||
4534 | 24 | #include "mysql_priv.h" | ||
4535 | 25 | #include "xt_config.h" | 24 | #include "xt_config.h" |
4536 | 25 | |||
4537 | 26 | #include <stdio.h> | ||
4538 | 27 | #include <string.h> | ||
4539 | 26 | #include <ctype.h> | 28 | #include <ctype.h> |
4540 | 27 | 29 | ||
4541 | 28 | #include "strutil_xt.h" | 30 | #include "strutil_xt.h" |
4542 | @@ -107,13 +109,17 @@ | |||
4543 | 107 | *dest = 0; | 109 | *dest = 0; |
4544 | 108 | return; | 110 | return; |
4545 | 109 | } | 111 | } |
4548 | 110 | /* If temporary file */ | 112 | |
4549 | 111 | if (!is_prefix(path, mysql_data_home) && | 113 | /* {INVALID-OLD-TABLE-FIX} |
4550 | 114 | * I have changed the implementation of | ||
4551 | 115 | * this bug fix (see {INVALID-OLD-TABLE-FIX}). | ||
4552 | 116 | if (!is_prefix(path, mysql_data_home) && | ||
4553 | 112 | !is_prefix(path, mysql_real_data_home)) | 117 | !is_prefix(path, mysql_real_data_home)) |
4554 | 113 | { | 118 | { |
4555 | 114 | *dest= 0; | 119 | *dest= 0; |
4556 | 115 | return; | 120 | return; |
4557 | 116 | } | 121 | } |
4558 | 122 | */ | ||
4559 | 117 | 123 | ||
4560 | 118 | ptr = path + len - 1; | 124 | ptr = path + len - 1; |
4561 | 119 | while (ptr != path && !XT_IS_DIR_CHAR(*ptr)) | 125 | while (ptr != path && !XT_IS_DIR_CHAR(*ptr)) |
4562 | @@ -374,7 +380,7 @@ | |||
4563 | 374 | /* Version number must also be set in configure.in! */ | 380 | /* Version number must also be set in configure.in! */ |
4564 | 375 | xtPublic c_char *xt_get_version(void) | 381 | xtPublic c_char *xt_get_version(void) |
4565 | 376 | { | 382 | { |
4567 | 377 | return "1.0.08d RC"; | 383 | return "1.0.09f RC"; |
4568 | 378 | } | 384 | } |
4569 | 379 | 385 | ||
4570 | 380 | /* Copy and URL decode! */ | 386 | /* Copy and URL decode! */ |
4571 | 381 | 387 | ||
4572 | === modified file 'storage/pbxt/src/systab_xt.cc' | |||
4573 | --- storage/pbxt/src/systab_xt.cc 2009-08-17 11:12:36 +0000 | |||
4574 | +++ storage/pbxt/src/systab_xt.cc 2009-12-10 11:57:20 +0000 | |||
4575 | @@ -130,7 +130,7 @@ | |||
4576 | 130 | * MYSQL UTILITIES | 130 | * MYSQL UTILITIES |
4577 | 131 | */ | 131 | */ |
4578 | 132 | 132 | ||
4580 | 133 | void xt_my_set_notnull_in_record(Field *field, char *record) | 133 | static void xt_my_set_notnull_in_record(Field *field, char *record) |
4581 | 134 | { | 134 | { |
4582 | 135 | if (field->null_ptr) | 135 | if (field->null_ptr) |
4583 | 136 | record[(uint) (field->null_ptr - (uchar *) field->table->record[0])] &= (uchar) ~field->null_bit; | 136 | record[(uint) (field->null_ptr - (uchar *) field->table->record[0])] &= (uchar) ~field->null_bit; |
4584 | @@ -518,7 +518,7 @@ | |||
4585 | 518 | * SYSTEM TABLE SHARES | 518 | * SYSTEM TABLE SHARES |
4586 | 519 | */ | 519 | */ |
4587 | 520 | 520 | ||
4589 | 521 | void st_path_to_table_name(size_t size, char *buffer, const char *path) | 521 | static void st_path_to_table_name(size_t size, char *buffer, const char *path) |
4590 | 522 | { | 522 | { |
4591 | 523 | char *str; | 523 | char *str; |
4592 | 524 | 524 | ||
4593 | 525 | 525 | ||
4594 | === modified file 'storage/pbxt/src/tabcache_xt.cc' | |||
4595 | --- storage/pbxt/src/tabcache_xt.cc 2009-09-03 06:15:03 +0000 | |||
4596 | +++ storage/pbxt/src/tabcache_xt.cc 2009-12-10 11:57:20 +0000 | |||
4597 | @@ -590,7 +590,7 @@ | |||
4598 | 590 | * So there could be a deadlock if I don't flush the log! | 590 | * So there could be a deadlock if I don't flush the log! |
4599 | 591 | */ | 591 | */ |
4600 | 592 | if ((self = xt_get_self())) { | 592 | if ((self = xt_get_self())) { |
4602 | 593 | if (!xt_xlog_flush_log(self)) | 593 | if (!xt_xlog_flush_log(tci_table->tab_db, self)) |
4603 | 594 | goto failed; | 594 | goto failed; |
4604 | 595 | } | 595 | } |
4605 | 596 | 596 | ||
4606 | @@ -1150,6 +1150,8 @@ | |||
4607 | 1150 | int count; | 1150 | int count; |
4608 | 1151 | void *mysql_thread; | 1151 | void *mysql_thread; |
4609 | 1152 | 1152 | ||
4610 | 1153 | myxt_wait_pbxt_plugin_slot_assigned(self); | ||
4611 | 1154 | |||
4612 | 1153 | mysql_thread = myxt_create_thread(); | 1155 | mysql_thread = myxt_create_thread(); |
4613 | 1154 | 1156 | ||
4614 | 1155 | while (!self->t_quit) { | 1157 | while (!self->t_quit) { |
4615 | 1156 | 1158 | ||
4616 | === modified file 'storage/pbxt/src/tabcache_xt.h' | |||
4617 | --- storage/pbxt/src/tabcache_xt.h 2009-08-17 11:12:36 +0000 | |||
4618 | +++ storage/pbxt/src/tabcache_xt.h 2009-12-10 11:57:20 +0000 | |||
4619 | @@ -168,7 +168,7 @@ | |||
4620 | 168 | #define TAB_CAC_UNLOCK(i, o) xt_xsmutex_unlock(i, o) | 168 | #define TAB_CAC_UNLOCK(i, o) xt_xsmutex_unlock(i, o) |
4621 | 169 | #elif defined(TAB_CAC_USE_PTHREAD_RW) | 169 | #elif defined(TAB_CAC_USE_PTHREAD_RW) |
4622 | 170 | #define TAB_CAC_LOCK_TYPE xt_rwlock_type | 170 | #define TAB_CAC_LOCK_TYPE xt_rwlock_type |
4624 | 171 | #define TAB_CAC_INIT_LOCK(s, i) xt_init_rwlock(s, i) | 171 | #define TAB_CAC_INIT_LOCK(s, i) xt_init_rwlock_with_autoname(s, i) |
4625 | 172 | #define TAB_CAC_FREE_LOCK(s, i) xt_free_rwlock(i) | 172 | #define TAB_CAC_FREE_LOCK(s, i) xt_free_rwlock(i) |
4626 | 173 | #define TAB_CAC_READ_LOCK(i, o) xt_slock_rwlock_ns(i) | 173 | #define TAB_CAC_READ_LOCK(i, o) xt_slock_rwlock_ns(i) |
4627 | 174 | #define TAB_CAC_WRITE_LOCK(i, o) xt_xlock_rwlock_ns(i) | 174 | #define TAB_CAC_WRITE_LOCK(i, o) xt_xlock_rwlock_ns(i) |
4628 | 175 | 175 | ||
4629 | === modified file 'storage/pbxt/src/table_xt.cc' | |||
4630 | --- storage/pbxt/src/table_xt.cc 2009-08-18 07:46:53 +0000 | |||
4631 | +++ storage/pbxt/src/table_xt.cc 2009-12-10 11:57:20 +0000 | |||
4632 | @@ -35,7 +35,6 @@ | |||
4633 | 35 | #include <drizzled/common.h> | 35 | #include <drizzled/common.h> |
4634 | 36 | #include <mysys/thr_lock.h> | 36 | #include <mysys/thr_lock.h> |
4635 | 37 | #include <drizzled/dtcollation.h> | 37 | #include <drizzled/dtcollation.h> |
4636 | 38 | #include <drizzled/plugin/storage_engine.h> | ||
4637 | 39 | #else | 38 | #else |
4638 | 40 | #include "mysql_priv.h" | 39 | #include "mysql_priv.h" |
4639 | 41 | #endif | 40 | #endif |
4640 | @@ -48,7 +47,6 @@ | |||
4641 | 48 | #include "cache_xt.h" | 47 | #include "cache_xt.h" |
4642 | 49 | #include "trace_xt.h" | 48 | #include "trace_xt.h" |
4643 | 50 | #include "index_xt.h" | 49 | #include "index_xt.h" |
4644 | 51 | #include "restart_xt.h" | ||
4645 | 52 | #include "systab_xt.h" | 50 | #include "systab_xt.h" |
4646 | 53 | 51 | ||
4647 | 54 | #ifdef DEBUG | 52 | #ifdef DEBUG |
4648 | @@ -2347,7 +2345,7 @@ | |||
4649 | 2347 | 2345 | ||
4650 | 2348 | } | 2346 | } |
4651 | 2349 | 2347 | ||
4653 | 2350 | xtPublic XTOpenTablePtr tab_open_table(XTTableHPtr tab) | 2348 | static XTOpenTablePtr tab_open_table(XTTableHPtr tab) |
4654 | 2351 | { | 2349 | { |
4655 | 2352 | volatile XTOpenTablePtr ot; | 2350 | volatile XTOpenTablePtr ot; |
4656 | 2353 | XTThreadPtr self; | 2351 | XTThreadPtr self; |
4657 | @@ -2588,7 +2586,7 @@ | |||
4658 | 2588 | return FAILED; | 2586 | return FAILED; |
4659 | 2589 | } | 2587 | } |
4660 | 2590 | 2588 | ||
4662 | 2591 | return xt_xlog_modify_table(ot, status, op_seq, free_rec_id, rec_id, size, buffer); | 2589 | return xt_xlog_modify_table(tab->tab_id, status, op_seq, free_rec_id, rec_id, size, buffer, ot->ot_thread); |
4663 | 2592 | } | 2590 | } |
4664 | 2593 | 2591 | ||
4665 | 2594 | xtPublic xtBool xt_tab_put_log_rec_data(XTOpenTablePtr ot, u_int status, xtRecordID free_rec_id, xtRecordID rec_id, size_t size, xtWord1 *buffer, xtOpSeqNo *op_seq) | 2592 | xtPublic xtBool xt_tab_put_log_rec_data(XTOpenTablePtr ot, u_int status, xtRecordID free_rec_id, xtRecordID rec_id, size_t size, xtWord1 *buffer, xtOpSeqNo *op_seq) |
4666 | @@ -2606,7 +2604,7 @@ | |||
4667 | 2606 | return FAILED; | 2604 | return FAILED; |
4668 | 2607 | } | 2605 | } |
4669 | 2608 | 2606 | ||
4671 | 2609 | return xt_xlog_modify_table(ot, status, *op_seq, free_rec_id, rec_id, size, buffer); | 2607 | return xt_xlog_modify_table(tab->tab_id, status, *op_seq, free_rec_id, rec_id, size, buffer, ot->ot_thread); |
4672 | 2610 | } | 2608 | } |
4673 | 2611 | 2609 | ||
4674 | 2612 | xtPublic xtBool xt_tab_get_rec_data(XTOpenTablePtr ot, xtRecordID rec_id, size_t size, xtWord1 *buffer) | 2610 | xtPublic xtBool xt_tab_get_rec_data(XTOpenTablePtr ot, xtRecordID rec_id, size_t size, xtWord1 *buffer) |
4675 | @@ -3541,7 +3539,7 @@ | |||
4676 | 3541 | tab->tab_row_fnum++; | 3539 | tab->tab_row_fnum++; |
4677 | 3542 | xt_unlock_mutex_ns(&tab->tab_row_lock); | 3540 | xt_unlock_mutex_ns(&tab->tab_row_lock); |
4678 | 3543 | 3541 | ||
4680 | 3544 | if (!xt_xlog_modify_table(ot, XT_LOG_ENT_ROW_FREED, op_seq, 0, row_id, sizeof(XTTabRowRefDRec), (xtWord1 *) &free_row)) | 3542 | if (!xt_xlog_modify_table(tab->tab_id, XT_LOG_ENT_ROW_FREED, op_seq, 0, row_id, sizeof(XTTabRowRefDRec), (xtWord1 *) &free_row, ot->ot_thread)) |
4681 | 3545 | return FAILED; | 3543 | return FAILED; |
4682 | 3546 | 3544 | ||
4683 | 3547 | return OK; | 3545 | return OK; |
4684 | @@ -3791,7 +3789,7 @@ | |||
4685 | 3791 | xt_unlock_mutex_ns(&tab->tab_rec_lock); | 3789 | xt_unlock_mutex_ns(&tab->tab_rec_lock); |
4686 | 3792 | 3790 | ||
4687 | 3793 | free_rec->rf_rec_type_1 = old_rec_type; | 3791 | free_rec->rf_rec_type_1 = old_rec_type; |
4689 | 3794 | return xt_xlog_modify_table(ot, XT_LOG_ENT_REC_REMOVED_BI, op_seq, (xtRecordID) new_rec_type, rec_id, rec_size, ot->ot_row_rbuffer); | 3792 | return xt_xlog_modify_table(tab->tab_id, XT_LOG_ENT_REC_REMOVED_BI, op_seq, (xtRecordID) new_rec_type, rec_id, rec_size, ot->ot_row_rbuffer, ot->ot_thread); |
4690 | 3795 | } | 3793 | } |
4691 | 3796 | 3794 | ||
4692 | 3797 | static xtRowID tab_new_row(XTOpenTablePtr ot, XTTableHPtr tab) | 3795 | static xtRowID tab_new_row(XTOpenTablePtr ot, XTTableHPtr tab) |
4693 | @@ -3837,7 +3835,7 @@ | |||
4694 | 3837 | op_seq = tab->tab_seq.ts_get_op_seq(); | 3835 | op_seq = tab->tab_seq.ts_get_op_seq(); |
4695 | 3838 | xt_unlock_mutex_ns(&tab->tab_row_lock); | 3836 | xt_unlock_mutex_ns(&tab->tab_row_lock); |
4696 | 3839 | 3837 | ||
4698 | 3840 | if (!xt_xlog_modify_table(ot, status, op_seq, next_row_id, row_id, 0, NULL)) | 3838 | if (!xt_xlog_modify_table(tab->tab_id, status, op_seq, next_row_id, row_id, 0, NULL, ot->ot_thread)) |
4699 | 3841 | return 0; | 3839 | return 0; |
4700 | 3842 | 3840 | ||
4701 | 3843 | XT_DISABLED_TRACE(("new row tx=%d row=%d\n", (int) ot->ot_thread->st_xact_data->xd_start_xn_id, (int) row_id)); | 3841 | XT_DISABLED_TRACE(("new row tx=%d row=%d\n", (int) ot->ot_thread->st_xact_data->xd_start_xn_id, (int) row_id)); |
4702 | @@ -3868,7 +3866,7 @@ | |||
4703 | 3868 | if (!tab->tab_rows.xt_tc_write(ot->ot_row_file, row_id, 0, sizeof(XTTabRowRefDRec), (xtWord1 *) &row_buf, &op_seq, TRUE, ot->ot_thread)) | 3866 | if (!tab->tab_rows.xt_tc_write(ot->ot_row_file, row_id, 0, sizeof(XTTabRowRefDRec), (xtWord1 *) &row_buf, &op_seq, TRUE, ot->ot_thread)) |
4704 | 3869 | return FAILED; | 3867 | return FAILED; |
4705 | 3870 | 3868 | ||
4707 | 3871 | return xt_xlog_modify_table(ot, status, op_seq, 0, row_id, sizeof(XTTabRowRefDRec), (xtWord1 *) &row_buf); | 3869 | return xt_xlog_modify_table(tab->tab_id, status, op_seq, 0, row_id, sizeof(XTTabRowRefDRec), (xtWord1 *) &row_buf, ot->ot_thread); |
4708 | 3872 | } | 3870 | } |
4709 | 3873 | 3871 | ||
4710 | 3874 | xtPublic xtBool xt_tab_free_record(XTOpenTablePtr ot, u_int status, xtRecordID rec_id, xtBool clean_delete) | 3872 | xtPublic xtBool xt_tab_free_record(XTOpenTablePtr ot, u_int status, xtRecordID rec_id, xtBool clean_delete) |
4711 | @@ -3937,7 +3935,7 @@ | |||
4712 | 3937 | tab->tab_rec_fnum++; | 3935 | tab->tab_rec_fnum++; |
4713 | 3938 | xt_unlock_mutex_ns(&tab->tab_rec_lock); | 3936 | xt_unlock_mutex_ns(&tab->tab_rec_lock); |
4714 | 3939 | 3937 | ||
4716 | 3940 | if (!xt_xlog_modify_table(ot, status, op_seq, rec_id, rec_id, sizeof(XTactFreeRecEntryDRec) - offsetof(XTactFreeRecEntryDRec, fr_stat_id_1), &free_rec.fr_stat_id_1)) | 3938 | if (!xt_xlog_modify_table(tab->tab_id, status, op_seq, rec_id, rec_id, sizeof(XTactFreeRecEntryDRec) - offsetof(XTactFreeRecEntryDRec, fr_stat_id_1), &free_rec.fr_stat_id_1, ot->ot_thread)) |
4717 | 3941 | return FAILED; | 3939 | return FAILED; |
4718 | 3942 | } | 3940 | } |
4719 | 3943 | return OK; | 3941 | return OK; |
4720 | @@ -4016,7 +4014,7 @@ | |||
4721 | 4016 | } | 4014 | } |
4722 | 4017 | xt_unlock_mutex_ns(&tab->tab_rec_lock); | 4015 | xt_unlock_mutex_ns(&tab->tab_rec_lock); |
4723 | 4018 | 4016 | ||
4725 | 4019 | if (!xt_xlog_modify_table(ot, status, op_seq, next_rec_id, rec_id, rec_info->ri_rec_buf_size, (xtWord1 *) rec_info->ri_fix_rec_buf)) | 4017 | if (!xt_xlog_modify_table(tab->tab_id, status, op_seq, next_rec_id, rec_id, rec_info->ri_rec_buf_size, (xtWord1 *) rec_info->ri_fix_rec_buf, ot->ot_thread)) |
4726 | 4020 | return FAILED; | 4018 | return FAILED; |
4727 | 4021 | 4019 | ||
4728 | 4022 | if (rec_info->ri_ext_rec) { | 4020 | if (rec_info->ri_ext_rec) { |
4729 | @@ -4932,6 +4930,12 @@ | |||
4730 | 4932 | #endif | 4930 | #endif |
4731 | 4933 | #endif | 4931 | #endif |
4732 | 4934 | 4932 | ||
4733 | 4933 | xtPublic void xt_tab_seq_repeat(XTOpenTablePtr ot) | ||
4734 | 4934 | { | ||
4735 | 4935 | ot->ot_seq_rec_id--; | ||
4736 | 4936 | ot->ot_seq_offset -= ot->ot_table->tab_dic.dic_rec_size; | ||
4737 | 4937 | } | ||
4738 | 4938 | |||
4739 | 4935 | xtPublic xtBool xt_tab_seq_next(XTOpenTablePtr ot, xtWord1 *buffer, xtBool *eof) | 4939 | xtPublic xtBool xt_tab_seq_next(XTOpenTablePtr ot, xtWord1 *buffer, xtBool *eof) |
4740 | 4936 | { | 4940 | { |
4741 | 4937 | register XTTableHPtr tab = ot->ot_table; | 4941 | register XTTableHPtr tab = ot->ot_table; |
4742 | @@ -5094,7 +5098,7 @@ | |||
4743 | 5094 | return FALSE; | 5098 | return FALSE; |
4744 | 5095 | } | 5099 | } |
4745 | 5096 | else { | 5100 | else { |
4747 | 5097 | if (!xt_open_file_ns(&of, file_path, XT_FS_DEFAULT)) | 5101 | if (!xt_open_file_ns(&of, file_path, XT_FS_DEFAULT | XT_FS_MISSING_OK)) |
4748 | 5098 | return FALSE; | 5102 | return FALSE; |
4749 | 5099 | } | 5103 | } |
4750 | 5100 | if (!of) | 5104 | if (!of) |
4751 | @@ -5190,15 +5194,76 @@ | |||
4752 | 5190 | return FALSE; | 5194 | return FALSE; |
4753 | 5191 | } | 5195 | } |
4754 | 5192 | 5196 | ||
4756 | 5193 | xtPublic void tab_make_table_name(XTTableHPtr tab, char *table_name, size_t size) | 5197 | static void tab_make_table_name(XTTableHPtr tab, char *table_name, size_t size) |
4757 | 5194 | { | 5198 | { |
4765 | 5195 | char name_buf[XT_IDENTIFIER_NAME_SIZE*3+3]; | 5199 | char *nptr; |
4766 | 5196 | 5200 | ||
4767 | 5197 | xt_2nd_last_name_of_path(sizeof(name_buf), name_buf, tab->tab_name->ps_path); | 5201 | nptr = xt_last_name_of_path(tab->tab_name->ps_path); |
4768 | 5198 | myxt_static_convert_file_name(name_buf, table_name, size); | 5202 | if (xt_starts_with(nptr, "#sql")) { |
4769 | 5199 | xt_strcat(size, table_name, "."); | 5203 | /* {INVALID-OLD-TABLE-FIX} |
4770 | 5200 | myxt_static_convert_file_name(xt_last_name_of_path(tab->tab_name->ps_path), name_buf, sizeof(name_buf)); | 5204 | * Temporary files can have strange paths, for example |
4771 | 5201 | xt_strcat(size, table_name, name_buf); | 5205 | * ..../var/tmp/mysqld.1/#sqldaec_1_6 |
4772 | 5206 | * This occurs, for example, occurs when the temp_table.test is | ||
4773 | 5207 | * run using the PBXT suite in MariaDB: | ||
4774 | 5208 | * ./mtr --suite=pbxt --do-test=temp_table | ||
4775 | 5209 | * | ||
4776 | 5210 | * Calling myxt_static_convert_file_name, with a '.', in the name | ||
4777 | 5211 | * causes the error: | ||
4778 | 5212 | * [ERROR] Invalid (old?) table or database name 'mysqld.1' | ||
4779 | 5213 | * To prevent this, we do not convert the temporary | ||
4780 | 5214 | * table names using the mysql functions. | ||
4781 | 5215 | * | ||
4782 | 5216 | * Note, this bug was found by Monty, and fixed by modifying | ||
4783 | 5217 | * xt_2nd_last_name_of_path(), see {INVALID-OLD-TABLE-FIX}. | ||
4784 | 5218 | * | ||
4785 | 5219 | */ | ||
4786 | 5220 | xt_2nd_last_name_of_path(size, table_name, tab->tab_name->ps_path); | ||
4787 | 5221 | xt_strcat(size, table_name, "."); | ||
4788 | 5222 | xt_strcat(size, table_name, nptr); | ||
4789 | 5223 | } | ||
4790 | 5224 | else { | ||
4791 | 5225 | char name_buf[XT_TABLE_NAME_SIZE*3+3]; | ||
4792 | 5226 | char *part_ptr; | ||
4793 | 5227 | size_t len; | ||
4794 | 5228 | |||
4795 | 5229 | xt_2nd_last_name_of_path(sizeof(name_buf), name_buf, tab->tab_name->ps_path); | ||
4796 | 5230 | myxt_static_convert_file_name(name_buf, table_name, size); | ||
4797 | 5231 | xt_strcat(size, table_name, "."); | ||
4798 | 5232 | |||
4799 | 5233 | /* Handle partition extensions to table names: */ | ||
4800 | 5234 | if ((part_ptr = strstr(nptr, "#P#"))) | ||
4801 | 5235 | xt_strncpy(sizeof(name_buf), name_buf, nptr, part_ptr - nptr); | ||
4802 | 5236 | else | ||
4803 | 5237 | xt_strcpy(sizeof(name_buf), name_buf, nptr); | ||
4804 | 5238 | |||
4805 | 5239 | len = strlen(table_name); | ||
4806 | 5240 | myxt_static_convert_file_name(name_buf, table_name + len, size - len); | ||
4807 | 5241 | |||
4808 | 5242 | if (part_ptr) { | ||
4809 | 5243 | /* Add the partition extension (which is relevant to the engine). */ | ||
4810 | 5244 | char *sub_part_ptr; | ||
4811 | 5245 | |||
4812 | 5246 | part_ptr += 3; | ||
4813 | 5247 | if ((sub_part_ptr = strstr(part_ptr, "#SP#"))) | ||
4814 | 5248 | xt_strncpy(sizeof(name_buf), name_buf, part_ptr, sub_part_ptr - part_ptr); | ||
4815 | 5249 | else | ||
4816 | 5250 | xt_strcpy(sizeof(name_buf), name_buf, part_ptr); | ||
4817 | 5251 | |||
4818 | 5252 | xt_strcat(size, table_name, " ("); | ||
4819 | 5253 | len = strlen(table_name); | ||
4820 | 5254 | myxt_static_convert_file_name(name_buf, table_name + len, size - len); | ||
4821 | 5255 | |||
4822 | 5256 | if (sub_part_ptr) { | ||
4823 | 5257 | |||
4824 | 5258 | sub_part_ptr += 4; | ||
4825 | 5259 | xt_strcat(size, table_name, " - "); | ||
4826 | 5260 | len = strlen(table_name); | ||
4827 | 5261 | myxt_static_convert_file_name(sub_part_ptr, table_name + len, size - len); | ||
4828 | 5262 | } | ||
4829 | 5263 | |||
4830 | 5264 | xt_strcat(size, table_name, ")"); | ||
4831 | 5265 | } | ||
4832 | 5266 | } | ||
4833 | 5202 | } | 5267 | } |
4834 | 5203 | 5268 | ||
4835 | 5204 | xtPublic xtBool xt_tab_is_table_repair_pending(XTTableHPtr tab) | 5269 | xtPublic xtBool xt_tab_is_table_repair_pending(XTTableHPtr tab) |
4836 | 5205 | 5270 | ||
4837 | === modified file 'storage/pbxt/src/table_xt.h' | |||
4838 | --- storage/pbxt/src/table_xt.h 2009-08-18 07:46:53 +0000 | |||
4839 | +++ storage/pbxt/src/table_xt.h 2009-12-10 11:57:20 +0000 | |||
4840 | @@ -127,7 +127,7 @@ | |||
4841 | 127 | #define XT_TAB_ROW_UNLOCK(i, s) xt_xsmutex_unlock(i, (s)->t_id) | 127 | #define XT_TAB_ROW_UNLOCK(i, s) xt_xsmutex_unlock(i, (s)->t_id) |
4842 | 128 | #elif defined(XT_TAB_ROW_USE_PTHREAD_RW) | 128 | #elif defined(XT_TAB_ROW_USE_PTHREAD_RW) |
4843 | 129 | #define XT_TAB_ROW_LOCK_TYPE xt_rwlock_type | 129 | #define XT_TAB_ROW_LOCK_TYPE xt_rwlock_type |
4845 | 130 | #define XT_TAB_ROW_INIT_LOCK(s, i) xt_init_rwlock(s, i) | 130 | #define XT_TAB_ROW_INIT_LOCK(s, i) xt_init_rwlock_with_autoname(s, i) |
4846 | 131 | #define XT_TAB_ROW_FREE_LOCK(s, i) xt_free_rwlock(i) | 131 | #define XT_TAB_ROW_FREE_LOCK(s, i) xt_free_rwlock(i) |
4847 | 132 | #define XT_TAB_ROW_READ_LOCK(i, s) xt_slock_rwlock_ns(i) | 132 | #define XT_TAB_ROW_READ_LOCK(i, s) xt_slock_rwlock_ns(i) |
4848 | 133 | #define XT_TAB_ROW_WRITE_LOCK(i, s) xt_xlock_rwlock_ns(i) | 133 | #define XT_TAB_ROW_WRITE_LOCK(i, s) xt_xlock_rwlock_ns(i) |
4849 | @@ -528,13 +528,14 @@ | |||
4850 | 528 | void xt_enum_tables_init(u_int *edx); | 528 | void xt_enum_tables_init(u_int *edx); |
4851 | 529 | XTTableEntryPtr xt_enum_tables_next(struct XTThread *self, struct XTDatabase *db, u_int *edx); | 529 | XTTableEntryPtr xt_enum_tables_next(struct XTThread *self, struct XTDatabase *db, u_int *edx); |
4852 | 530 | 530 | ||
4854 | 531 | void xt_enum_files_of_tables_init(struct XTDatabase *db, char *tab_name, xtTableID tab_id, XTFilesOfTablePtr ft); | 531 | void xt_enum_files_of_tables_init(XTPathStrPtr tab_name, xtTableID tab_id, XTFilesOfTablePtr ft); |
4855 | 532 | xtBool xt_enum_files_of_tables_next(XTFilesOfTablePtr ft); | 532 | xtBool xt_enum_files_of_tables_next(XTFilesOfTablePtr ft); |
4856 | 533 | 533 | ||
4857 | 534 | xtBool xt_tab_seq_init(XTOpenTablePtr ot); | 534 | xtBool xt_tab_seq_init(XTOpenTablePtr ot); |
4858 | 535 | void xt_tab_seq_reset(XTOpenTablePtr ot); | 535 | void xt_tab_seq_reset(XTOpenTablePtr ot); |
4859 | 536 | void xt_tab_seq_exit(XTOpenTablePtr ot); | 536 | void xt_tab_seq_exit(XTOpenTablePtr ot); |
4860 | 537 | xtBool xt_tab_seq_next(XTOpenTablePtr ot, xtWord1 *buffer, xtBool *eof); | 537 | xtBool xt_tab_seq_next(XTOpenTablePtr ot, xtWord1 *buffer, xtBool *eof); |
4861 | 538 | void xt_tab_seq_repeat(XTOpenTablePtr ot); | ||
4862 | 538 | 539 | ||
4863 | 539 | xtBool xt_tab_new_record(XTOpenTablePtr ot, xtWord1 *buffer); | 540 | xtBool xt_tab_new_record(XTOpenTablePtr ot, xtWord1 *buffer); |
4864 | 540 | xtBool xt_tab_delete_record(XTOpenTablePtr ot, xtWord1 *buffer); | 541 | xtBool xt_tab_delete_record(XTOpenTablePtr ot, xtWord1 *buffer); |
4865 | 541 | 542 | ||
4866 | === modified file 'storage/pbxt/src/thread_xt.cc' | |||
4867 | --- storage/pbxt/src/thread_xt.cc 2009-10-06 15:16:01 +0000 | |||
4868 | +++ storage/pbxt/src/thread_xt.cc 2009-12-10 11:57:20 +0000 | |||
4869 | @@ -75,6 +75,13 @@ | |||
4870 | 75 | /* Global accumulated statistics: */ | 75 | /* Global accumulated statistics: */ |
4871 | 76 | static XTStatisticsRec thr_statistics; | 76 | static XTStatisticsRec thr_statistics; |
4872 | 77 | 77 | ||
4873 | 78 | #ifdef DEBUG | ||
4874 | 79 | static void break_in_assertion(c_char *expr, c_char *func, c_char *file, u_int line) | ||
4875 | 80 | { | ||
4876 | 81 | printf("%s(%s:%d) %s\n", func, file, (int) line, expr); | ||
4877 | 82 | } | ||
4878 | 83 | #endif | ||
4879 | 84 | |||
4880 | 78 | /* | 85 | /* |
4881 | 79 | * ----------------------------------------------------------------------- | 86 | * ----------------------------------------------------------------------- |
4882 | 80 | * Error logging | 87 | * Error logging |
4883 | @@ -658,6 +665,9 @@ | |||
4884 | 658 | case XT_ERR_FK_REF_TEMP_TABLE: str = "Foreign key may not reference temporary table"; break; | 665 | case XT_ERR_FK_REF_TEMP_TABLE: str = "Foreign key may not reference temporary table"; break; |
4885 | 659 | case XT_ERR_MYSQL_SHUTDOWN: str = "Cannot open table, MySQL has shutdown"; break; | 666 | case XT_ERR_MYSQL_SHUTDOWN: str = "Cannot open table, MySQL has shutdown"; break; |
4886 | 660 | case XT_ERR_MYSQL_NO_THREAD: str = "Cannot create thread, MySQL has shutdown"; break; | 667 | case XT_ERR_MYSQL_NO_THREAD: str = "Cannot create thread, MySQL has shutdown"; break; |
4887 | 668 | case XT_ERR_BUFFER_TOO_SMALL: str = "System backup buffer too small"; break; | ||
4888 | 669 | case XT_ERR_BAD_BACKUP_FORMAT: str = "Unknown or corrupt backup format, restore aborted"; break; | ||
4889 | 670 | case XT_ERR_PBXT_NOT_INSTALLED: str = "PBXT plugin is not installed"; break; | ||
4890 | 661 | default: str = "Unknown XT error"; break; | 671 | default: str = "Unknown XT error"; break; |
4891 | 662 | } | 672 | } |
4892 | 663 | return str; | 673 | return str; |
4893 | @@ -862,6 +872,11 @@ | |||
4894 | 862 | return FAILED; | 872 | return FAILED; |
4895 | 863 | } | 873 | } |
4896 | 864 | 874 | ||
4897 | 875 | xtPublic void xt_exception_xterr(XTExceptionPtr e, XTThreadPtr self, c_char *func, c_char *file, u_int line, int xt_err) | ||
4898 | 876 | { | ||
4899 | 877 | xt_exception_error(e, self, func, file, line, xt_err, 0, thr_get_err_string(xt_err)); | ||
4900 | 878 | } | ||
4901 | 879 | |||
4902 | 865 | /* | 880 | /* |
4903 | 866 | * ----------------------------------------------------------------------- | 881 | * ----------------------------------------------------------------------- |
4904 | 867 | * LOG ERRORS | 882 | * LOG ERRORS |
4905 | @@ -887,7 +902,7 @@ | |||
4906 | 887 | #ifdef DEBUG | 902 | #ifdef DEBUG |
4907 | 888 | //xt_set_fflush(TRUE); | 903 | //xt_set_fflush(TRUE); |
4908 | 889 | //xt_dump_trace(); | 904 | //xt_dump_trace(); |
4910 | 890 | printf("%s(%s:%d) %s\n", func, file, (int) line, expr); | 905 | break_in_assertion(expr, func, file, line); |
4911 | 891 | #ifdef CRASH_ON_ASSERT | 906 | #ifdef CRASH_ON_ASSERT |
4912 | 892 | abort(); | 907 | abort(); |
4913 | 893 | #endif | 908 | #endif |
4914 | 894 | 909 | ||
4915 | === modified file 'storage/pbxt/src/thread_xt.h' | |||
4916 | --- storage/pbxt/src/thread_xt.h 2009-08-17 11:12:36 +0000 | |||
4917 | +++ storage/pbxt/src/thread_xt.h 2009-12-10 11:57:20 +0000 | |||
4918 | @@ -536,6 +536,8 @@ | |||
4919 | 536 | * Function prototypes | 536 | * Function prototypes |
4920 | 537 | */ | 537 | */ |
4921 | 538 | 538 | ||
4922 | 539 | extern "C" void *thr_main(void *data); | ||
4923 | 540 | |||
4924 | 539 | void xt_get_now(char *buffer, size_t len); | 541 | void xt_get_now(char *buffer, size_t len); |
4925 | 540 | xtBool xt_init_logging(void); | 542 | xtBool xt_init_logging(void); |
4926 | 541 | void xt_exit_logging(void); | 543 | void xt_exit_logging(void); |
4927 | @@ -583,6 +585,7 @@ | |||
4928 | 583 | void xt_exceptionf(XTExceptionPtr e, XTThreadPtr self, c_char *func, c_char *file, u_int line, int xt_err, int sys_err, c_char *fmt, ...); | 585 | void xt_exceptionf(XTExceptionPtr e, XTThreadPtr self, c_char *func, c_char *file, u_int line, int xt_err, int sys_err, c_char *fmt, ...); |
4929 | 584 | void xt_exception_error(XTExceptionPtr e, XTThreadPtr self, c_char *func, c_char *file, u_int line, int xt_err, int sys_err, c_char *msg); | 586 | void xt_exception_error(XTExceptionPtr e, XTThreadPtr self, c_char *func, c_char *file, u_int line, int xt_err, int sys_err, c_char *msg); |
4930 | 585 | xtBool xt_exception_errno(XTExceptionPtr e, XTThreadPtr self, c_char *func, c_char *file, u_int line, int err); | 587 | xtBool xt_exception_errno(XTExceptionPtr e, XTThreadPtr self, c_char *func, c_char *file, u_int line, int err); |
4931 | 588 | void xt_exception_xterr(XTExceptionPtr e, XTThreadPtr self, c_char *func, c_char *file, u_int line, int xt_err); | ||
4932 | 586 | 589 | ||
4933 | 587 | void xt_log_errno(XTThreadPtr self, c_char *func, c_char *file, u_int line, int err); | 590 | void xt_log_errno(XTThreadPtr self, c_char *func, c_char *file, u_int line, int err); |
4934 | 588 | 591 | ||
4935 | @@ -610,7 +613,7 @@ | |||
4936 | 610 | void xt_yield(void); | 613 | void xt_yield(void); |
4937 | 611 | void xt_sleep_milli_second(u_int t); | 614 | void xt_sleep_milli_second(u_int t); |
4938 | 612 | xtBool xt_suspend(XTThreadPtr self); | 615 | xtBool xt_suspend(XTThreadPtr self); |
4940 | 613 | xtBool xt_unsuspend(XTThreadPtr self, XTThreadPtr target); | 616 | xtBool xt_unsuspend(XTThreadPtr target); |
4941 | 614 | void xt_lock_thread(XTThreadPtr thread); | 617 | void xt_lock_thread(XTThreadPtr thread); |
4942 | 615 | void xt_unlock_thread(XTThreadPtr thread); | 618 | void xt_unlock_thread(XTThreadPtr thread); |
4943 | 616 | xtBool xt_wait_thread(XTThreadPtr thread); | 619 | xtBool xt_wait_thread(XTThreadPtr thread); |
4944 | 617 | 620 | ||
4945 | === modified file 'storage/pbxt/src/util_xt.cc' | |||
4946 | --- storage/pbxt/src/util_xt.cc 2009-08-17 11:12:36 +0000 | |||
4947 | +++ storage/pbxt/src/util_xt.cc 2009-12-10 11:57:20 +0000 | |||
4948 | @@ -150,6 +150,23 @@ | |||
4949 | 150 | return (xtWord1) (sum ^ (sum >> 24) ^ (sum >> 16) ^ (sum >> 8)); | 150 | return (xtWord1) (sum ^ (sum >> 24) ^ (sum >> 16) ^ (sum >> 8)); |
4950 | 151 | } | 151 | } |
4951 | 152 | 152 | ||
4952 | 153 | xtPublic xtWord4 xt_get_checksum4(xtWord1 *data, size_t len) | ||
4953 | 154 | { | ||
4954 | 155 | register xtWord4 sum = 0, g; | ||
4955 | 156 | xtWord1 *chk; | ||
4956 | 157 | |||
4957 | 158 | chk = data + len - 1; | ||
4958 | 159 | while (chk > data) { | ||
4959 | 160 | sum = (sum << 4) + *chk; | ||
4960 | 161 | if ((g = sum & 0xF0000000)) { | ||
4961 | 162 | sum = sum ^ (g >> 24); | ||
4962 | 163 | sum = sum ^ g; | ||
4963 | 164 | } | ||
4964 | 165 | chk--; | ||
4965 | 166 | } | ||
4966 | 167 | return sum; | ||
4967 | 168 | } | ||
4968 | 169 | |||
4969 | 153 | /* | 170 | /* |
4970 | 154 | * --------------- Data Buffer ------------------ | 171 | * --------------- Data Buffer ------------------ |
4971 | 155 | */ | 172 | */ |
4972 | 156 | 173 | ||
4973 | === modified file 'storage/pbxt/src/util_xt.h' | |||
4974 | --- storage/pbxt/src/util_xt.h 2009-03-26 12:18:01 +0000 | |||
4975 | +++ storage/pbxt/src/util_xt.h 2009-12-10 11:57:20 +0000 | |||
4976 | @@ -39,6 +39,7 @@ | |||
4977 | 39 | xtBool xt_time_difference(register xtWord4 now, register xtWord4 then); | 39 | xtBool xt_time_difference(register xtWord4 now, register xtWord4 then); |
4978 | 40 | xtWord2 xt_get_checksum(xtWord1 *data, size_t len, u_int interval); | 40 | xtWord2 xt_get_checksum(xtWord1 *data, size_t len, u_int interval); |
4979 | 41 | xtWord1 xt_get_checksum1(xtWord1 *data, size_t len); | 41 | xtWord1 xt_get_checksum1(xtWord1 *data, size_t len); |
4980 | 42 | xtWord4 xt_get_checksum4(xtWord1 *data, size_t len); | ||
4981 | 42 | 43 | ||
4982 | 43 | typedef struct XTDataBuffer { | 44 | typedef struct XTDataBuffer { |
4983 | 44 | size_t db_size; | 45 | size_t db_size; |
4984 | 45 | 46 | ||
4985 | === modified file 'storage/pbxt/src/xaction_xt.cc' | |||
4986 | --- storage/pbxt/src/xaction_xt.cc 2009-09-03 06:15:03 +0000 | |||
4987 | +++ storage/pbxt/src/xaction_xt.cc 2009-12-10 11:57:20 +0000 | |||
4988 | @@ -1075,6 +1075,7 @@ | |||
4989 | 1075 | #endif | 1075 | #endif |
4990 | 1076 | xt_spinlock_init_with_autoname(self, &db->db_xn_id_lock); | 1076 | xt_spinlock_init_with_autoname(self, &db->db_xn_id_lock); |
4991 | 1077 | xt_spinlock_init_with_autoname(self, &db->db_xn_wait_spinlock); | 1077 | xt_spinlock_init_with_autoname(self, &db->db_xn_wait_spinlock); |
4992 | 1078 | xt_init_mutex_with_autoname(self, &db->db_xn_xa_lock); | ||
4993 | 1078 | //xt_init_mutex_with_autoname(self, &db->db_xn_wait_lock); | 1079 | //xt_init_mutex_with_autoname(self, &db->db_xn_wait_lock); |
4994 | 1079 | //xt_init_cond(self, &db->db_xn_wait_cond); | 1080 | //xt_init_cond(self, &db->db_xn_wait_cond); |
4995 | 1080 | xt_init_mutex_with_autoname(self, &db->db_sw_lock); | 1081 | xt_init_mutex_with_autoname(self, &db->db_sw_lock); |
4996 | @@ -1096,6 +1097,9 @@ | |||
4997 | 1096 | } | 1097 | } |
4998 | 1097 | } | 1098 | } |
4999 | 1098 | 1099 | ||
5000 | 1100 | /* Create a sorted list for XA transactions recovered: */ |
This is the 3rd RC release of PBXT. It includes a number of bug fixes (some specifically for MariaDB), and 2 features:
- XA/2-Phase commit support
- Online backup native driver for PBXT
The backup uses the MySQL backup API (MySQL 6.0/5.4), and is not yet available in MariaDB.
Release notes since the RC2 version already in MariaDB are as follows:
------- 1.0.09f RC3 - 2009-11-30
RN291: Fixed bug #489088: On shutdown MySQL reports: [Warning] Plugin 'PBXT' will be forced to shutdown.
RN290: Fixed bug #345524: pbxt does not compile on 64 bit windows. Currently atomic operations are not supported on this platform.
RN286: Fixed a bug introduced in RN281, which could cause an index scan to hang. The original change was to prevent a warning in Valgrind.
RN285: Merged changes required to compile with Drizzle.
RN284: Fixed bug that cause the error "[ERROR] Invalid (old?) table or database name 'mysqld.1'", when running temp_table.test under MariaDB (thanks to Monty for his initial bug fix). Added a fix for partition table names as well.
RN283: Added win_inttypes.h to the distribution. This file is only required for the Windows build.
RN282: Fixed bug #451101: jump or move depends on uninitialised value in myxt_get_key_length
RN281: Fixed bug #451080: Uninitialised memory write in XTDatabaseLog: :xlog_append
RN280: Fixed bug #451085: jump or move depends on uninitialised value in my_type_to_string
RN279: Fixed bug #441000: xtstat crashes with segmentation fault on startup if max_pbxt_threads exceeded.
------- 1.0.09e RC3 - 2009-11-20
RN278: Fixed compile error with MySQL 5.1.41.
------- 1.0.09d RC3 - 2009-09-30
RN277: Added r/o flag to pbxt_max_threads server variable (this fix is related to bug #430637)
RN276: Added test case for replication on tables w/o PKs (see bug #430716)
RN275: Fixed bug #430600: 'Failed to read auto-increment value from storage engine' error.
RN274: Fixed bug #431240: This report is public edit xtstat fails if no PBXT table has been created. xtstat now accepts --database= information_ schema or --database=pbxt. Depending on this setting PBXT will either use the information_ schema. pbxt_statistics or the pbxt.statistics table. If information_schema is used, then the statistics are displayed even when no PBXT table exists. Recovery activity is also displayed, unless pbxt_support_xa=1, in which case MySQL will wait for PBXT recovery to complete before allowing connections.
RN273: Fixed bug #430633: XA_RBDEADLOCK is not returned on XA END after the transacting ended with a deadlock.
RN272: Fixed bug #430596: Backup/restore does not work well even on a basic PBXT table with auto-increment.
------- 1.0.09c RC3 - 2009-09-16
RN271: Windows build update: now you can simply put the pbxt directory under <mysql- root>/storage and build the PBXT engine as a part of the source tree. The engine will be linked statically. Be sure to specify the WITH_PBXT_ STORAGE_ ENGINE option when running win\configure.js
RN270: Correctly disabled PBMS so that this version now compiles under Windows. If PBMS_ENABLED is defined, PBXT will not compile under Windows becaause of a getpid() call in pbms.h.
------- 1.0.09 RC3 - 2009-09-09
RN26...