2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: JRD Access Method
|
|
|
|
* MODULE: rse.h
|
|
|
|
* DESCRIPTION: Record source block definitions
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
2002-06-29 15:03:13 +02:00
|
|
|
*
|
2005-11-06 04:31:16 +01:00
|
|
|
* 2001.07.28: Added rsb_t.rsb_skip to support LIMIT functionality.
|
2001-05-23 15:26:42 +02:00
|
|
|
*/
|
|
|
|
|
2003-10-03 03:53:34 +02:00
|
|
|
#ifndef JRD_RSE_H
|
|
|
|
#define JRD_RSE_H
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
#include "../include/fb_blk.h"
|
2003-10-17 22:29:52 +02:00
|
|
|
#include "../common/classes/array.h"
|
|
|
|
#include "../jrd/constants.h"
|
2010-10-12 10:02:57 +02:00
|
|
|
#include "../common/dsc.h"
|
2004-04-18 16:22:27 +02:00
|
|
|
#include "../jrd/lls.h"
|
2004-09-28 08:28:38 +02:00
|
|
|
#include "../jrd/sbm.h"
|
2009-10-21 02:42:38 +02:00
|
|
|
#include "../jrd/ExtEngineManager.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
#include "../jrd/RecordBuffer.h"
|
2010-10-12 13:36:51 +02:00
|
|
|
#include "../dsql/Nodes.h"
|
2006-07-17 19:44:18 +02:00
|
|
|
|
2004-03-28 11:10:30 +02:00
|
|
|
struct dsc;
|
2004-03-20 15:57:40 +01:00
|
|
|
|
|
|
|
namespace Jrd {
|
|
|
|
|
2004-03-11 06:04:26 +01:00
|
|
|
struct sort_key_def;
|
2004-03-28 11:10:30 +02:00
|
|
|
class CompilerScratch;
|
2010-10-12 13:36:51 +02:00
|
|
|
class BoolExprNode;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-06-26 00:12:20 +02:00
|
|
|
// Array which stores relative pointers to impure areas of invariant nodes
|
2010-04-08 14:17:54 +02:00
|
|
|
typedef Firebird::SortedArray<ULONG> VarInvariantArray;
|
2004-06-26 00:12:20 +02:00
|
|
|
|
2010-10-12 13:36:51 +02:00
|
|
|
class RseNode;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-30 14:43:37 +01:00
|
|
|
// General optimizer block
|
|
|
|
|
2004-03-28 11:10:30 +02:00
|
|
|
class OptimizerBlk : public pool_alloc<type_opt>
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
2003-10-17 22:29:52 +02:00
|
|
|
public:
|
2014-03-15 19:00:33 +01:00
|
|
|
OptimizerBlk(MemoryPool* pool, RseNode* aRse)
|
2010-10-12 13:36:51 +02:00
|
|
|
: opt_conjuncts(*pool),
|
|
|
|
opt_streams(*pool),
|
|
|
|
rse(aRse),
|
|
|
|
outerStreams(*pool),
|
|
|
|
subStreams(*pool),
|
2012-04-12 11:02:13 +02:00
|
|
|
compileStreams(*pool),
|
|
|
|
beds(*pool),
|
|
|
|
localStreams(*pool),
|
|
|
|
keyStreams(*pool)
|
2014-01-05 20:40:07 +01:00
|
|
|
{}
|
2010-10-12 13:36:51 +02:00
|
|
|
|
|
|
|
CompilerScratch* opt_csb; // compiler scratch block
|
2003-10-30 14:43:37 +01:00
|
|
|
double opt_best_cost; // cost of best join order
|
2012-04-12 11:02:13 +02:00
|
|
|
StreamType opt_best_count; // longest length of indexable streams
|
2009-07-12 12:16:15 +02:00
|
|
|
USHORT opt_base_conjuncts; // number of conjuncts in our rse, next conjuncts are distributed parent
|
|
|
|
USHORT opt_base_parent_conjuncts; // number of conjuncts in our rse + distributed with parent, next are parent
|
|
|
|
USHORT opt_base_missing_conjuncts; // number of conjuncts in our and parent rse, but without missing
|
2010-10-12 13:36:51 +02:00
|
|
|
|
2008-05-10 05:44:57 +02:00
|
|
|
struct opt_conjunct
|
|
|
|
{
|
2003-10-17 22:29:52 +02:00
|
|
|
// Conjunctions and their options
|
2010-10-12 13:36:51 +02:00
|
|
|
BoolExprNode* opt_conjunct_node; // conjunction
|
2003-10-17 22:29:52 +02:00
|
|
|
UCHAR opt_conjunct_flags;
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2010-10-12 13:36:51 +02:00
|
|
|
|
2008-05-10 05:44:57 +02:00
|
|
|
struct opt_stream
|
|
|
|
{
|
2003-10-17 22:29:52 +02:00
|
|
|
// Streams and their options
|
2012-04-12 11:02:13 +02:00
|
|
|
StreamType opt_best_stream; // stream in best join order seen so far
|
|
|
|
StreamType opt_stream_number; // stream in position of join order
|
2003-10-17 22:29:52 +02:00
|
|
|
};
|
2010-10-12 13:36:51 +02:00
|
|
|
|
2003-10-20 12:04:44 +02:00
|
|
|
Firebird::HalfStaticArray<opt_conjunct, OPT_STATIC_ITEMS> opt_conjuncts;
|
|
|
|
Firebird::HalfStaticArray<opt_stream, OPT_STATIC_ITEMS> opt_streams;
|
2010-10-12 13:36:51 +02:00
|
|
|
|
|
|
|
RseNode* const rse;
|
2011-02-20 16:34:08 +01:00
|
|
|
StreamList outerStreams, subStreams;
|
2012-04-12 11:02:13 +02:00
|
|
|
StreamList compileStreams, beds, localStreams, keyStreams;
|
2014-01-05 20:40:07 +01:00
|
|
|
bool optimizeFirstRows;
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-30 14:43:37 +01:00
|
|
|
// values for opt_conjunct_flags
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-10-30 14:43:37 +01:00
|
|
|
const USHORT opt_conjunct_used = 1; // conjunct is used
|
|
|
|
const USHORT opt_conjunct_matched = 2; // conjunct matches an index segment
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
} //namespace Jrd
|
|
|
|
|
2003-10-30 14:43:37 +01:00
|
|
|
#endif // JRD_RSE_H
|