+ // Get the LIMIT clause, if there is one
+ Expression* limit_count = NULL;
+ if( limit_count_id != -1 ) {
+ limit_count = getExpression( state, limit_count_id );
+ if( ! limit_count ) {
+ // shouldn't happen due to foreign key constraint
+ osrfLogError( OSRF_LOG_MARK, sqlAddMsg( state,
+ "Unable to fetch LIMIT expression for query id = %d", id ));
+ orderItemListFree( order_by_list );
+ freeQSeqList( child_list );
+ selectListFree( select_list );
+ fromRelationFree( from_clause );
+ state->error = 1;
+ return NULL;
+ }
+ }
+
+ // Get the OFFSET clause, if there is one
+ Expression* offset_count = NULL;
+ if( offset_count_id != -1 ) {
+ offset_count = getExpression( state, offset_count_id );
+ if( ! offset_count ) {
+ // shouldn't happen due to foreign key constraint
+ osrfLogError( OSRF_LOG_MARK, sqlAddMsg( state,
+ "Unable to fetch OFFSET expression for query id = %d", id ));
+ expressionFree( limit_count );
+ orderItemListFree( order_by_list );
+ freeQSeqList( child_list );
+ selectListFree( select_list );
+ fromRelationFree( from_clause );
+ state->error = 1;
+ return NULL;
+ }
+ }
+