1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2010 Padraig O'Sullivan
|
|
5 |
*
|
|
6 |
* Authors:
|
|
7 |
*
|
|
8 |
* Padraig O'Sullivan <posullivan@akibainc.com>
|
|
9 |
*
|
|
10 |
* This program is free software; you can redistribute it and/or modify
|
|
11 |
* it under the terms of the GNU General Public License as published by
|
|
12 |
* the Free Software Foundation; version 2 of the License.
|
|
13 |
*
|
|
14 |
* This program is distributed in the hope that it will be useful,
|
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 |
* GNU General Public License for more details.
|
|
18 |
*
|
|
19 |
* You should have received a copy of the GNU General Public License
|
|
20 |
* along with this program; if not, write to the Free Software
|
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
22 |
*/
|
|
23 |
||
24 |
#include "config.h" |
|
25 |
#include "drizzled/plugin/query_rewrite.h" |
|
26 |
#include "drizzled/gettext.h" |
|
27 |
||
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
28 |
#include <algorithm> |
1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
29 |
#include <vector> |
30 |
||
31 |
namespace drizzled |
|
32 |
{
|
|
33 |
||
1307.1.3
by Padraig O'Sullivan
Updated based on review comments from Jay. Thanks Jay! |
34 |
namespace plugin |
35 |
{
|
|
36 |
||
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
37 |
std::vector<plugin::QueryRewriter *> all_rewriters; |
1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
38 |
|
39 |
||
1307.1.3
by Padraig O'Sullivan
Updated based on review comments from Jay. Thanks Jay! |
40 |
bool QueryRewriter::addPlugin(QueryRewriter *in_rewriter) |
1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
41 |
{
|
42 |
if (in_rewriter != NULL) |
|
43 |
{
|
|
44 |
all_rewriters.push_back(in_rewriter); |
|
45 |
}
|
|
46 |
return false; |
|
47 |
}
|
|
48 |
||
49 |
||
1307.1.3
by Padraig O'Sullivan
Updated based on review comments from Jay. Thanks Jay! |
50 |
void QueryRewriter::removePlugin(QueryRewriter *in_rewriter) |
1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
51 |
{
|
52 |
if (in_rewriter != NULL) |
|
53 |
{
|
|
1966.2.13
by Brian Aker
Fix for solaris find for std::find. |
54 |
all_rewriters.erase(std::find(all_rewriters.begin(), |
55 |
all_rewriters.end(), |
|
56 |
in_rewriter)); |
|
1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
57 |
}
|
58 |
}
|
|
59 |
||
60 |
||
61 |
/*
|
|
62 |
* This is the QueryRewriter::rewrite entry point.
|
|
63 |
* This gets called from within the Drizzle kernel.
|
|
64 |
*/
|
|
1975.1.3
by Monty Taylor
Fixed a silly mistake - string needed std:: |
65 |
void QueryRewriter::rewriteQuery(const std::string &schema, std::string &to_rewrite) |
1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
66 |
{
|
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
67 |
for (std::vector<plugin::QueryRewriter *>::iterator iter= all_rewriters.begin(); |
1307.1.4
by Padraig O'Sullivan
Stopped using bind2 for now because of build error on centos. |
68 |
iter != all_rewriters.end(); |
69 |
++iter) |
|
70 |
{
|
|
1971.4.2
by Padraig O'Sullivan
Some re-factoring based on feedback from Monty on IRC. |
71 |
(*iter)->rewrite(schema, to_rewrite); |
1307.1.4
by Padraig O'Sullivan
Stopped using bind2 for now because of build error on centos. |
72 |
}
|
1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
73 |
}
|
74 |
||
1307.1.3
by Padraig O'Sullivan
Updated based on review comments from Jay. Thanks Jay! |
75 |
} /* namespace plugin */ |
76 |
||
1307.1.1
by Padraig O'Sullivan
Added query rewrite interface and plugin point. |
77 |
} /* namespace drizzled */ |