1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
1 |
/* Copyright (c) 2010 PrimeBase Technologies GmbH, Germany
|
2 |
*
|
|
3 |
* PrimeBase Media Stream for MySQL
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
8 |
* (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
18 |
*
|
19 |
* Barry Leslie
|
|
20 |
*
|
|
21 |
* 2010-05-25
|
|
22 |
*
|
|
23 |
* PBMS daemon global parameters.
|
|
24 |
*
|
|
25 |
*/
|
|
26 |
||
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
27 |
#ifdef DRIZZLED
|
28 |
#include "config.h" |
|
29 |
#include <set> |
|
30 |
#include <drizzled/common.h> |
|
31 |
#include <drizzled/plugin.h> |
|
32 |
#include <drizzled/session.h> |
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
33 |
using namespace std; |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
34 |
using namespace drizzled; |
35 |
using namespace drizzled::plugin; |
|
36 |
||
37 |
#define my_strdup(a,b) strdup(a)
|
|
38 |
||
39 |
#include "cslib/CSConfig.h" |
|
40 |
#else
|
|
41 |
#include "cslib/CSConfig.h" |
|
42 |
#include "mysql_priv.h" |
|
43 |
#include <mysql/plugin.h> |
|
44 |
#include <my_dir.h> |
|
45 |
#endif
|
|
46 |
||
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
47 |
#include <inttypes.h> |
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
48 |
#include <string.h> |
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
49 |
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
50 |
#include "cslib/CSDefs.h" |
51 |
#include "cslib/CSObject.h" |
|
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
52 |
#include "cslib/CSGlobal.h" |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
53 |
#include "cslib/CSThread.h" |
54 |
#include "cslib/CSStrUtil.h" |
|
55 |
#include "cslib/CSPath.h" |
|
56 |
#include "cslib/CSLog.h" |
|
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
57 |
|
1548.2.10
by Barry.Leslie at PrimeBase
Merge from trunk. |
58 |
#include "defs_ms.h" |
59 |
#include "database_ms.h" |
|
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
60 |
#include "parameters_ms.h" |
61 |
||
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
62 |
#ifndef PBMS_PORT
|
63 |
#define PBMS_PORT 8080
|
|
64 |
#endif
|
|
65 |
||
66 |
||
1909.4.4
by Stewart Smith
fix PBMS port variable to also be a command line option. Also add this to the master.opt for the PBMS test suite so that we'll start PBMS with our port number and won't conflict with 8080 |
67 |
uint32_t pbms_port_number = PBMS_PORT; |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
68 |
|
69 |
static char *my_repository_threshold = NULL; |
|
70 |
static char *my_temp_log_threshold = NULL; |
|
71 |
static char *my_http_metadata_headers = NULL; |
|
72 |
||
73 |
static u_long my_temp_blob_timeout = MS_DEFAULT_TEMP_LOG_WAIT; |
|
74 |
static u_long my_garbage_threshold = MS_DEFAULT_GARBAGE_LEVEL; |
|
75 |
static u_long my_max_keep_alive = MS_DEFAULT_KEEP_ALIVE; |
|
76 |
||
1644.3.1
by Barry.Leslie at PrimeBase
Merged in changes from PBMS project. |
77 |
static u_long my_backup_db_id = 1; |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
78 |
static uint32_t my_server_id = 1; |
79 |
||
1548.2.11
by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser. |
80 |
#ifdef DRIZZLED
|
81 |
static set<string> my_black_list; |
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
82 |
static bool my_events_enabled = true; |
83 |
static CSMutex my_table_list_lock; |
|
84 |
||
85 |
typedef enum {MATCH_ALL, MATCH_DBS, MATCH_SOME, MATCH_NONE, MATCH_UNKNOWN, MATCH_ERROR} TableMatchState; |
|
86 |
static char *my_table_list = NULL; |
|
87 |
static const char *dflt_my_table_list = "*"; |
|
88 |
||
1548.2.6
by Barry.Leslie at PrimeBase
trunk merge plus more pbms updates for drizzle. |
89 |
static TableMatchState my_table_match = MATCH_UNKNOWN; |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
90 |
|
91 |
static int32_t my_before_insert_position= 1; // Call this event observer first. |
|
92 |
static int32_t my_before_update_position= 1; |
|
93 |
||
94 |
using namespace drizzled; |
|
95 |
using namespace drizzled::plugin; |
|
96 |
||
97 |
#define st_mysql_sys_var drizzled::drizzle_sys_var
|
|
98 |
#else
|
|
99 |
||
100 |
struct st_mysql_sys_var |
|
101 |
{
|
|
102 |
MYSQL_PLUGIN_VAR_HEADER; |
|
103 |
};
|
|
104 |
||
105 |
#endif
|
|
106 |
||
107 |
#if MYSQL_VERSION_ID < 60000
|
|
108 |
||
109 |
#if MYSQL_VERSION_ID >= 50124
|
|
110 |
#define CONST_SAVE const
|
|
111 |
#endif
|
|
112 |
||
113 |
#else
|
|
114 |
||
115 |
#if MYSQL_VERSION_ID >= 60005
|
|
116 |
#define CONST_SAVE const
|
|
117 |
#endif
|
|
118 |
||
119 |
#endif
|
|
120 |
||
121 |
#ifndef CONST_SAVE
|
|
122 |
#define CONST_SAVE
|
|
123 |
#endif
|
|
124 |
||
125 |
//--------------
|
|
1909.4.4
by Stewart Smith
fix PBMS port variable to also be a command line option. Also add this to the master.opt for the PBMS test suite so that we'll start PBMS with our port number and won't conflict with 8080 |
126 |
uint32_t PBMSParameters::getPortNumber(){ return pbms_port_number;} |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
127 |
|
128 |
//--------------
|
|
129 |
uint32_t PBMSParameters::getServerID(){ return my_server_id;} |
|
130 |
||
131 |
//--------------
|
|
132 |
uint64_t PBMSParameters::getRepoThreshold() |
|
133 |
{
|
|
134 |
if (my_repository_threshold) |
|
135 |
return((uint64_t) cs_byte_size_to_int8(my_repository_threshold)); |
|
136 |
||
137 |
return((uint64_t) cs_byte_size_to_int8(MS_REPO_THRESHOLD_DEF)); |
|
138 |
}
|
|
139 |
||
140 |
//--------------
|
|
141 |
uint64_t PBMSParameters::getTempLogThreshold() |
|
142 |
{
|
|
143 |
if (my_temp_log_threshold) |
|
144 |
return((uint64_t) cs_byte_size_to_int8(my_temp_log_threshold)); |
|
145 |
||
146 |
return((uint64_t) cs_byte_size_to_int8(MS_TEMP_LOG_THRESHOLD_DEF)); |
|
147 |
}
|
|
148 |
||
149 |
//--------------
|
|
150 |
uint32_t PBMSParameters::getTempBlobTimeout(){ return my_temp_blob_timeout;} |
|
151 |
||
152 |
//--------------
|
|
153 |
uint32_t PBMSParameters::getGarbageThreshold(){ return my_garbage_threshold;} |
|
154 |
||
155 |
//--------------
|
|
156 |
uint32_t PBMSParameters::getMaxKeepAlive(){ return my_max_keep_alive;} |
|
157 |
||
158 |
//--------------
|
|
159 |
const char * PBMSParameters::getDefaultMetaDataHeaders() |
|
160 |
{
|
|
161 |
if (my_http_metadata_headers) |
|
162 |
return my_http_metadata_headers; |
|
163 |
||
164 |
return MS_HTTP_METADATA_HEADERS_DEF; |
|
165 |
}
|
|
166 |
||
167 |
//-----------------
|
|
1644.3.1
by Barry.Leslie at PrimeBase
Merged in changes from PBMS project. |
168 |
uint32_t PBMSParameters::getBackupDatabaseID() { return my_backup_db_id;} |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
169 |
|
170 |
//-----------------
|
|
1644.3.1
by Barry.Leslie at PrimeBase
Merged in changes from PBMS project. |
171 |
void PBMSParameters::setBackupDatabaseID(uint32_t id) { my_backup_db_id = id;} |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
172 |
|
1548.2.11
by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser. |
173 |
#ifdef DRIZZLED
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
174 |
//-----------------
|
175 |
bool PBMSParameters::isPBMSEventsEnabled() { return my_events_enabled;} |
|
176 |
||
177 |
||
178 |
#define NEXT_IN_TABLE_LIST(list) {\
|
|
179 |
while ((*list) && (*list != ',')) list++;\
|
|
180 |
if (*list) list++;\
|
|
181 |
}
|
|
182 |
||
183 |
static TableMatchState set_match_type(const char *list) |
|
184 |
{
|
|
185 |
const char *ptr = list; |
|
186 |
const char *name; |
|
187 |
int name_len; |
|
188 |
TableMatchState match_state; |
|
189 |
||
190 |
if (!list) |
|
191 |
return MATCH_ALL; |
|
192 |
||
193 |
if (!ptr) { |
|
194 |
return MATCH_NONE; |
|
195 |
}
|
|
196 |
||
197 |
while ((*ptr) && isspace(*ptr)) ptr++; |
|
198 |
if (!*ptr) { |
|
199 |
return MATCH_NONE; |
|
200 |
}
|
|
201 |
||
202 |
match_state = MATCH_UNKNOWN; |
|
203 |
||
204 |
while (*ptr) { |
|
205 |
||
206 |
// Check database name
|
|
207 |
name = ptr; |
|
208 |
name_len = 0; |
|
209 |
while ((*ptr) && (!isspace(*ptr)) && (*ptr != ',') && (*ptr != '.')) {ptr++;name_len++;} |
|
210 |
while ((*ptr) && isspace(*ptr)) ptr++; |
|
211 |
||
212 |
if (*ptr != '.') { |
|
213 |
if ((name_len == 1) && (*name == '*')) |
|
214 |
match_state = MATCH_ALL; |
|
215 |
else
|
|
216 |
goto bad_list; // Missing table |
|
217 |
} else { |
|
218 |
||
219 |
if ((match_state > MATCH_DBS) && (name_len == 1) && (*name == '*')) |
|
220 |
match_state = MATCH_DBS; |
|
221 |
||
222 |
ptr++; // Skip the '.' |
|
223 |
||
224 |
// Find the start of the table name.
|
|
225 |
while ((*ptr) && isspace(*ptr)) ptr++; |
|
226 |
if ((!*ptr) || (*ptr == ',') || (*ptr == '.')) |
|
227 |
goto bad_list; // Missing table |
|
228 |
||
229 |
// Find the end of the table name.
|
|
230 |
while ((*ptr) && (!isspace(*ptr)) && (*ptr != ',') && (*ptr != '.')) ptr++; |
|
231 |
}
|
|
232 |
||
233 |
// Locate the end of the element.
|
|
234 |
while ((*ptr) && isspace(*ptr)) ptr++; |
|
235 |
||
236 |
if ((*ptr) && (*ptr != ',')) |
|
237 |
goto bad_list; // Bad table name |
|
238 |
||
239 |
if (match_state > MATCH_SOME) |
|
240 |
match_state = MATCH_SOME; |
|
241 |
||
242 |
if (*ptr) ptr++; |
|
243 |
while ((*ptr) && isspace(*ptr)) ptr++; |
|
244 |
}
|
|
245 |
||
246 |
return match_state; |
|
247 |
bad_list: |
|
248 |
||
249 |
char info[120]; |
|
250 |
snprintf(info, 120, "pbms_watch_tables format error near character position %d", (int) (ptr - list)); |
|
251 |
CSL.logLine(NULL, CSLog::Error, info); |
|
252 |
CSL.logLine(NULL, CSLog::Error, list); |
|
253 |
||
254 |
return MATCH_ERROR; |
|
255 |
}
|
|
256 |
||
257 |
//-----------------
|
|
258 |
static const char* locate_db(const char *list, const char *db, int len) |
|
259 |
{
|
|
260 |
int match_len; |
|
261 |
||
262 |
while (*list) { |
|
263 |
while ((*list) && isspace(*list)) list++; |
|
264 |
if ((*list == 0) || (*(list+1) == 0) || (*(list+2) == 0)) // We need at least 3 characters |
|
265 |
return NULL; |
|
266 |
||
267 |
match_len = 0; |
|
268 |
if (*list == '*') |
|
269 |
match_len = 1; |
|
270 |
else if (strncmp(list, db, len) == 0) |
|
271 |
match_len = len; |
|
272 |
||
273 |
if (match_len) { |
|
274 |
list += match_len; |
|
275 |
||
276 |
// Find the '.'
|
|
277 |
while ((*list) && isspace(*list)) list++; |
|
278 |
if ((*list == 0) || (*(list+1) == 0) ) // We need at least 2 characters |
|
279 |
return NULL; |
|
280 |
||
281 |
if (*list == '.') { |
|
282 |
list++; |
|
283 |
while ((*list) && isspace(*list)) list++; |
|
284 |
if (*list == 0) |
|
285 |
return NULL; |
|
286 |
||
287 |
return list; // We have gound a table that could belong to this database; |
|
288 |
}
|
|
289 |
}
|
|
290 |
||
291 |
NEXT_IN_TABLE_LIST(list); |
|
292 |
}
|
|
293 |
||
294 |
return NULL; |
|
295 |
}
|
|
296 |
||
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
297 |
//--------------
|
298 |
// Parameter update functions are not called for parameters that are set on
|
|
299 |
// the command line. PBMSParameters::startUp() will perform any initialization required.
|
|
300 |
void PBMSParameters::startUp() |
|
301 |
{
|
|
302 |
my_table_match = set_match_type(my_table_list); |
|
303 |
}
|
|
304 |
||
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
305 |
//-----------------
|
306 |
bool PBMSParameters::isBlackListedDB(const char *db) |
|
307 |
{
|
|
308 |
if (my_black_list.find(string(db)) == my_black_list.end()) |
|
309 |
return false; |
|
310 |
||
311 |
return true; |
|
312 |
}
|
|
313 |
||
314 |
//-----------------
|
|
315 |
void PBMSParameters::blackListedDB(const char *db) |
|
316 |
{
|
|
317 |
my_black_list.insert(string(db)); |
|
318 |
}
|
|
319 |
||
320 |
//-----------------
|
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
321 |
bool PBMSParameters::try_LocateDB(CSThread *self, const char *db, bool *found) |
322 |
{
|
|
323 |
volatile bool rtc = true; |
|
324 |
try_(a) { |
|
325 |
lock_(&my_table_list_lock); |
|
326 |
||
327 |
||
328 |
*found = (locate_db(my_table_list, db, strlen(db)) != NULL); |
|
329 |
||
330 |
unlock_(&my_table_list_lock); |
|
331 |
rtc = false; |
|
332 |
}
|
|
333 |
||
334 |
catch_(a) |
|
335 |
cont_(a); |
|
336 |
return rtc; |
|
337 |
}
|
|
338 |
||
339 |
//-----------------
|
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
340 |
bool PBMSParameters::isBLOBDatabase(const char *db) |
341 |
{
|
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
342 |
CSThread *self; |
343 |
int err; |
|
344 |
PBMSResultRec result; |
|
345 |
bool found = false; |
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
346 |
|
347 |
if (isBlackListedDB(db)) |
|
348 |
return false; |
|
349 |
||
350 |
if (my_table_match == MATCH_UNKNOWN) |
|
351 |
my_table_match = set_match_type(my_table_list); |
|
352 |
||
353 |
if (my_table_match == MATCH_NONE) |
|
354 |
return false; |
|
355 |
||
356 |
if (my_table_match <= MATCH_DBS) |
|
357 |
return true; |
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
358 |
|
1548.2.24
by Barry.Leslie at PrimeBase
Reorganized code while fixing some minor problems. |
359 |
if ((err = MSEngine::enterConnectionNoThd(&self, &result)) == 0) { |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
360 |
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
361 |
inner_(); |
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
362 |
if (try_LocateDB(self, db, &found)) { |
1548.2.24
by Barry.Leslie at PrimeBase
Reorganized code while fixing some minor problems. |
363 |
err = MSEngine::exceptionToResult(&self->myException, &result); |
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
364 |
}
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
365 |
outer_(); |
366 |
||
367 |
}
|
|
368 |
||
369 |
if (err) { |
|
370 |
fprintf(stderr, "PBMSParameters::isBLOBDatabase(\"%s\") error (%d):'%s'\n", |
|
371 |
db, result.mr_code, result.mr_message); |
|
372 |
}
|
|
373 |
||
374 |
return found; |
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
375 |
}
|
376 |
||
377 |
//-----------------
|
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
378 |
bool PBMSParameters::try_LocateTable(CSThread *self, const char *db, const char *table, bool *found) |
379 |
{
|
|
380 |
volatile bool rtc = true; |
|
381 |
try_(a) { |
|
382 |
const char *ptr; |
|
383 |
int db_len, table_len, match_len; |
|
384 |
||
385 |
lock_(&my_table_list_lock); |
|
386 |
||
387 |
db_len = strlen(db); |
|
388 |
table_len = strlen(table); |
|
389 |
||
390 |
ptr = my_table_list; |
|
391 |
while (ptr) { |
|
392 |
ptr = locate_db(ptr, db, db_len); |
|
393 |
if (ptr) { |
|
394 |
match_len = 0; |
|
395 |
if (*ptr == '*') |
|
396 |
match_len = 1; |
|
397 |
else if (strncmp(ptr, table, table_len) == 0) |
|
398 |
match_len = table_len; |
|
399 |
||
400 |
if (match_len) { |
|
401 |
ptr += match_len; |
|
402 |
if ((!*ptr) || (*ptr == ',') || isspace(*ptr)) { |
|
403 |
*found = true; |
|
404 |
break; |
|
405 |
}
|
|
406 |
}
|
|
407 |
||
408 |
NEXT_IN_TABLE_LIST(ptr); |
|
409 |
}
|
|
410 |
}
|
|
411 |
||
412 |
unlock_(&my_table_list_lock); |
|
413 |
rtc = false; |
|
414 |
}
|
|
415 |
||
416 |
catch_(a) |
|
417 |
cont_(a); |
|
418 |
return rtc; |
|
419 |
}
|
|
420 |
||
421 |
//-----------------
|
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
422 |
bool PBMSParameters::isBLOBTable(const char *db, const char *table) |
423 |
{
|
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
424 |
CSThread *self; |
425 |
int err; |
|
426 |
PBMSResultRec result; |
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
427 |
bool found = false; |
428 |
||
429 |
if (isBlackListedDB(db)) |
|
430 |
return false; |
|
431 |
||
432 |
if (my_table_match == MATCH_UNKNOWN) |
|
433 |
my_table_match = set_match_type(my_table_list); |
|
434 |
||
435 |
if (my_table_match == MATCH_NONE) |
|
436 |
return false; |
|
437 |
||
438 |
if (my_table_match <= MATCH_ALL) |
|
439 |
return true; |
|
440 |
||
1548.2.24
by Barry.Leslie at PrimeBase
Reorganized code while fixing some minor problems. |
441 |
if ((err = MSEngine::enterConnectionNoThd(&self, &result)) == 0) { |
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
442 |
|
443 |
inner_(); |
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
444 |
if (try_LocateTable(self, db, table, &found)) { |
1548.2.24
by Barry.Leslie at PrimeBase
Reorganized code while fixing some minor problems. |
445 |
err = MSEngine::exceptionToResult(&self->myException, &result); |
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
446 |
}
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
447 |
outer_(); |
448 |
||
449 |
}
|
|
450 |
||
451 |
if (err) { |
|
452 |
fprintf(stderr, "PBMSParameters::isBLOBTable(\"%s\", \"%s\") error (%d):'%s'\n", |
|
453 |
db, table, result.mr_code, result.mr_message); |
|
454 |
}
|
|
455 |
||
456 |
return found; |
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
457 |
}
|
458 |
||
459 |
||
460 |
//-----------------
|
|
461 |
int32_t PBMSParameters::getBeforeUptateEventPosition() { return my_before_update_position;} |
|
462 |
||
463 |
//-----------------
|
|
464 |
int32_t PBMSParameters::getBeforeInsertEventPosition() { return my_before_insert_position;} |
|
1548.2.11
by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser. |
465 |
#endif // DRIZZLED |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
466 |
|
467 |
//-----------------
|
|
1644.3.1
by Barry.Leslie at PrimeBase
Merged in changes from PBMS project. |
468 |
static void pbms_temp_blob_timeout_func(THD *thd, struct st_mysql_sys_var *var, void *trg, CONST_SAVE void *save) |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
469 |
{
|
470 |
CSThread *self; |
|
471 |
PBMSResultRec result; |
|
472 |
||
1644.3.1
by Barry.Leslie at PrimeBase
Merged in changes from PBMS project. |
473 |
(void)thd; |
474 |
(void)var; |
|
475 |
||
476 |
*(u_long *)trg= *(u_long *) save; |
|
477 |
||
1548.2.24
by Barry.Leslie at PrimeBase
Reorganized code while fixing some minor problems. |
478 |
if (MSEngine::enterConnectionNoThd(&self, &result)) |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
479 |
return; |
480 |
try_(a) { |
|
481 |
MSDatabase::wakeTempLogThreads(); |
|
482 |
}
|
|
483 |
||
484 |
catch_(a); |
|
485 |
cont_(a); |
|
486 |
}
|
|
487 |
||
488 |
//-----------------
|
|
489 |
//-----------------
|
|
1909.4.4
by Stewart Smith
fix PBMS port variable to also be a command line option. Also add this to the master.opt for the PBMS test suite so that we'll start PBMS with our port number and won't conflict with 8080 |
490 |
static MYSQL_SYSVAR_UINT(port, pbms_port_number, |
491 |
PLUGIN_VAR_READONLY, |
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
492 |
"The port for the server stream-based communications.", |
493 |
NULL, NULL, PBMS_PORT, 0, 64*1024, 1); |
|
494 |
||
495 |
static MYSQL_SYSVAR_STR(repository_threshold, my_repository_threshold, |
|
496 |
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC, |
|
497 |
"The maximum size of a BLOB repository file.", |
|
498 |
NULL, NULL, MS_REPO_THRESHOLD_DEF); |
|
499 |
||
500 |
static MYSQL_SYSVAR_STR(temp_log_threshold, my_temp_log_threshold, |
|
501 |
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC, |
|
502 |
"The maximum size of a temorary BLOB log file.", |
|
503 |
NULL, NULL, MS_TEMP_LOG_THRESHOLD_DEF); |
|
504 |
||
505 |
static MYSQL_SYSVAR_STR(http_metadata_headers, my_http_metadata_headers, |
|
506 |
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY, |
|
507 |
"A ':' delimited list of metadata header names to be used to initialize the pbms_metadata_header table when a database is created.", |
|
508 |
NULL, NULL , MS_HTTP_METADATA_HEADERS_DEF); |
|
509 |
||
510 |
static MYSQL_SYSVAR_ULONG(temp_blob_timeout, my_temp_blob_timeout, |
|
511 |
PLUGIN_VAR_OPCMDARG, |
|
512 |
"The timeout, in seconds, for temporary BLOBs. Uploaded blob data is removed after this time, unless committed to the database.", |
|
513 |
NULL, pbms_temp_blob_timeout_func, MS_DEFAULT_TEMP_LOG_WAIT, 1, ~0L, 1); |
|
514 |
||
515 |
static MYSQL_SYSVAR_ULONG(garbage_threshold, my_garbage_threshold, |
|
516 |
PLUGIN_VAR_OPCMDARG, |
|
517 |
"The percentage of garbage in a repository file before it is compacted.", |
|
518 |
NULL, NULL, MS_DEFAULT_GARBAGE_LEVEL, 0, 100, 1); |
|
519 |
||
520 |
||
521 |
static MYSQL_SYSVAR_ULONG(max_keep_alive, my_max_keep_alive, |
|
522 |
PLUGIN_VAR_OPCMDARG, |
|
523 |
"The timeout, in milli-seconds, before the HTTP server will close an inactive HTTP connection.", |
|
524 |
NULL, NULL, MS_DEFAULT_KEEP_ALIVE, 1, UINT32_MAX, 1); |
|
525 |
||
1644.3.1
by Barry.Leslie at PrimeBase
Merged in changes from PBMS project. |
526 |
static MYSQL_SYSVAR_ULONG(next_backup_db_id, my_backup_db_id, |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
527 |
PLUGIN_VAR_OPCMDARG, |
528 |
"The next backup ID to use when backing up a PBMS database.", |
|
1644.3.1
by Barry.Leslie at PrimeBase
Merged in changes from PBMS project. |
529 |
NULL, NULL, 1, 1, UINT32_MAX, 1); |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
530 |
|
531 |
||
1548.2.11
by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser. |
532 |
#ifdef DRIZZLED
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
533 |
|
534 |
//----------
|
|
535 |
static int check_table_list(THD *, struct st_mysql_sys_var *, void *save, drizzle_value *value) |
|
536 |
{
|
|
537 |
char buffer[100]; |
|
538 |
int len = 100; |
|
539 |
const char *list = value->val_str(value, buffer, &len); |
|
540 |
TableMatchState state; |
|
541 |
||
542 |
state = set_match_type(list); |
|
543 |
if (state == MATCH_ERROR) |
|
544 |
return 1; |
|
545 |
||
546 |
char *new_list = strdup(list); |
|
547 |
if (!new_list) |
|
548 |
return 1; |
|
549 |
||
550 |
my_table_list_lock.lock(); |
|
551 |
if (my_table_list && (my_table_list != dflt_my_table_list)) free(my_table_list); |
|
552 |
my_table_list = new_list; |
|
553 |
||
554 |
my_table_match = state; |
|
555 |
my_table_list_lock.unlock(); |
|
556 |
||
557 |
*static_cast<const char**>(save)= my_table_list; |
|
558 |
||
559 |
return 0; |
|
560 |
}
|
|
561 |
||
562 |
//----------
|
|
563 |
static void set_table_list(THD *, struct st_mysql_sys_var *, void *var_ptr, CONST_SAVE void *) |
|
564 |
{
|
|
565 |
// Everything was done in check_table_list()
|
|
566 |
*static_cast<const char**>(var_ptr)= my_table_list; |
|
567 |
}
|
|
568 |
||
569 |
//----------
|
|
570 |
||
571 |
static MYSQL_SYSVAR_STR(watch_tables, |
|
572 |
my_table_list, |
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
573 |
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC, |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
574 |
N_("A comma delimited list of tables to watch of the format: <database>.<table>, ..."), |
575 |
check_table_list, /* check func */ |
|
576 |
set_table_list, /* update func */ |
|
577 |
dflt_my_table_list /* default */); |
|
578 |
||
579 |
static MYSQL_SYSVAR_BOOL(watch_enable, |
|
580 |
my_events_enabled, |
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
581 |
PLUGIN_VAR_OPCMDARG, |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
582 |
N_("Enable PBMS daemon Insert/Update/Delete event scanning"), |
583 |
NULL, /* check func */ |
|
584 |
NULL, /* update func */ |
|
585 |
true /* default */); |
|
586 |
||
587 |
static MYSQL_SYSVAR_INT(before_insert_position, |
|
588 |
my_before_insert_position, |
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
589 |
PLUGIN_VAR_OPCMDARG, |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
590 |
N_("Before insert row event observer call position"), |
591 |
NULL, /* check func */ |
|
592 |
NULL, /* update func */ |
|
593 |
1, /* default */ |
|
594 |
1, /* min */ |
|
595 |
INT32_MAX -1, /* max */ |
|
596 |
0 /* blk */); |
|
597 |
||
598 |
static MYSQL_SYSVAR_INT(before_update_position, |
|
599 |
my_before_update_position, |
|
1548.2.7
by Barry.Leslie at PrimeBase
Fixed some problems with transactions and drizzle. |
600 |
PLUGIN_VAR_OPCMDARG, |
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
601 |
N_("Before update row event observer call position"), |
602 |
NULL, /* check func */ |
|
603 |
NULL, /* update func */ |
|
604 |
1, /* default */ |
|
605 |
1, /* min */ |
|
606 |
INT32_MAX -1, /* max */ |
|
607 |
0 /* blk */); |
|
608 |
||
1548.2.11
by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser. |
609 |
#endif // DRIZZLED |
610 |
||
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
611 |
struct st_mysql_sys_var* pbms_system_variables[] = { |
612 |
MYSQL_SYSVAR(port), |
|
613 |
MYSQL_SYSVAR(repository_threshold), |
|
614 |
MYSQL_SYSVAR(temp_log_threshold), |
|
615 |
MYSQL_SYSVAR(temp_blob_timeout), |
|
616 |
MYSQL_SYSVAR(garbage_threshold), |
|
617 |
MYSQL_SYSVAR(http_metadata_headers), |
|
618 |
MYSQL_SYSVAR(max_keep_alive), |
|
619 |
MYSQL_SYSVAR(next_backup_db_id), |
|
620 |
||
1548.2.11
by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser. |
621 |
#ifdef DRIZZLED
|
1548.2.3
by Barry.Leslie at PrimeBase
Added drizzle event observer class to PBMS as well as a lot of mostly minor changes for drizzle compatability. |
622 |
MYSQL_SYSVAR(watch_tables), |
623 |
MYSQL_SYSVAR(watch_enable), |
|
624 |
||
625 |
MYSQL_SYSVAR(before_insert_position), |
|
626 |
MYSQL_SYSVAR(before_update_position), |
|
627 |
#endif
|
|
628 |
||
629 |
NULL
|
|
630 |
};
|
|
631 |
||
632 |
||
633 |
||
634 |
||
635 |