~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbxt/src/datadic_xt.cc

  • Committer: lbieber
  • Date: 2010-09-22 13:48:54 UTC
  • mfrom: (1784.1.3 build)
  • Revision ID: lbieber@orisndriz08-20100922134854-y7mae2taqhn73vsx
Merge Paul M. - latest changes from PBXT 1.0.11-7
Merge Paul M. - fix bug 641038 - pbxt rollback not working (tables reported as non-transactional)
Merge Andrew - fix show stoppers for new drizzledump

Show diffs side-by-side

added added

removed removed

Lines of Context:
396
396
struct charset_info_st;
397
397
 
398
398
class XTTokenizer {
399
 
        MX_CHARSET_INFO                 *tkn_charset;
 
399
        MX_CONST_CHARSET_INFO   *tkn_charset;
400
400
        char                                    *tkn_cstring;
401
401
        char                                    *tkn_curr_pos;
402
402
        XTToken                                 *tkn_current;
1324
1324
class XTCreateTable : public XTParseTable {
1325
1325
        public:
1326
1326
        bool                                    ct_convert;
1327
 
        MX_CHARSET_INFO                 *ct_charset;
 
1327
        MX_CONST_CHARSET_INFO   *ct_charset;
1328
1328
        XTPathStrPtr                    ct_tab_path;
1329
1329
        u_int                                   ct_contraint_no;
1330
1330
        XTDDTable                               *ct_curr_table;
2049
2049
        if (!(ot = xt_db_open_table_using_tab(tr_fkey->co_table->dt_table, self)))
2050
2050
                xt_throw(self);
2051
2051
 
2052
 
        /* {FREE-ROWS-BAD} */
2053
 
        /*
2054
 
        row_count = ((xtInt8) ot->ot_table->tab_row_eof_id) - 1;
2055
 
        row_count -= (xtInt8) ot->ot_table->tab_row_fnum;
2056
 
        */
2057
2052
        /* Check if there are any rows in the referencing table: */
2058
2053
        if (!xt_tab_seq_init(ot))
2059
2054
                goto failed;
2296
2291
{
2297
2292
        XTDDTable *ref_tab;
2298
2293
 
2299
 
        xt_xlock_rwlock(self, &co_table->dt_ref_lock);
2300
 
        pushr_(xt_unlock_rwlock, &co_table->dt_ref_lock);
 
2294
        xt_recurrwlock_xlock(self, &co_table->dt_ref_lock);
 
2295
        pushr_(xt_recurrwlock_unxlock, &co_table->dt_ref_lock);
2301
2296
 
2302
2297
        if ((ref_tab = fk_ref_table)) {                 
2303
2298
                fk_ref_table = NULL;
2307
2302
 
2308
2303
        fk_ref_index = UINT_MAX;
2309
2304
 
2310
 
        freer_(); // xt_unlock_rwlock(&co_table->dt_ref_lock);
 
2305
        freer_(); // xt_recurrwlock_unxlock(&co_table->dt_ref_lock);
2311
2306
}
2312
2307
 
2313
2308
/*
2326
2321
        /* This lock ensures that the foreign key references are not
2327
2322
         * changed.
2328
2323
         */
2329
 
        xt_slock_rwlock_ns(&co_table->dt_ref_lock);
 
2324
        xt_recurrwlock_slock_ns(&co_table->dt_ref_lock);
2330
2325
 
2331
2326
        if (!(loc_ind = getIndexPtr()))
2332
2327
                goto failed;
2411
2406
        xt_db_return_table_to_pool_ns(ot);
2412
2407
 
2413
2408
        failed:
2414
 
        xt_unlock_rwlock_ns(&co_table->dt_ref_lock);
 
2409
        xt_recurrwlock_unslock_ns(&co_table->dt_ref_lock);
2415
2410
        return false;
2416
2411
 
2417
2412
        success:
2418
 
        xt_unlock_rwlock_ns(&co_table->dt_ref_lock);
 
2413
        xt_recurrwlock_unslock_ns(&co_table->dt_ref_lock);
2419
2414
        return true;
2420
2415
}
2421
2416
 
2443
2438
 
2444
2439
void XTDDTable::init(XTThreadPtr self)
2445
2440
{
2446
 
        xt_init_rwlock_with_autoname(self, &dt_ref_lock);
 
2441
        xt_recurrwlock_init_with_autoname(self, &dt_ref_lock);
2447
2442
        dt_trefs = NULL;
2448
2443
}
2449
2444
 
2480
2475
                ptr->release(self);
2481
2476
        }
2482
2477
 
2483
 
