mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Add support for Gemini table handler, Monty has checked and approved
Fix bug when read return error
This commit is contained in:
@@ -35,6 +35,9 @@
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#include "ha_innobase.h"
|
||||
#endif
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
#include "ha_gemini.h"
|
||||
#endif
|
||||
#include <myisampack.h>
|
||||
#include <errno.h>
|
||||
|
||||
@@ -49,7 +52,7 @@ ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
|
||||
|
||||
const char *ha_table_type[] = {
|
||||
"", "DIAB_ISAM","HASH","MISAM","PISAM","RMS_ISAM","HEAP", "ISAM",
|
||||
"MRG_ISAM","MYISAM", "MRG_MYISAM", "BDB", "INNOBASE", "?", "?",NullS
|
||||
"MRG_ISAM","MYISAM", "MRG_MYISAM", "BDB", "INNOBASE", "GEMINI", "?", "?",NullS
|
||||
};
|
||||
|
||||
const char *ha_row_type[] = {
|
||||
@@ -77,6 +80,10 @@ enum db_type ha_checktype(enum db_type database_type)
|
||||
case DB_TYPE_INNOBASE:
|
||||
return(innobase_skip ? DB_TYPE_MYISAM : database_type);
|
||||
#endif
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
case DB_TYPE_GEMINI:
|
||||
return(gemini_skip ? DB_TYPE_MYISAM : database_type);
|
||||
#endif
|
||||
#ifndef NO_HASH
|
||||
case DB_TYPE_HASH:
|
||||
#endif
|
||||
@@ -118,6 +125,10 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
case DB_TYPE_INNOBASE:
|
||||
return new ha_innobase(table);
|
||||
#endif
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
case DB_TYPE_GEMINI:
|
||||
return new ha_gemini(table);
|
||||
#endif
|
||||
case DB_TYPE_HEAP:
|
||||
return new ha_heap(table);
|
||||
@@ -149,6 +160,15 @@ int ha_init()
|
||||
if (!innobase_skip) // If we couldn't use handler
|
||||
opt_using_transactions=1;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
if (!gemini_skip)
|
||||
{
|
||||
if (gemini_init())
|
||||
return -1;
|
||||
if (!gemini_skip) // If we couldn't use handler
|
||||
opt_using_transactions=1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -176,6 +196,10 @@ int ha_panic(enum ha_panic_function flag)
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
if (!innobase_skip)
|
||||
error|=innobase_end();
|
||||
#endif
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
if (!gemini_skip)
|
||||
error|=gemini_end();
|
||||
#endif
|
||||
return error;
|
||||
} /* ha_panic */
|
||||
@@ -187,6 +211,12 @@ void ha_close_connection(THD* thd)
|
||||
if (!innobase_skip)
|
||||
innobase_close_connection(thd);
|
||||
#endif
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
if (!gemini_skip && thd->gemini.context)
|
||||
{
|
||||
gemini_disconnect(thd);
|
||||
}
|
||||
#endif /* HAVE_GEMINI_DB */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -250,6 +280,20 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
/* Commit the transaction in behalf of the commit statement
|
||||
or if we're in auto-commit mode */
|
||||
if((trans == &thd->transaction.all) ||
|
||||
(!(thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))))
|
||||
{
|
||||
error=gemini_commit(thd);
|
||||
if (error)
|
||||
{
|
||||
my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
|
||||
sql_print_error("Error: Got error during commit; Binlog is not up to date!");
|
||||
@@ -287,6 +331,18 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
|
||||
error=1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
if((trans == &thd->transaction.stmt) &&
|
||||
(thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)))
|
||||
error = gemini_rollback_to_savepoint(thd);
|
||||
else
|
||||
error=gemini_rollback(thd);
|
||||
if (error)
|
||||
{
|
||||
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error);
|
||||
error=1;
|
||||
}
|
||||
#endif
|
||||
if (trans == &thd->transaction.all)
|
||||
reinit_io_cache(&thd->transaction.trans_log,
|
||||
@@ -678,6 +734,21 @@ int handler::rename_table(const char * from, const char * to)
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
int ha_commit_rename(THD *thd)
|
||||
{
|
||||
int error=0;
|
||||
#ifdef HAVE_GEMINI_DB
|
||||
/* Gemini needs to commit the rename; otherwise a rollback will change
|
||||
** the table names back internally but the physical files will still
|
||||
** have the new names.
|
||||
*/
|
||||
if (ha_commit_stmt(thd))
|
||||
error= -1;
|
||||
if (ha_commit(thd))
|
||||
error= -1;
|
||||
#endif
|
||||
return error;
|
||||
}
|
||||
|
||||
int handler::index_next_same(byte *buf, const byte *key, uint keylen)
|
||||
{
|
||||
|
Reference in New Issue
Block a user