当前位置: 首页>>代码示例>>C++>>正文


C++ dbi_result_free函数代码示例

本文整理汇总了C++中dbi_result_free函数的典型用法代码示例。如果您正苦于以下问题:C++ dbi_result_free函数的具体用法?C++ dbi_result_free怎么用?C++ dbi_result_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dbi_result_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: update_server_color

//*******************************************************************
// UPDATE SERVER COLOR
//*******************************************************************
static void update_server_color(trx *t, struct probe_result *prv)
{
  dbi_result result;
  int maxcolor, newcolor;

  if (t->def->server < 2) return;

  if (t->probe->fuse && (t->res->color < prv->color)) {
    // if this probe acts like a fuse, use the previous color if it's higher
    newcolor = prv->color;
  } else {
    newcolor = t->res->color;
  }
  maxcolor = newcolor; // init

  result = db_query(t->probe->db, 0,
                    "select max(color) as color from pr_status where server = '%u'", t->def->server);
  if (result && dbi_result_next_row(result)) {
    maxcolor = dbi_result_get_uint(result, "color");
  }
  dbi_result_free(result);
  //if (t->res->color <= maxcolor) return;

  result = db_query(t->probe->db, 0,
                    // update server set color = '200' where id = '345'
                    "update %s set %s = '%u' where %s = '%u'",
                     OPT_ARG(SERVER_TABLE_NAME), OPT_ARG(SERVER_TABLE_COLOR_FIELD), 
                     maxcolor, OPT_ARG(SERVER_TABLE_ID_FIELD), t->def->server);
  dbi_result_free(result);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:33,代码来源:process.c

示例2: main

int
main (int argc, char *argv[])
{
  dbi_conn conn;
  dbi_result result;
  const char *err_msg;
  int err_code;

  if (argc < 2)
    {
      fprintf (stderr, "%s: Need a libdir as argument!\n", argv[0]);
      return 1;
    }

  dbi_initialize (argv[1]);

  conn = dbi_conn_new ("null");
  dbi_conn_connect (conn);

  /*
   * Queries
   */
  result = dbi_conn_query (conn, "COMMIT");
  assert (result != NULL);
  dbi_result_free (result);

  dbi_conn_set_option_numeric (conn, "null.error.commit", 1);
  result = dbi_conn_query (conn, "COMMIT");
  assert (result == NULL);

  dbi_conn_set_option_numeric (conn, "null.error.commit", 0);
  result = dbi_conn_query (conn, "COMMIT");
  assert (result != NULL);
  dbi_result_free (result);

  /*
   * Normal queries
   */
  result = dbi_conn_query (conn, "SELECT * FROM DUAL");
  assert (result != NULL);
  dbi_result_free (result);

  dbi_conn_set_option_numeric (conn, "null.error.query", 1);
  result = dbi_conn_query (conn, "SELECT * FROM DUAL");
  assert (result == NULL);

  dbi_conn_set_option_numeric (conn, "null.error.query", 0);
  result = dbi_conn_query (conn, "SELECT * FROM DUAL");
  assert (result != NULL);
  dbi_result_free (result);

  /*
   * Cleanup
   */
  dbi_conn_close (conn);

  dbi_shutdown ();

  return 0;
}
开发者ID:Smellerbe,项目名称:dbd-null,代码行数:60,代码来源:test-dbd-null-error.c

示例3: calc_ser_cds

static void calc_ser_cds(struct module *mod, dbi_conn conn, int interval)
{
    int ct = 0, st = 0;
    dbi_result result = 0;
    ST_CDS *ps = NULL;
    ST_CDS *pe = NULL;
    long long rst = 0;

    ps = (ST_CDS *)mod->ser_array;
    pe = (ST_CDS *)mod->emp_array;

    st = 0;
    /* acquire ser uss stats */
    result = dbi_conn_queryf(conn, "select d_id from \"T_Device\" where d_type = 'mds' order by d_id");
    if (result) {
        while(dbi_result_next_row(result)) {
            ps[st].sdr_id = dbi_result_get_longlong(result, "d_id");
            convert_time_to_string(statis.cur_time, ps[st].sdr_record_time, 0);
            convert_time_to_string(statis.cur_time - 24*60*60, ps[st].sdr_time, 1);
            if (interval == 0) {
                ps[st].sdr_date_flag = 0;
            } else if (interval == 7) {
                ps[st].sdr_date_flag = 1;
            } else {
                ps[st].sdr_date_flag = 2;
            }
            st++;
        }
        dbi_result_free(result);
    }

    for (st = 0; st < mod->ser_record; st++)
    {
        result = dbi_conn_queryf(conn, "select e_id from \"T_Enterprise\" where \
                e_mds_id = %lld order by e_id ", ps[st].sdr_id);
        if (result) {
            while(dbi_result_next_row(result)) {
                rst = dbi_result_get_longlong(result, "e_id");
                for (ct = 0; ct < mod->emp_record; ct++) {
                    if (rst == pe[ct].sdr_id) {
                        ps[st].sdr_ptt_htime += pe[ct].sdr_ptt_htime;
                        ps[st].sdr_ptt_hcount += pe[ct].sdr_ptt_hcount;
                        ps[st].sdr_call_htime += pe[ct].sdr_call_htime;
                        ps[st].sdr_call_hcount += pe[ct].sdr_call_hcount;
                        ps[st].sdr_video_htime += pe[ct].sdr_video_htime;
                        ps[st].sdr_video_hcount += pe[ct].sdr_video_hcount;
                        ps[st].sdr_audio_htime += pe[ct].sdr_audio_htime;
                        ps[st].sdr_audio_hcount += pe[ct].sdr_audio_hcount;
                    }
                }
            }
            dbi_result_free(result);
        }
    }

    //log_cds_stats(ps, mod->ser_record);

    return;
}
开发者ID:longlovehehe,项目名称:gds,代码行数:59,代码来源:mod_cds.c

示例4: dateconds_execute

/////////////////////////////////////////////////////////////////////////////////
//
// Function:
//
// Purpose:
//
// Parameters:
//
// Return value:
//
// Author: Komatsu Yuji(Zheng Chuyu)
//
/////////////////////////////////////////////////////////////////////////////////
int dateconds_execute(const apr_uint64_t proc_jobunit_id,
                      const time_t base_time, const int beginning_of_week)
{
    int rc, rv;
    dbi_result result;
    datecond_t *obj = NULL;
    struct tm *tm = NULL;

    jhklog_trace
        ("In %s() proc_jobunit_id: %llu, base_time: %ld, beginning_of_week: %d",
         __func__, proc_jobunit_id, base_time, beginning_of_week);

    result =
        jhkdb_select
        ("SELECT * FROM proc_dateconds WHERE proc_jobunit_id = %llu",
         proc_jobunit_id);
    if (result == NULL)
        return -1;

    // unset date conditions
    if (dbi_result_get_numrows(result) == 0) {
        dbi_result_free(result);
        return CONNECTOR_KIND_NORMAL;
    }
    // init
    rc = -1;
    obj = datecond_new();

    // date condition
    while (dbi_result_next_row(result)) {
        datecond_load(obj, result);
        rv = datecond_execute(obj, base_time, beginning_of_week);
        if (rv == JHAKO_FALSE)
            continue;

        if (rv == JHAKO_TRUE) {
            rc = CONNECTOR_KIND_NORMAL;
        } else {
            rc = CONNECTOR_KIND_ERROR;
        }
        goto finish;
    }

    rc = CONNECTOR_KIND_BRANCH;
  finish:
    datecond_destroy(obj);
    dbi_result_free(result);
    return rc;
}
开发者ID:komatsuyuji,项目名称:jhako,代码行数:62,代码来源:datecond.c

示例5: delete_history

//*******************************************************************
// REMOVE ALL OCCURRENCES OF A PROBE IN THE HISTORY FILES
//*******************************************************************
static void delete_history(trx *t, struct probe_result *nxt)
{
  dbi_result result;

  result = db_query(t->probe->db, 0,
                    "delete from pr_hist "
                    "where stattime = '%u' and probe = '%u' and class = '%d'",
                    nxt->stattime, t->def->probeid, t->probe->class);
  dbi_result_free(result);
  result = db_query(t->probe->db, 0,
                    "delete from pr_status "
                    "where stattime = '%u' and probe = '%u' and class = '%d'",
                    nxt->stattime, t->def->probeid, t->probe->class);
  dbi_result_free(result);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:18,代码来源:process.c

示例6: g_malloc0

//*******************************************************************
// RETRIEVE PRECEDING RAW RECORD FROM DATABASE (well just the color)
//*******************************************************************
static struct probe_result *get_previous_record(trx *t)
{
  dbi_result result;
  struct probe_result *prv;

  prv = g_malloc0(sizeof(struct probe_result));
  if (prv == NULL) {
    return(NULL);
  }
  prv->stattime = t->res->stattime;
  prv->color = t->res->color;

  if (!t->probe->store_results) return(prv); // we probably don't have a xxxx_raw table

  result = db_query(t->probe->db, 0,
                    "select   color, stattime "
                    "from     pr_%s_raw use index(probstat) "
                    "where    probe = '%u' and stattime < '%u' "
                    "order by stattime desc limit 1", 
                    t->res->name, t->def->probeid, t->res->stattime);
  if (!result) return(prv);
  if (dbi_result_next_row(result)) {
    prv->color = dbi_result_get_uint(result, "color");
    prv->stattime = dbi_result_get_uint(result, "stattime");
  }
  dbi_result_free(result);
  t->res->prevcolor = prv->color;
  return(prv);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:32,代码来源:process.c

示例7: rpserver_db_authenticate

int rpserver_db_authenticate(dbi_conn db, const char *user, const char *password)
{
  int retval = AUTH_UNKNOWN_USER;
  dbi_result result;

  LOG(LOG_INFO, "%s():%d - username: %s  password: %s", __FUNCTION__, __LINE__, user, password);

  return 0;

  result = dbi_conn_queryf(db, 
                           "SELECT * FROM `users` WHERE `username` = '%s' AND `password` = MD5('%s')",
                           user, password);

  LOG(LOG_INFO, "%s():%d - SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'", 
         __FUNCTION__, __LINE__, user, password);

  if (result) {
    if( dbi_result_get_numrows(result) == 1 ) {
      while (dbi_result_next_row(result)) {
          LOG(LOG_INFO, "%s():%d - User \"%s\" is known and ACTIVE.",
                 __FUNCTION__, __LINE__, user);
          retval = AUTH_VALID;
      } 
    } else {
      LOG(LOG_INFO, "%s():%d - User \"%s\" is unknown",
             __FUNCTION__, __LINE__, user);
    }
  }
  dbi_result_free(result);

  return retval;
}
开发者ID:energinet,项目名称:datalogger-server,代码行数:32,代码来源:rpserver_db.c

示例8: ensure_connection

swd::blacklist_filters swd::database::get_blacklist_filters() {
    swd::log::i()->send(swd::notice, "Get blacklist filters from db");

    ensure_connection();

    boost::unique_lock<boost::mutex> scoped_lock(dbi_mutex_);

    dbi_result res = dbi_conn_query(conn_, "SELECT id, impact, rule FROM blacklist_filters");

    if (!res) {
        throw swd::exceptions::database_exception("Can't execute blacklist_filters query");
    }

    swd::blacklist_filters filters;

    while (dbi_result_next_row(res)) {
        swd::blacklist_filter_ptr filter(new swd::blacklist_filter());
        filter->set_id(dbi_result_get_uint(res, "id"));
        filter->set_impact(dbi_result_get_uint(res, "impact"));
        filter->set_regex(dbi_result_get_string(res, "rule"));

        filters.push_back(filter);
    }

    dbi_result_free(res);

    return filters;
}
开发者ID:MiauWuffMiau,项目名称:shadowd,代码行数:28,代码来源:database.cpp

示例9: query_handler

static char
query_handler(char *query_name, char *myq)
{

    if(myq == NULL) {
        myq = "SELECT NULL";
    }
    if(query_name == NULL) {
        query_name = "noname";
    }
    if(query_name == "") {
        query_name = "noname";
    }
    dbi_initialize(NULL);
    conn = dbi_conn_new("mysql");
    dbi_conn_set_option(conn, "host", getenv("DB_HOSTNAME"));
    dbi_conn_set_option(conn, "username", getenv("DB_USERNAME"));
    dbi_conn_set_option(conn, "password", getenv("DB_PASSWORD"));
    dbi_conn_set_option(conn, "dbname", getenv("DB_DATABASE"));
    dbi_conn_set_option(conn, "encoding", "UTF-8");
    if (dbi_conn_connect(conn) < 0) {
        printf("Could not connect. Please check the option settings and if the" \
            "specific driver is available\n");
    } else {
        result = dbi_conn_queryf(conn, myq, threshold);
        if (result) {
        xmlAddChild(sql_node,query_doc(result,query_name));
        dbi_result_free(result);
        }
        dbi_conn_close(conn);
    }
    return 0;

}
开发者ID:savonix,项目名称:dbrs2xml,代码行数:34,代码来源:fcgi_in_c_example.c

示例10: com_test

///////////////////////////////////
// developer's utils ;-)
int com_test(int p, param_list param)
{
	dbi_result result;
	unsigned int idnumber;
	const char *fullname;
	 int j,k;
	 for(k=1;k<10;k++)
	 {
	 for(j=1; j<100; j++)
	 {
		 char *fen=get_fen();
		 result = dbi_conn_queryf(conn, "INSERT INTO test (fen) values ('%s')",fen);
		 FREE(fen);
		 if (result) {
			while (dbi_result_next_row(result)) {
			  pprintf(p,"OK\n");
			}
			dbi_result_free(result);
			}
			else
			{
			  //pprintf(p,"no result\n");
			}
	 }
	}
  pprintf(p,"OK\n");
	return COM_OK;
}
开发者ID:SKAcz,项目名称:bics-current,代码行数:30,代码来源:adminproc.c

示例11: dateconds_put_history

/////////////////////////////////////////////////////////////////////////////////
//
// Function:
//
// Purpose:
//
// Parameters:
//
// Return value:
//
// Author: Komatsu Yuji(Zheng Chuyu)
//
/////////////////////////////////////////////////////////////////////////////////
int dateconds_put_history(const apr_uint64_t proc_jobunit_id,
                          const apr_uint64_t hist_jobunit_id)
{
    int rc;
    datecond_t *obj;
    dbi_result result;

    jhklog_debug("In %s() proc_jobunit_id: %llu, hist_jobunit_id: %llu",
                 __func__, proc_jobunit_id, hist_jobunit_id);

    result =
        jhkdb_select
        ("SELECT * FROM proc_dateconds WHERE proc_jobunit_id = %llu",
         proc_jobunit_id);
    if (result == NULL)
        return -1;

    rc = -1;
    obj = datecond_new();
    while (dbi_result_next_row(result)) {
        datecond_load(obj, result);
        obj->hist_jobunit_id = hist_jobunit_id;
        if (hist_datecond_insert(obj) == 0)
            goto error;
    }

    rc = 0;
  error:
    datecond_destroy(obj);
    dbi_result_free(result);
    return rc;
}
开发者ID:komatsuyuji,项目名称:jhako,代码行数:45,代码来源:datecond.c

示例12: afsql_dd_run_query

/**
 * afsql_dd_run_query:
 *
 * Run an SQL query on the connected database.
 *
 * NOTE: This function can only be called from the database thread.
 **/
static gboolean
afsql_dd_run_query(AFSqlDestDriver *self, const gchar *query, gboolean silent, dbi_result *result)
{
  dbi_result db_res;

  msg_debug("Running SQL query",
            evt_tag_str("query", query),
            NULL);

  db_res = dbi_conn_query(self->dbi_ctx, query);
  if (!db_res)
    {
      const gchar *dbi_error;

      if (!silent)
        {
          dbi_conn_error(self->dbi_ctx, &dbi_error);
          msg_error("Error running SQL query",
                    evt_tag_str("type", self->type),
                    evt_tag_str("host", self->host),
                    evt_tag_str("port", self->port),
                    evt_tag_str("user", self->user),
                    evt_tag_str("database", self->database),
                    evt_tag_str("error", dbi_error),
                    evt_tag_str("query", query),
                    NULL);
        }
      return FALSE;
    }
  if (result)
    *result = db_res;
  else
    dbi_result_free(db_res);
  return TRUE;
}
开发者ID:algernon,项目名称:syslog-ng-old,代码行数:42,代码来源:afsql.c

示例13: afsql_dd_ensure_table_is_syslogng_conform

/**
 * afsql_dd_validate_table:
 *
 * Check if the given table exists in the database. If it doesn't
 * create it, if it does, check if all the required fields are
 * present and create them if they don't.
 *
 * NOTE: This function can only be called from the database thread.
 **/
static gboolean
afsql_dd_ensure_table_is_syslogng_conform(AFSqlDestDriver *self, GString *table)
{
  dbi_result db_res = NULL;
  gboolean success = FALSE;

  if (self->flags & AFSQL_DDF_DONT_CREATE_TABLES)
    return TRUE;

  _sanitize_sql_identifier(table->str);

  if (_is_table_syslogng_conform(self, table->str))
    return TRUE;

  if (_is_table_present(self, table->str, &db_res))
    {
      /* table exists, check structure */
      success = _ensure_table_is_syslogng_conform(self, db_res, table->str);
      if (db_res)
        dbi_result_free(db_res);
    }
  else
    {
      /* table does not exist, create it */
      success = _table_create(self, table->str) && _table_create_indexes(self, table->str);
    }

  if (success)
    {
      /* we have successfully created/altered the destination table, record this information */
      _remember_table_as_syslogng_conform(self, table->str);
    }

  return success;
}
开发者ID:jbfuzier,项目名称:syslog-ng,代码行数:44,代码来源:afsql.c

示例14: get_table_list

template<> StrVec
GncDbiProviderImpl<DbType::DBI_MYSQL>::get_index_list (dbi_conn conn)
{
    StrVec retval;
    const char* errmsg;
    auto tables = get_table_list(conn, "");
    for (auto table_name : tables)
    {
        auto result = dbi_conn_queryf (conn,
                                       "SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
                                       table_name.c_str());
        if (dbi_conn_error (conn, &errmsg) != DBI_ERROR_NONE)
        {
            PWARN ("Index Table Retrieval Error: %s on table %s\n",
                   errmsg, table_name.c_str());
            continue;
        }

        while (dbi_result_next_row (result) != 0)
        {
            std::string index_name {dbi_result_get_string_idx (result, 3)};
            retval.push_back(index_name + " " + table_name);
        }
        dbi_result_free (result);
    }

    return retval;
}
开发者ID:Mechtilde,项目名称:gnucash,代码行数:28,代码来源:gnc-dbiproviderimpl.hpp

示例15: rpserver_db_pair_lookup

int rpserver_db_pair_lookup(dbi_conn *db, const char *localid, char *buf, size_t maxlen)
{
    
    dbi_result *result; 
    int len = 0;
        
    result = dbi_conn_queryf(db,  
			     "SELECT hname FROM "DB_TABLE_DEVICES
			     " WHERE localid='%s' AND name IS NULL "
			     ,localid);

    if(result){
	if(dbi_result_next_row(result)) {
	    len +=  snprintf(buf+len, maxlen-len, "%s",
			     dbi_result_get_string(result, "hname"));
	} 
    } else {
        const char *err;
        dbi_conn_error(db, &err);
        LOG(LOG_INFO, "%s():%d - dbi error querying database (%s)\n", 
            __FUNCTION__, __LINE__, err);
        return -1;
    }

    dbi_result_free(result);

    return len;

    
}
开发者ID:energinet,项目名称:datalogger-server,代码行数:30,代码来源:rpserver_db.c


注:本文中的dbi_result_free函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。