~clint-fewbar/drizzle/regex-policy-cache-limiter

« back to all changes in this revision

Viewing changes to plugin/pbms/src/parameters_ms.cc

  • Committer: Clint Byrum
  • Date: 2012-03-15 18:05:43 UTC
  • mfrom: (2224.1.302 workspace)
  • Revision ID: clint@ubuntu.com-20120315180543-9jxxm4q10k3np2ws
merging with latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
 
 *
19
 
 * Barry Leslie
20
 
 *
21
 
 * 2010-05-25
22
 
 *
23
 
 * PBMS daemon global parameters.
24
 
 *
25
 
 */
26
 
 
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>
33
 
 
34
 
 
35
 
#define my_strdup(a,b) strdup(a)
36
 
 
37
 
#include "cslib/CSConfig.h"
38
 
#else
39
 
#include "cslib/CSConfig.h"
40
 
#include "mysql_priv.h"
41
 
#include <mysql/plugin.h>
42
 
#include <my_dir.h>
43
 
#endif 
44
 
 
45
 
#include <inttypes.h>
46
 
#include <string.h>
47
 
 
48
 
#include "cslib/CSDefs.h"
49
 
#include "cslib/CSObject.h"
50
 
#include "cslib/CSGlobal.h"
51
 
#include "cslib/CSThread.h"
52
 
#include "cslib/CSStrUtil.h"
53
 
#include "cslib/CSPath.h"
54
 
#include "cslib/CSLog.h"
55
 
 
56
 
#include "defs_ms.h"
57
 
#include "database_ms.h"
58
 
#include "parameters_ms.h"
59
 
 
60
 
using namespace std;
61
 
using namespace drizzled;
62
 
using namespace drizzled::plugin;
63
 
 
64
 
#include <drizzled/module/option_map.h>
65
 
#include <boost/program_options.hpp>
66
 
namespace po= boost::program_options;
67
 
#ifndef PBMS_PORT
68
 
#define PBMS_PORT 8080
69
 
#endif
70
 
 
71
 
/* Note: 'new' used here is NOT CSObject::new which is a DEBUG define*/
72
 
#ifdef new
73
 
#undef new
74
 
#endif
75
 
 
76
 
 
77
 
#ifdef DRIZZLED
78
 
static port_constraint pbms_port_number;
79
 
 
80
 
static std::string my_repository_threshold;
81
 
static std::string my_temp_log_threshold;
82
 
static std::string my_http_metadata_headers;
83
 
 
84
 
typedef drizzled::constrained_check<uint32_t, 100, 0> percent_constraint;
85
 
static percent_constraint my_garbage_threshold;
86
 
static uint32_nonzero_constraint my_temp_blob_timeout;
87
 
static uint32_nonzero_constraint my_max_keep_alive;
88
 
static uint32_nonzero_constraint my_backup_db_id;
89
 
 
90
 
static uint32_t my_server_id = 1;
91
 
#else
92
 
uint32_t pbms_port_number;
93
 
 
94
 
static char             *my_repository_threshold = NULL;
95
 
static char             *my_temp_log_threshold = NULL;
96
 
static char             *my_http_metadata_headers = NULL;
97
 
 
98
 
static u_long   my_temp_blob_timeout = MS_DEFAULT_TEMP_LOG_WAIT;
99
 
static u_long   my_garbage_threshold = MS_DEFAULT_GARBAGE_LEVEL;
100
 
static u_long   my_max_keep_alive = MS_DEFAULT_KEEP_ALIVE;
101
 
 
102
 
static u_long   my_backup_db_id = 1;
103
 
static uint32_t my_server_id = 1;
104
 
#endif
105
 
 
106
 
#ifdef DRIZZLED
107
 
static set<string> my_black_list;
108
 
static bool my_events_enabled = true;
109
 
static CSMutex my_table_list_lock;
110
 
 
111
 
typedef enum {MATCH_ALL, MATCH_DBS, MATCH_SOME, MATCH_NONE, MATCH_UNKNOWN, MATCH_ERROR} TableMatchState;
112
 
static std::string my_table_list;
113
 
 
114
 
static TableMatchState my_table_match = MATCH_UNKNOWN;
115
 
 
116
 
typedef constrained_check<int32_t, INT32_MAX-1, 1> before_position_constraint;
117
 
static before_position_constraint my_before_insert_position;      // Call this event observer first.
118
 
