mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Merge pull request #18 from nyalldawson/fix_limit
Fix LIMIT clause is ignored when executing SQL via ODBC, incorrect behavior with LIMIT 0
This commit is contained in:
commit
1e983c70f1
@ -1081,6 +1081,9 @@ SQLRETURN SQL_API SQLFetch(
|
||||
//}
|
||||
//cur = cur->next;
|
||||
//}
|
||||
if ( stmt->sql->limit >= 0 && stmt->rows_affected == stmt->sql->limit ) {
|
||||
return SQL_NO_DATA_FOUND;
|
||||
}
|
||||
|
||||
if (mdb_fetch_row(stmt->sql->cur_table)) {
|
||||
stmt->rows_affected++;
|
||||
|
@ -590,7 +590,7 @@ void mdb_sql_reset(MdbSQL *sql)
|
||||
sql->sel_count = 0;
|
||||
sql->max_rows = -1;
|
||||
sql->row_count = 0;
|
||||
sql->limit = 0;
|
||||
sql->limit = -1;
|
||||
}
|
||||
static void print_break(int sz, int first)
|
||||
{
|
||||
@ -886,7 +886,7 @@ mdb_sql_fetch_row(MdbSQL *sql, MdbTableDef *table)
|
||||
{
|
||||
int rc = mdb_fetch_row(table);
|
||||
if (rc) {
|
||||
if (sql->row_count + 1 > sql->limit) {
|
||||
if (sql->limit >= 0 && sql->row_count + 1 > sql->limit) {
|
||||
return 0;
|
||||
}
|
||||
sql->row_count++;
|
||||
|
Loading…
Reference in New Issue
Block a user