Can anyone review the attached (in this message) patch?

Adriano


On 18/10/2013 09:51, Dmitriy Starodubov (JIRA) wrote:
>      [ 
> http://tracker.firebirdsql.org/browse/CORE-4247?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>  ]
>
> Dmitriy Starodubov updated CORE-4247:
> -------------------------------------
>
>     Attachment: scipt.sql
>
>> Delete "where current of" cursor fails for tables with newly added fields
>> -------------------------------------------------------------------------
>>
>>                 Key: CORE-4247
>>                 URL: http://tracker.firebirdsql.org/browse/CORE-4247
>>             Project: Firebird Core
>>          Issue Type: Bug
>>          Components: Engine
>>    Affects Versions: 2.5.3, 3.0 Alpha 2
>>            Reporter: Dmitriy Starodubov
>>         Attachments: scipt.sql
>>
>>
>> Executing the attached script crashes the server because of refetching 
>> record from DB during erase returns old format without added field.

diff --git a/src/jrd/recsrc/SortedStream.cpp b/src/jrd/recsrc/SortedStream.cpp
index 556711f..0d2af1f 100644
--- a/src/jrd/recsrc/SortedStream.cpp
+++ b/src/jrd/recsrc/SortedStream.cpp
@@ -302,6 +302,7 @@ UCHAR* SortedStream::getData(thread_db* tdbb) const
 
 void SortedStream::mapData(thread_db* tdbb, jrd_req* request, UCHAR* data) 
const
 {
+       StreamType stream = INVALID_STREAM;
        dsc from, to;
 
        const SortMap::Item* const end_item = m_map->items.begin() + 
m_map->items.getCount();
@@ -353,6 +354,14 @@ void SortedStream::mapData(thread_db* tdbb, jrd_req* 
request, UCHAR* data) const
                        continue;
                }
 
+               if (item->stream != stream)
+               {
+                       stream = item->stream;
+
+                       if (rpb->rpb_relation)
+                               VIO_record(tdbb, rpb, MET_current(tdbb, 
rpb->rpb_relation), tdbb->getDefaultPool());
+               }
+
                Record* const record = rpb->rpb_record;
 
                if (record && !flag && !record->rec_format)
@@ -361,14 +370,12 @@ void SortedStream::mapData(thread_db* tdbb, jrd_req* 
request, UCHAR* data) const
                        record->rec_format = record->rec_fmt_bk;
                }
 
-               EVL_field(NULL, record, id, &to);
-
                if (flag)
-               {
                        record->setNull(id);
-               }
                else
                {
+                       EVL_field(rpb->rpb_relation, record, id, &to);
+
                        MOV_move(tdbb, &from, &to);
                        record->clearNull(id);
                }
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to