1/*****************************************************************************
2
3Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
4Copyright (c) 2017, 2018, MariaDB Corporation.
5
6This program is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free Software
8Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program; if not, write to the Free Software Foundation, Inc.,
1651 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17
18*****************************************************************************/
19
20/**************************************************//**
21@file include/pars0opt.h
22Simple SQL optimizer
23
24Created 12/21/1997 Heikki Tuuri
25*******************************************************/
26
27#ifndef pars0opt_h
28#define pars0opt_h
29
30#include "univ.i"
31#include "que0types.h"
32#include "pars0sym.h"
33#include "dict0types.h"
34#include "row0sel.h"
35
36/*******************************************************************//**
37Optimizes a select. Decides which indexes to tables to use. The tables
38are accessed in the order that they were written to the FROM part in the
39select statement. */
40void
41opt_search_plan(
42/*============*/
43 sel_node_t* sel_node); /*!< in: parsed select node */
44/*******************************************************************//**
45Looks for occurrences of the columns of the table in the query subgraph and
46adds them to the list of columns if an occurrence of the same column does not
47already exist in the list. If the column is already in the list, puts a value
48indirection to point to the occurrence in the column list, except if the
49column occurrence we are looking at is in the column list, in which case
50nothing is done. */
51void
52opt_find_all_cols(
53/*==============*/
54 ibool copy_val, /*!< in: if TRUE, new found columns are
55 added as columns to copy */
56 dict_index_t* index, /*!< in: index to use */
57 sym_node_list_t* col_list, /*!< in: base node of a list where
58 to add new found columns */
59 plan_t* plan, /*!< in: plan or NULL */
60 que_node_t* exp); /*!< in: expression or condition */
61#ifdef UNIV_SQL_DEBUG
62/********************************************************************//**
63Prints info of a query plan. */
64void
65opt_print_query_plan(
66/*=================*/
67 sel_node_t* sel_node); /*!< in: select node */
68#endif /* UNIV_SQL_DEBUG */
69
70#endif
71