static before_position_constraint my_before_update_position;
119
 
 
120
 
using namespace drizzled;
121
 
using namespace drizzled::plugin;
122
 
 
123
 
#define st_mysql_sys_var drizzled::drizzle_sys_var
124
 
#else
125
 
 
126
 
struct st_mysql_sys_var
127
 
{
128
 
  MYSQL_PLUGIN_VAR_HEADER;
129
 
};
130
 
 
131
 
#endif
132
 
 
133
 
#if MYSQL_VERSION_ID < 60000
134
 
 
135
 
#if MYSQL_VERSION_ID >= 50124
136
 
#define CONST_SAVE const
137
 
#endif
138
 
 
139
 
#else
140
 
 
141
 
#if MYSQL_VERSION_ID >= 60005
142
 
#define CONST_SAVE const
143
 
#endif
144
 
 
145
 
#endif
146
 
 
147
 
#ifndef CONST_SAVE
148
 
#define CONST_SAVE 
149
 
#endif
150
 
 
151
 
//--------------
152
 
uint32_t PBMSParameters::getPortNumber(){ return pbms_port_number;}
153
 
 
154
 
//--------------
155
 
uint32_t PBMSParameters::getServerID(){ return my_server_id;}
156
 
 
157
 
//--------------
158
 
uint64_t PBMSParameters::getRepoThreshold()
159
 
{
160
 
#ifdef DRIZZLED
161
 
  return (uint64_t) cs_byte_size_to_int8(my_repository_threshold.c_str());
162
 
#else
163
 
        if (my_repository_threshold)
164
 
                return((uint64_t) cs_byte_size_to_int8(my_repository_threshold));
165
 
 
166
 
        return((uint64_t) cs_byte_size_to_int8(MS_REPO_THRESHOLD_DEF));
167
 
#endif
168
 
}
169
 
 
170
 
//--------------
171
 
uint64_t PBMSParameters::getTempLogThreshold()
172
 
{
173
 
#ifdef DRIZZLED
174
 
  return (uint64_t) cs_byte_size_to_int8(my_temp_log_threshold.c_str());
175
 
#else
176
 
        if (my_temp_log_threshold)
177
 
                return((uint64_t) cs_byte_size_to_int8(my_temp_log_threshold));
178
 
 
179
 
        return((uint64_t) cs_byte_size_to_int8(MS_TEMP_LOG_THRESHOLD_DEF));
180
 
#endif
181
 
}
182
 
 
183
 
//--------------
184
 
uint32_t PBMSParameters::getTempBlobTimeout(){ return static_cast<uint32_t>(my_temp_blob_timeout);}
185
 
 
186
 
//--------------
187
 
uint32_t PBMSParameters::getGarbageThreshold(){ return static_cast<uint32_t>(my_garbage_threshold);}
188
 
 
189
 
//--------------
190
 
uint32_t PBMSParameters::getMaxKeepAlive(){ return static_cast<uint32_t>(my_max_keep_alive);}
191
 
 
192
 
//--------------
193
 
const char * PBMSParameters::getDefaultMetaDataHeaders()
194
 
{
195
 
#ifdef DRIZZLED
196
 
        return my_http_metadata_headers.c_str();
197
 
#else
198
 
        if (my_http_metadata_headers)
199
 
                return my_http_metadata_headers; 
200
 
                
201
 
        return MS_HTTP_METADATA_HEADERS_DEF; 
202
 
#endif
203
 
}
204
 
 
205
 
//-----------------
206
 
uint32_t PBMSParameters::getBackupDatabaseID() { return static_cast<uint32_t>(my_backup_db_id);}
207
 
 
208
 
//-----------------
209
 
void PBMSParameters::setBackupDatabaseID(uint32_t id) { my_backup_db_id = id;}
210
 
 
211
 
#ifdef DRIZZLED
212
 
//-----------------
213
 
bool PBMSParameters::isPBMSEventsEnabled() { return my_events_enabled;}
214
 
 
215
 
 
216
 
#define NEXT_IN_TABLE_LIST(list) {\
217
 
        while ((*list) && (*list != ',')) list++;\
218
 
        if (*list) list++;\
219
 
}
220
 
        
221
 
static TableMatchState set_match_type(const char *list)
222
 
