Esempio n. 1
0
bool tizrmdb::resource_available (const unsigned int &rid,
                                  const unsigned int &quantity) const
{
  bool ret_val = false;
  int rc = SQLITE_OK;
  char query[255];

  TIZ_LOG (TIZ_PRIORITY_TRACE,
           "tizrmdb::resource_available : Checking resource "
           " availability for resid [%d] - quantity [%d]",
           rid, quantity);

  snprintf (query, sizeof(query),
            "select * from resources where resid='%d' and current>='%d'", rid,
            quantity);

  rc = run_query (query);

  if (SQLITE_OK == rc && !vdata_.empty ())
  {
    TIZ_LOG (TIZ_PRIORITY_TRACE,
             "tizrmdb::resource_available : "
             "Enough resource id [%d] available",
             rid);
    ret_val = true;
  }

  return ret_val;
}
Esempio n. 2
0
TEST(database, run_query){
  sqlite3_stmt* pstmt;
  TEST_ASSERT_EQUAL(SQLITE_ROW, run_query(&pstmt,"SELECT * FROM package;"));
  TEST_ASSERT_TRUE(pstmt);
  TEST_ASSERT_EQUAL_STRING("Gcc", sqlite3_column_text(pstmt,1));
  TEST_ASSERT_EQUAL(SQLITE_OK, sqlite3_finalize(pstmt));
}
Esempio n. 3
0
bool tizrmdb::comp_provisioned_with_resid (const std::string &cname,
                                           const unsigned int &rid) const
{
  bool ret_val = false;
  int rc = SQLITE_OK;
  char query[255];

  TIZ_LOG (TIZ_PRIORITY_TRACE,
           "tizrmdb::comp_provisioned_with_resid : "
           "'%s' : Checking component provisioning for "
           "resource id [%d]",
           cname.c_str (), rid);

  snprintf (query, sizeof(query),
            "select * from components where cname='%s' and resid=%d",
            cname.c_str (), rid);

  rc = run_query (query);

  if (SQLITE_OK == rc && !vdata_.empty ())
  {
    ret_val = true;
  }

  TIZ_LOG (TIZ_PRIORITY_TRACE, "'%s' : is [%s] with resource id [%d]",
           cname.c_str (),
           (true == ret_val ? "PROVISIONED" : "NOT PROVISIONED"), rid);

  return ret_val;
}
Esempio n. 4
0
static int run_sql_fix_privilege_tables(void)
{
  int found_real_errors= 0;
  const char **query_ptr;
  DYNAMIC_STRING ds_script;
  DYNAMIC_STRING ds_result;
  DBUG_ENTER("run_sql_fix_privilege_tables");

  if (init_dynamic_string(&ds_script, "", 65536, 1024))
    die("Out of memory");

  if (init_dynamic_string(&ds_result, "", 512, 512))
    die("Out of memory");

  verbose("Running 'mysql_fix_privilege_tables'...");

  /*
    Individual queries can not be executed independently by invoking
    a forked mysql client, because the script uses session variables
    and prepared statements.
  */
  for ( query_ptr= &mysql_fix_privilege_tables[0];
        *query_ptr != NULL;
        query_ptr++
      )
  {
    dynstr_append(&ds_script, *query_ptr);
  }

  run_query(ds_script.str,
            &ds_result, /* Collect result */
            TRUE);
  {
    /*
      Scan each line of the result for real errors
      and ignore the expected one(s) like "Duplicate column name",
      "Unknown column" and "Duplicate key name" since they just
      indicate the system tables are already up to date
    */
    char *line= ds_result.str;
    do
    {
      if (!is_expected_error(line))
      {
        /* Something unexpected failed, dump error line to screen */
        found_real_errors++;
        print_line(line);
      }
      else if ((strncmp(line, "WARNING", 7) == 0) ||
               (strncmp(line, "Warning", 7) == 0))
      {
        print_line(line);
      }
    } while ((line= get_line(line)) && *line);
  }

  dynstr_free(&ds_result);
  dynstr_free(&ds_script);
  DBUG_RETURN(found_real_errors);
}
Esempio n. 5
0
File: async.c Progetto: AndreRH/wine
/***********************************************************************
 *       WSAAsyncGetServByPort        (WS2_32.106)
 */
HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
                                        LPCSTR proto, LPSTR sbuf, INT buflen)
{
    struct async_query_getservbyport *aq;
    unsigned int len = proto ? strlen(proto) + 1 : 0;

    TRACE("hwnd %p, msg %04x, port %i, proto %s\n", hWnd, uMsg, port, debugstr_a(proto));

    if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len )))
    {
        SetLastError( WSAEWOULDBLOCK );
        return 0;
    }

    if (proto)
    {
        aq->serv_proto = (char *)(aq + 1);
        strcpy( aq->serv_proto, proto );
    }
    else
        aq->serv_proto = NULL;

    aq->serv_port = port;

    return run_query( hWnd, uMsg, async_getservbyport, &aq->query, sbuf, buflen );
}
Esempio n. 6
0
File: async.c Progetto: AndreRH/wine
/***********************************************************************
 *       WSAAsyncGetServByName        (WS2_32.107)
 */
HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name,
                                        LPCSTR proto, LPSTR sbuf, INT buflen)
{
    struct async_query_getservbyname *aq;
    unsigned int len1 = strlen(name) + 1;
    unsigned int len2 = proto ? strlen(proto) + 1 : 0;

    TRACE("hwnd %p, msg %04x, name %s, proto %s\n", hWnd, uMsg, debugstr_a(name), debugstr_a(proto));

    if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len1 + len2 )))
    {
        SetLastError( WSAEWOULDBLOCK );
        return 0;
    }

    aq->serv_name  = (char *)(aq + 1);
    strcpy( aq->serv_name, name );

    if (proto)
    {
        aq->serv_proto = aq->serv_name + len1;
        strcpy( aq->serv_proto, proto );
    }
    else
        aq->serv_proto = NULL;

    return run_query( hWnd, uMsg, async_getservbyname, &aq->query, sbuf, buflen );
}
Esempio n. 7
0
int mutt_query_complete(char *buf, size_t buflen)
{
    QUERY *results = NULL;
    ADDRESS *tmpa;

    if (!QueryCmd) {
        mutt_error _("Query command not defined.");
        return 0;
    }

    results = run_query(buf, 1);

    if (results) {
        /* only one response? */
        if (results->next == NULL) {
            tmpa = result_to_addr(results);
            mutt_addrlist_to_local(tmpa);
            buf[0] = '\0';
            rfc822_write_address(buf, buflen, tmpa, 0);
            rfc822_free_address(&tmpa);
            free_query(&results);
            mutt_clear_error();
            return 0;
        }

        /* multiple results, choose from query menu */
        query_menu(buf, buflen, results, 1);
    }
    return 0;
}
Esempio n. 8
0
/**
  Check if the server version matches with the server version mysql_upgrade
  was compiled with.

  @return 0 match successful
          1 failed
*/
static int check_version_match(void)
{
  DYNAMIC_STRING ds_version;
  char version_str[NAME_CHAR_LEN + 1];

  if (init_dynamic_string(&ds_version, NULL, NAME_CHAR_LEN, NAME_CHAR_LEN))
    die("Out of memory");

  if (run_query("show variables like 'version'",
                &ds_version, FALSE) ||
      extract_variable_from_show(&ds_version, version_str))
  {
    print_error("Version check failed. Got the following error when calling "
                "the 'mysql' command line client", &ds_version);
    dynstr_free(&ds_version);
    return 1;                                   /* Query failed */
  }

  dynstr_free(&ds_version);

  if (calc_server_version((char *) version_str) != MYSQL_VERSION_ID)
  {
    fprintf(stderr, "Error: Server version (%s) does not match with the "
            "version of\nthe server (%s) with which this program was built/"
            "distributed. You can\nuse --skip-version-check to skip this "
            "check.\n", version_str, MYSQL_SERVER_VERSION);
    return 1;
  }
  else
    return 0;
}
Esempio n. 9
0
static void run_list(void) {
	int i=0;
	for(i=0;i<listcnt;i++) {
		run_query(listq[i].cmd);
		usleep(72500); // cpu tune
	}
}
Esempio n. 10
0
bool tizrmdb::comp_provisioned (const std::string &cname) const
{
  bool ret_val = false;
  int rc = SQLITE_OK;

  TIZ_LOG (TIZ_PRIORITY_TRACE, "tizrmdb::comp_provisioned : Checking [%s]",
           cname.c_str ());

  rc = run_query (TIZ_RM_DB_CNAMES_FROM_COMPONENTS);

  if (SQLITE_OK == rc)
  {
    for (std::vector< std::string >::iterator it = vdata_.begin ();
         it < vdata_.end (); ++it)
    {
      if (cname.compare (*it) == 0)
      {
        ret_val = true;
      }
    }
  }

  TIZ_LOG (TIZ_PRIORITY_TRACE, "'%s' is [%s]", cname.c_str (),
           (true == ret_val ? "PROVISIONED" : "NOT PROVISIONED"));

  return ret_val;
}
Esempio n. 11
0
static void
query(const char *sql)
{
	if (run_query(tds, sql) != TDS_SUCCESS) {
		fprintf(stderr, "error executing query: %s\n", sql);
		exit(1);
	}
}
Esempio n. 12
0
int
main(int argc, char **argv)
{
	TDSRESULTINFO *info;
	char mymsg[256];

	fprintf(stdout, "%s: Testing flags from server\n", __FILE__);
	if (try_tds_login(&login, &tds, __FILE__, 0) != TDS_SUCCESS) {
		fprintf(stderr, "try_tds_login() failed\n");
		return 1;
	}

	if (run_query(tds, "create table #tmp1 (i numeric(10,0) identity primary key, b varchar(20) null, c int not null)") !=
	    TDS_SUCCESS)
		fatal_error("creating table error");

	/* TDS 4.2 without FOR BROWSE clause seem to forget flags... */
	if (!IS_TDS42(tds->conn)) {
		/* check select of all fields */
		test_begin("select * from #tmp1");
		info = tds->current_results;

		if (info->num_cols != 3) {
			sprintf(mymsg,"wrong number of columns returned expected 3 got %d", info->num_cols);
			fatal_error(mymsg);
		}

		check_flags(info->columns[0], 0, "identity");
		check_flags(info->columns[1], 1, "nullable writable");
		check_flags(info->columns[2], 2, "writable");

		test_end();
	}


	/* check select of 2 field */
	test_begin("select c, b from #tmp1 for browse");
	info = tds->current_results;

	if (info->num_cols != 3)
		fatal_error("wrong number of columns returned");

	check_flags(info->columns[0], 0, "writable");

	if (!IS_TDS42(tds->conn)) {
		check_flags(info->columns[1], 1, "nullable writable");
	} else {
		check_flags(info->columns[1], 1, "writable-nullable writable");
	}
	/* TDS5 return not identity information altough documented.. */
	check_flags(info->columns[2], 2, "writable identity key hidden-writable key hidden");

	test_end();

	try_tds_logout(login, tds, 0);
	return 0;
}
Esempio n. 13
0
/*
 * 读取倒排索引到内存中,进行相似度计算
 */
