~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Barry.Leslie at PrimeBase
  • Date: 2010-10-18 21:21:20 UTC
  • mto: This revision was merged to the branch mainline in revision 1871.
  • Revision ID: barry.leslie@primebase.com-20101018212120-dqukgtkwhb1imt1o
Merged changes from lp:pbms. These changes should remove any danger
of longjmp() clobbering local variables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <drizzled/common.h>
31
31
#include <drizzled/plugin.h>
32
32
#include <drizzled/session.h>
 
33
using namespace std;
33
34
using namespace drizzled;
34
35
using namespace drizzled::plugin;
35
36
 
44
45
#endif 
45
46
 
46
47
#include <inttypes.h>
 
48
#include <string.h>
47
49
 
48
50
#include "cslib/CSDefs.h"
49
51
#include "cslib/CSObject.h"
316
318
}               
317
319
 
318
320
//-----------------
 
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
//-----------------
319
340
bool PBMSParameters::isBLOBDatabase(const char *db)
320
341
{
321
342
        CSThread *self;
338
359
        if ((err = MSEngine::enterConnectionNoThd(&self, &result)) == 0) {
339
360
 
340
361
                inner_();
341
 
                try_(a) {
342
 
                        lock_(&my_table_list_lock);     
343
 
                        
344
 
                                
345
 
                        found = (locate_db(my_table_list, db, strlen(db)) != NULL);
346
 
                                
347
 
                        unlock_(&my_table_list_lock);
348
 
                }
349
 
                
350
 
                catch_(a) {
 
362
                if (try_LocateDB(self, db, &found)) {
351
363
                        err = MSEngine::exceptionToResult(&self->myException, &result);
352
 
                }
353
 
                cont_(a);
 
364
                }               
354
365
                outer_();
355
366
        
356
367
        }
364
375
}
365
376
        
366
377
//-----------------
 
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
//-----------------
367
422
bool PBMSParameters::isBLOBTable(const char *db, const char *table)
368
423
{
369
424
        CSThread *self;
370
425
        int             err;
371
426
        PBMSResultRec result;
372
427
        bool found = false;
373
 
        const char *ptr;
374
 
        int db_len, table_len, match_len;
375
428
        
376
429
        if (isBlackListedDB(db))
377
430
                return false;
388
441
        if ((err = MSEngine::enterConnectionNoThd(&self, &result)) == 0) {
389
442
 
390
443
                inner_();
391
 
                try_(a) {
392
 
                        lock_(&my_table_list_lock);     
393
 
                                        
394
 
                        db_len = strlen(db);
395
 
                        table_len = strlen(table);
396
 
                        
397
 
                        ptr = my_table_list;
398
 
                        while (ptr) {
399
 
                                ptr = locate_db(ptr, db, db_len);
400
 
                                if (ptr) {
401
 
                                        match_len = 0;
402
 
                                        if (*ptr == '*')
403
 
                                                match_len = 1;
404
 
                                        else if (strncmp(ptr, table, table_len) == 0)
405
 
                                                match_len = table_len;
406
 
                                                
407
 
                                        if (match_len) {
408
 
                                                ptr += match_len;
409
 
                                                if ((!*ptr) || (*ptr == ',') || isspace(*ptr)) {
410
 
                                                        found = true;
411
 
                                                        break;
412
 
                                                }
413
 
                                        }
414
 
                                        
415
 
                                        NEXT_IN_TABLE_LIST(ptr);
416
 
                                }
417
 
                        }
418
 
                                
419
 
                        unlock_(&my_table_list_lock);
420
 
                }
421
 
                catch_(a) {
 
444
                if (try_LocateTable(self, db, table, &found)) {
422
445
                        err = MSEngine::exceptionToResult(&self->myException, &result);
423
 
                }
424
 
                cont_(a);
 
446
                }               
425
447
                outer_();
426
448
        
427
449
        }