Logo Search packages:      
Sourcecode: freetds version File versions

int tds_process_row_tokens ( TDSSOCKET *  tds,
TDS_INT *  rowtype,
TDS_INT *  computeid 
)

process TDS row-type message streams. tds_process_row_tokens() is called once a result set has been obtained with tds_process_result_tokens(). It calls tds_process_row() to copy data into the row buffer.

Parameters:
tds A pointer to the TDSSOCKET structure managing a client/server operation.
rowtype A pointer to an integer variable which tds_process_row_tokens sets to indicate the current type of row
computeid A pointer to an integer variable which tds_process_row_tokens sets to identify the compute_id of the row being returned. A compute row is a row that is generated by a compute clause. The compute_id matches the number of the compute row that was read; the first compute row is 1, the second is 2, and so forth.
Possible values of *rowtype
  • TDS_REG_ROW A regular data row
  • TDS_COMP_ROW A row of compute data
  • TDS_NO_MORE_ROWS There are no more rows of data in this result set
Return values:
TDS_SUCCEED A row of data is available for processing.
TDS_NO_MORE_ROWS All rows have been completely processed.
TDS_FAIL An unexpected error occurred
Examples
The following code is cut from dbnextrow(), the db-library function

Definition at line 541 of file token.c.

References tds_result_info::computeid, tds_get_smallint(), tds_process_default_tokens(), tds_process_end(), and tds_process_row_tokens().

Referenced by tds_process_row_tokens(), and tds_process_simple_query().

{
int marker;
TDS_SMALLINT compute_id;
TDSRESULTINFO *info;
int i;

      if (tds->state == TDS_COMPLETED) {
            *rowtype = TDS_NO_MORE_ROWS;
            tdsdump_log(TDS_DBG_FUNC, "%L inside tds_process_row_tokens() state is COMPLETED\n");
            return TDS_NO_MORE_ROWS;
      }

      while (1) {

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

            switch (marker) {
            case TDS_RESULT_TOKEN:
            case TDS7_RESULT_TOKEN:

                  tds_unget_byte(tds);
                  *rowtype = TDS_NO_MORE_ROWS;
                  return TDS_NO_MORE_ROWS;

            case TDS_ROW_TOKEN:

                  tds_process_row(tds);
                  *rowtype = TDS_REG_ROW;
                  tds->curr_resinfo = tds->res_info;
                  return TDS_SUCCEED;

            case TDS_CMP_ROW_TOKEN:

                  *rowtype = TDS_COMP_ROW;
                  /* TODO put this code inside tds_process_compute ?? */
                  compute_id = tds_get_smallint(tds);

                  for (i = 0;; ++i) {
                        if (i >= tds->num_comp_info)
                              return TDS_FAIL;
                        info = tds->comp_info[i];
                        if (info->computeid == compute_id)
                              break;
                  }

                  tds->curr_resinfo = info;
                  tds_process_compute(tds);
                  if (computeid)
                        *computeid = compute_id;
                  return TDS_SUCCEED;

            case TDS_DONE_TOKEN:
            case TDS_DONEPROC_TOKEN:
            case TDS_DONEINPROC_TOKEN:

                  tds_process_end(tds, marker, NULL);
                  *rowtype = TDS_NO_MORE_ROWS;
                  return TDS_NO_MORE_ROWS;

            default:
                  if (tds_process_default_tokens(tds, marker) == TDS_FAIL)
                        return TDS_FAIL;
                  break;
            }
      }
      return TDS_SUCCEED;
}


Generated by  Doxygen 1.6.0   Back to index