Query::Query(ClientDeal &client, const std::string &invertedfile):client(client),min_str_size("") {
	// TODO Auto-generated constructor stub
	hash_search.clear();
	hash_query.clear() ;
	m_common_query.clear();

	read_to_hash_map(invertedfile); //将倒排索引表中的数据读入到内存中
	run_query(client);
}
Esempio n. 14
0
int main(int argc, char** argv)
{
  
  try {

    ORB_var orb = ORB_init(argc, argv);
    myORB=orb.in();

    Object_var obj;
    try {
       obj = orb->resolve_initial_references("UAKGQueryService");
    }catch(const ORB::InvalidName&){
       cerr << argv[0] << ": can't resolve UAKGQueryService" << endl;
       return 1;
    }
        
    if(is_nil(obj)) {
      cerr << argv[0] << ": UAKGQueryService is a nil object reference" << endl;
      return 1;
    }


    DBConnectionManager_var dbManager = DBConnectionManager::_narrow(obj);
    if (is_nil(dbManager)) {
      cerr << argv[0] << ": can't narrow dbManager to correct type" << endl;
      return 1;
    } 

    UAKGQueryManager_var queryManager;
    try {
      queryManager = 
           dbManager->createQueryManager("intbill","intbill","","Oracle8","");
    }catch(QueryManagerNotFound){
      cerr << argv[0] <<": can't find query manager." << endl;
      return 1;
    }

    //*****
    // added:
    run_query(queryManager);

    //time to disconnect.
    //
    cout << "disconnecting." << endl;
    queryManager->destroy();

  }catch(SystemException& ex){
#if defined(ORBACUS) && !defined(OB_INTEGER_VERSION)
    OBPrintException(ex);
#else
    cerr << ex << endl;
#endif
    return 1;
  }
  return 0;
}
Esempio n. 15
0
bool Client::query(	const std::string& database, const std::string& select,
					          Result& qr, const int flags)
{
	qr.clear();
	if (database.empty() || select.empty()) return false;

	int							errorCode = 0;
	SqlDatabase					sqlDb(database, SQLITE_OPEN_READONLY, &errorCode);
	if (errorCode != SQLITE_OK) return false;
	return run_query(sqlDb, select, qr, flags);
}
Esempio n. 16
0
bool Client::queryWrite(const std::string& database, const std::string& select,
						            Result& qr)
{
	qr.clear();
	if (database.empty()) return false;

	int							errorCode = 0;
	SqlDatabase					sqlDb(database, SQLITE_OPEN_READWRITE, &errorCode);
	if (errorCode != SQLITE_OK) return false;
	return run_query(sqlDb, select, qr);
}
/*
 * run_query_pager --
 *  Utility function similar to run_query_html. This function tries to
 *  pre-process the result assuming it will be piped to a pager.
 *  For this purpose it first calls it's own callback function callback_pager
 *  which then delegates the call to the user supplied callback.
 */
