-
-
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
Opening and closing a database multiple times fails #145
Comments
I suspect that you establish your database connections in some uncommon way, because opening and closing database connections via
Well, there is only a single place where this function is called, namely Currently, function Typically, an application calls However, I suspect that you call these functions every time you open resp close a database connection. Nevertheless, I agree that an application should not fail even if these functions are called several times. Therefore, thanks for reporting this issue.
Since function The drawback of calling
Therefore it is strongly recommended to call
In principle, the fix would work, but I will apply the simpler fix mentioned above. |
Thanks for your comments. I totally agree that I have been using I did not detect this, because in previous releases it was working (my app opens and closes a database only twice). |
Set globalCipherCount to 0 in function sqlite3mcTermCipherTables, so that the SQLite initialization and termination code can be called multiple times in an application without causing problems. Typically, the SQLite initialization and termination code should be called only once, at starting an application and at terminating an application.
Commit f1543a7 should fix the problem, so that the SQLite initialization and termination code can be called multiple times within an application without causing trouble. |
If a database file is opened and closed several times within a project, it fails after 2 or 3 successful connects.
I tracked this down to the function sqlite3mcTermCipherTables() which obviousley is freeing initializations performed by sqlite3mcRegisterCipher(). If --globalCipherCount; is added within the function everything seems to be working:
SQLITE_PRIVATE void
sqlite3mcTermCipherTables()
{
size_t n;
for (n = CODEC_COUNT_MAX+1; n > 0; --n)
{
if (globalCodecParameterTable[n].m_name[0] != 0)
{
int k;
CipherParams* params = globalCodecParameterTable[n].m_params;
for (k = 0; params[k].m_name[0] != 0; ++k)
{
sqlite3_free(params[k].m_name);
}
sqlite3_free(globalCodecParameterTable[n].m_params);
--globalCipherCount;
}
}
}
Please check if this fix is correct - since I'm not familiar with the internal structures used.
The text was updated successfully, but these errors were encountered: