Bug 288599 - Schema update to V6 failed
Summary: Schema update to V6 failed
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Schema (show other bugs)
Version: 2.4.0
Platform: Gentoo Packages Linux
: NOR major
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-09 21:08 UTC by serge
Modified: 2020-01-01 21:43 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.0.0


Attachments
Database structure (18.76 KB, text/plain)
2011-12-10 07:47 UTC, serge
Details
MYSQL server log (running digikam after executing SQL code from comment #3) (22.48 KB, text/x-log)
2011-12-11 12:01 UTC, serge
Details

Note You need to log in before you can comment on or make changes to this bug.
Description serge 2011-12-09 21:08:00 UTC
Version:           unspecified (using KDE 4.7.3) 
OS:                Linux

Today I have upgraded digikam from 1.9 up to 2.4.1  

I use MySQL database. When starting digikam prints

QSqlDatabasePrivate::removeDatabase: connection 'ConnectionTest' is still in use, all queries will cease to work.
digikam(14004)/digikam (core): Schema update to V6 failed! 

and finally I obtain empty albums.

Please, help

Reproducible: Didn't try

Steps to Reproduce:
Start digikam after upgrade


Expected Results:  
I want to see my albums
Comment 1 Francesco Riosa 2011-12-09 22:15:57 UTC
need more info to try to understand the problem:
1) is the database populated? (if yes please backup)
2) do a mysqldump --no-data of the database, will be needed to know the structure of the database.
3) if you leave digikam run for a pair of minutes and then restart it does it work?
4) using the `kdebugdialog` activate the output for the following areas:
  [50003] [50004] [50005] [50006] [50007] [51000] [51001] [digikam] [showfoto] [unnamed app]
  then run digikam from the command line, should give a lot of output

please attach at least the structure of the db and the digikam log to this bug
Comment 2 serge 2011-12-09 22:27:33 UTC
This is digikam output after 4). 

$ digikam 
digikam(25800)/kdeui (KIconLoader) KIconThemeDir::KIconThemeDir: Invalid Context= "Apps" line for icon theme:  "/usr/share/icons/Mist/22x22/apps"
digikam(25800)/kdeui (KIconLoader) KIconThemeDir::KIconThemeDir: Invalid Context= "Apps" line for icon theme:  "/usr/share/icons/Mist/16x16/apps"
digikam(25800)/kdeui (KIconLoader) KIconThemeDir::KIconThemeDir: Invalid Context= "Apps" line for icon theme:  "/usr/share/icons/Mist/32x32/apps"
digikam(25800)/kdeui (KIconLoader) KIconThemeDir::KIconThemeDir: Invalid Context= "Apps" line for icon theme:  "/usr/share/icons/Mist/48x48/apps"
digikam(25800)/kdeui (KIconLoader) KIconThemeDir::KIconThemeDir: Invalid Context= "Apps" line for icon theme:  "/usr/share/icons/Mist/24x24/apps"
digikam(25800)/kdeui (KIconLoader) KIconThemeDir::KIconThemeDir: Invalid Context= "Apps" line for icon theme:  "/usr/share/icons/Mist/256x256/apps"
digikam(25800)/digikam (core) Digikam::KInotify::Private::open: Successfully opened connection to inotify: 17
digikam(25800)/digikam (core) Digikam::AlbumManager::setDatabase: DatabaseParameters: [ Type "QMYSQL", Name "digikam" (Thumbnails Name "digikam"); ConnectOptions: "UNIX_SOCKET=/home/serge/.kde4/share/apps/digikam/db_misc/mysql.socket", Username and Password: "root", ""]
QSqlDatabasePrivate::removeDatabase: connection 'ConnectionTest' is still in use, all queries will cease to work.
digikam(25800)/digikam (core) Digikam::DatabaseConfigElementLoader::readConfig: Loading SQL code from config file "/usr/share/apps/digikam/database/dbconfig.xml"
digikam(25800)/digikam (core) Digikam::DatabaseConfigElementLoader::readConfig: false "1" 1 1
digikam(25800)/digikam (core) Digikam::SchemaUpdater::update: SchemaUpdater update
digikam(25800)/digikam (core) Digikam::SchemaUpdater::startUpdates: Have a database structure version  5
digikam(25800)/digikam (core) Digikam::SchemaUpdater::makeUpdates: makeUpdates  5  to  6
digikam(25800)/digikam (core) Digikam::DatabaseCoreBackendPrivate::debugOutputFailedQuery: Failure executing query:
 "" 
Error messages: "QMYSQL: Unable to execute query" "PROCEDURE digikam.create_index_if_not_exists does not exist" 1305 2 
Bound values:  ()
digikam(25800)/digikam (core) Digikam::DatabaseCoreBackend::execDBAction: Error while executing DBAction [ "UpdateSchemaFromV5ToV6" ] Statement [ "CALL create_index_if_not_exists('ImageTags','tag_id_index','imageid');" ]
digikam(25800)/digikam (core): Schema update to V6 failed!
Comment 3 Francesco Riosa 2011-12-09 22:36:49 UTC
the (mysql digikam code) problem is that you're using two different databases for images and thumbnails.

