pending lock macro
(1) By sqlite3_preupdate_count (XiongZaiBingGan) on 2021-02-07 04:28:26 [link] [source]
a sqlite book says:'The PENDING_BYTE macro (0x40000000, the first byte past the 1 GB boundary defines the beginning of the lock bytes) is the default byte used for setting PENDING locks.'
- i'm not sure about is the 0x40000000 offset from the beginning of the database file ? if it is ,when the database file size less than 0x40000000(aka 1GB),where is region for the pending_byte in database file ?
(2) By Stephan Beal (stephan) on 2021-02-07 09:14:52 in reply to 1 [link] [source]
i'm not sure about is the 0x40000000 offset from the beginning of the database file ? if it is ,when the database file size less than 0x40000000(aka 1GB),where is region for the pending_byte in database file ?
That's explained in the source code:
A partial snippet of those docs:
** Locking in windows is manditory. For this reason, we cannot store ** actual data in the bytes used for locking. The pager never allocates ** the pages involved in locking therefore. SHARED_SIZE is selected so ** that all locks will fit on a single page even at the minimum page size. ** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE ** is set high so that we don't have to allocate an unused page except ** for very large databases. But one should test the page skipping logic ** by setting PENDING_BYTE low and running the entire regression suite.
(3) By sqlite3_preupdate_count (XiongZaiBingGan) on 2021-02-07 10:16:12 in reply to 2 [link] [source]
thanks for your answer,but the docs don't describe when database size less than 1GB,which region in the file is used for the DEPEING_BYTE.do you know about the details of the implement?
(4) By David Raymond (dvdraymond) on 2021-02-08 13:48:14 in reply to 3 [source]
I believe it's still the same byte, and that when you say to the OS "lock byte 1 billion" and the file is less than that size, then the OS just shrugs and says "ok. If you ever get there it's locked." It does not expand the file out on disk or in memory to be 1 billion bytes just so it can lock byte 1 billion.
(5) By sqlite3_preupdate_count (XiongZaiBingGan) on 2021-02-09 01:29:23 in reply to 4 [link] [source]
thank you,i use linux api fcntl() set lock at offset 1GB in a file which filesize less than 1GB,it locks successful.my question has been solved.