Página 1 de 1

MariaDB Commands Out Of Sync error

Publicado: Jue Ene 07, 2016 2:22 pm
por emeasoft
Hi,

We are facing a problem with Execute(), QueryArray() and QueryRow() methods from TMariaDBDataSource.
If the result has a big amount of data and the method is called again before the previous one has finished
processing, Xailer throws the error:
TMARIADBDATASOURCE:NEWERROR(615)
Erro XAILER/2014 Commands out of sync; you can't run this command now: MariaDB:SELECT * FROM teste
Argumentos: ()
We are sending attached the test project. Just click rapidly and repeatedly the button and Xailer will throw the
error.

MySql and MariaDB documentation says it occurs when you have 2 result sets open at the same time and to
avoid it, it's necessary to call the mysql_free_result() method.

Doesn't Execute(), QueryArray() and QueryRow() methods call it?
It can be fixed?

Thank you,

André Corrêa

Re: MariaDB Commands Out Of Sync error

Publicado: Mié Ene 13, 2016 10:17 am
por jfgimenez
André,

I'm affraid that the MySQL and MariaDB connectors (libmysql.dll and libmariadb.dll) don't allow to open two querys at the same time. So, you need to carry a flag to avoid it. F.e.:

Código: Seleccionar todo

IF ! ::lQuering
   ::lQuering := .T.
   // Make your query
   // ...
   // -----
   ::lQuering := .F.
ENDIF

Re: MariaDB Commands Out Of Sync error

Publicado: Mié Ene 13, 2016 2:18 pm
por emeasoft
Good morning jfgimenez,

If you test with the sample we have provided, you can see that the error persists.

André Corrêa.

Re: MariaDB Commands Out Of Sync error

Publicado: Dom Ene 17, 2016 8:07 pm
por jfgimenez
André,

As I said before, you have to set a flag to avoid running a query twice at the same time. I've tested tour sample, and it raises an error as you said. Later, I've modified it by adding a property to the form:

Código: Seleccionar todo

PROPERTY lBusy   INIT .F.
And also changing the method BtnClick as so:

Código: Seleccionar todo

METHOD BtnClick( oSender ) CLASS TForm1

  LOCAL a01

   IF !::lBusy
      ::lBusy := .T.
     //a01:=AppData:tSql:QueryArray("SELECT * FROM teste")
     AppData:tSql:Execute("SELECT * FROM teste",,@a01)

     //Ocorre tanto com :Execute() quanto com :QueryArray()

     LogDebug("Nova Consulta", a01)
      ::lBusy := .F.
   ENDIF

RETURN Nil
And then, the error vanishes.

There is another way to avoid those errors... setting this property on the datasource:

Código: Seleccionar todo

AppData:tSql:lAllowProcessMessages := .F.
But this way causes that your program does not process any windows message while the datasource is busy. It could cause your program to be marked from windows as "program is not responding..."

Re: MariaDB Commands Out Of Sync error

Publicado: Lun Ene 18, 2016 1:00 pm
por emeasoft
jfgimenez,

We need more time testing, but It seems that setting lAllowProcessMessages to false solves our problem.

Thank you very much!

André Corrêa