1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

MWL#43 CREATE TABLE options (by Sanja)

Docs/sp-imp-spec.txt:
  New sql_mode added.
include/my_base.h:
  Flag in frm of create options.
libmysqld/CMakeLists.txt:
  New files added.
libmysqld/Makefile.am:
  New files added.
mysql-test/r/events_bugs.result:
  New sql_mode added.
mysql-test/r/information_schema.result:
  New sql_mode added.
mysql-test/r/sp.result:
  New sql_mode added.
mysql-test/r/system_mysql_db.result:
  New sql_mode added.
mysql-test/suite/funcs_1/r/is_columns_mysql.result:
  New sql_mode added.
mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result:
  New sql_mode added.
mysql-test/t/events_bugs.test:
  New sql_mode added.
mysql-test/t/sp.test:
  New sql_mode added.
scripts/mysql_system_tables.sql:
  New sql_mode added.
scripts/mysql_system_tables_fix.sql:
  New sql_mode added.
sql/CMakeLists.txt:
  New files added.
sql/Makefile.am:
  New files added.
sql/event_db_repository.cc:
  New sql_mode added.
sql/field.cc:
  Create options support added.
sql/field.h:
  Create options support added.
sql/ha_partition.cc:
  Create options support added.
sql/handler.cc:
  Create options support added.
sql/handler.h:
  Create options support added.
sql/log_event.h:
  New sql_mode added.
sql/mysql_priv.h:
  New sql_mode added.
sql/mysqld.cc:
  New sql_mode added.
sql/share/errmsg.txt:
  New error messages added.
sql/sp.cc:
  New sql_mode added.
sql/sp_head.cc:
  Create options support added.
sql/sql_class.cc:
  Create options support added.
  Debug added.
sql/sql_class.h:
  Create options support added.
sql/sql_insert.cc:
  my_safe_a* moved to mysqld_priv.h
sql/sql_lex.h:
  Create options support added.
sql/sql_parse.cc:
  Create options support added.
sql/sql_show.cc:
  Create options support added.
sql/sql_table.cc:
  Create options support added.
sql/sql_view.cc:
  New sql_mode added.
sql/sql_yacc.yy:
  Create options support added.
sql/structs.h:
  Create options support added.
sql/table.cc:
  Create options support added.
sql/table.h:
  Create options support added.
sql/unireg.cc:
  Create options support added.
storage/example/ha_example.cc:
  Create options example.
storage/example/ha_example.h:
  Create options example.
storage/pbxt/src/discover_xt.cc:
  Create options support added.
This commit is contained in:
Sergei Golubchik
2010-04-08 14:10:05 +02:00
parent 8e122db92d
commit e24e1668bc
52 changed files with 1701 additions and 168 deletions

View File

@@ -16,6 +16,9 @@
/* Definitions for parameters to do with handler-routines */
#ifndef SQL_HANDLER_INCLUDED
#define SQL_HANDLER_INCLUDED
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
@@ -549,6 +552,103 @@ struct handler_log_file_data {
enum log_status status;
};
/*
Definitions for engine-specific table/field/index options in the CREATE TABLE.
Options are declared with HA_*OPTION_* macros (HA_TOPTION_ULL, HA_FOPTION_ENUM,
HA_KOPTION_STRING, etc).
Every macros takes the option name, and the name of the underlying field of
the appropriate C structure. The "appropriate C structure" is
ha_table_option_struct for table level options,
ha_field_option_struct for field level options,
ha_key_option_struct for key level options. The engine either
defines a structure of this name, or uses #define's to map
these "appropriate" names to the actual structure type name.
ULL options use a ulonglong as the backing store.
HA_*OPTION_ULL() takes the option name, the structure field name,
the default value for the option, min, max, and blk_siz values.
STRING options use a char* as a backing store.
HA_*OPTION_STRING takes the option name and the structure field name.
The default value will be 0.
ENUM options use a uint as a backing store (not enum!!!).
HA_*OPTION_ENUM takes the option name, the structure field name,
the default value for the option as a number, and a string with the
permitted values for this enum - one string with comma separated values,
for example: "gzip,bzip2,lzma"
BOOL options use a bool as a backing store.
HA_*OPTION_BOOL takes the option name, the structure field name,
and the default value for the option.
From the SQL, BOOL options accept YES/NO, ON/OFF, and 1/0.
The name of the option is limited to 255 bytes,
the value (for string options) - to the 32767 bytes.
See ha_example.cc for an example.
*/
enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */
HA_OPTION_TYPE_STRING, /* char * */
HA_OPTION_TYPE_ENUM, /* uint */
HA_OPTION_TYPE_BOOL}; /* bool */
#define HA_xOPTION_ULL(name, struc, field, def, min, max, blk_siz) \
{ HA_OPTION_TYPE_ULL, name, sizeof(name)-1, \
offsetof(struc, field), def, min, max, blk_siz, 0 }
#define HA_xOPTION_STRING(name, struc, field) \
{ HA_OPTION_TYPE_STRING, name, sizeof(name)-1, \
offsetof(struc, field), 0, 0, 0, 0, 0 }
#define HA_xOPTION_ENUM(name, struc, field, values, def) \
{ HA_OPTION_TYPE_ENUM, name, sizeof(name)-1, \
offsetof(struc, field), def, 0, \
sizeof(values)-1, 0, values }
#define HA_xOPTION_BOOL(name, struc, field, def) \
{ HA_OPTION_TYPE_BOOL, name, sizeof(name)-1, \
offsetof(struc, field), def, 0, 1, 0, 0 }
#define HA_xOPTION_END { HA_OPTION_TYPE_ULL, 0, 0, 0, 0, 0, 0, 0, 0 }
#define HA_TOPTION_ULL(name, field, def, min, max, blk_siz) \
HA_xOPTION_ULL(name, ha_table_option_struct, field, def, min, max, blk_siz)
#define HA_TOPTION_STRING(name, field) \
HA_xOPTION_STRING(name, ha_table_option_struct, field)
#define HA_TOPTION_ENUM(name, field, values, def) \
HA_xOPTION_ENUM(name, ha_table_option_struct, field, values, def)
#define HA_TOPTION_BOOL(name, field, def) \
HA_xOPTION_BOOL(name, ha_table_option_struct, field, def)
#define HA_TOPTION_END HA_xOPTION_END
#define HA_FOPTION_ULL(name, field, def, min, max, blk_siz) \
HA_xOPTION_ULL(name, ha_field_option_struct, field, def, min, max, blk_siz)
#define HA_FOPTION_STRING(name, field) \
HA_xOPTION_STRING(name, ha_field_option_struct, field)
#define HA_FOPTION_ENUM(name, field, values, def) \
HA_xOPTION_ENUM(name, ha_field_option_struct, field, values, def)
#define HA_FOPTION_BOOL(name, field, def) \
HA_xOPTION_BOOL(name, ha_field_option_struct, field, def)
#define HA_FOPTION_END HA_xOPTION_END
#define HA_KOPTION_ULL(name, field, def, min, max, blk_siz) \
HA_xOPTION_ULL(name, ha_key_option_struct, field, def, min, max, blk_siz)
#define HA_KOPTION_STRING(name, field) \
HA_xOPTION_STRING(name, ha_key_option_struct, field)
#define HA_KOPTION_ENUM(name, field, values, def) \
HA_xOPTION_ENUM(name, ha_key_option_struct, field, values, def)
#define HA_KOPTION_BOOL(name, field, values, def) \
HA_xOPTION_BOOL(name, ha_key_option_struct, field, values, def)
#define HA_KOPTION_END HA_xOPTION_END
typedef struct st_ha_create_table_option {
enum ha_option_type type;
const char *name;
size_t name_length;
ptrdiff_t offset;
ulonglong def_value;
ulonglong min_value, max_value, block_size;
const char *values;
} ha_create_table_option;
enum handler_iterator_type
{
@@ -721,7 +821,13 @@ struct handlerton
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
const char *name);
uint32 license; /* Flag for Engine License */
void *data; /* Location for engines to keep personal structures */
/*
Optional clauses in the CREATE/ALTER TABLE
*/
ha_create_table_option *table_options; // table level options
ha_create_table_option *field_options; // these are specified per field
ha_create_table_option *index_options; // these are specified per index
};
@@ -945,11 +1051,16 @@ typedef struct st_ha_create_information
uint extra_size; /* length of extra data segment */
/** Transactional or not. Unused; reserved for future versions. */
enum ha_choice transactional;
bool table_existed; /* 1 in create if table existed */
bool frm_only; /* 1 if no ha_create_table() */
bool varchar; /* 1 if table has a VARCHAR */
enum ha_storage_media storage_media; /* DEFAULT, DISK or MEMORY */
enum ha_choice page_checksum; /* If we have page_checksums */
bool table_existed; ///< 1 in create if table existed
bool frm_only; ///< 1 if no ha_create_table()
bool varchar; ///< 1 if table has a VARCHAR
enum ha_storage_media storage_media; ///< DEFAULT, DISK or MEMORY
enum ha_choice page_checksum; ///< If we have page_checksums
engine_option_value *option_list; ///< list of table create options
/* the following three are only for ALTER TABLE, check_if_incompatible_data() */
void *option_struct; ///< structure with parsed table options
void **fileds_option_struct; ///< array of field option structures
void **keys_option_struct; ///< array of key option structures
} HA_CREATE_INFO;
@@ -2255,3 +2366,5 @@ int ha_binlog_end(THD *thd);
#define ha_binlog_wait(a) do {} while (0)
#define ha_binlog_end(a) do {} while (0)
#endif
#endif