svnno****@sourc*****
svnno****@sourc*****
2008年 6月 19日 (木) 12:32:06 JST
Revision: 154 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=tritonn&view=rev&rev=154 Author: mir Date: 2008-06-19 12:32:06 +0900 (Thu, 19 Jun 2008) Log Message: ----------- added table creation Modified Paths: -------------- trunk/src/ha_tritonn.cc -------------- next part -------------- Modified: trunk/src/ha_tritonn.cc =================================================================== --- trunk/src/ha_tritonn.cc 2008-06-18 08:49:59 UTC (rev 153) +++ trunk/src/ha_tritonn.cc 2008-06-19 03:32:06 UTC (rev 154) @@ -39,12 +39,12 @@ static void call_senna_ql(sen_ctx *ctx, const char *str); +static char *mysqltype2sennatype_string(enum_field_types types); + /* handlerton capability flags. see handler.h for more information */ static int tritonn_hton_flags = HTON_ALTER_NOT_SUPPORTED | HTON_CAN_RECREATE | HTON_TEMPORARY_NOT_SUPPORTED | HTON_NO_PARTITION; - - /* Variables for tritonn share methods */ static HASH tritonn_open_tables; ///< Hash used to track the number of open tables; variable for tritonn share methods pthread_mutex_t tritonn_mutex; ///< This is the mutex used to init the hash; variable for tritonn share methods @@ -335,17 +335,25 @@ DBUG_ENTER("ha_tritonn::create"); DBTN; //dump_create(name,table_arg,create_info); - char buf[200]; - my_snprintf(buf,200,"%s/tritonn.db",table_arg->s->db); + char buf[1024]; + my_snprintf(buf,1024,"%s/tritonn.db",table_arg->s->db); db = sen_db_open(buf); if (!db) { db = sen_db_create(buf,0,sen_enc_utf8); } ctx = sen_ctx_open(db,SEN_CTX_USEQL); - my_snprintf(buf,200,"(ptable '<%s>)",table_arg->s->table_name); + my_snprintf(buf,1024,"(ptable '<%s>)",table_arg->s->table_name); call_senna_ql(ctx,buf); - + int i; + for (i=0; i < table_arg->s->fields; i++) { + Field *field = table_arg->s->field[i]; + my_snprintf(buf,1024,"(<%s> ::def :%s <%s>)", + create_info->alias, + field->field_name, + mysqltype2sennatype_string(field->type())); + call_senna_ql(ctx,buf); + } sen_ctx_close(ctx); DBUG_RETURN(0); } @@ -527,3 +535,23 @@ } while (res_flags & SEN_CTX_MORE); free(ql); } + +static char *mysqltype2sennatype_string(enum_field_types types) +{ + switch(types) { + case MYSQL_TYPE_TINY: + case MYSQL_TYPE_SHORT: + case MYSQL_TYPE_INT24: + case MYSQL_TYPE_LONG: + return "int"; + case MYSQL_TYPE_FLOAT: + case MYSQL_TYPE_DOUBLE: + return "float"; + case MYSQL_TYPE_STRING: + case MYSQL_TYPE_VAR_STRING: + case MYSQL_TYPE_VARCHAR: + return "text"; + default: + return "null"; + } +}