In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

MariaDB Commands Out Of Sync error

Xailer professional forum in English
Responder
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

MariaDB Commands Out Of Sync error

Mensaje 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
Adjuntos
Testes.zip
(44.75 KiB) Descargado 224 veces
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5706
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Re: MariaDB Commands Out Of Sync error

Mensaje 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
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Re: MariaDB Commands Out Of Sync error

Mensaje por emeasoft »

Good morning jfgimenez,

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

André Corrêa.
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5706
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Re: MariaDB Commands Out Of Sync error

Mensaje 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..."
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Re: MariaDB Commands Out Of Sync error

Mensaje 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
Responder