summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2010-04-08 14:10:05 +0200
committerSergei Golubchik <sergii@pisem.net>2010-04-08 14:10:05 +0200
commite24e1668bc112afe4b4f6b3dc4d5b8d10635f60b (patch)
tree9c586042547cc441792db76369ef92eaa7deb47c /sql/unireg.cc
parent8e122db92d0a60670e421903c32213524cd54fdf (diff)
downloadmariadb-git-e24e1668bc112afe4b4f6b3dc4d5b8d10635f60b.tar.gz
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.
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 78d375e663a..3a153277337 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -24,11 +24,15 @@
*/
#include "mysql_priv.h"
+#include "create_options.h"
#include <m_ctype.h>
#include <assert.h>
#define FCOMP 17 /* Bytes for a packed field */
+/* threshold for safe_alloca */
+#define ALLOCA_THRESHOLD 2048
+
static uchar * pack_screens(List<Create_field> &create_fields,
uint *info_length, uint *screens, bool small_file);
static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info,
@@ -107,6 +111,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
ulong key_buff_length;
File file;
ulong filepos, data_offset;
+ uint options_len;
uchar fileinfo[64],forminfo[288],*keybuff;
TYPELIB formnames;
uchar *screen_buff;
@@ -183,6 +188,16 @@ bool mysql_create_frm(THD *thd, const char *file_name,
create_info->extra_size+= key_info[i].parser_name->length + 1;
}
+ options_len= engine_table_options_frm_length(create_info->option_list,
+ create_fields,
+ keys, key_info);
+ DBUG_PRINT("info", ("Options length: %u", options_len));
+ if (options_len)
+ {
+ create_info->table_options|= HA_OPTION_TEXT_CREATE_OPTIONS;
+ create_info->extra_size+= (options_len + 4);
+ }
+
if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo,
create_info, keys)) < 0)
{
@@ -294,6 +309,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
if (my_write(file, (uchar*) buff, 6, MYF_RW))
goto err;
}
+
for (i= 0; i < keys; i++)
{
if (key_info[i].parser_name)
@@ -304,6 +320,24 @@ bool mysql_create_frm(THD *thd, const char *file_name,
}
}
+ if (options_len)
+ {
+ uchar *optbuff= (uchar *)my_safe_alloca(options_len + 4, ALLOCA_THRESHOLD);
+ my_bool error;
+ DBUG_PRINT("info", ("Create options length: %u", options_len));
+ if (!optbuff)
+ goto err;
+ int4store(optbuff, options_len);
+ engine_table_options_frm_image(optbuff + 4,
+ create_info->option_list,
+ create_fields,
+ keys, key_info);
+ error= my_write(file, optbuff, options_len + 4, MYF_RW);
+ my_safe_afree(optbuff, options_len + 4, ALLOCA_THRESHOLD);
+ if (error)
+ goto err;
+ }
+
VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
if (my_write(file, forminfo, 288, MYF_RW) ||
my_write(file, screen_buff, info_length, MYF_RW) ||