Hierarchical database setup revisited

Arthur Clemens aclemens at xs4all.nl
Sun Nov 9 11:09:03 CST 2003


On 9-nov-03, at 9:11, Ruslan Zasukhin wrote:

> on 11/9/03 2:34 AM, Arthur Clemens at aclemens at xs4all.nl wrote:
>
>> I encounter a bug in my code where Valentina crashes. It happens when 
>> I
>> create a new record for boTranslation (see below) and pass the 
>> parent's
>> RecID. Now I wonder, is it possible to have parent pointers 2 levels
>> deep?
>>
>> I have this preliminary setup:
>>
>> class boRecord
>>
>> class boSloveneWord
>>    VDK_ObjectPtr   mfParentPtr; // pointer to boRecord
>>
>> class boRecordSection
>>    VDK_ObjectPtr   mfParentPtr; // pointer to boRecord
>>
>> class boTranslation
>>    VDK_ObjectPtr   mfParentPtr; // pointer to boRecordSection
>>
>>
>> When I add a new record to table boSloveneWord, and pass the 
>> FBL_REC_ID
>> of the parent's Record to it, all is fine:
>>
>> inline void boSloveneWord::addRecord(const FBL_REC_ID& inParentID) {
>>    this->SetBlank(); // Clear memory buffer of the BaseObject
>>    mfParentPtr = inParentID; // no problem
>>    VDK_BaseObject::AddRecord();
>>    Flush(); // from cache to disk
>> }
>>
>> But when I do the same: add a record to table boTranslation, and pass
>> the FBL_REC_ID of the parent's boRecordSection to it, it crashes: (the
>> code is the same)
>>
>> inline void boTranslation::addRecord(const FBL_REC_ID& inParentID) {
>>    this->SetBlank(); // Clear memory buffer of the BaseObject
>>    mfParentPtr = inParentID; // crash here
>>    VDK_BaseObject::AddRecord();
>>    Flush(); // from cache to disk
>> }
>>
>> Could it be that Valentina has a problem that I want to assign a 
>> parent
>> pointer that points to boRecordSection, that itself has a pointer to
>> boRecord?
>
> Of course no!
>
> 1) Arthur, check that you send correct RecID in the second case.
> This is OTHER value, correct?

Well, no. If I trace the value the RecID of the first RecordSection is 
1, the same as the RecID of the first Record. Should they be different 
(that is: is RecID a global counter)?

What I do to get the Record's RecID is:
// create new Record
// just after new Record is created:
FBL_REC_ID recordId = [self 
databaseDefinition]->getRecordTable()->GetRecID();
// returns 1 after first record

and for the RecordSection's RecID:
// create new RecordSection
// just after new RecordSection is created:
FBL_REC_ID recordSectionId = [self 
databaseDefinition]->getRecordSectionTable()->GetRecID();
// returns 1 after first recordsection

>
> 2) may be table itself is corrupted? Try on fresh db with ZERO records 
> in
> all  tables. Then you will know that must come RecID 1

That is what I did.

>
>
> 3) you can do this->Flush() to check only cache blocks for this table.
> This will be little faster.

OK. Here is not the problem.

Arthur




More information about the Valentina mailing list