Пример #1
0
/* Executes SELECT query */
QueryHandle * db_query(ConnHandle *c, char *q) 
{
    ResultHandle *res = NULL;
    QueryHandle *query;
    char *stmt;

    if( !c )
    {
	syslog(LOG_ERR, "ERROR: [db_query] Lost connection handle.");
	return NULL;
    }

    stmt = strdup(q);
    parse_query_stmt(&stmt);
#ifdef DEBUG0
    syslog(LOG_INFO, "DEBUG: [SQL] %s", stmt);
#endif
    if( mysql_query(&c->conn,stmt) != 0 ) {
	syslog(LOG_CRIT, "ERROR: [db_query] Query failed. %s", mysql_error(&c->conn));
	free(stmt);
	return NULL;
    }

    if( (res = mysql_store_result(&c->conn)) == NULL ) {
	syslog(LOG_CRIT, "ERROR: [db_query] Unable to get query result. %s", mysql_error(&c->conn));
	free(stmt);
	return NULL;
    }

    query = get_query_result(res);
    mysql_free_result(res);
    free(stmt);
    return query;
}
Пример #2
0
static void
st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q)
{
   struct pipe_context *pipe = st_context(ctx)->pipe;
   struct st_query_object *stq = st_query_object(q);
   assert(!q->Ready);   /* we should not get called if Ready is TRUE */
   q->Ready = get_query_result(pipe, stq, FALSE);
}
Пример #3
0
static void
st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q)
{
   struct pipe_context *pipe = st_context(ctx)->pipe;
   struct st_query_object *stq = st_query_object(q);

   /* this function should only be called if we don't have a ready result */
   assert(!stq->base.Ready);

   while (!stq->base.Ready &&
	  !get_query_result(pipe, stq, TRUE))
   {
      /* nothing */
   }
			    
   q->Ready = GL_TRUE;
}