390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
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.
|
390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
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 |
||
353
by Brian Aker
Moved Field iterator out to its own definition. |
20 |
|
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
21 |
#pragma once
|
353
by Brian Aker
Moved Field iterator out to its own definition. |
22 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
23 |
#include <drizzled/memory/sql_alloc.h> |
520.8.6
by Monty Taylor
Removed handler from common_includes. |
24 |
#include <drizzled/sql_list.h> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
25 |
#include <drizzled/natural_join_column.h> |
2198.1.2
by Olaf van der Spek
Refactor includes |
26 |
#include <drizzled/item/field.h> |
520.8.6
by Monty Taylor
Removed handler from common_includes. |
27 |
|
2198.1.2
by Olaf van der Spek
Refactor includes |
28 |
namespace drizzled { |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
29 |
|
353
by Brian Aker
Moved Field iterator out to its own definition. |
30 |
class Table; |
31 |
class TableList; |
|
32 |
||
33 |
/*
|
|
34 |
Iterator over the fields of a generic table reference.
|
|
35 |
*/
|
|
36 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
37 |
class Field_iterator: public memory::SqlAlloc |
353
by Brian Aker
Moved Field iterator out to its own definition. |
38 |
{
|
39 |
public: |
|
40 |
Field_iterator() {} /* Remove gcc warning */ |
|
41 |
virtual ~Field_iterator() {} |
|
42 |
virtual void set(TableList *)= 0; |
|
43 |
virtual void next()= 0; |
|
44 |
virtual bool end_of_fields()= 0; /* Return 1 at end of list */ |
|
45 |
virtual const char *name()= 0; |
|
520.1.21
by Brian Aker
THD -> Session rename |
46 |
virtual Item *create_item(Session *)= 0; |
353
by Brian Aker
Moved Field iterator out to its own definition. |
47 |
virtual Field *field()= 0; |
48 |
};
|
|
49 |
||
50 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
51 |
/*
|
353
by Brian Aker
Moved Field iterator out to its own definition. |
52 |
Iterator over the fields of a base table, view with temporary
|
53 |
table, or subquery.
|
|
54 |
*/
|
|
55 |
||
56 |
class Field_iterator_table: public Field_iterator |
|
57 |
{
|
|
58 |
Field **ptr; |
|
59 |
public: |
|
60 |
Field_iterator_table() :ptr(0) {} |
|
61 |
void set(TableList *table); |
|
62 |
void set_table(Table *table); |
|
63 |
void next() { ptr++; } |
|
64 |
bool end_of_fields() { return *ptr == 0; } |
|
65 |
const char *name(); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
66 |
Item *create_item(Session *session); |
353
by Brian Aker
Moved Field iterator out to its own definition. |
67 |
Field *field() { return *ptr; } |
68 |
};
|
|
69 |
||
70 |
||
71 |
/* Iterator over the fields of a merge view. */
|
|
72 |
||
73 |
/*
|
|
74 |
Field_iterator interface to the list of materialized fields of a
|
|
75 |
NATURAL/USING join.
|
|
76 |
*/
|
|
77 |
||
78 |
class Field_iterator_natural_join: public Field_iterator |
|
79 |
{
|
|
2183.2.2
by Olaf van der Spek
x |
80 |
List<Natural_join_column>::iterator column_ref_it; |
353
by Brian Aker
Moved Field iterator out to its own definition. |
81 |
Natural_join_column *cur_column_ref; |
82 |
public: |
|
83 |
Field_iterator_natural_join() :cur_column_ref(NULL) {} |
|
84 |
~Field_iterator_natural_join() {} |
|
85 |
void set(TableList *table); |
|
86 |
void next(); |
|
87 |
bool end_of_fields() { return !cur_column_ref; } |
|
88 |
const char *name() { return cur_column_ref->name(); } |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
89 |
Item *create_item(Session *session) { return cur_column_ref->create_item(session); } |
353
by Brian Aker
Moved Field iterator out to its own definition. |
90 |
Field *field() { return cur_column_ref->field(); } |
91 |
Natural_join_column *column_ref() { return cur_column_ref; } |
|
92 |
};
|
|
93 |
||
94 |
||
95 |
/*
|
|
96 |
Generic iterator over the fields of an arbitrary table reference.
|
|
97 |
||
98 |
DESCRIPTION
|
|
99 |
This class unifies the various ways of iterating over the columns
|
|
100 |
of a table reference depending on the type of SQL entity it
|
|
101 |
represents. If such an entity represents a nested table reference,
|
|
102 |
this iterator encapsulates the iteration over the columns of the
|
|
103 |
members of the table reference.
|
|
104 |
||
105 |
IMPLEMENTATION
|
|
106 |
The implementation assumes that all underlying NATURAL/USING table
|
|
107 |
references already contain their result columns and are linked into
|
|
108 |
the list TableList::next_name_resolution_table.
|
|
109 |
*/
|
|
110 |
||
111 |
class Field_iterator_table_ref: public Field_iterator |
|
112 |
{
|
|
113 |
TableList *table_ref, *first_leaf, *last_leaf; |
|
114 |
Field_iterator_table table_field_it; |
|
115 |
Field_iterator_natural_join natural_join_it; |
|
116 |
Field_iterator *field_it; |
|
117 |
void set_field_iterator(); |
|
118 |
public: |
|
119 |
Field_iterator_table_ref() :field_it(NULL) {} |
|
120 |
void set(TableList *table); |
|
121 |
void next(); |
|
122 |
bool end_of_fields() |
|
123 |
{ return (table_ref == last_leaf && field_it->end_of_fields()); } |
|
124 |
const char *name() { return field_it->name(); } |
|
125 |
const char *table_name(); |
|
126 |
const char *db_name(); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
127 |
Item *create_item(Session *session) { return field_it->create_item(session); } |
353
by Brian Aker
Moved Field iterator out to its own definition. |
128 |
Field *field() { return field_it->field(); } |
129 |
Natural_join_column *get_or_create_column_ref(TableList *parent_table_ref); |
|
130 |
Natural_join_column *get_natural_column_ref(); |
|
131 |
};
|
|
132 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
133 |
} /* namespace drizzled */ |
353
by Brian Aker
Moved Field iterator out to its own definition. |
134 |