#1 2019-09-17 18:21:26

Codorna
Member
Registered: 2018-06-26
Posts: 21

TSQLTableJSON Step thread safety

I seldom get this error on my IDE when using a direct sql (service is on per thread) and TSQLJSONTable

  tableResult := TSQLTableJSON.Create(sql, fSQLServiceEFD.Execute(sql, true, false));
  try
    while tableResult.Step(False, @r) do
    (...)

raised exception class ESQLite3Exception with message 'Error SQLITE_MISUSE (21) [bind_text] using 3.29.0 - not an error, extended_errcode=0'

I've also seen extended_errcode = 100

doesn't happen on single thread execution (I'm using a Parallel.ForEach from omnithread)

Offline

#2 2019-09-18 07:19:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: TSQLTableJSON Step thread safety

A single instance of TSQLTableJSON is not thread-safe by itself: you should call tableResult.Step in a single thread, or protect it using a mutex.

But TSQLDataBase.Execute is thread-safe, and used as such on multi-threaded production since years.
You may do something weird with your use of SQLite3.

Offline

Board footer

Powered by FluxBB