mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
7873b89fc5
Fixed bugs in group_concat with ORDER BY and DISTINCT (Bugs #2695, #3381 and #3319) Fixed crash when doing rollback in slave and the io thread catched up with the sql thread Set locked_in_memory properly include/mysql_com.h: Fixed compiler warning libmysqld/emb_qcache.cc: Removed not used variable libmysqld/lib_sql.cc: Removed not used variable myisam/mi_locking.c: Added comment myisam/mi_rnext.c: Fixed bug in concurrent insert myisam/mi_rprev.c: Simple optimization mysql-test/r/func_gconcat.result: New tests mysql-test/t/func_gconcat.test: New tests mysql-test/t/func_group.test: Cleanup sql-common/client.c: Removed compiler warning sql/derror.cc: Better comments sql/field.cc: Removed not used function/variable sql/field.h: Removed not needed variable sql/ha_innodb.cc: Removed not used function sql/item.cc: Fixed compiler warning sql/item_cmpfunc.cc: Fixed compiler warning sql/item_func.cc: Fixed compiler warning sql/item_geofunc.cc: Fixed compiler warning sql/item_sum.cc: Fixed bugs in group_concat and added more comments (Bugs #2695, #3381 and #3319) - field->abs_offset was not needed - Wrong assumption of field order in temporary table - Some not used variables removed - Added ORDER BY fields after argument fields so that code in sql_select.cc can move all fields to point to temporary tables, if needed. - Optimized loops sql/item_sum.h: Bug fixing and cleanup of group_concat() sql/log.cc: Removed wrong comment sql/log_event.cc: Removed compiler warning sql/mysqld.cc: Set locked_in_memory properly sql/protocol.cc: Removed compiler warning sql/set_var.cc: Code cleanup sql/slave.cc: Fixed crash when doing rollback in slave and the io thread catched up with the sql thread sql/sql_cache.cc: Removed compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Removed compiler warnings sql/sql_lex.cc: Removed not used lable sql/sql_lex.h: Removed compiler warnings sql/sql_parse.cc: Removed compiler warnings sql/sql_prepare.cc: Removed compiler warnings sql/sql_select.cc: Removed not used variables Added function comments sql/sql_show.cc: Removed compiler warnings sql/sql_yacc.yy: Fix for ORDER BY handling in GROUP_CONCAT()
88 lines
2.8 KiB
C
88 lines
2.8 KiB
C
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#include "myisamdef.h"
|
|
|
|
/*
|
|
Read previous row with the same key as previous read
|
|
One may have done a write, update or delete of the previous row.
|
|
NOTE! Even if one changes the previous row, the next read is done
|
|
based on the position of the last used key!
|
|
*/
|
|
|
|
int mi_rprev(MI_INFO *info, byte *buf, int inx)
|
|
{
|
|
int error,changed;
|
|
register uint flag;
|
|
MYISAM_SHARE *share=info->s;
|
|
DBUG_ENTER("mi_rprev");
|
|
|
|
if ((inx = _mi_check_index(info,inx)) < 0)
|
|
DBUG_RETURN(my_errno);
|
|
flag=SEARCH_SMALLER; /* Read previous */
|
|
if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_NEXT_FOUND)
|
|
flag=0; /* Read last */
|
|
|
|
if (fast_mi_readinfo(info))
|
|
DBUG_RETURN(my_errno);
|
|
changed=_mi_test_if_changed(info);
|
|
if (share->concurrent_insert)
|
|
rw_rdlock(&share->key_root_lock[inx]);
|
|
if (!flag)
|
|
error=_mi_search_last(info, share->keyinfo+inx,
|
|
share->state.key_root[inx]);
|
|
else if (!changed)
|
|
error=_mi_search_next(info,share->keyinfo+inx,info->lastkey,
|
|
info->lastkey_length,flag,
|
|
share->state.key_root[inx]);
|
|
else
|
|
error=_mi_search(info,share->keyinfo+inx,info->lastkey,
|
|
USE_WHOLE_KEY, flag, share->state.key_root[inx]);
|
|
|
|
if (share->concurrent_insert)
|
|
{
|
|
if (!error)
|
|
{
|
|
while (info->lastpos >= info->state->data_file_length)
|
|
{
|
|
/* Skip rows that are inserted by other threads since we got a lock */
|
|
if ((error=_mi_search_next(info,share->keyinfo+inx,info->lastkey,
|
|
info->lastkey_length,
|
|
SEARCH_SMALLER,
|
|
share->state.key_root[inx])))
|
|
break;
|
|
}
|
|
}
|
|
rw_unlock(&share->key_root_lock[inx]);
|
|
}
|
|
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
|
|
info->update|= HA_STATE_PREV_FOUND;
|
|
if (error)
|
|
{
|
|
if (my_errno == HA_ERR_KEY_NOT_FOUND)
|
|
my_errno=HA_ERR_END_OF_FILE;
|
|
}
|
|
else if (!buf)
|
|
{
|
|
DBUG_RETURN(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
|
|
}
|
|
else if (!(*info->read_record)(info,info->lastpos,buf))
|
|
{
|
|
info->update|= HA_STATE_AKTIV; /* Record is read */
|
|
DBUG_RETURN(0);
|
|
}
|
|
DBUG_RETURN(my_errno);
|
|
} /* mi_rprev */
|