osrfLogWarning( OSRF_LOG_MARK, "Unable to load stored query # %d", query_id );
osrfAppSessionStatus( ctx->session, OSRF_STATUS_BADREQUEST, "osrfMethodException",
ctx->request, "Unable to load stored query" );
+ if( state->panic ) {
+ osrfLogError( OSRF_LOG_MARK, sqlAddMsg( state,
+ "Database connection isn't working" ));
+ osrfAppSessionPanic( ctx->session );
+ }
return -1;
}
osrfLogInfo( OSRF_LOG_MARK, "Token for query id # %d is \"%s\"", query_id, token );
- // Build an object to return: a hash containing the query token
- // and a list of bind variables.
+ // Build an object to return. It will be a hash containing the query token and a
+ // list of bind variables.
jsonObject* returned_obj = jsonNewObjectType( JSON_HASH );
jsonObjectSetKey( returned_obj, "token", jsonNewObject( token ));
jsonObjectSetKey( returned_obj, "bind_variables",
if( query->state->error ) {
osrfAppSessionStatus( ctx->session, OSRF_STATUS_BADREQUEST, "osrfMethodException",
ctx->request, "Unable to get column names" );
+ if( query->state->panic ) {
+ osrfLogError( OSRF_LOG_MARK, sqlAddMsg( query->state,
+ "Database connection isn't working" ));
+ osrfAppSessionPanic( ctx->session );
+ }
return -1;
} else {
osrfAppRespondComplete( ctx, col_list );
"Unable to execute SQL statement for query id # %d", query->query->id ));
osrfAppSessionStatus( ctx->session, OSRF_STATUS_BADREQUEST, "osrfMethodException",
ctx->request, "Unable to execute SQL statement" );
+ if( query->state->panic ) {
+ osrfLogError( OSRF_LOG_MARK, sqlAddMsg( query->state,
+ "Database connection isn't working" ));
+ osrfAppSessionPanic( ctx->session );
+ }
return -1;
}
"Unable to execute dummy query for column names: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
return NULL;
}
"Unable to query query.stored_query table: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
pop_id( &state->query_stack );
osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
"%s query # %d has no child queries within it", type_str, parent_id ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
return NULL;
}
} else {
"Unable to query query.from_relation table: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
if( fr )
"Unable to query query.from_relation table for join list: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
return join_list;
"Unable to query query.select_list table: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
return select_list;
"Unable to query query.bind_variable table for \"%s\": #%d %s",
name, errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
if( bind ) {
"Unable to query query.case_branch table for parent expression # %d: %s",
parent_id, errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
return branch_list;
"Unable to query query.datatype table: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
return datatype;
}
"Unable to query query.expression table: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
pop_id( &state->expr_stack );
"Series expression is empty in expression # %d", id ));
state->error = 1;
return NULL;
+ } else if( operator && !is_good_operator( operator )) {
+ // The specified operator contains one or more characters that aren't allowed
+ // in an operator. This isn't a true validation; it's just a protective
+ // measure to prevent certain kinds of sql injection.
+ osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
+ "Series expression # %d contains invalid operator \"%s\"", id, operator ));
+ state->error = 1;
+ return NULL;
}
} else if( EXP_STRING == type ) {
"Unable to query query.expression table for expression list: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
return exp_list;
"Unable to query query.order_by_list table: #%d %s",
errnum, msg ? msg : "No description available" ));
state->error = 1;
+ if( ! oilsIsDBConnected( state->dbhandle ))
+ state->panic = 1;
}
return ord_list;