Skip to content
Prev 407 / 1559 Next

RSQLite: ATTACH statement not executed when the db connection is holding a resultSet

Hi Seth,
Seth Falcon wrote:
Are you sure? My understanding is that the ATTACH didn't occur on a temp connection
but really occurred on the db2 connection itself (I mean the real one). It's my
dbGetQuery(db2, "SELECT * FROM db1.t1") that was sent later thru a temporary connection
and thus was not aware that db1 was attached to db2. Or am I missing something?
I agree. But the ATTACH could have been sent a long time before (many queries before
in the query history), and not necessarily by me, so I don't really know the who/how/when
of it. And then suddenly, db1 doesn't seem to be attached to db2 anymore, even if everything
so far seemed to indicate that it was attached (let's say I've sent
dbGetQuery(db2, "SELECT * FROM db1.t1") many times before with no problems because there
was no pending results in db2).

So we have a situation where depending on whether I use dbGetQuery() or dbSendQuery() and
whether there is a pending result set or not, db1 will sometimes appear as attached to db2,
and sometimes not. That's what I mean by dbGetQuery() not reporting what one would expect.

Maybe the motivation behind the temporary connection "feature" feature was to provide
some convenience to the user so s/he can do:

  dbGetQuery(db2, myquery)

even if there is a pending result set. But then it should not affect the semantic of
dbGetQuery() i.e. one might expect the same result as with:

  ## clear all pending results first
  while (length(dbListResults(db2)) >= 1) dbClearResult(dbListResults(db2)[[1]])
  ## send the query
  dbGetQuery(db2, myquery)

which is not the case.

I understand that this is due to the temporary connection "feature" and that it might
look right to anybody who knows all the internal gears, but still...

BTW, according to the documentation it seems that the 'cache_size' and 'synchronous'
values that the user can specify when opening an SQLite connection with dbConnect()
are not used for the temporary connection. Any reason behind this?
Sounds good.

Thanks,
H.