{
223
 
        const char *ptr = list;
224
 
        const char *name;
225
 
        int name_len;
226
 
        TableMatchState match_state;
227
 
 
228
 
        if (!list)
229
 
                return MATCH_ALL;
230
 
                
231
 
        if (!ptr) {
232
 
                return MATCH_NONE;
233
 
        }
234
 
        
235
 
        while ((*ptr) && isspace(*ptr)) ptr++;
236
 
        if (!*ptr) {
237
 
                return MATCH_NONE;
238
 
        }
239
 
        
240
 
        match_state = MATCH_UNKNOWN;
241
 
 
242
 
        while (*ptr) {
243
 
        
244
 
                // Check database name
245
 
                name = ptr;
246
 
                name_len = 0;
247
 
                while ((*ptr) && (!isspace(*ptr)) && (*ptr != ',') && (*ptr != '.')) {ptr++;name_len++;}
248
 
                while ((*ptr) && isspace(*ptr)) ptr++;
249
 
                
250
 
                if (*ptr != '.') {
251
 
                        if ((name_len == 1) && (*name == '*'))
252
 
                                match_state = MATCH_ALL;
253
 
                        else
254
 
                                goto bad_list; // Missing table
255
 
                } else {
256
 
                
257
 
                        if ((match_state > MATCH_DBS) && (name_len == 1) && (*name == '*'))
258
 
                                match_state = MATCH_DBS;
259
 
                                
260
 
                        ptr++; // Skip the '.'
261
 
                        
262
 
                        // Find the start of the table name.
263
 
                        while ((*ptr) && isspace(*ptr)) ptr++;
264
 
                        if ((!*ptr) || (*ptr == ',') || (*ptr == '.'))
265
 
                                goto bad_list; // Missing table
266
 
                                
267
 
                        // Find the end of the table name.
268
 
                        while ((*ptr) && (!isspace(*ptr)) && (*ptr != ',') && (*ptr != '.')) ptr++;
269
 
                }
270
 
                
271
 
                // Locate the end of the element.
272
 
                while ((*ptr) && isspace(*ptr)) ptr++;
273
 
                                
274
 
                if ((*ptr) && (*ptr != ','))
275
 
                        goto bad_list; // Bad table name
276
 
                        
277
 
                if (match_state > MATCH_SOME)
278
 
                        match_state = MATCH_SOME;
279
 
                        
280
 
                if (*ptr) ptr++;
281
 
                while ((*ptr) && isspace(*ptr)) ptr++;
282
 
        }
283
 
        
284
 
        return match_state;
285
 
bad_list:
286
 
 
287
 
        char info[120];
288
 
        snprintf(info, 120, "pbms_watch_tables format error near character position %d", (int) (ptr - list));
289
 
        CSL.logLine(NULL, CSLog::Error, info);
290
 
        CSL.logLine(NULL, CSLog::Error, list);
291
 
        
292
 
        return MATCH_ERROR;
293
 
}
294
 
 
295
 
//-----------------
296
 
static const char* locate_db(const char *list, const char *db, int len)
297
 
{
298
 
        int match_len;
299
 
        
300
 
        while (*list) {
301
 
                while ((*list) && isspace(*list)) list++;
302
 
                if ((*list == 0) || (*(list+1) == 0) || (*(list+2) == 0)) // We need at least 3 characters
303
 
                        return NULL;
304
 
                
305
 
                match_len = 0;
306
 
                if (*list == '*') 
307
 
                        match_len = 1;
308
 
                else if (strncmp(list, db, len) == 0) 
309
 
                        match_len = len;
310
 
                
311
 
                if (match_len) {
312
 
                        list += match_len;
313
 
                        
314
 
                        // Find the '.'
315
 
                        while ((*list) && isspace(*list)) list++;
316
 
                        if ((*list == 0) || (*(list+1) == 0) ) // We need at least 2 characters
317
 
                                return NULL;
318
 
                                                
319
 
                        if (*list == '.') { 
320
 
                                list++;
321
 
                                while ((*list) && isspace(*list)) list++;
322
 
                                if (*list == 0)
323
 
                                         return NULL;
324
 
                                         
325
 
                                return list; // We have gound a table that could belong to this database;
326
 
                        }
327
 
                }
328
 
                
329
 
                NEXT_IN_TABLE_LIST(list);
330
 
        }
331
 
        
332
 
        return NULL;
333
 
}
334
 
 
335
 
#ifdef DRIZZLED
336
 
static void temp_blob_timeout_update(Session*, sql_var_t)
337
 
