Bug 209175 - [PATCH] Amarok 2.2.0 fails to import 1.4 Postgresql collection
Summary: [PATCH] Amarok 2.2.0 fails to import 1.4 Postgresql collection
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 2.2.0
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-02 06:04 UTC by Ionut Ciocirlan
Modified: 2009-10-11 12:02 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch made by me that fixes PostgreSQL database importing from Amarok 1.4 (i hope) (1.15 KB, patch)
2009-10-11 01:40 UTC, Anderson Medeiros Gomes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ionut Ciocirlan 2009-10-02 06:04:02 UTC
Version:           2.2.0 (using KDE 4.3.1)
OS:                Linux
Installed from:    Debian testing/unstable Packages

The debug log:

amarok: BEGIN: void DatabaseImporterDialog::pageChanged(KPageWidgetItem*, KPageWidgetItem*)
amarok:   BEGIN: virtual void DatabaseImporter::startImporting()
amarok:     BEGIN: virtual void FastForwardImporter::import()
amarok:     END__: virtual void FastForwardImporter::import() - Took 0.00015s
amarok:   END__: virtual void DatabaseImporter::startImporting() - Took 0.00024s
amarok:   BEGIN: virtual void FastForwardWorker::run()
amarok:   END__: void DatabaseImporterDialog::pageChanged(KPageWidgetItem*, KPageWidgetItem*) - Took 0.00057s
amarok:   BEGIN: QSqlDatabase FastForwardWorker::databaseConnection()
amarok:   END__: QSqlDatabase FastForwardWorker::databaseConnection() - Took 0.008s
amarok:    exec() false active? false size: -1
amarok:    [ERROR!] Error executing import query: "Could not execute import query:  "
amarok: END__: virtual void FastForwardWorker::run() - Took 0.7s
amarok: BEGIN: void FastForwardImporter::finishUp()
amarok: END__: void FastForwardImporter::finishUp() - Took 0.00044s

It doesn't say much, but the postgresql log is more interesting:

LOG:  statement: select version()
LOG:  statement: SET CLIENT_ENCODING TO 'UNICODE'
LOG:  statement: SET DATESTYLE TO 'ISO'
LOG:  statement: SELECT lastmountpoint, S.url, S.createdate, accessdate, percentage, rating, playcounter, lyrics, title, A.name, R.name, C.name, G.name, Y.name, track, discnumber, filesize FROM statistics S LEFT OUTER JOIN devices D   ON S.deviceid = D.id LEFT OUTER JOIN lyrics L   ON L.deviceid = S.deviceid   AND L.url = S.url LEFT OUTER JOIN tags T   ON T.deviceid = S.deviceid   AND T.url = S.url LEFT OUTER JOIN album A   ON T.album = A.id LEFT OUTER JOIN artist R   ON T.artist = R.id LEFT OUTER JOIN composer C   ON T.composer = C.id LEFT OUTER JOIN genre G   ON T.genre = G.id LEFT OUTER JOIN year Y   ON T.year = Y.id ORDER BY lastmountpoint, S.url
ERROR:  syntax error at end of input at character 9
STATEMENT:  EXECUTE

So it looks like it runs the query, but then issues an empty "EXECUTE".
Looking at the code it seems http://gitorious.org/amarok/amarok/blobs/master/src/databaseimporter/amarok14/FastForwardWorker.cpp#line138 should probably prepare the query, but instead simply runs it. Might be a bug in Qt?

Anyway, it worked in 2.1. so my guess is it was introduced by http://gitorious.org/amarok/amarok/commit/36e4e88761c269b2f90068373d4cf72848b9e886

Regards
Comment 1 Anderson Medeiros Gomes 2009-10-10 04:39:53 UTC
QT 4.5 documentation says the constructor "QSqlQuery(const QString & query = QString(), QSqlDatabase db = QSqlDatabase() )" automatically calls exec() when it receives a non-empty string.

http://qt.nokia.com/doc/4.5/qsqlquery.html#QSqlQuery-2
http://qt.gitorious.org/qt/qt/blobs/4.5/src/sql/kernel/qsqlquery.cpp#line282

My guess is: the line 140 of "src/databaseimporter/amarok14/FastForwardWorker.cpp" should not be there, because it tells the QSqlQuery object to execute a second (and not prepared yet) query.

http://gitorious.org/amarok/amarok/blobs/master/src/databaseimporter/amarok14/FastForwardWorker.cpp#line140

----

I'm now downloading Amarok 2.2 source code (Ubuntu 8.10 package). I will try to comment that line and see if that change makes importing from amarok 1.4 work again.
Comment 2 Mark Kretschmann 2009-10-10 09:38:23 UTC
@Anderson: That's great, a patch (or merge request) would be very welcome.
Comment 3 Anderson Medeiros Gomes 2009-10-11 01:40:57 UTC
Created attachment 37501 [details]
Patch made by me that fixes PostgreSQL database importing from Amarok 1.4 (i hope)

I hope the command line "$ diff -C 3 <original file> <modified file>" makes an useful patch... I used to apply patch from others, but this is my first patch ever... :-)
Comment 4 Mark Kretschmann 2009-10-11 12:02:04 UTC
Thanks, I've committed your patch. Seb, do you think the patch is OK?


commit f8d604e3c9111db376337fd0b20129162ed28f51
Author: Mark Kretschmann <kretschmann@kde.org>
Date:   Sun Oct 11 11:58:53 2009 +0200

    Fix database import from Amarok 1.4 for Postgres.

    Patch by Anderson <amg1127@cefetrs.tche.br>. Please test :)

    @Seb: Do you think the patch is OK?

    BUG: 209175