~pbms-core/pbms/5.11-beta

« back to all changes in this revision

Viewing changes to src/Repository_ms.cc

  • Committer: Barry.Leslie at PrimeBase
  • Date: 2010-02-25 17:15:10 UTC
  • Revision ID: barry.leslie@primebase.com-20100225171510-ztd2hnjosu40ci34
Pulled the BLOB alias support out of the  daemon. This was done because
supporting it in a transactional environment would have been complicated and
since it is not part of the core objectives of the PBMS daemon I felt that it was
not worth the effort it would take.

Show diffs side-by-side

added added

removed removed

Lines of Context:
321
321
                release_(buffer);
322
322
 
323
323
                ptr.rp_chars = otab->myOTBuffer;
 
324
#ifdef HAVE_ALIAS_SUPPORT
324
325
                /* Update the BLOB alias if required. */
325
326
                
326
327
                if (CS_GET_DISK_2(ptr.rp_head->rb_alias_offset_2)) {
327
328
                        csWord4 alias_hash = CS_GET_DISK_4(ptr.rp_head->rb_alias_hash_4);
328
329
                        myRepo->myRepoDatabase->moveBlobAlias(myRepo->myRepoID, offset, alias_hash, myRepo->myRepoID, dst_offset);
329
330
                }
330
 
 
 
331
#endif
331
332
 
332
333
                /* Update the references: */
333
334
                ref_size = CS_GET_DISK_1(ptr.rp_head->rb_ref_size_1);
404
405
        MSRepoBlobRefPtr        free2_ref = NULL;
405
406
        MSRepoTableRefPtr       tab_ref = NULL;
406
407
        csWord2                         new_head_size;
 
408
#ifdef HAVE_ALIAS_SUPPORT
407
409
        bool                            reset_alias_index = false;
408
410
        char                            blob_alias[BLOB_ALIAS_LENGTH];
 
411
#endif
409
412
        csWord8                         blob_size;
410
413
        
411
414
        enter_();
451
454
        ref_size = CS_GET_DISK_1(ptr.rp_head->rb_ref_size_1);
452
455
        ref_count = CS_GET_DISK_2(ptr.rp_head->rb_ref_count_2);
453
456
        
 
457
#ifdef HAVE_ALIAS_SUPPORT
454
458
        if (CS_GET_DISK_2(ptr.rp_head->rb_alias_offset_2)) {
455
459
                reset_alias_index = true;
456
460
                strcpy(blob_alias, otab->myOTBuffer + CS_GET_DISK_2(ptr.rp_head->rb_alias_offset_2));
457
461
        }
 
462
#endif
458
463
        
459
464
        size = head_size - myRepo->myRepoBlobHeadSize;
460
465
        if (size > ref_size * ref_count)
471
476
                                        free2_ref = ptr.rp_blob_ref;
472
477
                                break;
473
478
                        case MS_BLOB_TABLE_REF:
 
479
#ifdef HAVE_ALIAS_SUPPORT
474
480
                                reset_alias_index = false; // No need to reset the index if the BLOB is already referenced. (We don't care what table references it.)
 
481
#endif
475
482
                                if (CS_GET_DISK_4(ptr.rp_tab_ref->tr_table_id_4) == tab_id &&
476
483
                                        CS_GET_DISK_6(ptr.rp_tab_ref->tr_blob_id_6) == blob_id)
477
484
                                        tab_ref = ptr.rp_tab_ref;
620
627
        CS_SET_DISK_8(free_ref->er_blob_ref_id_8, UNCOMMITTED(blob_ref_id));
621
628
 
622
629
        update_blob_header(otab, offset, blob_size, head_size, new_head_size);
 
630
#ifdef HAVE_ALIAS_SUPPORT
623
631
        if (reset_alias_index) 
624
632
                myRepo->myRepoDatabase->registerBlobAlias(myRepo->myRepoID, offset, blob_alias);
 
633
#endif
625
634
 
626
635
done:
627
636
        
701
710
        CS_SET_DISK_2(ptr.rp_head->rb_mdata_size_2, mdata_size);
702
711
        CS_SET_DISK_2(ptr.rp_head->rb_mdata_offset_2, mdata_offset);
