Re: [sqlite] How lock is implemented upon write?

2019-07-04 Thread Simon Slavin
Here's my guess.  OP is trying to implement locking in Python.  OP sees that 
SQLite does locking and wants to copy code.

Obviously, that's beyond the range of this mailing list, but just to be 
helpful, here's some stackoverflow:



Be sure to read all the way down the comments before you start copying code.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How lock is implemented upon write?

2019-07-04 Thread Adrian Ho
On 5/7/19 3:14 AM, Larry Brasfield wrote:
> I notice that you have ignored repeated requests for insight into why
> you have made your inquiry. People who may be able to help you with
> your objective ask for such information because, often, that leads to
> or permits a more direct solution to your actual problem.
In fact, this phenomenon happens so often, it even has a Wikipedia
entry: https://en.wikipedia.org/wiki/XY_problem

It's surprisingly easy to build a consulting career around asking just
one question, "What problem *X* are you trying to solve, for which you
think this method *Y* is the (probably incorrect) solution?". The real
trick is to summon the patience to guide your clients through the
process of discovering *X*, because they're almost always fixated with *Y*.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How lock is implemented upon write?

2019-07-04 Thread Larry Brasfield
Peng Yu wrote:
>> So the fundamental C API that unix_os.c is based on is
>> the only following but nothing else?
>>  [ followed by links to *nix C API fcntl(…) docs ]

The (C and fundamental) API you cite is the interface provided for applications 
running on Unix-like operating systems to lock files in various ways.  
Applications can use that API if they can pass the right parameters to the 
OS-provided entry point using C calling convention.  This is but tangentially 
related to “how lock is implemented upon write”, presumably in SQLite, (the 
subject of this thread, I guess.)  I say “tangentially” because there is far 
more to SQLite’s database locking than managing an OS-provided file lock. I can 
see this at a glance by looking at fcnt() calls (or their macro stand-ins) in 
sqlite3.c .

You appear to want to understand SQLite implements locking, apparently without 
reading the (C) code which effects that behavior.  I am not surprised than 
nobody wants to recast all that logic for you into a language you are willing 
and/or able to read.  It is complex, and changes among the platforms targeted 
by SQLite.  And it hardly matters to most SQLite users *how* it is implemented; 
their concern is how it works, which is well documented (as others have 
mentioned), and that it works well and reliably.

I notice that you have ignored repeated requests for insight into why you have 
made your inquiry.  People who may be able to help you with your objective ask 
for such information because, often, that leads to or permits a more direct 
solution to your actual problem.  Certainly in this case, where the Pascal 
translation of many lines of C would take hours to generate, a more direct 
solution is probably going to be the only one likely to be offered.

Cheers,
-
Larry Brasfield
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How lock is implemented upon write?

2019-07-04 Thread Peng Yu
So the fundamental C API that unix_os.c is based on is the only
following but nothing else?

- fcntl: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
- flock: https://www.freebsd.org/cgi/man.cgi?query=flock=2

On 7/3/19, Jens Alfke  wrote:
>
>> On Jul 3, 2019, at 6:20 PM, Peng Yu  wrote:
>>
>> Something in a higher level language (e.g., Python) that is easy to
>> run maybe better. Or at least some stand-alone C code (compilable to
>> executables) that is solely for the purpose of demonstrating the
>> locking mechanism.
>
> After you figure it out, you should write that and contribute it to help
> others!
>
> —Jens
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Regards,
Peng
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users