try to execute the following SQL in both databases, and then restart digikam:

DROP PROCEDURE IF EXISTS create_index_if_not_exists;

delimiter ;;

CREATE PROCEDURE create_index_if_not_exists(table_name_vc varchar(50), index_name_vc varchar(50), field_list_vc varchar(1024), is_unique int)
SQL SECURITY INVOKER
BEGIN

set @Index_cnt = (
    SELECT COUNT(1) cnt
    FROM INFORMATION_SCHEMA.STATISTICS
    WHERE CONVERT(DATABASE() USING latin1) = CONVERT(TABLE_SCHEMA USING latin1)
    AND CONVERT(table_name USING latin1) = CONVERT(table_name_vc USING latin1)
    AND CONVERT(index_name USING latin1) = CONVERT(index_name_vc USING latin1)
);

IF IFNULL(@Index_cnt, 0) = 0 THEN
    set @index_sql = CONCAT(
        CONVERT( 'ALTER TABLE ' USING latin1),
        CONVERT( table_name_vc USING latin1),
        CONVERT( IF(is_unique = 0, ' ADD INDEX ', ' ADD UNIQUE INDEX ') USING latin1),
        CONVERT( index_name_vc USING latin1),
        CONVERT( '(' USING latin1),
        CONVERT( field_list_vc USING latin1),
        CONVERT( ');' USING latin1)
    );
    PREPARE stmt FROM @index_sql;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
END IF;
END ;;
Comment 4 Francesco Riosa 2011-12-09 22:39:52 UTC
please confirm the problem has been "fixed" (a real fix is waiting for me to understand much better qt+threads+database).
Comment 5 serge 2011-12-09 22:40:16 UTC
Ok, many thanks for quick answer, I will try tomorrow and send a feedback.
Comment 6 serge 2011-12-10 07:25:21 UTC
Dear Francesco, it is not absolutely clear for me what do you mean by different databases. I have the following settings in digikamrc:

[Database Settings]
Database Connectoptions=UNIX_SOCKET=/home/serge/.kde4/share/apps/digikam/db_misc/mysql.socket
Database Hostname=
Database Name=digikam
Database Name Thumbnails=digikam
Database Password=
Database Port=0
Database Type=QMYSQL
Database Username=root
Internal Database Server=false

So, it seems that I have only one database "digikam"
Comment 7 serge 2011-12-10 07:47:36 UTC
Created attachment 66581 [details]
Database structure
Comment 8 serge 2011-12-11 10:09:25 UTC
This is the digikam output after applying sql code from comment #3:

digikam(20752)/digikam (core) Digikam::AlbumManager::setDatabase: DatabaseParameters: [ Type "QMYSQL", Name "digikam" (Thumbnails Name "digikam"); ConnectOptions: "UNIX_SOCKET=/home/serge/.kde4/share/apps/digikam/db_misc/mysql.socket", Username and Password: "root", ""]
QSqlDatabasePrivate::removeDatabase: connection 'ConnectionTest' is still in use, all queries will cease to work.
digikam(20752)/digikam (core) Digikam::DatabaseConfigElementLoader::readConfig: Loading SQL code from config file "/usr/share/apps/digikam/database/dbconfig.xml"
digikam(20752)/digikam (core) Digikam::DatabaseConfigElementLoader::readConfig: false "1" 1 1
digikam(20752)/digikam (core) Digikam::SchemaUpdater::update: SchemaUpdater update
digikam(20752)/digikam (core) Digikam::SchemaUpdater::startUpdates: Have a database structure version  5
digikam(20752)/digikam (core) Digikam::SchemaUpdater::makeUpdates: makeUpdates  5  to  6
digikam(20752)/digikam (core) Digikam::DatabaseCoreBackendPrivate::debugOutputFailedQuery: Failure executing query:
 "" 
Error messages: "QMYSQL: Unable to execute query" "Incorrect number of arguments for PROCEDURE digikam.create_index_if_not_exists; expected 4, got 3" 1318 2 
Bound values:  ()
digikam(20752)/digikam (core) Digikam::DatabaseCoreBackend::execDBAction: Error while executing DBAction [ "UpdateSchemaFromV5ToV6" ] Statement [ "CALL create_index_if_not_exists('ImageTags','tag_id_index','imageid');" ]
digikam(20752)/digikam (core): Schema update to V6 failed! 

Please, help!
Comment 9 serge 2011-12-11 12:01:06 UTC
Created attachment 66621 [details]
MYSQL server log (running digikam after executing SQL code from comment #3)
Comment 10 serge 2011-12-11 14:19:16 UTC
I have fixed somehow my problems by means of executing of SQL code from bug 283502. Seems to be a duplicate of 283502
Comment 11 caulier.gilles 2011-12-11 14:54:16 UTC

*** This bug has been marked as a duplicate of bug 283502 ***
Comment 12 caulier.gilles 2020-01-01 21:43:08 UTC
Not reproducible with 7.0.0 beta1.