        xt_free_rwlock(&dt_ref_lock);
 
2478
        xt_recurrwlock_free(&dt_ref_lock);
2484
2479
}
2485
2480
 
2486
2481
XTDDColumn *XTDDTable::findColumn(char *name)
2556
2551
                        throw_();
2557
2552
        }
2558
2553
 
2559
 
        xt_xlock_rwlock(self, &dt_ref_lock);
2560
 
        pushr_(xt_unlock_rwlock, &dt_ref_lock);
 
2554
        xt_recurrwlock_xlock(self, &dt_ref_lock);
 
2555
        pushr_(xt_recurrwlock_unxlock, &dt_ref_lock);
2561
2556
 
2562
2557
        if (!(tr = new XTDDTableRef()))
2563
2558
                xt_throw_errno(XT_CONTEXT, XT_ENOMEM);
2572
2567
         */
2573
2568
        xt_heap_reference(self, fk->co_table->dt_table);
2574
2569
 
2575
 
        freer_(); // xt_unlock_rwlock(&dt_ref_lock);
 
2570
        freer_(); // xt_recurrwlock_unxlock(&dt_ref_lock);
2576
2571
}
2577
2572
 
2578
2573
/*
2582
2577
{
2583
2578
        XTDDTableRef    *tr, *prev_tr = NULL;
2584
2579
 
2585
 
        xt_xlock_rwlock(self, &dt_ref_lock);
2586
 
        pushr_(xt_unlock_rwlock, &dt_ref_lock);
 
2580
        xt_recurrwlock_xlock(self, &dt_ref_lock);
 
2581
        pushr_(xt_recurrwlock_unxlock, &dt_ref_lock);
2587
2582
 
2588
2583
        tr = dt_trefs;
2589
2584
        while (tr) {
2597
2592
                prev_tr = tr;
2598
2593
                tr = tr->tr_next;
2599
2594
        }
2600
 
        freer_(); // xt_unlock_rwlock(&dt_ref_lock);
 
2595
        freer_(); // xt_recurrwlock_unxlock(&dt_ref_lock);
2601
2596
        if (tr)
2602
2597
                tr->release(self);
2603
2598
}
2624
2619
 
2625
2620
                        dt->attachReference(self, fk);
2626
2621
 
2627
 
                        xt_xlock_rwlock(self, &dt_ref_lock);
2628
 
                        pushr_(xt_unlock_rwlock, &dt_ref_lock);
 
2622
                        xt_recurrwlock_xlock(self, &dt_ref_lock);
 
2623
                        pushr_(xt_recurrwlock_unxlock, &dt_ref_lock);
2629
2624
                        /* Referenced the table, not the index!
2630
2625
                         * We do this because we know that if the table is referenced, the
2631
2626
                         * index will remain valid!
2635
2630
                         */
2636
2631
                        xt_heap_reference(self, dt->dt_table);
2637
2632
                        fk->fk_ref_table = dt;
2638
 
                        freer_(); // xt_unlock_rwlock(&dt_ref_lock);
 
2633
                        freer_(); // xt_recurrwlock_unxlock(&dt_ref_lock);
2639
2634
                }
2640
2635
        }
2641
2636
}
2699
2694
        XTDDTableRef    *tr;
2700
2695
        XTDDTable               *tab;
2701
2696
 
2702
 
        xt_xlock_rwlock(self, &dt_ref_lock);
2703
 
        pushr_(xt_unlock_rwlock, &dt_ref_lock);
 
2697
        xt_recurrwlock_xlock(self, &dt_ref_lock);
 
2698
        pushr_(xt_recurrwlock_unxlock, &dt_ref_lock);
2704
2699
 
2705
2700
        for (u_int i=0; i<dt_fkeys.size(); i++) {
2706
2701
                fk = dt_fkeys.itemAt(i);
2711
2706
                                /* To avoid deadlock we do not hold more than
2712
2707
                                 * one lock at a time!
2713
2708
                                 */
2714
 
                                freer_(); // xt_unlock_rwlock(&dt_ref_lock);
 
2709
                                freer_(); // xt_recurrwlock_unxlock(&dt_ref_lock);
2715
2710
        
2716
2711
                                tab->removeReference(self, fk);
2717
2712
                                xt_heap_release(self, tab->dt_table); /* We referenced the table, not the index! */
2718
2713
        
2719
 
                                xt_xlock_rwlock(self, &dt_ref_lock);
2720
 
                                pushr_(xt_unlock_rwlock, &dt_ref_lock);
 
2714
                                xt_recurrwlock_xlock(self, &dt_ref_lock);
 
2715
                                pushr_(xt_recurrwlock_unxlock, &dt_ref_lock);
2721
2716
                        }
