You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot move row immediately after creating it #878
I am presented with a warning popup alert with the message:
renameColumn: cannot find column firebase_token.
This didn't happen in 3.9.0 (tested) though I don't have time now to test in the yesterday's nightly.
Wow, it looks like it's completely broken. After clicking "OK", if I go to "Modify table" again, the last row is named "Field18", being the default name. And if I only change (not move it) and hit "OK", it does nothing.
My suggestions: when a field is just created, it gets a name like FieldN and then after you rename it upon creation, bool DBBrowserDB::renameColumn method gets called. However, this method obtains the version of a table which still has the old name of the field because table schemas are loaded directly from database, therefore the membership check fails. If you move field up, the same bool DBBrowserDB::renameColumn method gets called.
Currently I have no idea how to make this right. Here is my traceback when moving a field (truncated for short):
#0 DBBrowserDB::renameColumn (this=0xba4558, tablename=..., name=..., to=..., move=-1)
at /home/oleg/Документы/программирование/Sources/sqlitebrowser/src/sqlitedb.cpp:1111#1 0x000000000056e0bd in EditTableDialog::moveCurrentField (this=0x7fffffffc150, down=false)
at /home/oleg/Документы/программирование/Sources/sqlitebrowser/src/EditTableDialog.cpp:613#2 0x000000000056dbf1 in EditTableDialog::moveUp (this=0x7fffffffc150)
at /home/oleg/Документы/программирование/Sources/sqlitebrowser/src/EditTableDialog.cpp:564#3 0x000000000064a4d4 in EditTableDialog::qt_static_metacall (_o=0x7fffffffc150, _c=QMetaObject::InvokeMetaMethod, _id=9, _a=0x7fffffffb370)
at /home/oleg/Документы/программирование/Sources/sqlitebrowser/build/moc_EditTableDialog.cpp:120#4 0x00007ffff6cfc9d5 in QMetaObject::activate(QObject*, int, int, void**) () from /opt/qt57/lib/libQt5Core.so.5#5 0x00007ffff7473f52 in QAbstractButton::clicked(bool) () from /opt/qt57/lib/libQt5Widgets.so.5
@revolter@MKleusberg
I found that commit: e76e5b3. If i just remove this check, moving fields up/down works as expected. This check returns false, the function returns false to another functions, which in turn return false again with similar checks, and in majority of them there is no emit dbChanged(getDirty()) signal, which should trigger update of objMap data structure. I still have not figured out which checks should be corrected.
That is, if you release a savepoint X, the savepoints between setting and releasing X get released, and you cannot access them anymore.
I added a log statement in bool DBBrowserDB::executeSQL method and here is what I got when I opened a database, created a new column, tried to move it and closed the database:
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "PRAGMA foreign_keys = \"1\";"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "SAVEPOINT `edittable_wordcount_save_1480896969992`;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "ALTER TABLE `wordcount` ADD COLUMN \t`Field3`\tINTEGER"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "SAVEPOINT RESTOREPOINT;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:992) - setting savepoint 'sqlitebrowser_rename_column'
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "SAVEPOINT sqlitebrowser_rename_column;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "CREATE TABLE `sqlitebrowser_rename_column_new_table` (\n\t`word`\tTEXT,\n\t`cnt`\tINTEGER,\n\t`new_field`\tINTEGER\n);"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "INSERT INTO sqlitebrowser_rename_column_new_table SELECT `word`,`cnt`,`Field3` FROM `wordcount`;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "RELEASE RESTOREPOINT;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "PRAGMA defer_foreign_keys = \"1\";"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "DROP TABLE `wordcount`;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "ALTER TABLE `sqlitebrowser_rename_column_new_table` RENAME TO `wordcount`"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "RELEASE RESTOREPOINT;"
[warning] DB Browser for SQLite (../../src/sqlitedb.cpp:629) - executeSQL: "RELEASE RESTOREPOINT;" -> no such savepoint: RESTOREPOINT
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "PRAGMA defer_foreign_keys = \"0\";"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "SAVEPOINT RESTOREPOINT;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:1104) - releasing savepoint 'sqlitebrowser_rename_column'
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "RELEASE sqlitebrowser_rename_column;"
[warning] DB Browser for SQLite (../../src/sqlitedb.cpp:629) - executeSQL: "RELEASE sqlitebrowser_rename_column;" -> no such savepoint: sqlitebrowser_rename_column
[warning] DB Browser for SQLite (../../src/sqlitedb.cpp:1108) - "переименованиеСтолбца: ошибока освобождения точки сохранения. БД говорит: no such savepoint: sqlitebrowser_rename_column (RELEASE sqlitebrowser_rename_column;)"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:992) - setting savepoint 'sqlitebrowser_rename_column'
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "SAVEPOINT sqlitebrowser_rename_column;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "CREATE TABLE `sqlitebrowser_rename_column_new_table` (\n\t`word`\tTEXT,\n\t`new_field`\tINTEGER,\n\t`cnt`\tINTEGER\n);"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "INSERT INTO sqlitebrowser_rename_column_new_table SELECT `word`,`new_field`,`cnt` FROM `wordcount`;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "RELEASE RESTOREPOINT;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "PRAGMA defer_foreign_keys = \"1\";"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "DROP TABLE `wordcount`;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "ALTER TABLE `sqlitebrowser_rename_column_new_table` RENAME TO `wordcount`"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "RELEASE RESTOREPOINT;"
[warning] DB Browser for SQLite (../../src/sqlitedb.cpp:629) - executeSQL: "RELEASE RESTOREPOINT;" -> no such savepoint: RESTOREPOINT
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "PRAGMA defer_foreign_keys = \"0\";"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "SAVEPOINT RESTOREPOINT;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:1104) - releasing savepoint 'sqlitebrowser_rename_column'
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "RELEASE sqlitebrowser_rename_column;"
[warning] DB Browser for SQLite (../../src/sqlitedb.cpp:629) - executeSQL: "RELEASE sqlitebrowser_rename_column;" -> no such savepoint: sqlitebrowser_rename_column
[warning] DB Browser for SQLite (../../src/sqlitedb.cpp:1108) - "переименованиеСтолбца: ошибока освобождения точки сохранения. БД говорит: no such savepoint: sqlitebrowser_rename_column (RELEASE sqlitebrowser_rename_column;)"
[warning] DB Browser for SQLite (unknown:0) - QXcbConnection: XCB error: 3 (BadWindow), sequence: 1280, resource id: 15531982, major code: 40 (TranslateCoords), minor code: 0
[warning] DB Browser for SQLite (unknown:0) - QXcbConnection: XCB error: 3 (BadWindow), sequence: 1339, resource id: 15530383, major code: 40 (TranslateCoords), minor code: 0
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "ROLLBACK TO SAVEPOINT `edittable_wordcount_save_1480896969992`;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "RELEASE `edittable_wordcount_save_1480896969992`;"
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "ROLLBACK TO SAVEPOINT RESTOREPOINT;"
[warning] DB Browser for SQLite (../../src/sqlitedb.cpp:629) - executeSQL: "ROLLBACK TO SAVEPOINT RESTOREPOINT;" -> no such savepoint: RESTOREPOINT
[debug] DB Browser for SQLite (../../src/sqlitedb.cpp:613) - "RELEASE RESTOREPOINT;"
[warning] DB Browser for SQLite (../../src/sqlitedb.cpp:629) - executeSQL: "RELEASE RESTOREPOINT;" -> no such savepoint: RESTOREPOINT
So the handling of savepoint needs to be improved. Some questions arise:
Should we return false if there is no savepoint to release? (Doing this causes many thigs to break down)
Should we release all savepoints in between or do something else? (Seems like we should)
Activity
chrisjlocke commentedon Nov 28, 2016
Tested this in the latest nightly (on Windows) and after creating a new table and then clicking 'Write Changes' threw up an error.

