~pbxt-core/pbxt/rc4

« back to all changes in this revision

Viewing changes to src/table_xt.cc

  • Committer: Barry.Leslie at PrimeBase
  • Date: 2009-07-27 22:39:29 UTC
  • mto: This revision was merged to the branch mainline in revision 678.
  • Revision ID: barry.leslie@primebase.com-20090727223929-jc283putlzctt5ps
PBMS compatibility changes for PBMS version 0.5.09-alpha and later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#include "myxt_xt.h"
48
48
#include "cache_xt.h"
49
49
#include "trace_xt.h"
50
 
#ifdef XT_STREAMING
51
 
#include "streaming_xt.h"
52
 
#endif
53
50
#include "index_xt.h"
54
51
#include "restart_xt.h"
55
52
#include "systab_xt.h"
1239
1236
                return_(NULL);
1240
1237
        }
1241
1238
 
1242
 
#ifdef XT_STREAMING
1243
 
        /* Tell PBMS to close all open tables of this sort: */
1244
 
        xt_pbms_close_all_tables(name->ps_path);
1245
 
#endif
1246
 
 
1247
1239
        /* Wait for all open tables to close: */
1248
1240
        xt_db_wait_for_open_tables(self, table_pool);
1249
1241
 
1320
1312
 
1321
1313
                /* Remove the PBMS table: */
1322
1314
                ASSERT(xt_get_self() == self);
1323
 
#ifdef XT_STREAMING
1324
 
                xt_pbms_drop_table(name->ps_path);
1325
 
#endif
1326
1315
 
1327
1316
                /* Remove the table from the directory. It will get a new
1328
1317
                 * ID so the handle in the directory will no longer be valid.
1645
1634
                        tab_delete_table_files(self, tab_name, tab_id);
1646
1635
 
1647
1636
                        ASSERT(xt_get_self() == self);
1648
 
#ifdef XT_STREAMING
1649
 
                        xt_pbms_drop_table(tab_name->ps_path);
1650
 
#endif
1651
1637
                        if ((te_ptr = (XTTableEntryPtr) xt_sl_find(self, db->db_table_by_id, &tab_id))) {
1652
1638
                                tab_remove_table_path(self, db, te_ptr->te_tab_path);
1653
1639
                                xt_sl_delete(self, db->db_table_by_id, &tab_id);
3708
3694
                }
3709
3695
        }
3710
3696
 
3711
 
#ifdef XT_STREAMING
3712
 
        if (tab->tab_dic.dic_blob_count) {
3713
 
                /* If the record contains any LONGBLOB then check how much
3714
 
                 * space we need.
3715
 
                 */
3716
 
                size_t blob_size;
3717
 
 
3718
 
                switch (old_rec_type) {
3719
 
                        case XT_TAB_STATUS_DELETE:
3720
 
                        case XT_TAB_STATUS_DEL_CLEAN:
3721
 
                                break;
3722
 
                        case XT_TAB_STATUS_FIXED:
3723
 
                        case XT_TAB_STATUS_FIX_CLEAN:
3724
 
                                /* Should not be the case, record with LONGBLOB can never be fixed! */
3725
 
                                break;
3726
 
                        case XT_TAB_STATUS_VARIABLE:
3727
 
                        case XT_TAB_STATUS_VAR_CLEAN:
3728
 
                                cols_req = tab->tab_dic.dic_blob_cols_req;
3729
 
                                cols_in_buffer = cols_req;
3730
 
                                blob_size = myxt_load_row_length(ot, rec_size - XT_REC_FIX_HEADER_SIZE, ot->ot_row_rbuffer + XT_REC_FIX_HEADER_SIZE, &cols_in_buffer);
3731
 
                                if (cols_in_buffer < cols_req)
3732
 
                                        blob_size = tab->tab_dic.dic_rec_size;
3733
 
                                else 
3734
 
                                        blob_size += XT_REC_FIX_HEADER_SIZE;
3735
 
                                if (blob_size > rec_size)
3736
 
                                        rec_size = blob_size;
3737
 
                                break;
3738
 
                        case XT_TAB_STATUS_EXT_DLOG:
3739
 
                        case XT_TAB_STATUS_EXT_CLEAN:
3740
 
                                cols_req = tab->tab_dic.dic_blob_cols_req;
3741
 
                                cols_in_buffer = cols_req;
3742
 
                                blob_size = myxt_load_row_length(ot, rec_size - XT_REC_EXT_HEADER_SIZE, ot->ot_row_rbuffer + XT_REC_EXT_HEADER_SIZE, &cols_in_buffer);
3743
 
                                if (cols_in_buffer < cols_req)
3744
 
                                        blob_size = tab->tab_dic.dic_rec_size;
3745
 
                                else 
3746
 
                                        blob_size += XT_REC_EXT_HEADER_SIZE;
3747
 
                                if (blob_size > rec_size)
3748
 
                                        rec_size = blob_size;
3749
 
                                break;
3750
 
                }
