~ubuntu-branches/debian/squeeze/mysql-5.1/squeeze

« back to all changes in this revision

Viewing changes to sql/mysql_priv.h

  • Committer: Package Import Robot
  • Author(s): Moritz Muehlenhoff
  • Date: 2014-01-14 10:40:30 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140114104030-44alii0hx3x3g41y
Tags: 5.1.73-1
* New upstream release
  http://dev.mysql.com/doc/relnotes/mysql/5.1/en/news-5-1-73.html
* Update patches
* Disable flaky test rpl.rpl_innodb_bug28430 breaking the build. It's  marked
  as experimental by upstream and the internet is full of reports about it's
  unrelialibity

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
 
1
/*
 
2
   Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
/**
17
19
  @file
499
501
*/
500
502
#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
501
503
 
 
504
/*
 
505
  Check how many bytes are available on buffer.
 
506
 
 
507
  @param buf_start    Pointer to buffer start.
 
508
  @param buf_current  Pointer to the current position on buffer.
 
509
  @param buf_len      Buffer length.
 
510
 
 
511
  @return             Number of bytes available on event buffer.
 
512
*/
 
513
template <class T> T available_buffer(const char* buf_start,
 
514
                                      const char* buf_current,
 
515
                                      T buf_len)
 
516
{
 
517
  return buf_len - (buf_current - buf_start);
 
518
}
 
519
 
 
520
/*
 
521
  Check if jump value is within buffer limits.
 
522
 
 
523
  @param jump         Number of positions we want to advance.
 
524
  @param buf_start    Pointer to buffer start
 
525
  @param buf_current  Pointer to the current position on buffer.
 
526
  @param buf_len      Buffer length.
 
527
 
 
528
  @return      True   If jump value is within buffer limits.
 
529
               False  Otherwise.
 
530
*/
 
531
template <class T> bool valid_buffer_range(T jump,
 
532
                                           const char* buf_start,
 
533
                                           const char* buf_current,
 
534
                                           T buf_len)
 
535
{
 
536
  return (jump <= available_buffer(buf_start, buf_current, buf_len));
 
537
}
 
538
 
502
539
/* The rest of the file is included in the server only */
503
540
#ifndef MYSQL_CLIENT
504
541
 
566
603
 
567
604
#define MY_CHARSET_BIN_MB_MAXLEN 1
568
605
 
 
606
/*
 
607
  Flags below are set when we perform
 
608
  context analysis of the statement and make
 
609
  subqueries non-const. It prevents subquery
 
610
  evaluation at context analysis stage.
 
611
*/
 
612
 
 
613
/*
 
614
  Don't evaluate this subquery during statement prepare even if
 
615
  it's a constant one. The flag is switched off in the end of
 
616
  mysqld_stmt_prepare.
 
617
*/ 
 
618
#define CONTEXT_ANALYSIS_ONLY_PREPARE 1
 
619
/*
 
620
  Special JOIN::prepare mode: changing of query is prohibited.
 
621
  When creating a view, we need to just check its syntax omitting
 
622
  any optimizations: afterwards definition of the view will be
 
623
  reconstructed by means of ::print() methods and written to
 
624
  to an .frm file. We need this definition to stay untouched.
 
625
*/ 
 
626
#define CONTEXT_ANALYSIS_ONLY_VIEW    2
 
627
/*
 
628
  Don't evaluate this subquery during derived table prepare even if
 
629
  it's a constant one.
 
630
*/
 
631
#define CONTEXT_ANALYSIS_ONLY_DERIVED 4
 
632
 
569
633
// uncachable cause
570
634
#define UNCACHEABLE_DEPENDENT   1
571
635
#define UNCACHEABLE_RAND        2
572
636
#define UNCACHEABLE_SIDEEFFECT  4
573
637
/// forcing to save JOIN for explain
574
638
#define UNCACHEABLE_EXPLAIN     8
575
 
/** Don't evaluate subqueries in prepare even if they're not correlated */
576
 