{
338
 
        CSThread                *self;
339
 
        PBMSResultRec   result;
340
 
        
341
 
        if (MSEngine::enterConnectionNoThd(&self, &result))
342
 
                return;
343
 
        try_(a) {
344
 
                MSDatabase::wakeTempLogThreads();
345
 
        }
346
 
        
347
 
        catch_(a);
348
 
        cont_(a);
349
 
}
350
 
//----------
351
 
static int table_list_validate(Session*, set_var *var)
352
 
{
353
 
        const char *list= var->value->str_value.ptr();
354
 
        if (list == NULL)
355
 
                return 1;
356
 
 
357
 
        TableMatchState state = set_match_type(list);
358
 
        if (state == MATCH_ERROR)
359
 
                return 1;
360
 
                
361
 
        std::string new_list(list);
362
 
 
363
 
        my_table_list_lock.lock();
364
 
        my_table_list.swap(new_list);
365
 
        my_table_match = state;
366
 
        my_table_list_lock.unlock();
367
 
 
368
 
        return 0;
369
 
}
370
 
 
371
 
//----------
372
 
#endif
373
 
 
374
 
//--------------
375
 
// Parameter update functions are not called for parameters that are set on
376
 
// the command line. PBMSParameters::startUp() will perform any initialization required.
377
 
#ifdef DRIZZLED
378
 
void PBMSParameters::startUp(drizzled::module::Context &context)
379
 
#else
380
 
void PBMSParameters::startup()
381
 
#endif
382
 
383
 
 
384
 
#ifdef DRIZZLED
385
 
        my_table_match = set_match_type(my_table_list.c_str());
386
 
        const module::option_map &vm= context.getOptions();
387
 
        my_events_enabled= (vm.count("watch-disable")) ? false : true;
388
 
 
389
 
        context.registerVariable(new sys_var_constrained_value_readonly<in_port_t>("port",
390
 
                                                                         pbms_port_number));
391
 
        context.registerVariable(new sys_var_std_string("repository_threshold",
392
 
                                                        my_repository_threshold));
393
 
        context.registerVariable(new sys_var_std_string("temp_log_threshold",
394
 
                                                        my_temp_log_threshold));
395
 
        context.registerVariable(new sys_var_const_string("http_metadata_headers",
396
 
                                                          my_http_metadata_headers));
397
 
        context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("garbage_threshold", my_garbage_threshold));
398
 
        context.registerVariable(new sys_var_constrained_value<uint32_t>("temp_blob_timeout",
399
 
                                                                         my_temp_blob_timeout,
400
 
                                                                         temp_blob_timeout_update));
401
 
        context.registerVariable(new sys_var_constrained_value<uint32_t>("max_keep_alive",
402
 
                                                                         my_max_keep_alive));
403
 
        context.registerVariable(new sys_var_constrained_value<uint32_t>("next_backup_db_id",
404
 
                                                                         my_backup_db_id));
405
 
        context.registerVariable(new sys_var_std_string("watch_tables",
406
 
                                                        my_table_list,
407
 
                                                        table_list_validate));
408
 
        context.registerVariable(new sys_var_bool_ptr("watch_enable",
409
 
                                                      &my_events_enabled));
410
 
        context.registerVariable(new sys_var_constrained_value<int32_t>("before_insert_position",
411
 
                                                                        my_before_insert_position));
412
 
        context.registerVariable(new sys_var_constrained_value<int32_t>("before_update_position",
413
 
                                                                        my_before_update_position));
414
 
 
415
 
#else
416
 
        my_table_match = set_match_type(my_table_list);
417
 
#endif
418
 
}
419
 
 
420
 
 
421
 
#ifdef DRIZZLED
422
 
void PBMSParameters::initOptions(drizzled::module::option_context &context)
423
 
