Logo Search packages:      
Sourcecode: freetds version File versions

int tds_process_result_tokens ( TDSSOCKET *  tds,
TDS_INT *  result_type 
)

process TDS result-type message streams. tds_process_result_tokens() is called after submitting a query with tds_submit_query() and is responsible for calling the routines to populate tds->res_info if appropriate (some query have no result sets)

Parameters:
tds A pointer to the TDSSOCKET structure managing a client/server operation.
result_type A pointer to an integer variable which tds_process_result_tokens sets to indicate the current type of result.
Values that indicate command status
TDS_CMD_SUCCEEDThe results of a command have been completely processed. This command return no rows.
TDS_CMD_DONEThe results of a command have been completely processed. This command return rows.
TDS_CMD_FAILThe server encountered an error while executing a command
Values that indicate results information is available
TDS_ROWFMT_RESULTRegular Data format information tds->res_info now contains the result details ; tds->curr_resinfo now points to that data
TDS_COMPUTEFMT_ RESULTCompute data format information tds->comp_info now contains the result data; tds->curr_resinfo now points to that data
TDS_DESCRIBE_RESULT
Values that indicate data is available
ValueMeaningInformation returned
TDS_ROW_RESULTRegular row results 1 or more rows of regular data can now be retrieved
TDS_COMPUTE_RESULTCompute row results A single row of compute data can now be retrieved
TDS_PARAM_RESULTReturn parameter results
TDS_STATUS_RESULTStored procedure status results tds->ret_status contain the returned code
Todo:
Complete TDS_DESCRIBE_RESULT and TDS_PARAM_RESULT description
Return values:
TDS_SUCCEED if a result set is available for processing.
TDS_NO_MORE_RESULTS if all results have been completely processed.
Examples
The following code is cut from ct_results(), the ct-library function

Definition at line 408 of file token.c.

References tds_get_int(), tds_process_default_tokens(), tds_process_end(), and tds_process_result_tokens().

Referenced by tds_process_result_tokens(), and tds_process_simple_query().

{
int marker;
int done_flags;

      if (tds->state == TDS_COMPLETED) {
            tdsdump_log(TDS_DBG_FUNC, "%L inside tds_process_result_tokens() state is COMPLETED\n");
            *result_type = TDS_CMD_DONE;
            return TDS_NO_MORE_RESULTS;
      }

      for (;;) {

            marker = tds_get_byte(tds);
            tdsdump_log(TDS_DBG_INFO1, "%L processing result tokens.  marker is  %x(%s)\n", marker, _tds_token_name(marker));

            switch (marker) {
            case TDS7_RESULT_TOKEN:
                  tds7_process_result(tds);
                  *result_type = TDS_ROWFMT_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS_RESULT_TOKEN:
                  tds_process_result(tds);
                  *result_type = TDS_ROWFMT_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS_COLNAME_TOKEN:
                  tds_process_col_name(tds);
                  break;
            case TDS_COLFMT_TOKEN:
                  tds_process_col_fmt(tds);
                  *result_type = TDS_ROWFMT_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS_PARAM_TOKEN:
                  tds_unget_byte(tds);
                  tds_process_param_result_tokens(tds);
                  *result_type = TDS_PARAM_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS_COMPUTE_NAMES_TOKEN:
                  tds_process_compute_names(tds);
                  break;
            case TDS_COMPUTE_RESULT_TOKEN:
                  tds_process_compute_result(tds);
                  *result_type = TDS_COMPUTEFMT_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS7_COMPUTE_RESULT_TOKEN:
                  tds7_process_compute_result(tds);
                  *result_type = TDS_COMPUTEFMT_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS_ROW_TOKEN:
                  /* overstepped the mark... */
                  *result_type = TDS_ROW_RESULT;
                  tds->res_info->rows_exist = 1;
                  tds->curr_resinfo = tds->res_info;
                  tds_unget_byte(tds);
                  return TDS_SUCCEED;
                  break;
            case TDS_CMP_ROW_TOKEN:
                  *result_type = TDS_COMPUTE_RESULT;
                  tds->res_info->rows_exist = 1;
                  tds_unget_byte(tds);
                  return TDS_SUCCEED;
                  break;
            case TDS_RETURNSTATUS_TOKEN:
                  tds->has_status = 1;
                  tds->ret_status = tds_get_int(tds);
                  *result_type = TDS_STATUS_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS5_DYNAMIC_TOKEN:
                  /* TODO correct? */
                  tds->cur_dyn = tds_process_dynamic(tds);
                  break;
            case TDS5_PARAMFMT_TOKEN:
                  tds_process_dyn_result(tds);
                  *result_type = TDS_DESCRIBE_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS5_PARAMS_TOKEN:
                  tds_process_params_result_token(tds);
                  *result_type = TDS_PARAM_RESULT;
                  return TDS_SUCCEED;
                  break;
            case TDS_DONE_TOKEN:
            case TDS_DONEPROC_TOKEN:
            case TDS_DONEINPROC_TOKEN:
                  /* FIXME should we free results ?? */
                  if (tds_process_end(tds, marker, &done_flags) == TDS_SUCCEED)
                        *result_type = (done_flags & TDS_DONE_COUNT) ? TDS_CMD_DONE : TDS_CMD_SUCCEED;
                  else
                        *result_type = TDS_CMD_FAIL;
                  return TDS_SUCCEED;
                  break;
            default:
                  if (tds_process_default_tokens(tds, marker) == TDS_FAIL) {
                        return TDS_FAIL;
                  }
                  break;
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index