3751
 
        }
3752
 
#endif
3753
 
 
3754
3697
        set_removed:
3755
3698
        if (XT_REC_IS_EXT_DLOG(old_rec_type)) {
3756
3699
                /* {LOCK-EXT-REC} Lock, and read again to make sure that the
4387
4330
        xtRowID                                 row_id;
4388
4331
        u_int                                   idx_cnt = 0;
4389
4332
        XTIndexPtr                              *ind;
4390
 
#ifdef XT_STREAMING
4391
 
        void                                    *pbms_table;
4392
 
 
4393
 
        /* PBMS: Reference BLOBs!? */
4394
 
        if (tab->tab_dic.dic_blob_count) {
4395
 
                if (!myxt_use_blobs(ot, &pbms_table, rec_buf))
4396
 
                        return FAILED;
4397
 
        }
4398
 
#endif
4399
4333
 
4400
4334
        if (!myxt_store_row(ot, &rec_info, (char *) rec_buf))
4401
4335
                goto failed_0;
4430
4364
                }
4431
4365
        }
4432
4366
 
4433
 
#ifdef XT_STREAMING
4434
 
        /* Reference the BLOBs in the row: */
4435
 
        if (tab->tab_dic.dic_blob_count) {
4436
 
                if (!myxt_retain_blobs(ot, pbms_table, rec_info.ri_rec_id)) {
4437
 
                        pbms_table = NULL;
4438
 
                        goto failed_2;
4439
 
                }
4440
 
                pbms_table = NULL;
4441
 
        }
4442
 
#endif
4443
 
 
4444
4367
        /* Do the foreign key stuff: */
4445
4368
        if (ot->ot_table->tab_dic.dic_table->dt_fkeys.size() > 0) {
4446
4369
                if (!ot->ot_table->tab_dic.dic_table->insertRow(ot, rec_buf))
4461
4384
        tab_free_row_on_fail(ot, tab, row_id);
4462
4385
 
4463
4386
        failed_0:
4464
 
#ifdef XT_STREAMING
4465
 
        if (tab->tab_dic.dic_blob_count && pbms_table)
4466
 
                myxt_unuse_blobs(ot, pbms_table);
4467
 
#endif
4468
4387
        return FAILED;
4469
4388
}
4470
4389
 
4568
4487
        xtLogOffset                             log_offset;
4569
4488
        xtBool                                  prev_ext_rec;
4570
4489
 
4571
 
#ifdef XT_STREAMING
4572
 
        void                                    *pbms_table;
4573
 
 
4574
 
        if (tab->tab_dic.dic_blob_count) {
4575
 
                if (!myxt_use_blobs(ot, &pbms_table, after_buf))
4576
 
                        return FAILED;
4577
 
        }
4578
 
#endif
4579
 
 
4580
4490
        if (!myxt_store_row(ot, &rec_info, (char *) after_buf))
