Skip to content

Commit

Permalink
fix reading from timertag table by key
Browse files Browse the repository at this point in the history
index position was incremented twice, which caused wrong results when
reading from timertag table by timer_id
  • Loading branch information
tony2001 committed Jul 26, 2011
1 parent 8ff5861 commit 3a0cb51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/ha_pinba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ int ha_pinba::index_next(unsigned char *buf) /* {{{ */
DBUG_RETURN(HA_ERR_WRONG_INDEX);
}

ret = read_next_row(buf, active_index);
ret = read_next_row(buf, active_index, true);
if (!ret) {
this_index[active_index].position++;
}
Expand All @@ -1713,7 +1713,7 @@ int ha_pinba::index_prev(unsigned char *buf) /* {{{ */
DBUG_RETURN(HA_ERR_WRONG_INDEX);
}

ret = read_next_row(buf, active_index);
ret = read_next_row(buf, active_index, true);
if (!ret) {
this_index[active_index].position--;
}
Expand Down Expand Up @@ -1805,7 +1805,7 @@ int ha_pinba::rnd_next(unsigned char *buf) /* {{{ */

DBUG_ENTER("ha_pinba::rnd_next");

ret = read_next_row(buf, 0);
ret = read_next_row(buf, 0, false);
DBUG_RETURN(ret);
}
/* }}} */
Expand Down Expand Up @@ -1997,7 +1997,7 @@ int ha_pinba::read_row_by_key(unsigned char *buf, uint active_index, const unsig
}
/* }}} */

int ha_pinba::read_next_row(unsigned char *buf, uint active_index) /* {{{ */
int ha_pinba::read_next_row(unsigned char *buf, uint active_index, bool by_key) /* {{{ */
{
DBUG_ENTER("ha_pinba::read_next_row");
int ret = HA_ERR_INTERNAL_ERROR;
Expand Down Expand Up @@ -2066,6 +2066,9 @@ int ha_pinba::read_next_row(unsigned char *buf, uint active_index) /* {{{ */
break;
case PINBA_TABLE_TIMERTAG:
ret = tag_values_fetch_next(buf, &(this_index[0].ival), &(this_index[0].position));
if (!by_key) {
this_index[0].position++;
}
break;
case PINBA_TABLE_INFO:
ret = info_fetch_row(buf);
Expand Down Expand Up @@ -2581,8 +2584,6 @@ inline int ha_pinba::tag_values_fetch_next(unsigned char *buf, size_t *index, si
}
dbug_tmp_restore_column_map(table->write_set, old_map);

(*position)++;

pthread_rwlock_unlock(&D->collector_lock);
DBUG_RETURN(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ha_pinba.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ha_pinba: public handler
pinba_index_st this_index[PINBA_MAX_KEYS];

int read_row_by_key(unsigned char *buf, uint active_index, const unsigned char *key, uint key_len, int exact);
int read_next_row(unsigned char *buf, uint active_index);
int read_next_row(unsigned char *buf, uint active_index, bool by_key);
int read_index_first(unsigned char *buf, uint active_index);

inline int requests_fetch_row(unsigned char *buf, size_t index, size_t *new_index);
Expand Down

0 comments on commit 3a0cb51

Please sign in to comment.