{
424
 
        context("port",
425
 
                po::value<port_constraint>(&pbms_port_number)->default_value(DEFAULT_PBMS_PORT),
426
 
                _("Port number to use for connection or 0 for default PBMS port "));
427
 
        context("repository-threshold",
428
 
                po::value<std::string>(&my_repository_threshold)->default_value(MS_REPO_THRESHOLD_DEF),
429
 
                _("The maximum size of a BLOB repository file."));
430
 
        context("temp-log-threshold",
431
 
                po::value<std::string>(&my_temp_log_threshold)->default_value(MS_TEMP_LOG_THRESHOLD_DEF),
432
 
                _("The maximum size of a temorary BLOB log file."));
433
 
        context("http-metadata-headers",
434
 
                po::value<std::string>(&my_http_metadata_headers)->default_value(MS_HTTP_METADATA_HEADERS_DEF),
435
 
                _("A ':' delimited list of metadata header names to be used to initialize "
436
 
                   "the pbms_metadata_header table when a database is created."));
437
 
        context("garbage-threshold",
438
 
                po::value<percent_constraint>(&my_garbage_threshold)->default_value(MS_DEFAULT_GARBAGE_LEVEL),
439
 
                _("The percentage of garbage in a repository file before it is compacted."));
440
 
        context("temp-blob-timeout",
441
 
                po::value<uint32_nonzero_constraint>(&my_temp_blob_timeout)->default_value(MS_DEFAULT_TEMP_LOG_WAIT),
442
 
                _("The timeout, in seconds, for temporary BLOBs. Uploaded blob data is removed after this time, unless committed to the database."));
443
 
        context("max-keep-alive",
444
 
                po::value<uint32_nonzero_constraint>(&my_temp_blob_timeout)->default_value(MS_DEFAULT_KEEP_ALIVE),
445
 
                _("The timeout, in milli-seconds, before the HTTP server will close an inactive HTTP connection."));
446
 
        context("next-backup-db-id",
447
 
                po::value<uint32_nonzero_constraint>(&my_backup_db_id)->default_value(1),
448
 
                _("The next backup ID to use when backing up a PBMS database."));
449
 
        context("watch-tables",
450
 
                po::value<std::string>(&my_table_list)->default_value("*"),
451
 
                _("A comma delimited list of tables to watch of the format: <database>.<table>, ..."));
452
 
        context("watch-disable",
453
 
                _("Enable PBMS daemon Insert/Update/Delete event scanning"));
454
 
 
455
 
        context("before-insert-position",
456
 
                po::value<before_position_constraint>(&my_before_insert_position)->default_value(1),
457
 
                _("Before insert row event observer call position"));
458
 
 
459
 
        context("before-update-position",
460
 
                po::value<before_position_constraint>(&my_before_update_position)->default_value(1),
461
 
                _("Before update row event observer call position"));
462
 
 
463
 
}
464
 
#endif
465
 
 
466
 
//-----------------
467
 
bool PBMSParameters::isBlackListedDB(const char *db)
468
 
{
469
 
        if (my_black_list.find(string(db)) == my_black_list.end())
470
 
                return false;
471
 
                
472
 
        return true;
473
 
}               
474
 
 
475
 
//-----------------
476
 
void PBMSParameters::blackListedDB(const char *db)
477
 
{
478
 
        my_black_list.insert(string(db));
479
 
}               
480
 
 
481
 
//-----------------
482
 
bool PBMSParameters::try_LocateDB(CSThread *self, const char *db, bool *found)
483
 
{
484
 
        volatile bool rtc = true;
485
 
        try_(a) {
486
 
                lock_(&my_table_list_lock);     
487
 
                
488
 
                        
489
 
                *found = (locate_db(my_table_list.c_str(), db, strlen(db)) != NULL);
490
 
                        
491
 
                unlock_(&my_table_list_lock);
492
 
                rtc = false;
493
 
        }
494
 
        
495
 
        catch_(a)
496
 
        cont_(a);
497
 
        return rtc;
498
 
}
499
 
 
500
 
//-----------------
501
 
bool PBMSParameters::isBLOBDatabase(const char *db)
502
 
{
503
 
        CSThread *self= NULL;
504
 
        int             err;
505
 
        PBMSResultRec result;
506
 
        bool found = false;
507
 
        
508
 
        if (isBlackListedDB(db))
509
 
                return false;
510
 
                
511
 
        if (my_table_match == MATCH_UNKNOWN)
512
 
        {
513
 
                try_(a) {
514
 
                        lock_(&my_table_list_lock);     
515
 
                        my_table_match = set_match_type(my_table_list.c_str());
516
 
                        unlock_(&my_table_list_lock);
517
 
                }
518
 
 
519
 
                catch_(a)
520
 
                cont_(a);
521
 
        }
522
 
 
523
 
        if (my_table_match == MATCH_NONE)
524
 
                return false;
525
 
 
526
 
        if (my_table_match <= MATCH_DBS)
527
 
                return true;
528
 
        
529
 
        if ((err = MSEngine::enterConnectionNoThd(&self, &result)) == 0) {
530
 
 
531
 
                inner_();
532
 
                if (try_LocateDB(self, db, &found)) {
533
 
                        err = MSEngine::exceptionToResult(&self->myException, &result);
534
 
                }               
535
 
                outer_();
536
 
        
537
 
        }
538
 
        
539
 
        if (err) {
540
 
                fprintf(stderr, "PBMSParameters::isBLOBDatabase(\"%s\") error (%d):'%s'\n", 
541
 
                        db, result.mr_code,  result.mr_message);
542
 
        }
543
 
        
544
 
        return found;
545
 
}
546
 
        
547
 
