Exemple #1
0
static PyObject*
ConnectionObject_autocommit(ConnectionObject *self, PyObject *args)
{
    int flag, status = 1;
    char query[256];

    drizzle_return_t ret;
    drizzle_result_st result;

    if (!PyArg_ParseTuple(args, "i", &flag)) {
        return NULL;
    }

    DEBUG("autocommit %d", flag);
    snprintf(query, 256, "SET AUTOCOMMIT=%d;", flag);
    BDEBUG("query %s", query);
    
    while(status){
        (void)drizzle_query(self->con, &result, query, 256, &ret);
        status = io_wait(self->con, ret);
        if (status == -1){
            goto error;
        }
    }

    drizzle_result_free(&result);
    Py_RETURN_NONE;
error:
    drizzle_result_free(&result);
    PyErr_SetString(PyExc_IOError, drizzle_error(drizzle));
    return NULL;
}
Exemple #2
0
static PyObject*
ConnectionObject_rollback(ConnectionObject *self, PyObject *args)
{
    int status = 1;
    drizzle_return_t ret;
    drizzle_result_st result;
    
    while(status){
        (void)drizzle_query(self->con, &result, "ROLLBACK;", 9, &ret);
        status = io_wait(self->con, ret);
        if (status == -1){
            goto error;
        }
    }

    drizzle_result_free(&result);
    Py_RETURN_NONE;
error:
    drizzle_result_free(&result);
    PyErr_SetString(PyExc_IOError, drizzle_error(drizzle));
    return NULL;
}
Exemple #3
0
static void drizzle_query_run_state(drizzle_query_st* query,
                                    drizzle_return_t* ret_ptr)
{
  switch (query->state)
  {
  case DRIZZLE_QUERY_STATE_INIT:
    query->state= DRIZZLE_QUERY_STATE_QUERY;
  case DRIZZLE_QUERY_STATE_QUERY:
    query->result= drizzle_query(query->con, query->result, query->string,
                                 query->size, ret_ptr);
    if (*ret_ptr == DRIZZLE_RETURN_IO_WAIT)
    {
      return;
    }
    else if (*ret_ptr != DRIZZLE_RETURN_OK)
    {
      query->state= DRIZZLE_QUERY_STATE_DONE;
      return;
    }

    query->state= DRIZZLE_QUERY_STATE_RESULT;

  case DRIZZLE_QUERY_STATE_RESULT:
    *ret_ptr= drizzle_result_buffer(query->result);
    if (*ret_ptr == DRIZZLE_RETURN_IO_WAIT)
    {
      return;
    }

    query->state= DRIZZLE_QUERY_STATE_DONE;
    return;

  default:
  case DRIZZLE_QUERY_STATE_DONE:
    return;
  }
}