/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/* Functions to create an item. Used by sql/sql_yacc.yy */
#ifndef ITEM_CREATE_H
#define ITEM_CREATE_H
typedef struct st_udf_func udf_func;
/**
Public function builder interface.
The parser (sql/sql_yacc.yy) uses a factory / builder pattern to
construct an Item
object for each function call.
All the concrete function builders implements this interface,
either directly or indirectly with some adapter helpers.
Keeping the function creation separated from the bison grammar allows
to simplify the parser, and avoid the need to introduce a new token
for each function, which has undesirable side effects in the grammar.
*/
class Create_func
{
public:
/**
The builder create method.
Given the function name and list or arguments, this method creates
an Item
that represents the function call.
In case or errors, a NULL item is returned, and an error is reported.
Note that the thd
object may be modified by the builder.
In particular, the following members/methods can be set/called,
depending on the function called and the function possible side effects.
thd->lex->binlog_row_based_if_mixed
thd->lex->current_context()
thd->lex->safe_to_cache_query
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT)
thd->lex->uncacheable(UNCACHEABLE_RAND)
thd->lex->add_time_zone_tables_to_query_tables(thd)
db.func(expr, expr, ...)
.
*/
class Create_qfunc : public Create_func
{
public:
/**
The builder create method, for unqualified functions.
This builder will use the current database for the database name.
@param thd The current thread
@param name The function name
@param item_list The list of arguments to the function, can be NULL
@return An item representing the parsed function call
*/
virtual Item *create_func(THD *thd, LEX_STRING name, List