//-----------------
548
 
bool PBMSParameters::try_LocateTable(CSThread *self, const char *db, const char *table, bool *found)
549
 
{
550
 
        volatile bool rtc = true;
551
 
        try_(a) {
552
 
                int db_len, table_len, match_len;
553
 
                
554
 
                lock_(&my_table_list_lock);     
555
 
                                
556
 
                db_len = strlen(db);
557
 
                table_len = strlen(table);
558
 
                
559
 
                const char *ptr = my_table_list.c_str();
560
 
                while (ptr) {
561
 
                        ptr = locate_db(ptr, db, db_len);
562
 
                        if (ptr) {
563
 
                                match_len = 0;
564
 
                                if (*ptr == '*')
565
 
                                        match_len = 1;
566
 
                                else if (strncmp(ptr, table, table_len) == 0)
567
 
                                        match_len = table_len;
568
 
                                        
569
 
                                if (match_len) {
570
 
                                        ptr += match_len;
571
 
                                        if ((!*ptr) || (*ptr == ',') || isspace(*ptr)) {
572
 
                                                *found = true;
573
 
                                                break;
574
 
                                        }
575
 
                                }
576
 
                                
577
 
                                NEXT_IN_TABLE_LIST(ptr);
578
 
                        }
579
 
                }
580
 
                        
581
 
                unlock_(&my_table_list_lock);
582
 
                rtc = false;
583
 
        }
584
 
        
585
 
        catch_(a)
586
 
        cont_(a);
587
 
        return rtc;
588
 
}
589
 
 
590
 
//-----------------
591
 
bool PBMSParameters::isBLOBTable(const char *db, const char *table)
592
 
{
593
 
        CSThread *self= NULL;
594
 
        int             err;
595
 
        PBMSResultRec result;
596
 
        bool found = false;
597
 
        
598
 
        if (isBlackListedDB(db))
599
 
                return false;
600
 
                
601
 
        if (my_table_match == MATCH_UNKNOWN)
602
 
        {
603
 
                try_(a) {
604
 
                        lock_(&my_table_list_lock);     
605
 
                        my_table_match = set_match_type(my_table_list.c_str());
606
 
                        unlock_(&my_table_list_lock);
607
 
                }
608
 
 
609
 
                catch_(a)
610
 
                cont_(a);
611
 
        }
612
 
 
613
 
        if (my_table_match == MATCH_NONE)
614
 
                return false;
615
 
 
616
 
        if (my_table_match <= MATCH_ALL)
617
 
                return true;
618
 
 
619
 
        if ((err = MSEngine::enterConnectionNoThd(&self, &result)) == 0) {
620
 
 
621
 
                inner_();
622
 
                if (try_LocateTable(self, db, table, &found)) {
623
 
                        err = MSEngine::exceptionToResult(&self->myException, &result);
624
 
                }               
625
 
                outer_();
626
 
        
627
 
        }
628
 
        
629
 
        if (err) {
630
 
                fprintf(stderr, "PBMSParameters::isBLOBTable(\"%s\", \"%s\") error (%d):'%s'\n", 
631
 
                        db, table, result.mr_code,  result.mr_message);
632
 
        }
633
 
        
634
 
        return found;
635
 
}
636
 
 
637
 
 
638
 
//-----------------
639
 
int32_t PBMSParameters::getBeforeUptateEventPosition() { return static_cast<int32_t>(my_before_update_position);}
640
 
 
641
 
//-----------------
642
 
int32_t PBMSParameters::getBeforeInsertEventPosition() { return static_cast<int32_t>(my_before_insert_position);}
643
 
#endif // DRIZZLED
644
 
 
645
 
//-----------------
646
 
#ifndef DRIZZLED
647
 
static void pbms_temp_blob_timeout_func(THD *thd, struct st_mysql_sys_var *var, void *trg, CONST_SAVE void *save)
648
 
