2003-04-25 16:51:04 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: Server Code
|
|
|
|
* MODULE: rpb_chain.cpp
|
|
|
|
* DESCRIPTION: Keeps track of rpb's, updated_in_place in
|
2003-12-31 06:36:12 +01:00
|
|
|
* single transaction
|
2003-04-25 16:51:04 +02:00
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* Created by: Alex Peshkov <peshkoff@mail.ru>
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "firebird.h"
|
2004-03-22 12:38:23 +01:00
|
|
|
#include "../jrd/common.h"
|
2003-04-25 16:51:04 +02:00
|
|
|
#include "../jrd/rpb_chain.h"
|
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
using namespace Jrd;
|
|
|
|
|
2003-11-28 07:48:34 +01:00
|
|
|
#ifdef DEBUG_GDS_ALLOC
|
2003-11-04 00:59:24 +01:00
|
|
|
#define ExecAssert(x) fb_assert(x)
|
2003-11-28 07:48:34 +01:00
|
|
|
#else //DEBUG_GDS_ALLOC
|
2003-04-25 16:51:04 +02:00
|
|
|
#define ExecAssert(x) x
|
2003-11-28 07:48:34 +01:00
|
|
|
#endif //DEBUG_GDS_ALLOC
|
2003-04-25 16:51:04 +02:00
|
|
|
|
2004-03-18 06:56:06 +01:00
|
|
|
// rpb_chain.h includes req.h => struct record_param.
|
2004-03-11 06:04:26 +01:00
|
|
|
|
2004-03-18 06:56:06 +01:00
|
|
|
int traRpbList::PushRpb(record_param* value)
|
2004-03-11 06:04:26 +01:00
|
|
|
{
|
2003-05-05 13:48:37 +02:00
|
|
|
if (value->rpb_relation->rel_view_rse || // this is view
|
2003-12-31 06:36:12 +01:00
|
|
|
value->rpb_relation->rel_file) // this is external file
|
|
|
|
{
|
2003-05-05 13:48:37 +02:00
|
|
|
return -1;
|
2003-04-25 16:51:04 +02:00
|
|
|
}
|
|
|
|
int pos = add(traRpbListElement(value, ~0));
|
|
|
|
int level = -1;
|
|
|
|
if (pos-- > 0) {
|
|
|
|
traRpbListElement& prev = (*this)[pos];
|
|
|
|
if (prev.lr_rpb->rpb_relation->rel_id == value->rpb_relation->rel_id &&
|
2003-12-31 06:36:12 +01:00
|
|
|
prev.lr_rpb->rpb_number == value->rpb_number)
|
|
|
|
{
|
|
|
|
// we got the same record once more - mark for refetch
|
|
|
|
level = prev.level;
|
|
|
|
fb_assert(pos >= level);
|
|
|
|
fb_assert((*this)[pos - level].level == 0);
|
|
|
|
prev.lr_rpb->rpb_stream_flags |= RPB_s_refetch;
|
2003-04-25 16:51:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
(*this)[++pos].level = ++level;
|
|
|
|
return level;
|
|
|
|
}
|
|
|
|
|
2004-03-18 06:56:06 +01:00
|
|
|
bool traRpbList::PopRpb(record_param* value, int Level)
|
2004-03-11 06:04:26 +01:00
|
|
|
{
|
2003-04-25 16:51:04 +02:00
|
|
|
if (Level < 0) {
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-17 01:06:31 +02:00
|
|
|
size_t pos;
|
2003-04-25 16:51:04 +02:00
|
|
|
ExecAssert(find(traRpbListElement(value, Level), pos));
|
2003-12-31 06:36:12 +01:00
|
|
|
const bool rc = (*this)[pos].lr_rpb->rpb_stream_flags & RPB_s_refetch;
|
2003-04-25 16:51:04 +02:00
|
|
|
remove(pos);
|
|
|
|
return rc;
|
|
|
|
}
|
2004-03-11 06:04:26 +01:00
|
|
|
|