int
run_query_pager(sqlite3 *db, query_args *args)
{
	struct orig_callback_data orig_data;
	orig_data.callback = args->callback;
	orig_data.data = args->callback_data;
	const char *snippet_args[] = {"\002", "\003", "..."};
	args->callback = &callback_pager;
	args->callback_data = (void *) &orig_data;
	return run_query(db, snippet_args, args);
}
Esempio n. 18
0
int main(int argc, char** argv)
{
  
  try {

    ORB_var orb = ORB_init(argc, argv);
    myORB=orb.in();

    Object_var obj;
    try {
       obj = orb->resolve_initial_references("UAKGQueryService");
    }catch(const ORB::InvalidName&){
       cerr << argv[0] << ": can't resolve UAKGQueryService" << endl;
       return 1;
    }
        
    if(is_nil(obj)) {
      cerr << argv[0] << ": UAKGQueryService is a nil object reference" << endl;
      return 1;
    }


    DBConnectionManager_var dbManager = DBConnectionManager::_narrow(obj);
    if (is_nil(dbManager)) {
      cerr << argv[0] << ": can't narrow dbManager to correct type" << endl;
      return 1;
    } 

    UAKGQueryManager_var queryManager;
    try {
      queryManager = 
           dbManager->createQueryManager("scott","tiger","sun_db","Oracle8","");
    }catch(QueryManagerNotFound){
      cerr << argv[0] <<": can't find query manager." << endl;
      return 1;
    }

    // main
    run_query(queryManager);

    //time to disconnect.
    //
    cout << "disconnecting." << endl;
    queryManager->destroy();

  }
  catch(const SystemException& ex)
  {
//    OBPrintException(ex);
    return 1;
  }
  return 0;
}
Esempio n. 19
0
static gboolean
process_query (MuQuery *xapian, const gchar *query, MuConfig *opts, GError **err)
{
	MuMsgIter *iter;
	gboolean rv;

	iter = run_query (xapian, query, opts, err);
	if (!iter)
		return FALSE;

	rv = output_query_results (iter, opts, err);
	mu_msg_iter_destroy (iter);

	return rv;
}
Esempio n. 20
0
File: async.c Progetto: AndreRH/wine
/***********************************************************************
 *       WSAAsyncGetProtoByNumber     (WS2_32.104)
 */
HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, INT number,
                                           LPSTR sbuf, INT buflen)
{
    struct async_query_getprotobynumber *aq;

    TRACE("hwnd %p, msg %04x, num %i\n", hWnd, uMsg, number );

    if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) )))
    {
        SetLastError( WSAEWOULDBLOCK );
        return 0;
    }
    aq->proto_number = number;
    return run_query( hWnd, uMsg, async_getprotobynumber, &aq->query, sbuf, buflen );
}
Esempio n. 21
0
/**
 * cmd_query - Execute a SQL statement
 *
 * This method executes the query specified as a character array that is
 * located in data memory. It copies the query to the local buffer then
 * calls the run_query() method to execute the query.
 *
 * If a result set is available after the query executes, the field
 * packets and rows can be read separately using the get_field() and
 * get_row() methods.
 *
 * query[in]       SQL statement (using normal memory access)
 *
 * Returns boolean - True = a result set is available for reading
*/
boolean Connector::cmd_query(const char *query)
{
  int query_len = (int)strlen(query);

  if (buffer != NULL)
    free(buffer);

  buffer = (byte *)malloc(query_len+5);

  // Write query to packet
  memcpy(&buffer[5], query, query_len);

  // Send the query
  return run_query(query_len);
}
Esempio n. 22
0
/**
 * cmd_query_P - Execute a SQL statement
 *
 * This method executes the query specified as a character array that is
 * located in program memory. It copies the query to the local buffer then
 * calls the run_query() method to execute the query.
 *
 * If a result set is available after the query executes, the field
 * packets and rows can be read separately using the get_field() and
 * get_row() methods.
 *
 * query[in]       SQL statement (using PROGMEM)
 *
 * Returns boolean - True = a result set is available for reading
*/
boolean Connector::cmd_query_P(const char *query)
{
  int query_len = (int)strlen_P(query);

  if (buffer != NULL)
    free(buffer);

  buffer = (byte *)malloc(query_len+5);

  // Write query to packet
  for (int c = 0; c < query_len; c++)
    buffer[c+5] = pgm_read_byte_near(query+c);

  // Send the query
  return run_query(query_len);
}
Esempio n. 23
0
File: async.c Progetto: AndreRH/wine
/***********************************************************************
 *       WSAAsyncGetProtoByName       (WS2_32.105)
 */
HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, LPCSTR name,
                                         LPSTR sbuf, INT buflen)
{
    struct async_query_getprotobyname *aq;
    unsigned int len = strlen(name) + 1;

    TRACE("hwnd %p, msg %04x, proto %s, buffer %i\n", hWnd, uMsg, debugstr_a(name), buflen );

    if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len )))
    {
        SetLastError( WSAEWOULDBLOCK );
        return 0;
    }
    aq->proto_name = (char *)(aq + 1);
    strcpy( aq->proto_name, name );
    return run_query( hWnd, uMsg, async_getprotobyname, &aq->query, sbuf, buflen );
}
Esempio n. 24
0
File: async.c Progetto: AndreRH/wine
/***********************************************************************
 *       WSAAsyncGetHostByAddr        (WS2_32.102)
 */
HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
                               INT len, INT type, LPSTR sbuf, INT buflen)
{
    struct async_query_gethostbyaddr *aq;

    TRACE("hwnd %p, msg %04x, addr %p[%i]\n", hWnd, uMsg, addr, len );

    if (!(aq = HeapAlloc( GetProcessHeap(), 0, sizeof(*aq) + len )))
    {
        SetLastError( WSAEWOULDBLOCK );
        return 0;
    }
    aq->host_addr = (char *)(aq + 1);
    aq->host_len  = len;
    aq->host_type = type;
    memcpy( aq->host_addr, addr, len );
    return run_query( hWnd, uMsg, async_gethostbyaddr, &aq->query, sbuf, buflen );
}
Esempio n. 25
0
static my_bool is_mysql()
{
  my_bool ret= TRUE;
  DYNAMIC_STRING ds_events_struct;

  if (init_dynamic_string(&ds_events_struct, NULL,
                          EVENTS_STRUCT_LEN, EVENTS_STRUCT_LEN))
    die("Out of memory");

  if (run_query("show create table mysql.event",
                &ds_events_struct, FALSE) ||
      strstr(ds_events_struct.str, "IGNORE_BAD_TABLE_OPTIONS") != NULL)
    ret= FALSE;
  else
    verbose("MySQL upgrade detected");

  dynstr_free(&ds_events_struct);
  return(ret);
}
Esempio n. 26
0
static int
update_model (GtkListStore * store, const char *xpath, const char *query,
	      MugMsgListView * self)
{
	MuMsgIter *iter;
	int count;

	iter = run_query (xpath, query, self);
	if (!iter) {
		g_warning ("error: running query failed\n");
		return -1;
	}

	for (count = 0; !mu_msg_iter_is_done (iter);
	     mu_msg_iter_next (iter), ++count)
		add_row (store, mu_msg_iter_get_msg_floating(iter)); /* don't unref */

	mu_msg_iter_destroy (iter);

	return count;
}
Esempio n. 27
0
static int run_sql_fix_privilege_tables(void)
{
  int found_real_errors= 0;
  DYNAMIC_STRING ds_result;
  DBUG_ENTER("run_sql_fix_privilege_tables");

  if (init_dynamic_string(&ds_result, "", 512, 512))
    die("Out of memory");

  verbose("Phase 3/3: Running 'mysql_fix_privilege_tables'...");
  run_query(mysql_fix_privilege_tables,
            &ds_result, /* Collect result */
            TRUE);

  {
    /*
      Scan each line of the result for real errors
      and ignore the expected one(s) like "Duplicate column name",
      "Unknown column" and "Duplicate key name" since they just
      indicate the system tables are already up to date
    */
    char *line= ds_result.str;
    do
    {
      if (!is_expected_error(line))
      {
        /* Something unexpected failed, dump error line to screen */
        found_real_errors++;
        print_line(line);
      }
      else if (strncmp(line, "WARNING", 7) == 0)
      {
        print_line(line);
      }
    } while ((line= get_line(line)) && *line);
  }

  dynstr_free(&ds_result);
  DBUG_RETURN(found_real_errors);
}
Esempio n. 28
0
static int
update_model (GtkTreeStore *store, const char *xpath, const char *query,
	      MugMsgListView *self)
{
	MuMsgIter *iter;
	int count;
	const MuMsgIterThreadInfo *prev_ti = NULL;

	iter = run_query (xpath, query, self);
	if (!iter) {
		g_warning ("error: running query failed\n");
		return -1;
	}

	for (count = 0; !mu_msg_iter_is_done (iter);
	     mu_msg_iter_next (iter), ++count) {

		GtkTreeIter treeiter, prev_treeiter;
		const MuMsgIterThreadInfo *ti;

		ti = mu_msg_iter_get_thread_info (iter);

		if (!prev_ti || !g_str_has_prefix (ti->threadpath,
						   prev_ti->threadpath))
			gtk_tree_store_append (store, &treeiter, NULL);
		else
			gtk_tree_store_append (store, &treeiter, &prev_treeiter);

		/* don't unref msg */
		add_row (store, mu_msg_iter_get_msg_floating (iter), &treeiter);

		prev_ti = ti;
		prev_treeiter = treeiter;
	}

	mu_msg_iter_destroy (iter);

	return count;
}
Esempio n. 29
0
static int get_upgrade_info_file_name(char* name)
{
  DYNAMIC_STRING ds_datadir;
  DBUG_ENTER("get_upgrade_info_file_name");

  if (init_dynamic_string(&ds_datadir, NULL, 32, 32))
    die("Out of memory");

  if (run_query("show variables like 'datadir'",
                &ds_datadir, FALSE) ||
      extract_variable_from_show(&ds_datadir, name))
  {
    dynstr_free(&ds_datadir);
    DBUG_RETURN(1); /* Query failed */
  }

  dynstr_free(&ds_datadir);

  fn_format(name, "mysql_upgrade_info", name, "", MYF(0));
  DBUG_PRINT("exit", ("name: %s", name));
  DBUG_RETURN(0);
}
Esempio n. 30
0
void run_test(int nargs, char* args[]) {
    if (nargs < 2) {
        return;
    }
    struct timespec start, end;
    char* dbname = args[1];
    drop_buffer_cache();

    trace_loader_t loader;
    load_trace(&loader, args[2], atoi(args[3]));

    struct MetaDB mdb;
    metadb_init(&mdb, dbname);

    enable_monitor_thread(&mdb);
    clock_gettime(CLOCK_MONOTONIC, &start);

    get_metric();

    if (strcmp(args[4], "create") == 0) {
      run_create(mdb, &loader, atoi(args[5]));
    } else {
      run_query(mdb, &loader, atoi(args[5]), atoi(args[6]), atoi(args[7]));
    }
    clock_gettime(CLOCK_MONOTONIC, &end);
    disable_monitor_thread();
    metadb_close(mdb);

    get_metric();

    uint64_t timeElapsed = timespecDiff(&end, &start);
    timeElapsed = timespecDiff(&end, &start);
    printf("%s.%d %d  %.1f \n", args[4], num_test,
                   (int) time(NULL), timeElapsed/1.0);

    destroy_trace_loader(&loader);
    drop_buffer_cache();
}