if( !state->error ) {
if( expr->negate )
buffer_add( state->sql, "NOT " );
+ buffer_add( state->sql, " IN (" );
if( expr->subquery ) {
- buffer_add( state->sql, " IN (" );
incr_indent( state );
build_Query( state, expr->subquery );
- decr_indent( state );
- add_newline( state );
- buffer_add_char( state->sql, ')' );
+ if( state->error )
+ sqlAddMsg( state, "Unable to build subquery for IN condition" );
+ else {
+ decr_indent( state );
+ add_newline( state );
+ buffer_add_char( state->sql, ')' );
+ }
} else {
- sqlAddMsg( state, "IN lists not yet supported" );
- state->error = 1;
+ buildSeries( state, expr->subexp_list, expr->op );
+ if( state->error )
+ sqlAddMsg( state, "Unable to build IN list" );
+ else
+ buffer_add_char( state->sql, ')' );
}
}
}
BindVar* bind = NULL;
Expression* subexp_list = NULL;
- if( EXP_OPERATOR == type ) {
+ if( EXP_BIND == type ) {
+ if( bind_variable ) {
+ // To do: Build a BindVar
+ bind = getBindVar( state, bind_variable );
+ if( ! bind ) {
+ osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
+ "Unable to load bind variable \"%s\" for expression # %d",
+ bind_variable, id ));
+ state->error = 1;
+ return NULL;
+ }
+ PRINT( "\tBind variable is \"%s\"\n", bind_variable );
+ } else {
+ osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
+ "No variable specified for bind variable expression # %d",
+ bind_variable, id ));
+ state->error = 1;
+ return NULL;
+ }
+ } else if( EXP_OPERATOR == type ) {
// Load left and/or right operands
if( -1 == left_operand_id && -1 == right_operand_id ) {
osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
}
if( -1 == subquery_id ) {
- // To do: load IN list of subexpressions
- osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
- "IN lists not yet supported for expression # %d", id ));
- state->error = 1;
- return NULL;
+ // Load an IN list of subexpressions
+ subexp_list = getExpressionList( state, id );
+ if( state->error ) {
+ osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
+ "Unable to get subexpressions for IN list" ));
+ return NULL;
+ } else if( !subexp_list ) {
+ osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
+ "IN list is empty in expression # %d", id ));
+ state->error = 1;
+ return NULL;
+ }
} else {
+ // Load a subquery
subquery = getStoredQuery( state, subquery_id );
if( !subquery ) {
osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
"Unable to get subexpressions for expression series using operator \"%s\"",
operator ? operator : "," ));
return NULL;
+ } else if( !subexp_list ) {
+ osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
+ "Series expression is empty in expression # %d", id ));
+ state->error = 1;
+ return NULL;
}
+
} else if( EXP_SUBQUERY == type ) {
if( -1 == subquery_id ) {
osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
}
PRINT( "\tExpression is subquery %d\n", subquery_id );
}
- } else if( EXP_BIND == type ) {
- if( bind_variable ) {
- // To do: Build a BindVar
- bind = getBindVar( state, bind_variable );
- if( ! bind ) {
- osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
- "Unable to load bind variable \"%s\" for expression # %d",
- bind_variable, id ));
- state->error = 1;
- return NULL;
- }
- PRINT( "\tBind variable is \"%s\"\n", bind_variable );
- } else {
- osrfLogWarning( OSRF_LOG_MARK, sqlAddMsg( state,
- "No variable specified for bind variable expression # %d",
- bind_variable, id ));
- state->error = 1;
- return NULL;
- }
}
// Allocate an Expression: from the free list if possible, from the heap if necessary