584.4.4
by Monty Taylor
Split out Name_resolution_context. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
19 |
||
20 |
#ifndef DRIZZLED_NAME_RESOLUTION_CONTEXT_H
|
|
21 |
#define DRIZZLED_NAME_RESOLUTION_CONTEXT_H
|
|
22 |
||
23 |
class TableList; |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
24 |
class Security_context; |
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
25 |
class Session; |
846
by Brian Aker
Removing on typedeffed class. |
26 |
class Select_Lex; |
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
27 |
|
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
28 |
/**
|
29 |
* Instances of Name_resolution_context store the information necesary for
|
|
30 |
* name resolution of Items and other context analysis of a query made in
|
|
31 |
* fix_fields().
|
|
32 |
*
|
|
33 |
* This structure is a part of Select_Lex, a pointer to this structure is
|
|
34 |
* assigned when an item is created (which happens mostly during parsing
|
|
35 |
* (sql_yacc.yy)), but the structure itself will be initialized after parsing
|
|
36 |
* is complete
|
|
37 |
*
|
|
38 |
* @todo
|
|
39 |
*
|
|
40 |
* Move subquery of INSERT ... SELECT and CREATE ... SELECT to
|
|
41 |
* separate Select_Lex which allow to remove tricks of changing this
|
|
42 |
* structure before and after INSERT/CREATE and its SELECT to make correct
|
|
43 |
* field name resolution.
|
|
44 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
45 |
class Name_resolution_context: public Sql_alloc |
46 |
{
|
|
47 |
public: |
|
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
48 |
/**
|
49 |
* The name resolution context to search in when an Item cannot be
|
|
50 |
* resolved in this context (the context of an outer select)
|
|
51 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
52 |
Name_resolution_context *outer_context; |
53 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
54 |
/**
|
55 |
* List of tables used to resolve the items of this context. Usually these
|
|
56 |
* are tables from the FROM clause of SELECT statement. The exceptions are
|
|
57 |
* INSERT ... SELECT and CREATE ... SELECT statements, where SELECT
|
|
58 |
* subquery is not moved to a separate Select_Lex. For these types of
|
|
59 |
* statements we have to change this member dynamically to ensure correct
|
|
60 |
* name resolution of different parts of the statement.
|
|
61 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
62 |
TableList *table_list; |
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
63 |
/**
|
64 |
* In most cases the two table references below replace 'table_list' above
|
|
65 |
* for the purpose of name resolution. The first and last name resolution
|
|
66 |
* table references allow us to search only in a sub-tree of the nested
|
|
67 |
* join tree in a FROM clause. This is needed for NATURAL JOIN, JOIN ... USING
|
|
68 |
* and JOIN ... ON.
|
|
69 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
70 |
TableList *first_name_resolution_table; |
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
71 |
/**
|
72 |
* Last table to search in the list of leaf table references that begins
|
|
73 |
* with first_name_resolution_table.
|
|
74 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
75 |
TableList *last_name_resolution_table; |
76 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
77 |
/**
|
78 |
* Select_Lex item belong to, in case of merged VIEW it can differ from
|
|
79 |
* Select_Lex where item was created, so we can't use table_list/field_list
|
|
80 |
* from there
|
|
81 |
*/
|
|
846
by Brian Aker
Removing on typedeffed class. |
82 |
Select_Lex *select_lex; |
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
83 |
|
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
84 |
/**
|
85 |
* Processor of errors caused during Item name resolving, now used only to
|
|
86 |
* hide underlying tables in errors about views (i.e. it substitute some
|
|
87 |
* errors for views)
|
|
88 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
89 |
void (*error_processor)(Session *, void *); |
90 |
void *error_processor_data; |
|
91 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
92 |
/**
|
93 |
* When true items are resolved in this context both against the
|
|
94 |
* SELECT list and this->table_list. If false, items are resolved
|
|
95 |
* only against this->table_list.
|
|
96 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
97 |
bool resolve_in_select_list; |
98 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
99 |
/**
|
100 |
* Security context of this name resolution context. It's used for views
|
|
101 |
* and is non-zero only if the view is defined with SQL SECURITY DEFINER.
|
|
102 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
103 |
Security_context *security_ctx; |
104 |
||
105 |
Name_resolution_context() |
|
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
106 |
:
|
107 |
outer_context(0), |
|
108 |
table_list(0), |
|
109 |
select_lex(0), |
|
110 |
error_processor_data(0), |
|
111 |
security_ctx(0) |
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
112 |
{}
|
113 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
114 |
inline void init() |
115 |
{
|
|
116 |
resolve_in_select_list= false; |
|
117 |
error_processor= &dummy_error_processor; |
|
118 |
first_name_resolution_table= NULL; |
|
119 |
last_name_resolution_table= NULL; |
|
120 |
}
|
|
121 |
||
122 |
inline void resolve_in_table_list_only(TableList *tables) |
|
123 |
{
|
|
124 |
table_list= first_name_resolution_table= tables; |
|
125 |
resolve_in_select_list= false; |
|
126 |
}
|
|
127 |
||
128 |
inline void process_error(Session *session) |
|
129 |
{
|
|
130 |
(*error_processor)(session, error_processor_data); |
|
131 |
}
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
132 |
};
|
133 |
||
134 |
#endif /* DRIZZLED_NAME_RESOLUTION_CONTEXT_H */ |