-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing key doesn't change key and says ok #153
Comments
I agree that returning
That is, the behaviour you are seeing is expected behaviour. |
Note that I set the key, modified the database, and then set a different key. |
Unfortunately, the extension does not know the state of the database. This would require to keep track of the state of the database - whether a read/write after issuing If |
You would only need to track whether there have been any reads or writes since open - a single bit of information :-) As you described this also affects unencrypted databases where key pragma says I was surprised at how easy it is to make this mistake. I suggest closing as wontfix, or implementing it as a feature request making it easier to catch programming errors. |
Sounds easy to accomplish, but isn't. For example, let's assume we have an existing unencrypted database. We open the database and perform some read/write operations successfully. Where do we store the information that the database file was accessed successfully? There is no attached codec where we could add this information. The codec is only created when
Well, if the user is able to access the database without a key, why on earth should he/she issue a
Typically, an application should issue a |
I'm guessing that you have no VFS hooks hence no idea about reads/writes that have happened. There isn't even a file control with I/O counters. There are some DBSTATUS counters but that would be fragile. Note that this issue is not about correct usage! It is about developers making mistakes. The very first code I wrote did this. Python developers expect exceptions when they make mistakes as soon as possible, and it does lead to more robust code including detecting problems where and when they happen, rather than later. That is why I was surprised and created the issue, I suggest closing as cantfix. |
SQlite3 Multiple Ciphers's encryption extension is implemented as a VFS shim. So detecting that reads/writes have happened is possible. However, The VFS layer has no means to detect whether the data read are valid or not. Only SQLite's pager can tell whether the data are valid or corrupt. I'm not aware of any SQLite hook that allows to detect whether SQLite identifies read data as valid or not.
Since I started with providing a SQLite encryption extension in 2005, this topic came up several times. In principal, the behaviour of the function I decided to keep the current behaviour for 2 reasons:
Well, as said in principal it could be fixed, but because of the reasons mentioned I don't intend to change anything at the moment. |
If the |
If I do the key pragma on an already open database with a different key, I still get back
ok
. But that new passphrase is wrong and had no effect. I don't thinkok
is the right thing to return.The text was updated successfully, but these errors were encountered: