20#include <drizzled/item/num.h>
21#include <drizzled/abort_exception.h>
22#include <drizzled/error.h>
23#include <drizzled/nested_join.h>
24#include <drizzled/transaction_services.h>
25#include <drizzled/sql_parse.h>
26#include <drizzled/data_home.h>
27#include <drizzled/sql_base.h>
29#include <drizzled/function/time/unix_timestamp.h>
30#include <drizzled/function/get_system_var.h>
31#include <drizzled/item/cmpfunc.h>
32#include <drizzled/item/null.h>
33#include <drizzled/session.h>
34#include <drizzled/session/cache.h>
35#include <drizzled/sql_load.h>
36#include <drizzled/lock.h>
37#include <drizzled/select_send.h>
38#include <drizzled/plugin/client.h>
39#include <drizzled/statement.h>
40#include <drizzled/statement/alter_table.h>
41#include <drizzled/probes.h>
42#include <drizzled/charset.h>
43#include <drizzled/plugin/logging.h>
44#include <drizzled/plugin/query_rewrite.h>
45#include <drizzled/plugin/query_cache.h>
46#include <drizzled/plugin/authorization.h>
47#include <drizzled/optimizer/explain_plan.h>
48#include <drizzled/pthread_globals.h>
49#include <drizzled/plugin/event_observer.h>
50#include <drizzled/display.h>
52#include <drizzled/kill.h>
53#include <drizzled/schema.h>
54#include <drizzled/item/subselect.h>
55#include <drizzled/diagnostics_area.h>
56#include <drizzled/table_ident.h>
57#include <drizzled/statistics_variables.h>
58#include <drizzled/system_variables.h>
59#include <drizzled/session/times.h>
60#include <drizzled/session/transactions.h>
61#include <drizzled/create_field.h>
62#include <drizzled/lex_input_stream.h>
68#include <boost/date_time.hpp>
69#include <drizzled/internal/my_sys.h>
76bool my_yyoverflow(
short **a, ParserType **b, ulong *yystacksize);
84extern size_t my_thread_stack_size;
87static atomic<uint64_t> g_query_id;
91 static const std::string command_name[]=
105const char *xa_state_names[]=
107 "NON-EXISTING",
"ACTIVE",
"IDLE",
"PREPARED"
125const std::string &getCommandName(
const enum_server_command& command)
127 return command_name[command];
130void init_update_queries(
void)
132 for (uint32_t x= uint32_t(SQLCOM_SELECT);
133 x <= uint32_t(SQLCOM_END); x++)
193 DRIZZLE_COMMAND_START(session.thread_id, command);
195 session.command= command;
196 session.lex().sql_command= SQLCOM_END;
197 session.times.set_time();
198 session.setQueryId(g_query_id.increment());
200 if (command != COM_PING)
203 session.status_var.questions++;
208 plugin::Logging::preDo(&session);
209 if (DRIZZLE_UNLIKELY(plugin::EventObserver::beforeStatement(session)))
214 session.server_status&= ~(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED);
222 my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
225 if (not schema::change(session,
identifier::Schema(session.catalog().identifier(), packet)))
234 session.readAndStoreQuery(packet);
235 DRIZZLE_QUERY_START(session.getQueryString()->c_str(), session.thread_id, session.schema()->c_str());
236 parse(session, *session.getQueryString());
242 session.main_da().disable_status();
248 if (packet.size() != 4)
250 my_error(ER_NO_SUCH_THREAD, MYF(0), 0);
256 memcpy(&kill_id, packet.data(),
sizeof(uint32_t));
258 kill_id= ntohl(kill_id);
259 (void)drizzled::kill(*session.user(), kill_id,
true);
267 session.status_var.com_other++;
269 session.close_thread_tables();
276 session.status_var.com_other++;
284 my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
289 session.main_da().can_overwrite_status=
true;
291 session.main_da().can_overwrite_status=
false;
293 session.transaction.stmt.reset();
297 if (session.killed_errno())
299 if (not session.main_da().is_set())
300 session.send_kill_message();
302 if (session.getKilled() == Session::KILL_QUERY || session.getKilled() == Session::KILL_BAD_DATA)
304 session.setKilled(Session::NOT_KILLED);
305 session.setAbort(
false);
309 assert(not session.main_da().is_sent);
311 switch (session.main_da().status())
315 session.getClient()->sendError(session.main_da().sql_errno(), session.main_da().message());
319 session.getClient()->sendEOF();
323 session.getClient()->sendOK();
331 session.getClient()->sendOK();
334 session.main_da().is_sent=
true;
336 session.set_proc_info(
"closing tables");
338 session.close_thread_tables();
340 plugin::Logging::postDo(&session);
341 if (DRIZZLE_UNLIKELY(plugin::EventObserver::afterStatement(session)))
347 session.set_proc_info(
"cleaning up");
348 session.command= COM_SLEEP;
349 session.resetQueryString();
351 session.set_proc_info(NULL);
352 session.mem_root->free_root(MYF(memory::KEEP_PREALLOC));
354 if (DRIZZLE_QUERY_DONE_ENABLED() || DRIZZLE_COMMAND_DONE_ENABLED())
356 if (command == COM_QUERY)
358 DRIZZLE_QUERY_DONE(session.is_error());
360 DRIZZLE_COMMAND_DONE(session.is_error());
395 bitset<NUM_OF_TABLE_OPTIONS> table_options;
400 session.make_lex_string(&db, str_ref(
"data_dictionary"));
401 session.make_lex_string(&table, schema_table_name);
402 return not sel.add_table_to_list(&session,
new Table_ident(db, table), NULL, table_options, TL_READ);
405int prepare_new_schema_table(Session *session, LEX& lex0,
const string& schema_table_name)
407 Select_Lex& lex= *lex0.current_select;
410 TableList *table_list= (TableList*)lex.table_list.first;
411 table_list->schema_select_lex= NULL;
448 Select_Lex *select_lex= &session->lex().select_lex;
465 session->lex().first_lists_tables_same();
469 TableList* all_tables= session->lex().query_tables;
472 select_lex->context.resolve_in_table_list_only((
TableList*)select_lex->table_list.first);
481 if (all_tables || ! session->lex().is_single_level_stmt())
483 drizzle_reset_errors(*session, 0);
486 assert(not session->transaction.stmt.hasModifiedNonTransData());
488 if (not (session->server_status & SERVER_STATUS_AUTOCOMMIT)
489 && not session->inTransaction()
490 && session->lex().statement->isTransactional())
492 if (not session->startTransaction())
494 my_error(drizzled::ER_UNKNOWN_ERROR, MYF(0));
500 bool res= session->lex().statement->execute();
501 session->set_proc_info(
"query end");
508 if (not
sql_command_flags[session->lex().sql_command].test(CF_BIT_HAS_ROW_COUNT))
510 session->row_count_func= -1;
513 return res || session->is_error();
516bool execute_sqlcom_select(Session *session, TableList *all_tables)
518 LEX *lex= &session->lex();
519 select_result *result=lex->result;
523 Select_Lex *param= lex->unit.global_parameters;
524 if (!param->explicit_limit)
526 new Item_int((uint64_t) session->variables.select_limit);
530 && ! (session->server_status & SERVER_STATUS_AUTOCOMMIT)
531 && ! session->inTransaction()
532 && ! lex->statement->isShow())
534 if (not session->startTransaction())
536 my_error(drizzled::ER_UNKNOWN_ERROR, MYF(0));
541 if (not (res= session->openTablesLock(all_tables)))
552 session->send_explain_fields(result);
554 res= planner.explainUnion(session, &session->lex().unit, result);
555 if (lex->describe & DESCRIBE_EXTENDED)
558 String str(buff,(uint32_t)
sizeof(buff), system_charset_info);
560 session->lex().unit.print(&str);
562 push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
578 plugin::QueryCache::prepareResultset(session);
581 plugin::QueryCache::setResultset(session);
583 if (result != lex->result)
591#define MY_YACC_INIT 1000
592#define MY_YACC_MAX 32000
594bool my_yyoverflow(
short **yyss, ParserType **yyvs, ulong *yystacksize)
596 LEX *lex= ¤t_session->lex();
598 if ((uint32_t) *yystacksize >= MY_YACC_MAX)
601 old_info= *yystacksize;
602 *yystacksize= set_zone((*yystacksize)*2,MY_YACC_INIT,MY_YACC_MAX);
603 unsigned char *tmpptr= NULL;
604 if (!(tmpptr= (
unsigned char *)realloc(lex->yacc_yyvs,
605 *yystacksize*
sizeof(**yyvs))))
607 lex->yacc_yyvs= tmpptr;
609 if (!(tmpptr= (
unsigned char*)realloc(lex->yacc_yyss,
610 *yystacksize*
sizeof(**yyss))))
612 lex->yacc_yyss= tmpptr;
615 memcpy(lex->yacc_yyss, *yyss, old_info*
sizeof(**yyss));
616 memcpy(lex->yacc_yyvs, *yyvs, old_info*
sizeof(**yyvs));
618 *yyss=(
short*) lex->yacc_yyss;
619 *yyvs=(ParserType*) lex->yacc_yyvs;
627 Select_Lex *select_lex= lex->current_select;
628 select_lex->init_select();
630 if (select_lex == &lex->select_lex)
632 assert(lex->result == 0);
638bool new_select(LEX *lex,
bool move_down)
640 Session* session= lex->session;
641 Select_Lex* select_lex=
new (session->mem_root) Select_Lex;
644 select_lex->parent_lex= lex;
645 select_lex->init_query();
646 select_lex->init_select();
649 if (lex->nest_level > (
int) MAX_SELECT_NESTING)
651 my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT,MYF(0),MAX_SELECT_NESTING);
655 select_lex->nest_level= lex->nest_level;
659 Select_Lex_Unit* unit=
new (session->mem_root) Select_Lex_Unit();
663 unit->session= session;
664 unit->include_down(lex->current_select);
667 unit->return_to= lex->current_select;
668 select_lex->include_down(unit);
673 select_lex->context.outer_context= &select_lex->outer_select()->context;
677 if (lex->current_select->order_list.first && !lex->current_select->braces)
679 my_error(ER_WRONG_USAGE, MYF(0),
"UNION",
"order_st BY");
683 select_lex->include_neighbour(lex->current_select);
684 Select_Lex_Unit *unit= select_lex->master_unit();
686 if (not unit->fake_select_lex && unit->add_fake_select_lex(lex->session))
689 select_lex->context.outer_context= unit->first_select()->context.outer_context;
692 select_lex->master_unit()->global_parameters= select_lex;
693 select_lex->include_global((Select_Lex_Node**)&lex->all_selects_list);
694 lex->current_select= select_lex;
699 select_lex->context.resolve_in_select_list=
true;
716 LEX& lex= session->lex();
718 lex.sql_command= SQLCOM_SELECT;
720 tmp.assign(var_name, strlen(var_name));
725 if (
Item*
var= get_system_var(session, OPT_SESSION, tmp, null_lex_string()))
727 char buff[MAX_SYS_VAR_LENGTH*2+4+8];
729 end+= snprintf(buff,
sizeof(buff),
"@@session.%s", var_name);
730 var->set_name(buff, end-buff);
731 session->add_item_to_list(
var);
746 session.lex().start(&session);
747 session.reset_for_next_command();
752 if (plugin::QueryCache::isCached(&session) && not plugin::QueryCache::sendCachedResultset(&session))
755 if (parse_sql(&session, &lip))
756 assert(session.is_error());
757 else if (not session.is_error())
759 DRIZZLE_QUERY_EXEC_START(session.getQueryString()->c_str(), session.thread_id, session.schema()->c_str());
772 DRIZZLE_QUERY_EXEC_DONE(0);
774 session.lex().unit.cleanup();
775 session.set_proc_info(
"freeing items");
776 session.end_statement();
777 session.cleanup_after_query();
778 session.times.set_end_timer(session);
790 const char *length,
const char *decimals,
791 uint32_t type_modifier, column_format_type column_format,
792 Item *default_value,
Item *on_update_value, str_ref comment,
795 LEX *lex= &session->lex();
798 if (check_identifier_name(field_name, ER_TOO_LONG_IDENT))
801 if (type_modifier & PRI_KEY_FLAG)
804 statement->alter_info.key_list.push_back(
new Key(Key::PRIMARY, null_lex_string(), &default_key_create_info, 0, lex->col_list));
805 lex->col_list.clear();
807 if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG))
810 statement->alter_info.key_list.push_back(
new Key(Key::UNIQUE, null_lex_string(), &default_key_create_info, 0, lex->col_list));
811 lex->col_list.clear();
823 if (default_value->type() == Item::FUNC_ITEM &&
824 !(((
Item_func*)default_value)->functype() == Item_func::NOW_FUNC &&
825 (
type == DRIZZLE_TYPE_TIMESTAMP or
type == DRIZZLE_TYPE_MICROTIME)))
827 my_error(ER_INVALID_DEFAULT, MYF(0), field_name.data());
830 else if (default_value->type() == Item::NULL_ITEM)
833 if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG)
835 my_error(ER_INVALID_DEFAULT, MYF(0), field_name.data());
839 else if (type_modifier & AUTO_INCREMENT_FLAG)
841 my_error(ER_INVALID_DEFAULT, MYF(0), field_name.data());
846 if (on_update_value && (
type != DRIZZLE_TYPE_TIMESTAMP and
type != DRIZZLE_TYPE_MICROTIME))
848 my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name.data());
853 if (new_field->
init(session, field_name.data(),
type, length, decimals, type_modifier, comment, change, interval_list, cs, 0, column_format)
854 || new_field->setDefaultValue(default_value, on_update_value))
857 statement->alter_info.create_list.push_back(new_field);
858 lex->last_field=new_field;
883TableList *Select_Lex::add_table_to_list(Session *session,
886 const bitset<NUM_OF_TABLE_OPTIONS>& table_options,
887 thr_lock_type lock_type,
888 List<Index_hint> *index_hints_arg,
889 lex_string_t *option)
891 TableList *previous_table_ref;
892 LEX *lex= &session->lex();
896 const char* alias_str= alias ? alias->data() : table->table.data();
897 if (not table_options.test(TL_OPTION_ALIAS) && check_table_name(table->table))
899 my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.data());
903 if (not table->is_derived_table() && table->db.data())
905 files_charset_info->casedn_str(table->db.str_);
906 if (not schema::check(*session,
identifier::Schema(session->catalog().identifier(), table->db)))
908 my_error(ER_WRONG_DB_NAME, MYF(0), table->db.data());
917 my_message(ER_DERIVED_MUST_HAVE_ALIAS, ER(ER_DERIVED_MUST_HAVE_ALIAS), MYF(0));
920 alias_str= (
char*) session->mem.memdup(alias_str, table->table.size() + 1);
924 if (table->db.data())
926 ptr->setIsFqtn(
true);
927 ptr->setSchemaName(table->db.data());
931 str_ref schema = lex->session->copy_db_to();
934 ptr->setIsFqtn(
false);
935 ptr->setSchemaName(schema.data());
938 ptr->alias= alias_str;
939 ptr->setIsAlias(alias ?
true :
false);
940 ptr->setTableName(table->table.data());
941 ptr->lock_type= lock_type;
942 ptr->force_index= table_options.test(TL_OPTION_FORCE_INDEX);
943 ptr->ignore_leaves= table_options.test(TL_OPTION_IGNORE_LEAVES);
944 ptr->derived= table->sel;
945 ptr->select_lex= lex->current_select;
946 ptr->index_hints= index_hints_arg;
949 if (lock_type != TL_IGNORE)
954 if (not table_alias_charset->strcasecmp(alias_str, tables->alias) &&
955 not system_charset_info->strcasecmp(ptr->getSchemaName(), tables->getSchemaName()))
957 my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str);
963 if (table_list.size() > 0)
970 previous_table_ref= (
TableList*) ((
char*) table_list.next - ((
char*) &(ptr->next_local) - (
char*) ptr));
978 previous_table_ref->next_name_resolution_table= ptr;
987 table_list.link_in_list((
unsigned char*) ptr, (
unsigned char**) &ptr->next_local);
988 ptr->next_name_resolution_table= NULL;
990 lex->add_to_query_tables(ptr);
1014void Select_Lex::init_nested_join(
Session& session)
1017 ptr->setNestedJoin(((
NestedJoin*) ((
unsigned char*) ptr + ALIGN_SIZE(
sizeof(
TableList)))));
1018 NestedJoin* nested_join= ptr->getNestedJoin();
1019 join_list->push_front(ptr);
1020 ptr->setEmbedding(embedding);
1021 ptr->setJoinList(join_list);
1022 ptr->alias= (
char*)
"(nested_join)";
1024 join_list= &nested_join->join_list;
1047 join_list= ptr->getJoinList();
1048 embedding= ptr->getEmbedding();
1049 NestedJoin* nested_join= ptr->getNestedJoin();
1050 if (nested_join->join_list.size() == 1)
1054 embedded->setJoinList(join_list);
1055 embedded->setEmbedding(embedding);
1056 join_list->push_front(embedded);
1059 else if (not nested_join->join_list.size())
1084 ptr->setNestedJoin(((
NestedJoin*) ((
unsigned char*) ptr + ALIGN_SIZE(
sizeof(
TableList)))));
1085 NestedJoin* nested_join= ptr->getNestedJoin();
1086 ptr->setEmbedding(embedding);
1087 ptr->setJoinList(join_list);
1088 ptr->alias= (
char*)
"(nest_last_join)";
1090 embedded_list->clear();
1092 for (uint32_t i=0; i < 2; i++)
1095 table->setJoinList(embedded_list);
1096 table->setEmbedding(ptr);
1097 embedded_list->push_back(table);
1098 if (table->natural_join)
1100 ptr->is_natural_join=
true;
1105 if (prev_join_using)
1106 ptr->join_using_fields= prev_join_using;
1109 join_list->push_front(ptr);
1110 nested_join->used_tables= nested_join->not_null_tables= (table_map) 0;
1129void Select_Lex::add_joined_table(
TableList *table)
1131 join_list->push_front(table);
1132 table->setJoinList(join_list);
1133 table->setEmbedding(embedding);
1168TableList *Select_Lex::convert_right_join()
1173 join_list->push_front(tab2);
1174 join_list->push_front(tab1);
1191void Select_Lex::set_lock_for_tables(thr_lock_type lock_type)
1195 tables->lock_type= lock_type;
1226bool Select_Lex_Unit::add_fake_select_lex(
Session *session_arg)
1228 Select_Lex *first_sl= first_select();
1229 assert(!fake_select_lex);
1231 fake_select_lex=
new (session_arg->mem_root) Select_Lex();
1232 fake_select_lex->include_standalone(
this, (Select_Lex_Node**)&fake_select_lex);
1233 fake_select_lex->select_number= INT_MAX;
1234 fake_select_lex->parent_lex= &session_arg->lex();
1235 fake_select_lex->make_empty_select();
1236 fake_select_lex->linkage= GLOBAL_OPTIONS_TYPE;
1237 fake_select_lex->select_limit= 0;
1239 fake_select_lex->context.outer_context=first_sl->context.outer_context;
1241 fake_select_lex->context.resolve_in_select_list=
true;
1242 fake_select_lex->context.select_lex= fake_select_lex;
1252 global_parameters= fake_select_lex;
1253 fake_select_lex->no_table_names_allowed= 1;
1254 session_arg->lex().current_select= fake_select_lex;
1256 session_arg->lex().pop_context();
1284 on_context->first_name_resolution_table= left_op.first_leaf_for_name_resolution();
1285 on_context->last_name_resolution_table= right_op.last_leaf_for_name_resolution();
1286 session.lex().push_context(on_context);
1319 b->on_expr->top_level_item();
1361 lex->prev_join_using= using_fields;
1376 if (session->lex().current_select != &session->lex().select_lex)
1380 strncpy(command, lip->
yylval->symbol.str,
1381 min(lip->
yylval->symbol.length, (uint32_t)(
sizeof(command)-1)));
1382 command[min(lip->
yylval->symbol.length, (uint32_t)(
sizeof(command)-1))]=0;
1383 my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
1402 chooser_compare_func_creator cmp,
1404 Select_Lex *select_lex)
1406 if ((cmp == &comp_eq_creator) && !all)
1409 if ((cmp == &comp_ne_creator) && all)
1436 Select_Lex *select_lex= &session->lex().select_lex;
1438 if (session->lex().select_lex.item_list.size() != session->lex().value_list.size())
1440 my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
1444 if (session->lex().select_lex.table_list.size() > 1)
1446 if (select_lex->order_list.size())
1448 else if (select_lex->select_limit)
1452 my_error(ER_WRONG_USAGE, MYF(0),
"UPDATE", msg);
1478 if (session->lex().update_list.size() != session->lex().value_list.size())
1480 my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
1500 if (expr->type() == Item::FUNC_ITEM &&
1501 ((
Item_func *) expr)->functype() == Item_func::NOT_FUNC)
1505 enum_parsing_place place= session->lex().current_select->parsing_place;
1506 if (arg->is_bool_func() || place == IN_WHERE || place == IN_HAVING)
1515 if ((negated= expr->neg_transformer(session)) != 0)
1537bool check_string_char_length(str_ref str,
const char *err_msg,
1538 uint32_t max_char_length,
const charset_info_st *
const cs,
1541 int well_formed_error;
1542 uint32_t res= cs->cset->well_formed_len(*cs, str, max_char_length, &well_formed_error);
1544 if (!well_formed_error && str.size() == res)
1548 my_error(ER_WRONG_STRING_LENGTH, MYF(0), str.data(), err_msg, max_char_length);
1553bool check_identifier_name(str_ref str, error_t err_code)
1555 uint32_t max_char_length= NAME_CHAR_LEN;
1563 int well_formed_error;
1564 uint32_t res= cs->cset->well_formed_len(*cs, str, max_char_length, &well_formed_error);
1566 if (well_formed_error)
1568 my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
"identifier", str.data());
1572 if (str.size() == res)
1579 case ER_WRONG_STRING_LENGTH:
1580 my_error(err_code, MYF(0), str.data(),
"", max_char_length);
1582 case ER_TOO_LONG_IDENT:
1583 my_error(err_code, MYF(0), str.data());
bool init(Session *, const char *field_name, enum_field_types type, const char *length, const char *decimals, uint32_t type_modifier, str_ref comment, const char *change, List< String > *interval_list, const charset_info_st *, uint32_t uint_geom_type, column_format_type column_format)
uint32_t outer_join
Which join type.
List< TableList > * join_list
join list the table belongs to
static int autocommitOrRollback(Session &, int error)
bool handle_select(Session *session, LEX *lex, select_result *result, uint64_t setup_tables_done_option)
void parse(Session &, str_ref)
void create_select_for_variable(Session *session, const char *var_name)
bool insert_precheck(Session *session, TableList *)
bool check_simple_select(Session *session)
static bool _schema_select(Session &session, Select_Lex &sel, const string &schema_table_name)
bool add_field_to_list(Session *session, str_ref field_name, enum enum_field_types type, const char *length, const char *decimal, uint32_t type_modifier, enum column_format_type column_format, Item *default_value, Item *on_update_value, str_ref comment, const char *change, List< String > *interval_list, const charset_info_st *const cs)
bool update_precheck(Session *session, TableList *)
bitset< CF_BIT_SIZE > sql_command_flags[SQLCOM_END+1]
bool dispatch_command(enum_server_command command, Session &session, str_ref packet)
static int execute_command(Session *session)
Item * negate_expression(Session *session, Item *expr)
Item * all_any_subquery_creator(Item *left_expr, chooser_compare_func_creator cmp, bool all, Select_Lex *select_lex)
void add_join_natural(TableList *a, TableList *b, List< String > *using_fields, Select_Lex *lex)
Convert from decimal to binary representation.
TODO: Rename this file - func.h is stupid.
Visibility Control Macros.