#1195 the pragma() method used to set a value will return OOD_UNEXPECTED_RESULT

ooSQLite.preview
closed
ooSQLite (10)
complete
1
2014-02-15
2013-09-08
hex
No

-- Seems that a file object can't be used as a parameter in aooSQLiteBackup statement.

-- see comments below
-- 64bit oorexx and oosqlite

trace ?R
parse source . . thisProgram .
thisProgramPath = FILESPEC("LOCA",thisProgram)
thisProgramName = FILESPEC("NAME",thisProgram)

dbName = 'TEST_DB'

/ next statement will result in a file, named "a file", when executing the oosqliteBackup~new /
fileDB = .File~new(dbName||'_NOTOK.sqlite',thisProgramPath)

/ next statment will result i a correct named databasefile, when executing the oosqliteBackup~new /
-- fileDB = thisProgramPath || dbName||'_OKFILE'||'.sqlite'

memDB = .ooSQLiteConnection~new(":memory:")
memDB~busyTimeout(3000)
ret = memdb~pragma(journal_mode)        -- says memory
ret = memdb~pragma(journal_mode,OFF)      -- gives "ooSQLite Error: rc = 1002, Unexpected result, data returned from pragma journal_mode" but seems to work

ret = memdb~pragma(journal_mode) -- says off

discDB = .ooSQLiteBackup~new(memDB, fileDB,.true)

memDB~close

::requires oosqlite.cls

Discussion

  • hex

    hex - 2013-09-08

    changing discDB = .ooSQLiteBackup~new(memDB, fileDB,.true) to
    discDB = .ooSQLiteBackup~new(memDB, fileDB~string,.true)
    then it will work with a fileobject

     
  • Mark Miesfeld

    Mark Miesfeld - 2013-09-08

    Hi hex,

    The .ooSQLitBackup~new() statement is working as designed. I know I don't have much of the ooSQLite doc finished, but I do have the doc for ooSQLiteBackup~new() done:

    dstDb [required]
    Specifies the destination database. This argument can either be an open database connection
    or the file name for the database.

    So, the destination database arg can be a file name or an ooSQLiteConnection object. It is not intended to accept a .File object.

    The other thing you bring up here:

    ret = memdb~pragma(journal_mode,OFF)

    gives ooSQLite Error: rc = 1002, Unexpected...

    comes from my implementation code. The pragma() method is meant to be a convenience method. Executing some of the pragmas in SQLite return rows, some don't. Most all of the 'set' pragmas do not return rows. I tried testing all the pragmas in different ways to see how they worked. So, in this case I did not ever see a row returned. It could be a new behavior in SQLite, or ... who knows. ;-) I'll try to fix that up.

    It will work just fine, despite the error return code. The pragma method works by executing the standard SQL stament.

    There is no reason why the new() method for the backup object couldn't accept a .File object for the destination source. I'd consider that a RFE rather than a a bug though. ;-)

     
  • Mark Miesfeld

    Mark Miesfeld - 2013-09-09

    In the explanation hex submitted:

    ret = memdb~pragma(journal_mode,OFF)

    -- gives "ooSQLite Error: rc = 1002, Unexpected result, data returned from pragma journal_mode" but seems to work

    is a bug, or at least a mistake in the implementation. Originally I didn't think that pragmas that set values would return rows. But, some, (many ?), do return a result set.

    When a result set is returned, it should be handled correctly and the result set returned from the method invocation.

     
  • Mark Miesfeld

    Mark Miesfeld - 2013-09-09
    • labels: --> ooSQLite
    • summary: oosqlitebackup~new and fileobject as parameter --> the prama() method used to set a value will return OOD_UNEXPECTED_RESULT
    • status: open --> accepted
    • assigned_to: Mark Miesfeld
     
  • Mark Miesfeld

    Mark Miesfeld - 2013-09-12
    • status: accepted --> pending
     
  • Mark Miesfeld

    Mark Miesfeld - 2013-09-12

    Committed revision 9418. r[9418] doc update
    Committed revision 9419. r[9419] bug fix

    The implementation for the pragma() method had a number of wholes in it besides the one that hex discovered. These should all be fixed now. In addition the doc for the pragma() method has been updated to be more complete in describing how the method works.

    hex - A new ooSQLite.pdf should be generated on the build machine (http://build.oorexx.org/) tonight or tomorrow. Provided I don't have any syntax errors in the doc source.

    With that doc, if you find any discrepancies in the behavior of pragma() with how it is documented, please report it. A bug is fine.

     
  • hex

    hex - 2013-09-12

    Mark
    I briefly read thru the manual and tested some pragmas, looks good so far.
    /hex

     
  • Mark Miesfeld

    Mark Miesfeld - 2014-02-15
    • summary: the prama() method used to set a value will return OOD_UNEXPECTED_RESULT --> the pragma() method used to set a value will return OOD_UNEXPECTED_RESULT
    • status: pending --> closed
    • Pending work items: none --> complete
     
  • Mark Miesfeld

    Mark Miesfeld - 2014-02-15

    This is fixed and available in the current preview build on SourceForge. Moving it to closed.

     


Anonymous

Cancel  Add attachments