Skip to content

Forever fetching zero-row data frame when query is killed at server side #126

@renkun-ken

Description

@renkun-ken

The following code sends a query to MySQL and fetch 10000 records each time.

dt <- list()
n <- 1L
res <- dbSendQuery(con, "select * from data")
while (!dbHasCompleted(res)) {
  dt[[n]] <- dbFetch(res, 10000)
  cat(sprintf("[%s][%d] %d rows fetched\n", as.character(Sys.time()), n, nrow(dt[[n]]))
  n <- n + 1L
}

If the query is killed at server side (e.g. done in MySQL Workbench), the while loop runs forever getting zero-row data frame in each fetch and dbHasCompleted does not return TRUE.

Is it a desired behavior or shouldn't it just throw an error and stop everything?

The walk-around is simple, just look at the row number of the latest chunk fetched.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions