2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/Exception.h>
|
|
|
|
#include <Interpreters/Context.h>
|
2017-01-21 04:24:28 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <TableFunctions/TableFunctionFactory.h>
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-11 21:46:36 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
extern const int READONLY;
|
|
|
|
extern const int UNKNOWN_FUNCTION;
|
2016-01-11 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
TableFunctionPtr TableFunctionFactory::get(
|
2017-04-01 07:20:54 +00:00
|
|
|
const std::string & name,
|
|
|
|
const Context & context) const
|
2014-01-28 16:45:10 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
if (context.getSettings().limits.readonly == 1) /** For example, for readonly = 2 - allowed. */
|
|
|
|
throw Exception("Table functions are forbidden in readonly mode", ErrorCodes::READONLY);
|
|
|
|
|
2017-06-10 09:04:31 +00:00
|
|
|
auto it = functions.find(name);
|
|
|
|
if (it == functions.end())
|
2017-04-01 07:20:54 +00:00
|
|
|
throw Exception("Unknown table function " + name, ErrorCodes::UNKNOWN_FUNCTION);
|
2017-06-10 09:04:31 +00:00
|
|
|
return it->second();
|
2014-01-28 16:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|