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


C++ CHECK_CONNECTION函数代码示例

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


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

示例1: wsql_connection_set_charset

static int wsql_connection_set_charset(wsql_connection *self, PyObject *arg, void* closure)
{
    int error = 0;
    const char* charset = PyString_AsString(arg);
    if (!charset)
        return -1;

    CHECK_CONNECTION(self, -1);

    Py_BEGIN_ALLOW_THREADS
    if (strcmp(mysql_character_set_name(&(self->connection)), charset) != 0) {
#if MYSQL_VERSION_ID >= 40100
        error = mysql_set_character_set(&(self->connection), charset);
#else
        char query[256];
        snprintf(query, 256, "SET NAMES %s", charset);
        error = mysql_query(&(self->connection), query);
#endif
    }

    Py_END_ALLOW_THREADS

    if (error)
    {
        wsql_raise_error(self);
        return -1;
    }
    return 0;
}
开发者ID:kepkin,项目名称:wsql,代码行数:29,代码来源:connection.c

示例2: sb_lua_db_close

int sb_lua_db_close(lua_State *L)
{
  sb_lua_ctxt_t    *ctxt;
  sb_lua_db_stmt_t *stmt;
  unsigned int     i;
  
  ctxt = sb_lua_get_context(L);

  CHECK_CONNECTION(L, ctxt);

  stmt = (sb_lua_db_stmt_t *)luaL_checkudata(L, 1, "sysbench.stmt");
  luaL_argcheck(L, stmt != NULL, 1, "prepared statement expected");

  for (i = 0; i < stmt->nparams; i++)
  {
    if (stmt->params[i].buf != NULL)
      free(stmt->params[i].buf);
  }
  free(stmt->params);
  stmt->params = NULL;
  
  luaL_unref(L, LUA_REGISTRYINDEX, stmt->param_ref);
  luaL_unref(L, LUA_REGISTRYINDEX, stmt->result_ref);

  db_close(stmt->ptr);
  
  return 0;
}
开发者ID:smachin1000,项目名称:sysbench,代码行数:28,代码来源:script_lua.c

示例3: wsql_connection_set_autocommit

static int wsql_connection_set_autocommit(wsql_connection *self, PyObject *value, void *closure)
{
    int error = 0;
    int flag = PyLong_AsLong(value);
    if (PyErr_Occurred())
        return -1;

    CHECK_CONNECTION(self, -1);
    Py_BEGIN_ALLOW_THREADS
#if MYSQL_VERSION_ID >= 40100
    error = mysql_autocommit(&(self->connection), flag);
#else
    {
        char query[256];
        snprintf(query, 256, "SET AUTOCOMMIT=%d", flag);
        error = mysql_query(&(self->connection), query);
    }
#endif
    Py_END_ALLOW_THREADS
    if (error)
    {
        wsql_raise_error(self);
        return -1;
    }
    self->autocommit = flag ? 1 : 0;
    return 0;
}
开发者ID:kepkin,项目名称:wsql,代码行数:27,代码来源:connection.c

示例4: wsql_connection_get_charset_info

static PyObject* wsql_connection_get_charset_info(wsql_connection *self, void* closure)
{
    PyObject *result, *tmp;
    MY_CHARSET_INFO cs;

    CHECK_CONNECTION(self, NULL);

    mysql_get_character_set_info(&(self->connection), &cs);
    if (!(result = PyDict_New()))
        return NULL;

#define SET_ITEM_STRING(k, v) \
    if (v) { tmp = PyString_FromString(v); PyDict_SetItemString(result, k, tmp); Py_DECREF(tmp); }

    SET_ITEM_STRING("name", cs.csname);
    SET_ITEM_STRING("collation", cs.name);
    SET_ITEM_STRING("comment", cs.comment);
    SET_ITEM_STRING("dir", cs.dir);

#undef SET_ITEM_STRING

#define SET_ITEM_LONG(k, v) \
    { tmp = PyLong_FromLong(v); PyDict_SetItemString(result, k, tmp); Py_DECREF(tmp); }

    SET_ITEM_LONG("mbminlen", cs.mbminlen);
    SET_ITEM_LONG("mbmaxlen", cs.mbmaxlen);

#undef SET_ITEM_LONG

    return result;
}
开发者ID:kepkin,项目名称:wsql,代码行数:31,代码来源:connection.c