Creating a table, then moving a row threw up a similar error.

Seems similar to #390 and #836.
justinclift commentedon Nov 28, 2016
Interesting. I saw similar a week or so ago. Something seems to have gone wrong somewhere which needs tracking down. 👼
prutz1311 commentedon Nov 28, 2016
My suggestions: when a field is just created, it gets a name like
FieldNand then after you rename it upon creation,bool DBBrowserDB::renameColumnmethod gets called. However, this method obtains the version of a table which still has the old name of the field because table schemas are loaded directly from database, therefore the membership check fails. If you move field up, the samebool DBBrowserDB::renameColumnmethod gets called.Currently I have no idea how to make this right. Here is my traceback when moving a field (truncated for short):
revolter commentedon Nov 29, 2016
Maybe a
git bisectbetweenHEADand3.9.0would help figure it out.prutz1311 commentedon Dec 2, 2016
@revolter @MKleusberg
I found that commit: e76e5b3. If i just remove this check, moving fields up/down works as expected. This check returns
false, the function returnsfalseto another functions, which in turn returnfalseagain with similar checks, and in majority of them there is noemit dbChanged(getDirty())signal, which should trigger update ofobjMapdata structure. I still have not figured out which checks should be corrected.justinclift commentedon Dec 2, 2016
@prutz1311 Cool, it sounds like you're investigating this properly. 😄
Do you want to assign it to yourself?
prutz1311 commentedon Dec 5, 2016
It seems that we are not handling savepoints properly. For example, not every order of setting/releasing savepoints is possible:
That is, if you release a savepoint
X, the savepoints between setting and releasingXget released, and you cannot access them anymore.I added a log statement in bool DBBrowserDB::executeSQL method and here is what I got when I opened a database, created a new column, tried to move it and closed the database:
So the handling of savepoint needs to be improved. Some questions arise:
justinclift commentedon Dec 5, 2016
Hmmm, at first thought yeah... 2. seems like the better idea.
Want to try it out and see if turns out to be ok?
Improve handling of SQLite savepoints (sqlitebrowser#878) (sqlitebrow…
Improve handling of SQLite savepoints (sqlitebrowser#878) (sqlitebrow…
Merge pull request #895 from prutz1311/master
Improve handling of SQLite savepoints (#878) (#836)
Merge pull request #895 from prutz1311/master
MKleusberg commentedon May 8, 2017
@justinclift and @revolter Have you tried Oleg's changes? They seem to work for me 😃
justinclift commentedon May 17, 2017
Yep, just tested it here on OSX too. Working well.
Thanks heaps @prutz1311. 😀