703
712
        
 
713
#ifdef HAVE_ALIAS_SUPPORT
704
714
        if (alias) {
705
715
                alias_hash = CS_GET_DISK_4(ptr.rp_head->rb_alias_hash_4);
706
716
                alias_offset = CS_GET_DISK_2(ptr.rp_head->rb_alias_offset_2);
718
728
                myRepo->myRepoDatabase->deleteBlobAlias(myRepo->myRepoID, offset, CS_GET_DISK_4(ptr.rp_head->rb_alias_hash_4));
719
729
                alias_offset = 0;
720
730
        }
 
731
#else
 
732
        if (alias || reset_alias) {
 
733
                CSException::throwException(CS_CONTEXT, MS_ERR_NOT_IMPLEMENTED, "No BLOB alias support.");
 
734
        }
 
735
#endif
721
736
 
722
737
        CS_SET_DISK_2(ptr.rp_head->rb_alias_offset_2, alias_offset);
723
738
        CS_SET_DISK_4(ptr.rp_head->rb_alias_hash_4, alias_hash);
841
856
                csWord4 log_id;
842
857
                csWord4 log_offset;
843
858
                csWord4 temp_time;
 
859
#ifdef HAVE_ALIAS_SUPPORT
844
860
                MSDiskAliasRec aliasDiskRec;
845
861
                MSDiskAliasPtr aliasDiskPtr = NULL;
846
862
                
852
868
                }
853
869
                
854
870
                myRepo->myRepoDatabase->queueForDeletion(otab, MS_TL_BLOB_REF, tab_id, blob_id, auth_code, &log_id, &log_offset, &temp_time, aliasDiskPtr);
 
871
#else
 
872
                myRepo->myRepoDatabase->queueForDeletion(otab, MS_TL_BLOB_REF, tab_id, blob_id, auth_code, &log_id, &log_offset, &temp_time);
 
873
#endif
855
874
                myRepo->myLastTempTime = temp_time;
856
875
                CS_SET_DISK_2(temp_ref->rr_type_2, MS_BLOB_DELETE_REF);
857
876
                CS_SET_DISK_2(temp_ref->tp_del_ref_2, tab_index+1);
971
990
        csWord8                         blob_id;
972
991
        size_t                          size;
973
992
        MSRepoPointersRec       ptr;
974
 
        csWord4                         alias_hash;
975
993
        enter_();
976
994
        
977
995
        ptr.rp_chars = buffer;
985
1003
                myRepo->myRepoDatabase->myBlobCloud->cl_deleteData(&key); 
986
1004
        }
987
1005
                
 
1006
#ifdef HAVE_ALIAS_SUPPORT
 
1007
        csWord4                         alias_hash;
988
1008
        alias_hash = CS_GET_DISK_4(ptr.rp_head->rb_alias_hash_4);
989
1009
        if (alias_hash != INVALID_ALIAS_HASH)
990
1010
                myRepo->myRepoDatabase->deleteBlobAlias(myRepo->myRepoID, offset, alias_hash);
 
1011
#endif
991
1012
 
992
1013
        // Assuming the BLOB is still locked:
993
1014
        CS_SET_DISK_1(ptr.rp_head->rb_status_1, MS_BLOB_DELETED);
1432
1453
 
1433
1454
        CS_SET_DISK_2(blob->rb_mdata_size_2, metadata_size);
1434
1455
        if (metadata_size) {
1435
 
                const char *alias;      
1436
 
                MetaData md;    
1437
1456
                csWord2 metadata_offset = head_size - metadata_size;
1438
1457
                
1439
1458
                CS_SET_DISK_2(blob->rb_mdata_offset_2, metadata_offset);
1440
1459
                memcpy(otab->myOTBuffer + metadata_offset, metadata, metadata_size);
1441
1460
                
 
1461
#ifdef HAVE_ALIAS_SUPPORT
 
1462
                MetaData md;    
1442
1463
                md.use_data(metadata, metadata_size);
 
1464
                const char *alias;      
1443
1465
                alias = md.findAlias();
1444
1466
                if (alias) {
1445
1467
                        csWord4 alias_hash;
1450
1472
                } else {
1451
1473
                        CS_SET_DISK_2(blob->rb_alias_offset_2, 0);
1452
1474
                }
 
1475
#else
 
1476
                CS_SET_DISK_2(blob->rb_alias_offset_2, 0);
 
1477
#endif
1453
1478
                
1454
1479
        } else {
1455
1480
                CS_SET_DISK_2(blob->rb_mdata_offset_2, 0);