示例5: cubrid_conn_glo_new

/* call-seq:
 *   glo_new(classname <, filename>) -> Oid
 *
 * 새로운 GLO 객체를 생성하고 Oid로 반환합니다.
 * CUBRID는 바이너리 데이터를 저장할 수 있도록 GLO를 제공합니다. GLO 객체는 OID로 직접 접근할 수 있습니다.
 *
 * filename이 주어지면 해당 파일의 데이터를 데이터베이스에 저장합니다. 주어지지 않으면 빈 GLO 객체를 생성합니다.
 *
 *  con = Cubrid.connect('subway')
 *  con.query('create table attachfile under glo (name string)')
 *  con.commit
 *
 *  glo = con.glo_new('attachfile', 'pic.jpg')
 *  glo.glo_size  #=> 1234
 *
 *  glo = con.glo_new('attachfile')
 *  glo.glo_size  #=> 0
 *  glo.glo_save('pic.jpg')
 *  glo.glo_size  #=> 1234
 */
VALUE
cubrid_conn_glo_new(VALUE self, VALUE table, VALUE file)
{
    char oid_str[MAX_STR_LEN], *table_name, *file_name;
    int res;
    T_CCI_ERROR error;
    Connection *con;

    GET_CONN_STRUCT(self, con);
    CHECK_CONNECTION(con, Qnil);

    if (NIL_P(table)) {
        rb_raise(rb_eArgError, "class name is required.");
        return Qnil;
    }
    table_name = StringValueCStr(table);

    if (NIL_P(file)) {
        file_name = NULL;
    } else {
        file_name = StringValueCStr(file);
    }

    res = cci_glo_new(con->handle, table_name, file_name, oid_str, &error);
    if (res < 0) {
        cubrid_handle_error(res, &error);
        return Qnil;
    }

    return cubrid_oid_new(con, oid_str);
}
开发者ID:hellohuizhang,项目名称:cubrid-ruby,代码行数:51,代码来源:conn.c

示例6: wsql_connection_get_thread_id

static PyObject* wsql_connection_get_thread_id(wsql_connection *self, void* closure)
{
    unsigned long pid;
    CHECK_CONNECTION(self, NULL);
    Py_BEGIN_ALLOW_THREADS
    pid = mysql_thread_id(&(self->connection));
    Py_END_ALLOW_THREADS
    return PyLong_FromLong((long)pid);
}
开发者ID:kepkin,项目名称:wsql,代码行数:9,代码来源:connection.c

示例7: wsql_connection_get_info

static PyObject* wsql_connection_get_info(wsql_connection *self, void* closure)
{
    const char *s;
    CHECK_CONNECTION(self, NULL);
    s = mysql_info(&(self->connection));
    if (s)
        return PyString_FromString(s);
    Py_RETURN_NONE;
}
开发者ID:kepkin,项目名称:wsql,代码行数:9,代码来源:connection.c

示例8: wsql_connection_get_field_count

static PyObject* wsql_connection_get_field_count(wsql_connection *self, void* closure)
{
    CHECK_CONNECTION(self, NULL);
#if MYSQL_VERSION_ID < 32224
    return PyLong_FromLong((long)mysql_num_fields(&(self->connection)));
#else
    return PyLong_FromLong((long)mysql_field_count(&(self->connection)));
#endif
}
开发者ID:kepkin,项目名称:wsql,代码行数:9,代码来源:connection.c

示例9: wsql_connection_get_insert_id