2722
2717
                }
2723
2718
        }
2725
2720
        while (dt_trefs) {
2726
2721
                tr = dt_trefs;
2727
2722
                dt_trefs = tr->tr_next;
2728
 
                freer_(); // xt_unlock_rwlock(&dt_ref_lock);
 
2723
                freer_(); // xt_recurrwlock_unxlock(&dt_ref_lock);
2729
2724
                tr->release(self);
2730
 
                xt_xlock_rwlock(self, &dt_ref_lock);
2731
 
                pushr_(xt_unlock_rwlock, &dt_ref_lock);
 
2725
                xt_recurrwlock_xlock(self, &dt_ref_lock);
 
2726
                pushr_(xt_recurrwlock_unxlock, &dt_ref_lock);
2732
2727
        }
2733
2728
 
2734
 
        freer_(); // xt_unlock_rwlock(&dt_ref_lock);
 
2729
        freer_(); // xt_recurrwlock_unxlock(&dt_ref_lock);
2735
2730
}
2736
2731
 
2737
2732
void XTDDTable::checkForeignKeys(XTThreadPtr self, bool temp_table)
2880
2875
                return false;
2881
2876
        rec_ptr = rec_buf.ib_db.db_data;
2882
2877
 
2883
 
        xt_slock_rwlock_ns(&dt_ref_lock);
 
2878
        xt_recurrwlock_slock_ns(&dt_ref_lock);
2884
2879
        tr = dt_trefs;
2885
2880
        while (tr) {
2886
2881
                if (!tr->checkReference(rec_ptr, ot->ot_thread)) {
2889
2884
                }
2890
2885
                tr = tr->tr_next;
2891
2886
        }
2892
 
        xt_unlock_rwlock_ns(&dt_ref_lock);
 
2887
        xt_recurrwlock_unslock_ns(&dt_ref_lock);
2893
2888
        xt_ib_free(NULL, &rec_buf);
2894
2889
        return ok;
2895
2890
}
2910
2905
                rec_ptr = rec_buf.ib_db.db_data;
2911
2906
                
2912
2907
        }
2913
 
        xt_slock_rwlock_ns(&dt_ref_lock);
 
2908
        xt_recurrwlock_slock_ns(&dt_ref_lock);
2914
2909
        tr = dt_trefs;
2915
2910
        while (tr) {
2916
2911
                if (!tr->modifyRow(ot, rec_ptr, NULL, ot->ot_thread)) {
2919
2914
                }
2920
2915
                tr = tr->tr_next;
2921
2916
        }
2922
 
        xt_unlock_rwlock_ns(&dt_ref_lock);
 
2917
        xt_recurrwlock_unslock_ns(&dt_ref_lock);
2923
2918
        xt_ib_free(NULL, &rec_buf);
2924
2919
        return ok;
2925
2920
}
2928
2923
{
2929
2924
        XTDDTableRef    *tr;
2930
2925
 
2931
 
        xt_slock_rwlock(self, &dt_ref_lock);
2932
 
        pushr_(xt_unlock_rwlock, &dt_ref_lock);
 
2926
        xt_recurrwlock_slock(self, &dt_ref_lock);
 
2927
        pushr_(xt_recurrwlock_unslock, &dt_ref_lock);
2933
2928
 
2934
2929
        tr = dt_trefs;
2935
2930
        while (tr) {
2937
2932
                tr = tr->tr_next;
2938
2933
        }
2939
2934
 
2940
 
        freer_(); // xt_unlock_rwlock(&dt_ref_lock);
 
2935
        freer_(); // xt_recurrwlock_unslock(&dt_ref_lock);
2941
2936
}
2942
2937
 
2943
2938
bool XTDDTable::updateRow(XTOpenTablePtr ot, xtWord1 *before, xtWord1 *after)
2967
2962
        ok = true;
2968
2963
        before_buf.ib_free = FALSE;
2969
2964
 
2970
 
        xt_slock_rwlock_ns(&dt_ref_lock);
 
2965
        xt_recurrwlock_slock_ns(&dt_ref_lock);
2971
2966
        if ((tr = dt_trefs)) {
2972
2967
                if (!before) {
2973
2968
                        if (!xt_tab_load_record(ot, ot->ot_curr_rec_id, &before_buf))
2983
2978
                        tr = tr->tr_next;
2984
2979
                }
2985
2980
        }
2986
 
        xt_unlock_rwlock_ns(&dt_ref_lock);
 
2981
        xt_recurrwlock_unslock_ns(&dt_ref_lock);
2987
2982
        
2988
2983
        xt_ib_free(NULL, &before_buf);
2989
2984
        return ok;