4581
4491
                goto failed_0;
4582
4492
 
4640
4550
        if (prev_ext_rec)
4641
4551
                tab_free_ext_record_on_fail(ot, rec_id, &prev_rec_head, TRUE);
4642
4552
 
4643
 
#ifdef XT_STREAMING
4644
 
        if (tab->tab_dic.dic_blob_count) {
4645
 
                /* Retain the BLOBs new record: */
4646
 
                if (!myxt_retain_blobs(ot, pbms_table, rec_id))
4647
 
                        return FAILED;
4648
 
                /* Release the BLOBs in the old record: */
4649
 
                myxt_release_blobs(ot, before_buf, rec_id);
4650
 
        }
4651
 
#endif
4652
 
 
4653
4553
        return OK;
4654
4554
 
4655
4555
        failed_2:
4692
4592
                tab_free_ext_record_on_fail(ot, rec_id, &prev_rec_head, TRUE);
4693
4593
 
4694
4594
        failed_0:
4695
 
#ifdef XT_STREAMING
4696
 
        /* Unuse the BLOBs of the new record: */
4697
 
        if (tab->tab_dic.dic_blob_count && pbms_table)
4698
 
                myxt_unuse_blobs(ot, pbms_table);
4699
 
#endif
4700
4595
        return FAILED;
4701
4596
}
4702
4597
 
4710
4605
        u_int                                   idx_cnt = 0;
4711
4606
        XTIndexPtr                              *ind;
4712
4607
 
4713
 
#ifdef XT_STREAMING
4714
 
        void                                    *pbms_table;
4715
 
#endif
4716
 
 
4717
4608
        /*
4718
4609
         * Originally only the flag ot->ot_curr_updated was checked, and if it was on, then
4719
4610
         * tab_overwrite_record() was called, but this caused crashes in some cases like:
4753
4644
        row_id = ot->ot_curr_row_id;
4754
4645
        self = ot->ot_thread;
4755
4646
 
4756
 
#ifdef XT_STREAMING
4757
 
        /* PBMS: Reference BLOBs!? */
4758
 
        if (tab->tab_dic.dic_blob_count) {
4759
 
                if (!myxt_use_blobs(ot, &pbms_table, after_buf))
4760
 
                        return FAILED;
4761
 
        }
4762
 
#endif
4763
 
 
4764
4647
        if (!myxt_store_row(ot, &rec_info, (char *) after_buf))
4765
4648
                goto failed_0;
4766
4649
 
4810
4693
                }
4811
4694
        }
4812
4695
 
4813
 
#ifdef XT_STREAMING
4814
 
        /* Reference the BLOBs in the row: */
4815
 
        if (tab->tab_dic.dic_blob_count) {
4816
 
                if (!myxt_retain_blobs(ot, pbms_table, rec_info.ri_rec_id)) {
4817
 
                        pbms_table = NULL;
4818
 
                        goto failed_2;
4819
 
                }
4820
 
                pbms_table = NULL;
4821
 
        }
4822
 
#endif
4823
 
 
4824
4696
        if (ot->ot_table->tab_dic.dic_table->dt_trefs || ot->ot_table->tab_dic.dic_table->dt_fkeys.size() > 0) {
4825
4697
                if (!ot->ot_table->tab_dic.dic_table->updateRow(ot, before_buf, after_buf))
4826
4698
                        goto failed_2;
4837
4709
        XT_TAB_ROW_UNLOCK(&tab->tab_row_rwlock[row_id % XT_ROW_RWLOCKS], ot->ot_thread);
4838
4710
 
4839
4711
        failed_0:
4840
 
#ifdef XT_STREAMING
4841
 
        if (tab->tab_dic.dic_blob_count && pbms_table)
4842
 
                myxt_unuse_blobs(ot, pbms_table);
4843
 
#endif
4844
4712
        return FAILED;
4845
4713
}
4846
4714