static PyObject* wsql_connection_get_insert_id(wsql_connection *self, void* closure)
{
    my_ulonglong r;
    CHECK_CONNECTION(self, NULL);
    Py_BEGIN_ALLOW_THREADS
    r = mysql_insert_id(&(self->connection));
    Py_END_ALLOW_THREADS
    return PyLong_FromUnsignedLongLong(r);
}
开发者ID:kepkin,项目名称:wsql,代码行数:9,代码来源:connection.c

示例10: cubrid_conn_get_auto_commit

/* call-seq:
 *   auto_commit? -> true or false
 *
 * Connection이 auto commit 모드인지 아닌지를 반환합니다.
 * Connection은 기본적으로 auto commit 모드가 아니며, auto_commit= 메쏘드로 auto commit 여부를 설정할 수 있습니다.
 *
 */
VALUE
cubrid_conn_get_auto_commit(VALUE self)
{
    Connection *con;

    GET_CONN_STRUCT(self, con);
    CHECK_CONNECTION(con, Qnil);

    return con->auto_commit;
}
开发者ID:hellohuizhang,项目名称:cubrid-ruby,代码行数:17,代码来源:conn.c

示例11: cubrid_conn_set_auto_commit

/* call-seq:
 *   auto_commit= true or false -> nil
 *
 * Connection의 auto commit 모드를 설정합니다.
 * auto commit이 true로 설정되면 Statement.execute의 실행이 끝난 후 바로 commit이 실행됩니다.
 *
 */
VALUE
cubrid_conn_set_auto_commit(VALUE self, VALUE auto_commit)
{
    Connection *con;

    GET_CONN_STRUCT(self, con);
    CHECK_CONNECTION(con, self);

    con->auto_commit = auto_commit;
    return Qnil;
}
开发者ID:hellohuizhang,项目名称:cubrid-ruby,代码行数:18,代码来源:conn.c

示例12: wsql_connection_get_server_info

static PyObject* wsql_connection_get_server_info(wsql_connection *self, void* closure)
{
    CHECK_CONNECTION(self, NULL);
    const char* info = mysql_get_server_info(&(self->connection));
    if (!info)
    {
        PyErr_SetString(wsql_programming_error, "connection is not ready");
        return NULL;
    }
    return PyString_FromString(info);
}
开发者ID:kepkin,项目名称:wsql,代码行数:11,代码来源:connection.c

示例13: wsql_connection_next_result_async

static PyObject* wsql_connection_next_result_async(wsql_connection *self)
{
    int error;
    net_async_status status;
    CHECK_CONNECTION(self, NULL);
    status = mysql_next_result_nonblocking(&(self->connection), &error);
    if (status == NET_ASYNC_COMPLETE && error > 0)
    {
        return wsql_raise_error(self);
    }
    return Py_BuildValue("(ii)", (int)status, !error);
}
开发者ID:kepkin,项目名称:wsql,代码行数:12,代码来源:connection.c

示例14: wsql_connection_get_stat

static PyObject* wsql_connection_get_stat(wsql_connection *self, void* closure)
{
    const char *s;
    CHECK_CONNECTION(self, NULL);
    Py_BEGIN_ALLOW_THREADS
    s = mysql_stat(&(self->connection));
    Py_END_ALLOW_THREADS
    if (!s)
        return wsql_raise_error(self);

    return PyString_FromString(s);
}
开发者ID:kepkin,项目名称:wsql,代码行数:12,代码来源:connection.c

示例15: wsql_connection_dump_debug_info

static PyObject* wsql_connection_dump_debug_info(wsql_connection *self)
{
    int error;
    CHECK_CONNECTION(self, NULL);
    Py_BEGIN_ALLOW_THREADS
    error = mysql_dump_debug_info(&(self->connection));
    Py_END_ALLOW_THREADS
    if (error)
        return wsql_raise_error(self);

    Py_RETURN_NONE;
}
开发者ID:kepkin,项目名称:wsql,代码行数:12,代码来源:connection.c


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