Skip to content

Commit

Permalink
tds: Empty record set if message received outside record set
Browse files Browse the repository at this point in the history
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
  • Loading branch information
freddy77 committed Oct 10, 2017
1 parent 906f3e6 commit 965a3a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/freetds/tds.h
Expand Up @@ -1192,6 +1192,7 @@ struct tds_socket
TDSCURSOR *cur_cursor; /**< cursor in use */
bool bulk_query; /**< true is query sent was a bulk query so we need to switch state to QUERYING */
bool has_status; /**< true is ret_status is valid */
bool in_row; /**< true if we are getting rows */
TDS_INT ret_status; /**< return status from store procedure */
TDS_STATE state;
volatile
Expand Down
3 changes: 3 additions & 0 deletions src/tds/mem.c
Expand Up @@ -477,6 +477,7 @@ tds_set_current_results(TDSSOCKET *tds, TDSRESULTINFO *info)
tds->current_results->attached_to = NULL;
if (info)
info->attached_to = tds;
tds->in_row = (info != NULL);
tds->current_results = info;
}

Expand All @@ -488,6 +489,7 @@ tds_detach_results(TDSRESULTINFO *info)
{
if (info && info->attached_to) {
info->attached_to->current_results = NULL;
info->attached_to->in_row = false;
info->attached_to = NULL;
}
}
Expand Down Expand Up @@ -660,6 +662,7 @@ tds_free_all_results(TDSSOCKET * tds)
tds->param_info = NULL;
tds_free_compute_results(tds);
tds->has_status = false;
tds->in_row = false;
tds->ret_status = 0;
if (tds->cur_dyn)
tds_detach_results(tds->cur_dyn->res_info);
Expand Down
5 changes: 5 additions & 0 deletions src/tds/token.c
Expand Up @@ -2089,6 +2089,8 @@ tds_process_end(TDSSOCKET * tds, int marker, int *flags_parm)
"\t\terror = %d\n"
"\t\tdone_count_valid = %d\n", more_results, was_cancelled, error, done_count_valid);

tds->in_row = false;

if (tds->res_info) {
tds->res_info->more_results = more_results;
/* FIXME this should not happen !!! */
Expand Down Expand Up @@ -2291,6 +2293,9 @@ tds_process_info(TDSSOCKET * tds, int marker)

CHECK_TDS_EXTRA(tds);

if (!tds->in_row)
tds_free_all_results(tds);

/* make sure message has been freed */
memset(&msg, 0, sizeof(TDSMESSAGE));

Expand Down

0 comments on commit 965a3a9

Please sign in to comment.