#define UNCACHEABLE_PREPARE    16
577
639
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
578
 
#define UNCACHEABLE_UNITED     32
579
 
#define UNCACHEABLE_CHECKOPTION   64
 
640
#define UNCACHEABLE_UNITED     16
 
641
#define UNCACHEABLE_CHECKOPTION 32
580
642
 
581
643
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
582
644
#define UNDEF_POS (-1)
645
707
extern "C" THD *_current_thd_noinline();
646
708
#define _current_thd() _current_thd_noinline()
647
709
#else
 
710
/*
 
711
  THR_THD is a key which will be used to set/get THD* for a thread,
 
712
  using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
 
713
*/
648
714
extern pthread_key(THD*, THR_THD);
649
715
inline THD *_current_thd(void)
650
716
{
768
834
bool insert_precheck(THD *thd, TABLE_LIST *tables);
769
835
bool create_table_precheck(THD *thd, TABLE_LIST *tables,
770
836
                           TABLE_LIST *create_table);
771
 
int append_query_string(CHARSET_INFO *csinfo,
 
837
int append_query_string(THD *thd, CHARSET_INFO *csinfo,
772
838
                        String const *from, String *to);
773
839
 
774
840
void get_default_definer(THD *thd, LEX_USER *definer);
804
870
void sql_print_information(const char *format, ...)
805
871
  ATTRIBUTE_FORMAT(printf, 1, 2);
806
872
typedef void (*sql_print_message_func)(const char *format, ...)
807
 
  ATTRIBUTE_FORMAT(printf, 1, 2);
 
873
  ATTRIBUTE_FORMAT_FPTR(printf, 1, 2);
808
874
extern sql_print_message_func sql_print_message_handlers[];
809
875
 
810
876
int error_log_print(enum loglevel level, const char *format,
994
1060
bool check_mqh(THD *thd, uint check_command);
995
1061
void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
996
1062
void decrease_user_connections(USER_CONN *uc);
997
 
void thd_init_client_charset(THD *thd, uint cs_number);
 
1063
bool thd_init_client_charset(THD *thd, uint cs_number);
 
1064
inline bool is_supported_parser_charset(CHARSET_INFO *cs)
 
1065
{
 
1066
  return test(cs->mbminlen == 1);
 
1067
}
998
1068
bool setup_connection_thread_globals(THD *thd);
999
1069
 
1000
1070
int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
1024
1094
                         bool force_switch,
1025
1095
                         bool *cur_db_changed);
1026
1096
 
1027
 
void mysql_parse(THD *thd, const char *inBuf, uint length,
 
1097
void mysql_parse(THD *thd, char *rawbuf, uint length,
1028
1098
                 const char ** semicolon);
1029
1099
 
1030
1100
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
1047
1117
                      char* packet, uint packet_length);
1048
1118
void log_slow_statement(THD *thd);
1049
1119
bool check_dup(const char *db, const char *name, TABLE_LIST *tables);
1050
 
bool compare_record(TABLE *table);
 
1120
bool records_are_comparable(const TABLE *table);
 
1121
bool compare_records(const TABLE *table);
1051
1122
bool append_file_to_dir(THD *thd, const char **filename_ptr, 
1052
1123
                        const char *table_name);
1053
1124
void wait_while_table_is_used(THD *thd, TABLE *table,
1062
1133
void kill_mysql(void);
1063
1134
void close_connection(THD *thd, uint errcode, bool lock);
1064
1135
bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, 
1065
 
                          bool *write_to_binlog);
 
1136
                          int *write_to_binlog);
1066
1137
#ifndef NO_EMBEDDED_ACCESS_CHECKS
1067
1138
bool check_access(THD *thd, ulong access, const char *db, ulong *save_priv,
1068
1139
                  bool no_grant, bool no_errors, bool schema_db);
1225
1296
bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
1226
1297
uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
1227
1298
                          bool tmp_table);
 
