[fpc-devel] Patch to remove useless bookmark store in TDataset.DoInsertAppend
Luiz Américo
pascalive at bol.com.br
Mon Jul 25 18:17:01 CEST 2005
Alexandrov Alexandru wrote:
> On 7/24/05, Luiz Américo <pascalive at bol.com.br> wrote:
>
>>As already commented in the code, the bookmarking done inside
>>TDataset.DoInsertAppend is useless, not to say buggy.
>>It makes 2 records to have the same bookmark data but this is not
>>noticed because the bookmarkdata is set to the correct value after
>>Post->Resync.
>>
>>In TDBF, if the bookmark is get just after a insert call this bookmark
>>will point to the previous record (see the attached example).
>>
>>The patch remove this code and also refactory a if statement.
>>
>>Unfortunately, after applying the patch if a bookmark is get after
>>insert this bookmark points to the first record. This occurs because
>>TDBF inits a buffer with BookMarkData=0 and BookMarkFlag=bfCurrent
>>instead of bfInserted (this makes bookmarkavailable returns true)
>>
>>As far as i can understand it seems that is not allowed to get a
>>bookmark in a not posted record, is it?
>
>
> You can bookmark at any time.
No, see BookMarkAvailable function in TDataSet: it return true only when
there's a record and when BookMarkFlag= bfCurrent.
After a insert, in TBufDataset at least, the bookmarkFlag is set to
bfInserted, so if a user try to BookMark after a insert/append and
before Post, the BookMark will be nil.
> But as the inserted record is not posted
> yet, the bookmark will point to the current record in dataset.
See above
> Multiple users can insert records at same time.
Sql based TDataSet keeps a cache of the data, inserting in the dataset
will only modify the cache. The conflict of multiuser changing records
can rise when the changes are sent to the database not when manipulating
the cache.
BTW: TDbf allows multiple accesses?
>
> This example is bad. See above.
>
> Most datasets don't allow inserting records. Including TDbf.
It's also valid for append. Anyway it's not possible to get a BookMark
after a append because of the BookMarkFlag (bfEOf).
> If a dataset allow to insert records, and if the bookmark is the same
> as record number, then the new record must have the same bookmark as
> the old record.
> Next records bookmarks must be changed.
Ok. But's up to the TDataset descendant do this in InternalInsert
> If the record is appended, after DoInsert, follow
> SetBookmarkFlag(ActiveBuffer,bfEOF);
> It is ok i think.
Luiz
More information about the fpc-devel
mailing list