[V4RB] The Open/Close trick Lives!

Ruslan Zasukhin sunshine at public.kherson.ua
Fri Feb 14 20:00:17 CST 2003


on 2/14/03 7:31 PM, Keith DeLong at delong at redcort.com wrote:

> After months of pondering and 3 focused days of testing and investigation, I
> have a solution for basic shared data file access under OS X
> 
> The Situation
> Pseudo multi-user access to Valentina files was pretty easily achieved by
> opening and closing the data file between uses. Under OS 9 and Windows,
> doing a db.open(f) will throw an error if the data file is already open.
> Using a timer to attempt opens until successful proved quite stable and
> robust.
> 
> The problem
> OS X will does not grant exclusive file access
> (http://developer.apple.com/technotes/tn/tn2037.html). This means that any
> Valentina data residing on OS X will open happily without an error even if
> someone else has already opened and is using it. The result is the dreaded
> -61 error as well as data corruption and a host of other complications.
> 
> The solution!
> Valentina will open, access and write to baseobjects as well as select
> cursors even when someone else is using the data file. The key was to find a
> reliable way to test a db on OS X for write access before giving the open db
> object back to the program for use.
> 
> I've discovered that that Valentina reliably throws the -61 error
> (permissions violation) when trying to select multiple tables. I suspect
> this has something to do with accessing the index file.
> 
> Thus, with a little overhead for a quick select from a small table, we can
> now test for both a successful Open AND the ability to have write access --
> meaning no one else is using the data file.
> 
> One last note: the -61 error reveals itself as db.errnumber.  Db.errstring
> is blank. This makes the the errstring an unreliable test for an error.
> 
> Example:
> 
> Function OpenDB(dbFolderItem) as vDatabase
> if MyDatabase.open(dbFolderItem) then
>  //test for full write access - dummy select 2 tables test for -61 error
>  c = MyDatabase.sqlselect("SELECT TaskName,DefTask FROM Tasks,Settings" )
>  if Mydatabase.errNumber = 0 then
>     return MyDatabase //success ...
>  else
>     c = nil
>  end
> end
> END
> 
> If the open fails, show a 'file busy' dialog with a timer that repeats the
> loop until a successful open or a Cancel from the user.
> 
> Ruslan,
> Perhaps on the backend you could use whatever is causing this -61 error to
> test a db.open. In this way a more elegant test and Open error could be
> thrown natively by Valentina under OSX.

Okay, I see.

Then I think I have advice to you.
SELECT to few tables give you this -61 error, because to do such SELECT,
Valentina need build TMP table on disk. As result it try to write.

Then I can advice to you to have HELPER table with one field and one record.
And simply do for that table.
    UPDATE f = 2 WHERE RecID = 1

This also will try to do write, so you must get the same -61 error.

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://listserv.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list