1299
 
 
1300
/**
 
1301
  Create a table cache key for non-temporary table.
 
1302
 
 
1303
  @param key         Buffer for key (must be at least NAME_LEN*2+2 bytes).
 
1304
  @param db          Database name.
 
1305
  @param table_name  Table name.
 
1306
 
 
1307
  @return Length of key.
 
1308
 
 
1309
  @sa create_table_def_key(thd, char *, table_list, bool)
 
1310
*/
 
1311
 
 
1312
inline uint
 
1313
create_table_def_key(char *key, const char *db, const char *table_name)
 
1314
{
 
1315
  /*
 
1316
    In theory caller should ensure that both db and table_name are
 
1317
    not longer than NAME_LEN bytes. In practice we play safe to avoid
 
1318
    buffer overruns.
 
1319
  */
 
1320
  return (uint)(strmake(strmake(key, db, NAME_LEN) + 1, table_name,
 
1321
                        NAME_LEN) - key + 1);
 
1322
}
 
1323
 
1228
1324
TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
1229
1325
                             uint key_length, uint db_flags, int *error);
1230
1326
void release_table_share(TABLE_SHARE *share, enum release_type type);
1440
1536
extern Item **not_found_item;
1441
1537
 
1442
1538
/*
1443
 
  A set of constants used for checking non aggregated fields and sum
1444
 
  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
1445
 
*/
1446
 
#define NON_AGG_FIELD_USED  1
1447
 
#define SUM_FUNC_USED       2
1448
 
 
1449
 
/*
1450
1539
  This enumeration type is used only by the function find_item_in_list
1451
1540
  to return the info on how an item has been resolved against a list
1452
1541
  of possibly aliased items.
1529
1618
int decide_logging_format(THD *thd, TABLE_LIST *tables);
1530
1619
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
1531
1620
                            const char *table_name, bool link_in_list);
1532
 
bool rm_temporary_table(handlerton *base, char *path);
 
1621
bool rm_temporary_table(handlerton *base, const char *path);
1533
1622
void free_io_cache(TABLE *entry);
1534
1623
void intern_close_table(TABLE *entry);
1535
1624
bool close_thread_table(THD *thd, TABLE **table_ptr);
1915
2004
extern uint max_user_connections;
1916
2005
extern ulong what_to_log,flush_time;
1917
2006
extern ulong query_buff_size;
 
2007
extern ulong slave_max_allowed_packet;
1918
2008
extern ulong max_prepared_stmt_count, prepared_stmt_count;
1919
2009
extern ulong binlog_cache_size, open_files_limit;
1920
2010
extern ulonglong max_binlog_cache_size;
1935
2025
extern uint test_flags,select_errors,ha_open_options;
1936
2026
extern uint protocol_version, mysqld_port, dropping_tables;
1937
2027
extern uint delay_key_write_options;
 
2028
extern ulong max_long_data_size;
1938
2029
#endif /* MYSQL_SERVER */
1939
2030
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1940
2031
extern MYSQL_PLUGIN_IMPORT uint lower_case_table_names;
1991
2082
extern FILE *bootstrap_file;
1992
2083
extern int bootstrap_error;
1993
2084
extern FILE *stderror_file;
 
2085
/*
 
2086
  THR_MALLOC is a key which will be used to set/get MEM_ROOT** for a thread,
 
2087
  using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
 
2088
*/
1994
2089
extern pthread_key(MEM_ROOT**,THR_MALLOC);
1995
2090
extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
1996
2091
       LOCK_mapped_file,LOCK_user_locks, LOCK_status,
2332
2427
  return thd->lex->current_select->add_order_to_list(thd, item, asc);
2333
2428
}
2334
2429
 
 
2430
inline bool add_gorder_to_list(THD *thd, Item *item, bool asc)
 
2431
{
 
2432
  return thd->lex->current_select->add_gorder_to_list(thd, item, asc);
 
2433
}
 
2434
 
2335
2435
inline bool add_group_to_list(THD *thd, Item *item, bool asc)
2336
2436
{
2337
2437
  return thd->lex->current_select->add_group_to_list(thd, item, asc);