{
649
 
        CSThread                *self;
650
 
        PBMSResultRec   result;
651
 
 
652
 
        (void)thd;
653
 
        (void)var;
654
 
        
655
 
        *(u_long *)trg= *(u_long *) save;
656
 
        
657
 
        if (MSEngine::enterConnectionNoThd(&self, &result))
658
 
                return;
659
 
        try_(a) {
660
 
                MSDatabase::wakeTempLogThreads();
661
 
        }
662
 
        
663
 
        catch_(a);
664
 
        cont_(a);
665
 
}
666
 
#endif
667
 
//-----------------
668
 
//-----------------
669
 
 
670
 
#ifndef DRIZZLED
671
 
 
672
 
static MYSQL_SYSVAR_UINT(port, pbms_port_number,
673
 
        PLUGIN_VAR_READONLY,
674
 
        "The port for the server stream-based communications.",
675
 
        NULL, NULL, PBMS_PORT, 0, 64*1024, 1);
676
 
 
677
 
static MYSQL_SYSVAR_STR(repository_threshold, my_repository_threshold,
678
 
        PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC,
679
 
        "The maximum size of a BLOB repository file.",
680
 
        NULL, NULL, MS_REPO_THRESHOLD_DEF);
681
 
 
682
 
static MYSQL_SYSVAR_STR(temp_log_threshold, my_temp_log_threshold,
683
 
        PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC,
684
 
        "The maximum size of a temorary BLOB log file.",
685
 
        NULL, NULL, MS_TEMP_LOG_THRESHOLD_DEF);
686
 
 
687
 
static MYSQL_SYSVAR_STR(http_metadata_headers, my_http_metadata_headers,
688
 
        PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
689
 
        "A ':' delimited list of metadata header names to be used to initialize the pbms_metadata_header table when a database is created.",
690
 
        NULL, NULL , MS_HTTP_METADATA_HEADERS_DEF);
691
 
 
692
 
static MYSQL_SYSVAR_ULONG(temp_blob_timeout, my_temp_blob_timeout,
693
 
        PLUGIN_VAR_OPCMDARG,
694
 
        "The timeout, in seconds, for temporary BLOBs. Uploaded blob data is removed after this time, unless committed to the database.",
695
 
        NULL, pbms_temp_blob_timeout_func, MS_DEFAULT_TEMP_LOG_WAIT, 1, ~0L, 1);
696
 
 
697
 
static MYSQL_SYSVAR_ULONG(garbage_threshold, my_garbage_threshold,
698
 
        PLUGIN_VAR_OPCMDARG,
699
 
        "The percentage of garbage in a repository file before it is compacted.",
700
 
        NULL, NULL, MS_DEFAULT_GARBAGE_LEVEL, 0, 100, 1);
701
 
 
702
 
 
703
 
static MYSQL_SYSVAR_ULONG(max_keep_alive, my_max_keep_alive,
704
 
        PLUGIN_VAR_OPCMDARG,
705
 
        "The timeout, in milli-seconds, before the HTTP server will close an inactive HTTP connection.",
706
 
        NULL, NULL, MS_DEFAULT_KEEP_ALIVE, 1, UINT32_MAX, 1);
707
 
 
708
 
static MYSQL_SYSVAR_ULONG(next_backup_db_id, my_backup_db_id,
709
 
        PLUGIN_VAR_OPCMDARG,
710
 
        "The next backup ID to use when backing up a PBMS database.",
711
 
        NULL, NULL, 1, 1, UINT32_MAX, 1);
712
 
 
713
 
struct st_mysql_sys_var* pbms_system_variables[] = {
714
 
        MYSQL_SYSVAR(port),
715
 
        MYSQL_SYSVAR(repository_threshold),
716
 
        MYSQL_SYSVAR(temp_log_threshold),
717
 
        MYSQL_SYSVAR(temp_blob_timeout),
718
 
        MYSQL_SYSVAR(garbage_threshold),
719
 
        MYSQL_SYSVAR(http_metadata_headers),
720
 
        MYSQL_SYSVAR(max_keep_alive),
721
 
        MYSQL_SYSVAR(next_backup_db_id),
722
 
        NULL
723
 
};
724
 
 
725
 
#endif // !DRIZZLED
726
 
 
727
 
 
728
 
// vim:noexpandtab:sts=8:sw=8:tabstop=8:smarttab: