Drizzled Public API Documentation

common.h

00001 /* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 /*
00021 ** Common definition between mysql server & client
00022 */
00023 
00024 #pragma once
00025 
00026 #include <unistd.h>
00027 #include <stdint.h>
00028 #include <drizzled/korr.h>
00029 
00030 /*
00031    This is included in the server and in the client.
00032    Options for select set by the yacc parser (stored in lex->options).
00033 
00034    XXX:
00035    log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
00036    options list are written into binlog. These options can NOT change their
00037    values, or it will break replication between version.
00038 
00039    context is encoded as following:
00040    SELECT - Select_Lex_Node::options
00041    THD    - THD::options
00042    intern - neither. used only as
00043             func(..., select_node->options | thd->options | OPTION_XXX, ...)
00044 
00045    TODO: separate three contexts above, move them to separate bitfields.
00046 */
00047 
00048 #define SELECT_DISTINCT         (UINT64_C(1) << 0)     // SELECT, user
00049 #define SELECT_STRAIGHT_JOIN    (UINT64_C(1) << 1)     // SELECT, user
00050 #define SELECT_DESCRIBE         (UINT64_C(1) << 2)     // SELECT, user
00051 #define SELECT_SMALL_RESULT     (UINT64_C(1) << 3)     // SELECT, user
00052 #define SELECT_BIG_RESULT       (UINT64_C(1) << 4)     // SELECT, user
00053 #define OPTION_FOUND_ROWS       (UINT64_C(1) << 5)     // SELECT, user
00054 #define SELECT_NO_JOIN_CACHE    (UINT64_C(1) << 7)     // intern
00055 #define OPTION_BIG_TABLES       (UINT64_C(1) << 8)     // THD, user
00056 #define OPTION_BIG_SELECTS      (UINT64_C(1) << 9)     // THD, user
00057 #define TMP_TABLE_ALL_COLUMNS   (UINT64_C(1) << 12)    // SELECT, intern
00058 #define OPTION_WARNINGS         (UINT64_C(1) << 13)    // THD, user
00059 #define OPTION_AUTO_IS_NULL     (UINT64_C(1) << 14)    // THD, user, binlog
00060 #define OPTION_FOUND_COMMENT    (UINT64_C(1) << 15)    // SELECT, intern, parser
00061 #define OPTION_BUFFER_RESULT    (UINT64_C(1) << 17)    // SELECT, user
00062 #define OPTION_NOT_AUTOCOMMIT   (UINT64_C(1) << 19)    // THD, user
00063 #define OPTION_BEGIN            (UINT64_C(1) << 20)    // THD, intern
00064 
00065 /* The following is used to detect a conflict with DISTINCT */
00066 #define SELECT_ALL              (UINT64_C(1) << 24)    // SELECT, user, parser
00067 
00070 #define OPTION_NO_FOREIGN_KEY_CHECKS    (UINT64_C(1) << 26) // THD, user, binlog
00071 
00073 #define OPTION_RELAXED_UNIQUE_CHECKS    (UINT64_C(1) << 27) // THD, user, binlog
00074 #define SELECT_NO_UNLOCK                (UINT64_C(1) << 28) // SELECT, intern
00075 
00076 #define OPTION_SETUP_TABLES_DONE        (UINT64_C(1) << 30) // intern
00077 
00078 #define OPTION_SQL_NOTES                (UINT64_C(1) << 31) // THD, user
00079 
00084 #define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
00085 
00086 #define HOSTNAME_LENGTH 60
00087 #define SYSTEM_CHARSET_MBMAXLEN 4
00088 #define USERNAME_CHAR_LENGTH 16
00089 #define NAME_CHAR_LEN 64              /* Field/table name length */
00090 #define NAME_LEN                (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
00091 #define MAXIMUM_IDENTIFIER_LENGTH NAME_LEN
00092 #define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
00093 
00094 #define SERVER_VERSION_LENGTH 60
00095 #define SQLSTATE_LENGTH 5
00096 
00097 /*
00098   USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
00099   username and hostname parts of the user identifier with trailing zero in
00100   MySQL standard format:
00101   user_name_part@host_name_part\0
00102 */
00103 #define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
00104 
00105 /*
00106   You should add new commands to the end of this list, otherwise old
00107   servers won't be able to handle them as 'unsupported'.
00108 */
00109 
00110 /*
00111   Length of random string sent by server on handshake; this is also length of
00112   obfuscated password, recieved from client
00113 */
00114 #define SCRAMBLE_LENGTH 20
00115 #define SCRAMBLE_LENGTH_323 8
00116 
00117 #define NOT_NULL_FLAG 1   /* Field can't be NULL */
00118 #define PRI_KEY_FLAG  2   /* Field is part of a primary key */
00119 #define UNIQUE_KEY_FLAG 4   /* Field is part of a unique key */
00120 #define MULTIPLE_KEY_FLAG 8   /* Field is part of a key */
00121 #define BLOB_FLAG 16    /* Field is a blob */
00122 #define UNSIGNED_FLAG 32    /* Field is unsigned */
00123 #define BINARY_FLAG 128   /* Field is binary   */
00124 
00125 /* The following are only sent to new clients */
00126 #define ENUM_FLAG 256   /* field is an enum */
00127 #define AUTO_INCREMENT_FLAG 512   /* field is a autoincrement field */
00128 #define FUNCTION_DEFAULT_FLAG 1024    /* Field is a timestamp, uses a function to generate the value. */
00129 #define NO_DEFAULT_VALUE_FLAG 4096  /* Field doesn't have default value */
00130 #define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
00131 #define PART_KEY_FLAG 16384   /* Intern; Part of some key */
00132 #define GROUP_FLAG  32768   /* Intern: Group field */
00133 #define UNIQUE_FLAG 65536   /* Intern: Used by sql_yacc */
00134 #define BINCMP_FLAG 131072    /* Intern: Used by sql_yacc */
00135 #define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
00136 #define COLUMN_FORMAT_MASK 7
00137 
00138 #define SERVER_STATUS_IN_TRANS     1  /* Transaction has started */
00139 #define SERVER_STATUS_AUTOCOMMIT   2  /* Server in auto_commit mode */
00140 #define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
00141 #define SERVER_QUERY_NO_GOOD_INDEX_USED 16
00142 #define SERVER_QUERY_NO_INDEX_USED      32
00143 #define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
00144 
00145 #define DRIZZLE_ERRMSG_SIZE 512
00146 
00147 #define ONLY_KILL_QUERY         1
00148 
00149 #define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
00150 #define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
00151 #define MAX_BLOB_WIDTH    (uint32_t)16777216  /* Default width for blob */
00152 
00153 #define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
00154 
00155 
00156 
00157 
00158 #define packet_error UINT32_MAX
00159 
00160 #if defined(__cplusplus)
00161 
00162 namespace drizzled
00163 {
00164 
00165 enum enum_server_command
00166 {
00167   COM_SLEEP,
00168   COM_QUIT,
00169   COM_INIT_DB,
00170   COM_QUERY,
00171   COM_SHUTDOWN,
00172   COM_CONNECT,
00173   COM_PING,
00174   COM_KILL,
00175   /* don't forget to update const char *command_name[] in sql_parse.cc */
00176   /* Must be last */
00177   COM_END
00178 };
00179 
00180 
00181 enum enum_field_types { 
00182                         DRIZZLE_TYPE_LONG,
00183                         DRIZZLE_TYPE_DOUBLE,
00184                         DRIZZLE_TYPE_NULL,
00185                         DRIZZLE_TYPE_TIMESTAMP,
00186                         DRIZZLE_TYPE_LONGLONG,
00187                         DRIZZLE_TYPE_DATETIME,
00188                         DRIZZLE_TYPE_DATE,
00189                         DRIZZLE_TYPE_VARCHAR,
00190                         DRIZZLE_TYPE_DECIMAL,
00191                         DRIZZLE_TYPE_ENUM,
00192                         DRIZZLE_TYPE_BLOB,
00193                         DRIZZLE_TYPE_TIME,
00194                         DRIZZLE_TYPE_BOOLEAN,
00195                         DRIZZLE_TYPE_UUID,
00196                         DRIZZLE_TYPE_MICROTIME
00197 };
00198 const int enum_field_types_size= DRIZZLE_TYPE_MICROTIME + 1;
00199 
00200 } /* namespace drizzled */
00201 
00202 #endif /* defined(__cplusplus) */
00203