On Friday, 21 February, 2020 19:36, Simon Slavin <slav...@bigfraud.org> wrote:

>On 22 Feb 2020, at 2:28am, Keith Medcalf <kmedc...@dessus.com> wrote:

>> When a database is to be created these commands must be given BEFORE
>any command which opens or creates the database:
>>
>> pragma auto_vacuum
>> pragma encoding
>> pragma page_size
>> pragma data_store_directory

>> The issuance (or preparation) of ANY OTHER COMMAND will cause a new
>> blank database to be created using the values of auto_vacuum, encoding,
>> and page_size in effect at the time that command is issued (prepared).

>The problem is, Jens points out, that this is not documented.  The
>documentation doesn't distinguish between those four PRAGMAs and other
>PRAGMAs which stop those four from working.

That is not entirely true.  All of them say that they change the format of a 
database and only work if the database does not yet exist, although in various 
variant wording.  Perhaps the wording needs to be more clear like it is for the 
"encoding" pragma which is very clear in stating that the attempt to change the 
encoding of an existing database will have no effect and therefore this command 
must be given before the database file is created in order to have effect.

In the case of the auto_vacuum and page_size pragma's, however, they DO have 
effect on a currently existing open database in particular circumstances.  

However if you want them to have effect for a newly created database you need 
to issue them before the database is created.

>I've previously suggested that the PRAGMAs should be divided into
>categories.  Perhaps this should be a new category: those which do not
>create a database but have to be done before anything that creates the
>database.

Well, that would be only one pragma, encoding.  Whether on not the same applies 
to any other pragma (page_size, auto_vacuum) depends on the intent of the 
issuer of the command.  If they are expected to affect a database which has not 
yet been created, then obviously they must be issued before the database is 
created.  If they are intended to affect the database after it is created then 
they should be issued after the database is created.  If they are issued after 
the database is created they are subject to the limitations of the operation of 
those commands on already existant databases.

Perhaps the pragma encoding, pragma auto_vacuum and pragma page_size simply 
need to say that if one wants the change to apply to a "newly created" database 
these commands must be given first, before any other command.

-- 
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.




_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to