Undetected Syntax Error?

  1. 6 months ago

    Not sure if this belongs in here or as a bug so apologies if I've put this query in the wrong place.

    In one of my prepared statements I made the mistake? of putting dataset = ps.SQLSelect() rather than ps.SQLExecute().

    I didn't realise at the time and I was able to run and build without an exception. See example below:

    sql = "select * from user_notes where refno_note=?"
    ps=session.gdb.Prepare(sql)
    ps.BindType(0,SQLitePreparedStatement.SQLITE_TEXT)
    ps.Bind(0,temp_ref)
    dataset =ps.SQLSelect()
    if dataset.field("web_status").StringValue= "Created" then
    sql = "delete from user_notes where user_notes.refno_note=? and user_notes.web_status='Created'"
    ps=session.gdb.Prepare(sql)
    ps.BindType(0,SQLitePreparedStatement.SQLITE_TEXT)
    ps.Bind(0,temp_ref)
    dataset = ps.SQLSelect()

    When I uploaded this build to my apache web server and tried to delete, apache crashed with the following error:

    *** Error in `/example/myapp': free(): invalid pointer: 0xb333bfc8 ***

    Which prompted me to go back into my code and change that last line to ps.SQLExecute().

    So I suppose my question is, how come I was able to build with the original code and delete without any issues while in the debug
    build?

    Thanks,
    Owen

    No invalid syntax: SQLSelect returns a recordset.
    Usually after each operation on a db an error check must be done.
    Please, try checking for errors after dataset = ps.SQLSelect() and see what's is reported.

    N.B.
    Error checking must be done also after a Prepare statement.

  2. Maurizio R

    Jun 19 Pre-Release Testers, Xojo Pro

    Maybe the execution environment isn't the same .
    I'm supposing your project is a web application and you deploy the built application as cgi.
    If this is the case, during debug no external web server is used.
    Maybe something else happens.

  3. This is correct, the execution environment is quite different in that no external web server is used during debug. This is done locally on a 64 Bit Windows 10 Machine whereas the live environment is a Standalone app on a 32 Bit Ubuntu Server 16.04 Machine.

    Is the Syntax dataset = ps.SQLSelect() not completely incorrect then? Because I would have thought that this would have been picked up as a Syntax error looking back at it.

  4. Maurizio R

    Jun 19 Pre-Release Testers, Xojo Pro Answer
    Edited 6 months ago

    No invalid syntax: SQLSelect returns a recordset.
    Usually after each operation on a db an error check must be done.
    Please, try checking for errors after dataset = ps.SQLSelect() and see what's is reported.

    N.B.
    Error checking must be done also after a Prepare statement.

  5. I see, thank you for the clarification

or Sign Up to reply!