mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
feature #206: SQL queries for HostPool compatible with both sqlite and mysql
This commit is contained in:
parent
b80e688d05
commit
3e4a7b7545
@ -56,9 +56,9 @@ const char * Host::db_names = "(oid,host_name,state,im_mad,vm_mad,"
|
||||
"tm_mad,last_mon_time)";
|
||||
|
||||
const char * Host::db_bootstrap = "CREATE TABLE host_pool ("
|
||||
"oid INTEGER PRIMARY KEY,host_name TEXT,state INTEGER,"
|
||||
"im_mad TEXT,vm_mad TEXT,tm_mad TEXT,last_mon_time INTEGER, "
|
||||
"UNIQUE(host_name, im_mad, vm_mad, tm_mad) )";
|
||||
"oid INTEGER PRIMARY KEY,host_name VARCHAR(512), state INTEGER,"
|
||||
"im_mad VARCHAR(128),vm_mad VARCHAR(128),tm_mad VARCHAR(128),"
|
||||
"last_mon_time INTEGER, UNIQUE(host_name, im_mad, vm_mad, tm_mad) )";
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -115,7 +115,7 @@ int HostPool::dump(ostringstream& oss, const string& where)
|
||||
set_callback(static_cast<Callbackable::Callback>(&HostPool::dump_cb),
|
||||
static_cast<void *>(&oss));
|
||||
|
||||
cmd << "SELECT * FROM " << Host::table << "," << HostShare::table
|
||||
cmd << "SELECT * FROM " << Host::table << " JOIN " << HostShare::table
|
||||
<< " ON " << Host::table << ".oid = " << HostShare::table << ".hid";
|
||||
|
||||
if ( !where.empty() )
|
||||
@ -128,4 +128,4 @@ int HostPool::dump(ostringstream& oss, const string& where)
|
||||
oss << "</HOST_POOL>";
|
||||
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,8 @@
|
||||
#include "HostTemplate.h"
|
||||
|
||||
const char * HostTemplate::table = "host_attributes";
|
||||
|
||||
const char * HostTemplate::db_bootstrap = "CREATE TABLE host_attributes"
|
||||
" (id INTEGER, name TEXT, type INTEGER, value TEXT, PRIMARY KEY(id,name))";
|
||||
|
||||
const char * HostTemplate::db_bootstrap = "CREATE TABLE host_attributes"
|
||||
" (id INTEGER, name VARCHAR(256), type INTEGER, value TEXT, "
|
||||
"PRIMARY KEY(id,name))";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user