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 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
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 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
20 |
#pragma once
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
21 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
22 |
#include <drizzled/item.h> |
1237.9.3
by Padraig O'Sullivan
Removed one the includes I put in server_includes.h for the last commit to get rid of the inclusion |
23 |
|
2252.1.15
by Olaf van der Spek
Common fwd |
24 |
namespace drizzled { |
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
25 |
|
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
26 |
/**
|
27 |
* Instances of Name_resolution_context store the information necesary for
|
|
28 |
* name resolution of Items and other context analysis of a query made in
|
|
29 |
* fix_fields().
|
|
30 |
*
|
|
31 |
* This structure is a part of Select_Lex, a pointer to this structure is
|
|
32 |
* assigned when an item is created (which happens mostly during parsing
|
|
33 |
* (sql_yacc.yy)), but the structure itself will be initialized after parsing
|
|
34 |
* is complete
|
|
35 |
*
|
|
36 |
* @todo
|
|
37 |
*
|
|
38 |
* Move subquery of INSERT ... SELECT and CREATE ... SELECT to
|
|
39 |
* separate Select_Lex which allow to remove tricks of changing this
|
|
40 |
* structure before and after INSERT/CREATE and its SELECT to make correct
|
|
41 |
* field name resolution.
|
|
42 |
*/
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
43 |
class Name_resolution_context: public memory::SqlAlloc |
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
44 |
{
|
45 |
public: |
|
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
46 |
/**
|
47 |
* The name resolution context to search in when an Item cannot be
|
|
48 |
* resolved in this context (the context of an outer select)
|
|
49 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
50 |
Name_resolution_context *outer_context; |
51 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
52 |
/**
|
53 |
* List of tables used to resolve the items of this context. Usually these
|
|
54 |
* are tables from the FROM clause of SELECT statement. The exceptions are
|
|
55 |
* INSERT ... SELECT and CREATE ... SELECT statements, where SELECT
|
|
56 |
* subquery is not moved to a separate Select_Lex. For these types of
|
|
57 |
* statements we have to change this member dynamically to ensure correct
|
|
58 |
* name resolution of different parts of the statement.
|
|
59 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
60 |
TableList *table_list; |
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
61 |
/**
|
62 |
* In most cases the two table references below replace 'table_list' above
|
|
63 |
* for the purpose of name resolution. The first and last name resolution
|
|
64 |
* table references allow us to search only in a sub-tree of the nested
|
|
65 |
* join tree in a FROM clause. This is needed for NATURAL JOIN, JOIN ... USING
|
|
66 |
* and JOIN ... ON.
|
|
67 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
68 |
TableList *first_name_resolution_table; |
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
69 |
/**
|
70 |
* Last table to search in the list of leaf table references that begins
|
|
71 |
* with first_name_resolution_table.
|
|
72 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
73 |
TableList *last_name_resolution_table; |
74 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
75 |
/**
|
76 |
* Select_Lex item belong to, in case of merged VIEW it can differ from
|
|
77 |
* Select_Lex where item was created, so we can't use table_list/field_list
|
|
78 |
* from there
|
|
79 |
*/
|
|
846
by Brian Aker
Removing on typedeffed class. |
80 |
Select_Lex *select_lex; |
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
81 |
|
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
82 |
/**
|
83 |
* Processor of errors caused during Item name resolving, now used only to
|
|
84 |
* hide underlying tables in errors about views (i.e. it substitute some
|
|
85 |
* errors for views)
|
|
86 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
87 |
void (*error_processor)(Session *, void *); |
88 |
void *error_processor_data; |
|
89 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
90 |
/**
|
91 |
* When true items are resolved in this context both against the
|
|
92 |
* SELECT list and this->table_list. If false, items are resolved
|
|
93 |
* only against this->table_list.
|
|
94 |
*/
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
95 |
bool resolve_in_select_list; |
96 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
97 |
/**
|
98 |
* Security context of this name resolution context. It's used for views
|
|
99 |
* and is non-zero only if the view is defined with SQL SECURITY DEFINER.
|
|
100 |
*/
|
|
1273.11.1
by Dennis Schoen
rename class |
101 |
SecurityContext *security_ctx; |
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
102 |
|
103 |
Name_resolution_context() |
|
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
104 |
:
|
105 |
outer_context(0), |
|
106 |
table_list(0), |
|
107 |
select_lex(0), |
|
108 |
error_processor_data(0), |
|
109 |
security_ctx(0) |
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
110 |
{}
|
111 |
||
1055.2.23
by Jay Pipes
Doxygenates documentation for name_resolution_context.h |
112 |
inline void init() |
113 |
{
|
|
114 |
resolve_in_select_list= false; |
|
115 |
error_processor= &dummy_error_processor; |
|
116 |
first_name_resolution_table= NULL; |
|
117 |
last_name_resolution_table= NULL; |
|
118 |
}
|
|
119 |
||
120 |
inline void resolve_in_table_list_only(TableList *tables) |
|
121 |
{
|
|
122 |
table_list= first_name_resolution_table= tables; |
|
123 |
resolve_in_select_list= false; |
|
124 |
}
|
|
125 |
||
126 |
inline void process_error(Session *session) |
|
127 |
{
|
|
128 |
(*error_processor)(session, error_processor_data); |
|
129 |
}
|
|
584.4.4
by Monty Taylor
Split out Name_resolution_context. |
130 |
};
|
131 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
132 |
} /* namespace drizzled */ |
133 |