Drizzled Public API Documentation

nested_join.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <drizzled/item.h>
00023 #include <drizzled/lex_string.h>
00024 #include <drizzled/sql_list.h>
00025 
00026 #include <bitset>
00027 
00028 namespace drizzled
00029 {
00030 class TableList;
00031 class JoinTable;
00032 
00033 class NestedJoin
00034 {
00035 public:
00036   /* list of elements in the nested join */
00037   List<TableList> join_list;
00038 
00039   /* bitmap of tables in the nested join */
00040   table_map used_tables;
00041 
00042   /* tables that rejects nulls           */
00043   table_map not_null_tables;
00044 
00045   /* the first nested table in the plan  */
00046   JoinTable *first_nested;
00047 
00048   /*
00049     Used to count tables in the nested join in 2 isolated places:
00050     1. In make_outerjoin_info().
00051     2. check_interleaving_with_nj/restore_prev_nj_state (these are called
00052     by the join optimizer.
00053     Before each use the counters are zeroed by reset_nj_counters.
00054   */
00055   uint32_t counter_;
00056 
00057   /* Bit used to identify this nested join*/
00058   std::bitset<64> nj_map;
00059 
00060   /*
00061     (Valid only for semi-join nests) Bitmap of tables outside the semi-join
00062     that are used within the semi-join's ON condition.
00063   */
00064   table_map sj_depends_on;
00065   /* Outer non-trivially correlated tables */
00066   table_map sj_corr_tables;
00067 
00068   List<Item> sj_outer_expr_list;
00069 
00078   bool is_fully_covered() const { return join_list.size() == counter_; }
00079 };
00080 
00081 } /* namespace drizzled */
00082