mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
Merge sinisa@bk-internal.mysql.com:/home/bk/mysql-4.1
into sinisa.nasamreza.org:/mnt/work/mysql-4.1
This commit is contained in:
commit
a017778493
3 changed files with 70 additions and 0 deletions
|
@ -943,3 +943,5 @@ ac_available_languages_fragment
|
|||
libmysqld/ha_archive.cc
|
||||
libmysqld/ha_example.cc
|
||||
libmysqld/ha_tina.cc
|
||||
analyse.test
|
||||
client/mysqladmin.c
|
||||
|
|
|
@ -4413,6 +4413,12 @@ mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong row)
|
|||
for (; tmp && row; --row, tmp= tmp->next)
|
||||
;
|
||||
stmt->data_cursor= tmp;
|
||||
if (!row && tmp)
|
||||
{
|
||||
/* Rewind the counter */
|
||||
stmt->read_row_func= stmt_read_row_buffered;
|
||||
stmt->state= MYSQL_STMT_EXECUTE_DONE;
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
|
|
@ -11389,6 +11389,67 @@ static void test_conversion()
|
|||
myquery(rc);
|
||||
}
|
||||
|
||||
static void test_rewind(void)
|
||||
{
|
||||
MYSQL_STMT *stmt;
|
||||
MYSQL_BIND bind;
|
||||
int rc = 0;
|
||||
const char *stmt_text;
|
||||
long unsigned int length=4, Data=0;
|
||||
my_bool isnull=0;
|
||||
|
||||
myheader("test_rewind");
|
||||
|
||||
stmt_text= "CREATE TABLE t1 (a int)";
|
||||
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
|
||||
myquery(rc);
|
||||
stmt_text= "INSERT INTO t1 VALUES(2),(3),(4)";
|
||||
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
|
||||
myquery(rc);
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
|
||||
stmt_text= "SELECT * FROM t1";
|
||||
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
|
||||
check_execute(stmt, rc);
|
||||
|
||||
bzero(&bind,sizeof(MYSQL_BIND));
|
||||
bind.buffer_type= MYSQL_TYPE_LONG;
|
||||
bind.buffer= (void *)&Data; /* this buffer won't be altered */
|
||||
bind.length= &length;
|
||||
bind.is_null= &isnull;
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_execute(stmt, rc);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
DIE_UNLESS(rc == 0);
|
||||
|
||||
rc= mysql_stmt_bind_result(stmt, &bind);
|
||||
DIE_UNLESS(rc == 0);
|
||||
|
||||
/* retreive all result sets till we are at the end */
|
||||
while(!mysql_stmt_fetch(stmt))
|
||||
printf("fetched result:%ld\n", Data);
|
||||
|
||||
DIE_UNLESS(rc != MYSQL_NO_DATA);
|
||||
|
||||
/* seek to the first row */
|
||||
mysql_stmt_data_seek(stmt, 0);
|
||||
|
||||
/* now we should be able to fetch the results again */
|
||||
/* but mysql_stmt_fetch returns MYSQL_NO_DATA */
|
||||
while(!(rc= mysql_stmt_fetch(stmt)))
|
||||
printf("fetched result after seek:%ld\n", Data);
|
||||
|
||||
DIE_UNLESS(rc == MYSQL_NO_DATA);
|
||||
|
||||
stmt_text= "DROP TABLE t1";
|
||||
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
|
||||
myquery(rc);
|
||||
rc= mysql_stmt_free_result(stmt);
|
||||
rc= mysql_stmt_close(stmt);
|
||||
}
|
||||
|
||||
/*
|
||||
Read and parse arguments and MySQL options from my.cnf
|
||||
|
@ -11594,6 +11655,7 @@ static struct my_tests_st my_tests[]= {
|
|||
{ "test_datetime_ranges", test_datetime_ranges },
|
||||
{ "test_bug4172", test_bug4172 },
|
||||
{ "test_conversion", test_conversion },
|
||||
{ "test_rewind", test_rewind },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue