Re: [SailfishDevel] Contacts db issue

2015-10-27 Thread Matthew Vogt
Hi Tone.

Are you saying that you created a new database by using sqlite3 to import the 
dump you previously, and then you ran "pragma integrity_check;" on that new 
database, and found errors?  That should be unpossible...

You have no contacts in the people app?  Can you try using contacts-tool as 
well (from a privileged shell):
$ contacts-tool list

Thanks,
Matt


From: devel-boun...@lists.sailfishos.org [devel-boun...@lists.sailfishos.org] 
on behalf of Tone Kastlunger [users.giulie...@gmail.com]
Sent: Tuesday, October 27, 2015 5:10 PM
To: Sailfish OS Developers
Subject: Re: [SailfishDevel] Contacts db issue

Hey Matthew;
thanks for the fast reply!

Here's what I get from the new DB (after having run sqlite3 
qtcontacts-sqlite/contacts.db "pragma integrity_check;" on the newly created 
db):

[nemo@Jolla Contacts]$ sqlite3 qtcontacts-sqlite/contacts.db "pragma 
integrity_check;"
*** in database main ***
On tree page 3275 cell 0: invalid page number 11395
On tree page 3275 cell 0: Rowid 271735 out of order (min less than parent min 
of 524637)
On tree page 2 cell 1: Child page depth differs
and a bunch of the following:
Page xx is never used

Needless to say, after reboot, contact app shows no contacts at all (of course 
:) ).

Best,
tk

On Tue, Oct 27, 2015 at 12:30 AM, Matthew Vogt 
<matthew.v...@jolla.com<mailto:matthew.v...@jolla.com>> wrote:
Hi Tone.
Yes, it sounds like you have a corrupted contacts database.  Any idea how that 
might have happened?

In any case, you can try to recreate the database to fix the issue.  You need 
to do something along the lines of the following (but please sanity-check these 
instructions before running them, I'm typing them into email, not having tested 
them on device!):

You will need to have a privileged user session:
$ devel-su -p

Then stop everything that might be writing to the contacts database:
$ systemctl --user stop lipstick
$ systemctl --user stop msyncd
$ systemctl --user stop contactsd
$ systemctl --user stop as-daemon

Change to the directory where the database resides:
$ cd ~/.local/share/system/privileged/Contacts

Check that DB is actually corrupted; this will say 'ok' if there are no 
problems, or report a bunch of error messages:
$ sqlite3 qtcontacts-sqlite/contacts.db "pragma integrity_check;"

If there are problems, continue:

Make a backup copy of the broken DB just in case we lose something:
$ mkdir bkp
$ cp -R qtcontacts-sqlite bkp/

Dump the DB contents:
$ mkdir temp
$ sqlite3 qtcontacts-sqlite/contacts.db .dump > temp/dump.sql

Record the current schema version of the DB, which is reported by the following 
command (it is probably 15 or 16 or something similar):
$ sqlite3 qtcontacts-sqlite/contacts.db "pragma user_version;"

Recreate the database from the dump:
$ mkdir new-db
$ sqlite3 new-db/contacts.db < temp/dump.sql

Set the schema version in the new database, where VER is the number reported 
above:
$ sqlite3 new-db/contacts.db "pragma user_version = ;"

Move the new database to be the device database:
$ mv qtcontacts-sqlite old-db
$ mv new-db qtcontacts-sqlite

Then reboot, and the device will restart using the new version of the DB.

You can then remove the bkp, temp and old-db directories, assuming things went 
well.  If things did not go well, you can restore the old-db directory to the 
'qtcontacts-sqlite' location (after stopping everything as we did earlier) and 
contact me directly.

Thanks,
Matt


From: 
devel-boun...@lists.sailfishos.org<mailto:devel-boun...@lists.sailfishos.org> 
[devel-boun...@lists.sailfishos.org<mailto:devel-boun...@lists.sailfishos.org>] 
on behalf of Tone Kastlunger 
[users.giulie...@gmail.com<mailto:users.giulie...@gmail.com>]
Sent: Tuesday, October 27, 2015 5:47 AM
To: devel@lists.sailfishos.org<mailto:devel@lists.sailfishos.org>
Subject: [SailfishDevel] Contacts db issue

Hey;
looking through the logs (for something else) on my Jolla I happened to find the
following error; it appears to be realated to the contacts db. Any way to fix 
it?


 "Failed to prepare query for joined details:
  database disk image is malformed Unable to fetch 
row
  Query:
  SELECT 
Details.detailId,Details.contactId,Details.detail,Details.detailUri,Details.linkedDetailUris,Details.contexts,Details.accessConstraints,Details.provenance,COALESCE(Details.modifiable,
 0),COALESCE(Details.nonexportable, 
0),Addresses.*,Anniversaries.*,Avatars.*,Birthdays.*,EmailAddresses.*,Families.*,GeoLocations.*,Guids.*,Hobbies.*,Nicknames.*,Notes.*,OnlineAccounts.*,Organizations.*,PhoneNumbers.*,Presences.*,Ringtones.*,Tags.*,Urls.*,OriginMetadata.*,GlobalPresences.*,ExtendedDetails.*
 FROM temp.RegenerateAggregate CROSS JOIN Details ON Details.contactId = 
temp.Regenera

Re: [SailfishDevel] Contacts db issue

2015-10-27 Thread Tone Kastlunger
Okay! After doing it from the sqlite3 shell another time, the
integrity_check succeeded on the new file.

Thanks!


On Tue, Oct 27, 2015 at 9:10 AM, Tone Kastlunger <users.giulie...@gmail.com>
wrote:

> Hey Matthew;
> thanks for the fast reply!
>
> Here's what I get from the new DB (after having run sqlite3
> qtcontacts-sqlite/contacts.db "pragma integrity_check;" on the newly
> created db):
>
> [nemo@Jolla Contacts]$ sqlite3 qtcontacts-sqlite/contacts.db "pragma
> integrity_check;"
> *** in database main ***
> On tree page 3275 cell 0: invalid page number 11395
> On tree page 3275 cell 0: Rowid 271735 out of order (min less than parent
> min of 524637)
> On tree page 2 cell 1: Child page depth differs
> and a bunch of the following:
> Page xx is never used
>
> Needless to say, after reboot, contact app shows no contacts at all (of
> course :) ).
>
> Best,
> tk
>
> On Tue, Oct 27, 2015 at 12:30 AM, Matthew Vogt <matthew.v...@jolla.com>
> wrote:
>
>> Hi Tone.
>> Yes, it sounds like you have a corrupted contacts database.  Any idea how
>> that might have happened?
>>
>> In any case, you can try to recreate the database to fix the issue.  You
>> need to do something along the lines of the following (but please
>> sanity-check these instructions before running them, I'm typing them into
>> email, not having tested them on device!):
>>
>> You will need to have a privileged user session:
>> $ devel-su -p
>>
>> Then stop everything that might be writing to the contacts database:
>> $ systemctl --user stop lipstick
>> $ systemctl --user stop msyncd
>> $ systemctl --user stop contactsd
>> $ systemctl --user stop as-daemon
>>
>> Change to the directory where the database resides:
>> $ cd ~/.local/share/system/privileged/Contacts
>>
>> Check that DB is actually corrupted; this will say 'ok' if there are no
>> problems, or report a bunch of error messages:
>> $ sqlite3 qtcontacts-sqlite/contacts.db "pragma integrity_check;"
>>
>> If there are problems, continue:
>>
>> Make a backup copy of the broken DB just in case we lose something:
>> $ mkdir bkp
>> $ cp -R qtcontacts-sqlite bkp/
>>
>> Dump the DB contents:
>> $ mkdir temp
>> $ sqlite3 qtcontacts-sqlite/contacts.db .dump > temp/dump.sql
>>
>> Record the current schema version of the DB, which is reported by the
>> following command (it is probably 15 or 16 or something similar):
>> $ sqlite3 qtcontacts-sqlite/contacts.db "pragma user_version;"
>>
>> Recreate the database from the dump:
>> $ mkdir new-db
>> $ sqlite3 new-db/contacts.db < temp/dump.sql
>>
>> Set the schema version in the new database, where VER is the number
>> reported above:
>> $ sqlite3 new-db/contacts.db "pragma user_version = ;"
>>
>> Move the new database to be the device database:
>> $ mv qtcontacts-sqlite old-db
>> $ mv new-db qtcontacts-sqlite
>>
>> Then reboot, and the device will restart using the new version of the DB.
>>
>> You can then remove the bkp, temp and old-db directories, assuming things
>> went well.  If things did not go well, you can restore the old-db directory
>> to the 'qtcontacts-sqlite' location (after stopping everything as we did
>> earlier) and contact me directly.
>>
>> Thanks,
>> Matt
>>
>> --
>> *From:* devel-boun...@lists.sailfishos.org [
>> devel-boun...@lists.sailfishos.org] on behalf of Tone Kastlunger [
>> users.giulie...@gmail.com]
>> *Sent:* Tuesday, October 27, 2015 5:47 AM
>> *To:* devel@lists.sailfishos.org
>> *Subject:* [SailfishDevel] Contacts db issue
>>
>> Hey;
>> looking through the logs (for something else) on my Jolla I happened to
>> find the
>> following error; it appears to be realated to the contacts db. Any way to
>> fix it?
>>
>>
>>  "Failed to prepare query for joined details:
>>   database disk image is malformed Unable to
>> fetch row
>>   Query:
>>   SELECT
>> Details.detailId,Details.contactId,Details.detail,Details.detailUri,Details.linkedDetailUris,Details.contexts,Details.accessConstraints,Details.provenance,COALESCE(Details.modifiable,
>> 0),COALESCE(Details.nonexportable,
>> 0),Addresses.*,Anniversaries.*,Avatars.*,Birthdays.*,EmailAddresses.*,Families.*,GeoLocations.*,Guids.*,Hobbies.*,Nicknames.*,Notes.*,OnlineAccounts.*,Organizations.*,PhoneNumbers.*,Presences.*,Ringtones.*,

Re: [SailfishDevel] Contacts db issue

2015-10-27 Thread Matthew Vogt
That's not as easy to answer as I would like, but it's from qtcontacts-sqlite 
0.2.0 onward, which I think is in sailfish OS 2.0.1.1 :-)

Thanks,
Matt


From: devel-boun...@lists.sailfishos.org [devel-boun...@lists.sailfishos.org] 
on behalf of Tone Kastlunger [users.giulie...@gmail.com]
Sent: Tuesday, October 27, 2015 5:39 PM
To: Sailfish OS Developers
Subject: Re: [SailfishDevel] Contacts db issue

Okay, I added the pragma_version; everything seems fine and legit - contacts 
show and load faster than before!.
Out of curiosity, which update upgrades to version 16?


On Tue, Oct 27, 2015 at 9:37 AM, Matthew Vogt 
<matthew.v...@jolla.com<mailto:matthew.v...@jolla.com>> wrote:
Hmm, it shouldn't be possible to have a malformed database after doing the 
import.  I have no idea how that could happen.

If you don't update the user_version to the correct version, then at each boot 
the first process to open the database will look at the version and try to run 
all the scripts required to update from version 0 to 1, 1 to 2, etc. to the 
latest version it knows about.  This will of course fail, since the database 
already has the schema for version 15.  When you eventually upgrade to software 
that knows about version 16, it will fail to make the necessary adjustments 
since it can't upgrade from 0 to 15 prior to upgrading to 16.

Thanks,
Matt


From: 
devel-boun...@lists.sailfishos.org<mailto:devel-boun...@lists.sailfishos.org> 
[devel-boun...@lists.sailfishos.org<mailto:devel-boun...@lists.sailfishos.org>] 
on behalf of Tone Kastlunger 
[users.giulie...@gmail.com<mailto:users.giulie...@gmail.com>]
Sent: Tuesday, October 27, 2015 5:28 PM

To: Sailfish OS Developers
Subject: Re: [SailfishDevel] Contacts db issue

Here's what I did:
a) I followed your instructions, this gave me a new database (with imported 
contacts) and the integrity errors as per the mail above;
b) I did a
  mv contacts.db broken.db;
  sqlite3 contacts.db
  .read ../temp/dump.sql
c) i did NOT run this : sqlite3 new-db/contacts.db "pragma user_version = 
;" (btw my VER was 15)


d) rebooted
e) "pragma integrity_check" returned OK on this latest db file.


On Tue, Oct 27, 2015 at 9:24 AM, Matthew Vogt 
<matthew.v...@jolla.com<mailto:matthew.v...@jolla.com>> wrote:
Hi Tone.

Are you saying that you created a new database by using sqlite3 to import the 
dump you previously, and then you ran "pragma integrity_check;" on that new 
database, and found errors?  That should be unpossible...

You have no contacts in the people app?  Can you try using contacts-tool as 
well (from a privileged shell):
$ contacts-tool list

Thanks,
Matt


From: 
devel-boun...@lists.sailfishos.org<mailto:devel-boun...@lists.sailfishos.org> 
[devel-boun...@lists.sailfishos.org<mailto:devel-boun...@lists.sailfishos.org>] 
on behalf of Tone Kastlunger 
[users.giulie...@gmail.com<mailto:users.giulie...@gmail.com>]
Sent: Tuesday, October 27, 2015 5:10 PM
To: Sailfish OS Developers
Subject: Re: [SailfishDevel] Contacts db issue

Hey Matthew;
thanks for the fast reply!

Here's what I get from the new DB (after having run sqlite3 
qtcontacts-sqlite/contacts.db "pragma integrity_check;" on the newly created 
db):

[nemo@Jolla Contacts]$ sqlite3 qtcontacts-sqlite/contacts.db "pragma 
integrity_check;"
*** in database main ***
On tree page 3275 cell 0: invalid page number 11395
On tree page 3275 cell 0: Rowid 271735 out of order (min less than parent min 
of 524637)
On tree page 2 cell 1: Child page depth differs
and a bunch of the following:
Page xx is never used

Needless to say, after reboot, contact app shows no contacts at all (of course 
:) ).

Best,
tk

On Tue, Oct 27, 2015 at 12:30 AM, Matthew Vogt 
<matthew.v...@jolla.com<mailto:matthew.v...@jolla.com>> wrote:
Hi Tone.
Yes, it sounds like you have a corrupted contacts database.  Any idea how that 
might have happened?

In any case, you can try to recreate the database to fix the issue.  You need 
to do something along the lines of the following (but please sanity-check these 
instructions before running them, I'm typing them into email, not having tested 
them on device!):

You will need to have a privileged user session:
$ devel-su -p

Then stop everything that might be writing to the contacts database:
$ systemctl --user stop lipstick
$ systemctl --user stop msyncd
$ systemctl --user stop contactsd
$ systemctl --user stop as-daemon

Change to the directory where the database resides:
$ cd ~/.local/share/system/privileged/Contacts

Check that DB is actually corrupted; this will say 'ok' if there are no 
problems, or report a bunch of error messages:
$ sqlite3 qtcontacts-sqlite/contacts.db "pragma integrity_check;"

If there are problems, continue:

Make a backup copy of the broken DB just in case we lo

Re: [SailfishDevel] Contacts db issue

2015-10-27 Thread Tone Kastlunger
Hey Matthew;
thanks for the fast reply!

Here's what I get from the new DB (after having run sqlite3
qtcontacts-sqlite/contacts.db "pragma integrity_check;" on the newly
created db):

[nemo@Jolla Contacts]$ sqlite3 qtcontacts-sqlite/contacts.db "pragma
integrity_check;"
*** in database main ***
On tree page 3275 cell 0: invalid page number 11395
On tree page 3275 cell 0: Rowid 271735 out of order (min less than parent
min of 524637)
On tree page 2 cell 1: Child page depth differs
and a bunch of the following:
Page xx is never used

Needless to say, after reboot, contact app shows no contacts at all (of
course :) ).

Best,
tk

On Tue, Oct 27, 2015 at 12:30 AM, Matthew Vogt <matthew.v...@jolla.com>
wrote:

> Hi Tone.
> Yes, it sounds like you have a corrupted contacts database.  Any idea how
> that might have happened?
>
> In any case, you can try to recreate the database to fix the issue.  You
> need to do something along the lines of the following (but please
> sanity-check these instructions before running them, I'm typing them into
> email, not having tested them on device!):
>
> You will need to have a privileged user session:
> $ devel-su -p
>
> Then stop everything that might be writing to the contacts database:
> $ systemctl --user stop lipstick
> $ systemctl --user stop msyncd
> $ systemctl --user stop contactsd
> $ systemctl --user stop as-daemon
>
> Change to the directory where the database resides:
> $ cd ~/.local/share/system/privileged/Contacts
>
> Check that DB is actually corrupted; this will say 'ok' if there are no
> problems, or report a bunch of error messages:
> $ sqlite3 qtcontacts-sqlite/contacts.db "pragma integrity_check;"
>
> If there are problems, continue:
>
> Make a backup copy of the broken DB just in case we lose something:
> $ mkdir bkp
> $ cp -R qtcontacts-sqlite bkp/
>
> Dump the DB contents:
> $ mkdir temp
> $ sqlite3 qtcontacts-sqlite/contacts.db .dump > temp/dump.sql
>
> Record the current schema version of the DB, which is reported by the
> following command (it is probably 15 or 16 or something similar):
> $ sqlite3 qtcontacts-sqlite/contacts.db "pragma user_version;"
>
> Recreate the database from the dump:
> $ mkdir new-db
> $ sqlite3 new-db/contacts.db < temp/dump.sql
>
> Set the schema version in the new database, where VER is the number
> reported above:
> $ sqlite3 new-db/contacts.db "pragma user_version = ;"
>
> Move the new database to be the device database:
> $ mv qtcontacts-sqlite old-db
> $ mv new-db qtcontacts-sqlite
>
> Then reboot, and the device will restart using the new version of the DB.
>
> You can then remove the bkp, temp and old-db directories, assuming things
> went well.  If things did not go well, you can restore the old-db directory
> to the 'qtcontacts-sqlite' location (after stopping everything as we did
> earlier) and contact me directly.
>
> Thanks,
> Matt
>
> --
> *From:* devel-boun...@lists.sailfishos.org [
> devel-boun...@lists.sailfishos.org] on behalf of Tone Kastlunger [
> users.giulie...@gmail.com]
> *Sent:* Tuesday, October 27, 2015 5:47 AM
> *To:* devel@lists.sailfishos.org
> *Subject:* [SailfishDevel] Contacts db issue
>
> Hey;
> looking through the logs (for something else) on my Jolla I happened to
> find the
> following error; it appears to be realated to the contacts db. Any way to
> fix it?
>
>
>  "Failed to prepare query for joined details:
>   database disk image is malformed Unable to
> fetch row
>   Query:
>   SELECT
> Details.detailId,Details.contactId,Details.detail,Details.detailUri,Details.linkedDetailUris,Details.contexts,Details.accessConstraints,Details.provenance,COALESCE(Details.modifiable,
> 0),COALESCE(Details.nonexportable,
> 0),Addresses.*,Anniversaries.*,Avatars.*,Birthdays.*,EmailAddresses.*,Families.*,GeoLocations.*,Guids.*,Hobbies.*,Nicknames.*,Notes.*,OnlineAccounts.*,Organizations.*,PhoneNumbers.*,Presences.*,Ringtones.*,Tags.*,Urls.*,OriginMetadata.*,GlobalPresences.*,ExtendedDetails.*
> FROM temp.RegenerateAggregate CROSS JOIN Details ON Details.contactId =
> temp.RegenerateAggregate.contactId LEFT JOIN Addresses ON
> Addresses.detailId = Details.detailId LEFT JOIN Anniversaries ON
> Anniversaries.detailId = Details.detailId LEFT JOIN Avatars ON
> Avatars.detailId = Details.detailId LEFT JOIN Birthdays ON
> Birthdays.detailId = Details.detailId LEFT JOIN EmailAddresses ON
> EmailAddresses.detailId = Details.detailId LEFT JOIN Families ON
> Families.detailId = Details.detailId LEFT JOIN GeoLocations ON
> GeoLocations.detailId

Re: [SailfishDevel] Contacts db issue

2015-10-27 Thread Tone Kastlunger
Here's what I did:
a) I followed your instructions, this gave me a new database (with imported
contacts) and the integrity errors as per the mail above;
b) I did a
  mv contacts.db broken.db;
  sqlite3 contacts.db
  .read ../temp/dump.sql
c) i did NOT run this : sqlite3 new-db/contacts.db "pragma user_version =
;" (btw my VER was 15)


d) rebooted
e) "pragma integrity_check" returned OK on this latest db file.


On Tue, Oct 27, 2015 at 9:24 AM, Matthew Vogt <matthew.v...@jolla.com>
wrote:

> Hi Tone.
>
> Are you saying that you created a new database by using sqlite3 to import
> the dump you previously, and then you ran "pragma integrity_check;" on that
> new database, and found errors?  That should be unpossible...
>
> You have no contacts in the people app?  Can you try using contacts-tool
> as well (from a privileged shell):
> $ contacts-tool list
>
> Thanks,
> Matt
>
> --
> *From:* devel-boun...@lists.sailfishos.org [
> devel-boun...@lists.sailfishos.org] on behalf of Tone Kastlunger [
> users.giulie...@gmail.com]
> *Sent:* Tuesday, October 27, 2015 5:10 PM
> *To:* Sailfish OS Developers
> *Subject:* Re: [SailfishDevel] Contacts db issue
>
> Hey Matthew;
> thanks for the fast reply!
>
> Here's what I get from the new DB (after having run sqlite3
> qtcontacts-sqlite/contacts.db "pragma integrity_check;" on the newly
> created db):
>
> [nemo@Jolla Contacts]$ sqlite3 qtcontacts-sqlite/contacts.db "pragma
> integrity_check;"
> *** in database main ***
> On tree page 3275 cell 0: invalid page number 11395
> On tree page 3275 cell 0: Rowid 271735 out of order (min less than parent
> min of 524637)
> On tree page 2 cell 1: Child page depth differs
> and a bunch of the following:
> Page xx is never used
>
> Needless to say, after reboot, contact app shows no contacts at all (of
> course :) ).
>
> Best,
> tk
>
> On Tue, Oct 27, 2015 at 12:30 AM, Matthew Vogt <matthew.v...@jolla.com>
> wrote:
>
>> Hi Tone.
>> Yes, it sounds like you have a corrupted contacts database.  Any idea how
>> that might have happened?
>>
>> In any case, you can try to recreate the database to fix the issue.  You
>> need to do something along the lines of the following (but please
>> sanity-check these instructions before running them, I'm typing them into
>> email, not having tested them on device!):
>>
>> You will need to have a privileged user session:
>> $ devel-su -p
>>
>> Then stop everything that might be writing to the contacts database:
>> $ systemctl --user stop lipstick
>> $ systemctl --user stop msyncd
>> $ systemctl --user stop contactsd
>> $ systemctl --user stop as-daemon
>>
>> Change to the directory where the database resides:
>> $ cd ~/.local/share/system/privileged/Contacts
>>
>> Check that DB is actually corrupted; this will say 'ok' if there are no
>> problems, or report a bunch of error messages:
>> $ sqlite3 qtcontacts-sqlite/contacts.db "pragma integrity_check;"
>>
>> If there are problems, continue:
>>
>> Make a backup copy of the broken DB just in case we lose something:
>> $ mkdir bkp
>> $ cp -R qtcontacts-sqlite bkp/
>>
>> Dump the DB contents:
>> $ mkdir temp
>> $ sqlite3 qtcontacts-sqlite/contacts.db .dump > temp/dump.sql
>>
>> Record the current schema version of the DB, which is reported by the
>> following command (it is probably 15 or 16 or something similar):
>> $ sqlite3 qtcontacts-sqlite/contacts.db "pragma user_version;"
>>
>> Recreate the database from the dump:
>> $ mkdir new-db
>> $ sqlite3 new-db/contacts.db < temp/dump.sql
>>
>> Set the schema version in the new database, where VER is the number
>> reported above:
>> $ sqlite3 new-db/contacts.db "pragma user_version = ;"
>>
>> Move the new database to be the device database:
>> $ mv qtcontacts-sqlite old-db
>> $ mv new-db qtcontacts-sqlite
>>
>> Then reboot, and the device will restart using the new version of the DB.
>>
>> You can then remove the bkp, temp and old-db directories, assuming things
>> went well.  If things did not go well, you can restore the old-db directory
>> to the 'qtcontacts-sqlite' location (after stopping everything as we did
>> earlier) and contact me directly.
>>
>> Thanks,
>> Matt
>>
>> --
>> *From:* devel-boun...@lists.sailfishos.org [
>> devel-boun...@lists.sailfishos.org] on behalf of Tone Kastlunger [
>> users.giulie...@gmail.com]
>&

[SailfishDevel] Contacts db issue

2015-10-26 Thread Tone Kastlunger
Hey;
looking through the logs (for something else) on my Jolla I happened to
find the
following error; it appears to be realated to the contacts db. Any way to
fix it?


 "Failed to prepare query for joined details:
  database disk image is malformed Unable to
fetch row
  Query:
  SELECT
Details.detailId,Details.contactId,Details.detail,Details.detailUri,Details.linkedDetailUris,Details.contexts,Details.accessConstraints,Details.provenance,COALESCE(Details.modifiable,
0),COALESCE(Details.nonexportable,
0),Addresses.*,Anniversaries.*,Avatars.*,Birthdays.*,EmailAddresses.*,Families.*,GeoLocations.*,Guids.*,Hobbies.*,Nicknames.*,Notes.*,OnlineAccounts.*,Organizations.*,PhoneNumbers.*,Presences.*,Ringtones.*,Tags.*,Urls.*,OriginMetadata.*,GlobalPresences.*,ExtendedDetails.*
FROM temp.RegenerateAggregate CROSS JOIN Details ON Details.contactId =
temp.RegenerateAggregate.contactId LEFT JOIN Addresses ON
Addresses.detailId = Details.detailId LEFT JOIN Anniversaries ON
Anniversaries.detailId = Details.detailId LEFT JOIN Avatars ON
Avatars.detailId = Details.detailId LEFT JOIN Birthdays ON
Birthdays.detailId = Details.detailId LEFT JOIN EmailAddresses ON
EmailAddresses.detailId = Details.detailId LEFT JOIN Families ON
Families.detailId = Details.detailId LEFT JOIN GeoLocations ON
GeoLocations.detailId = Details.detailId LEFT JOIN Guids ON Guids.detailId
= Details.detailId LEFT JOIN Hobbies ON Hobbies.detailId = Details.detailId
LEFT JOIN Nicknames ON Nicknames.detailId = Details.detailId LEFT JOIN
Notes ON Notes.detailId = Details.detailId LEFT JOIN OnlineAccounts ON
OnlineAccounts.detailId = Details.detailId LEFT JOIN Organizations ON
Organizations.detailId = Details.detailId LEFT JOIN PhoneNumbers ON
PhoneNumbers.detailId = Details.detailId LEFT JOIN Presences ON
Presences.detailId = Details.detailId LEFT JOIN Ringtones ON
Ringtones.detailId = Details.detailId LEFT JOIN Tags ON Tags.detailId =
Details.detailId LEFT JOIN Urls ON Urls.detailId = Details.detailId LEFT
JOIN OriginMetadata ON OriginMetadata.detailId = Details.detailId LEFT JOIN
GlobalPresences ON GlobalPresences.detailId = Details.detailId LEFT JOIN
ExtendedDetails ON ExtendedDetails.detailI
Oct 26 21:38:30 Jolla [1156]: [W] ContactWriter::regenerateAggregates:3652
- "Failed to read constituent contacts for aggregate 8487 during regenerate"
___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Re: [SailfishDevel] Contacts db issue

2015-10-26 Thread Matthew Vogt
Hi Tone.
Yes, it sounds like you have a corrupted contacts database.  Any idea how that 
might have happened?

In any case, you can try to recreate the database to fix the issue.  You need 
to do something along the lines of the following (but please sanity-check these 
instructions before running them, I'm typing them into email, not having tested 
them on device!):

You will need to have a privileged user session:
$ devel-su -p

Then stop everything that might be writing to the contacts database:
$ systemctl --user stop lipstick
$ systemctl --user stop msyncd
$ systemctl --user stop contactsd
$ systemctl --user stop as-daemon

Change to the directory where the database resides:
$ cd ~/.local/share/system/privileged/Contacts

Check that DB is actually corrupted; this will say 'ok' if there are no 
problems, or report a bunch of error messages:
$ sqlite3 qtcontacts-sqlite/contacts.db "pragma integrity_check;"

If there are problems, continue:

Make a backup copy of the broken DB just in case we lose something:
$ mkdir bkp
$ cp -R qtcontacts-sqlite bkp/

Dump the DB contents:
$ mkdir temp
$ sqlite3 qtcontacts-sqlite/contacts.db .dump > temp/dump.sql

Record the current schema version of the DB, which is reported by the following 
command (it is probably 15 or 16 or something similar):
$ sqlite3 qtcontacts-sqlite/contacts.db "pragma user_version;"

Recreate the database from the dump:
$ mkdir new-db
$ sqlite3 new-db/contacts.db < temp/dump.sql

Set the schema version in the new database, where VER is the number reported 
above:
$ sqlite3 new-db/contacts.db "pragma user_version = ;"

Move the new database to be the device database:
$ mv qtcontacts-sqlite old-db
$ mv new-db qtcontacts-sqlite

Then reboot, and the device will restart using the new version of the DB.

You can then remove the bkp, temp and old-db directories, assuming things went 
well.  If things did not go well, you can restore the old-db directory to the 
'qtcontacts-sqlite' location (after stopping everything as we did earlier) and 
contact me directly.

Thanks,
Matt


From: devel-boun...@lists.sailfishos.org [devel-boun...@lists.sailfishos.org] 
on behalf of Tone Kastlunger [users.giulie...@gmail.com]
Sent: Tuesday, October 27, 2015 5:47 AM
To: devel@lists.sailfishos.org
Subject: [SailfishDevel] Contacts db issue

Hey;
looking through the logs (for something else) on my Jolla I happened to find the
following error; it appears to be realated to the contacts db. Any way to fix 
it?


 "Failed to prepare query for joined details:
  database disk image is malformed Unable to fetch 
row
  Query:
  SELECT 
Details.detailId,Details.contactId,Details.detail,Details.detailUri,Details.linkedDetailUris,Details.contexts,Details.accessConstraints,Details.provenance,COALESCE(Details.modifiable,
 0),COALESCE(Details.nonexportable, 
0),Addresses.*,Anniversaries.*,Avatars.*,Birthdays.*,EmailAddresses.*,Families.*,GeoLocations.*,Guids.*,Hobbies.*,Nicknames.*,Notes.*,OnlineAccounts.*,Organizations.*,PhoneNumbers.*,Presences.*,Ringtones.*,Tags.*,Urls.*,OriginMetadata.*,GlobalPresences.*,ExtendedDetails.*
 FROM temp.RegenerateAggregate CROSS JOIN Details ON Details.contactId = 
temp.RegenerateAggregate.contactId LEFT JOIN Addresses ON Addresses.detailId = 
Details.detailId LEFT JOIN Anniversaries ON Anniversaries.detailId = 
Details.detailId LEFT JOIN Avatars ON Avatars.detailId = Details.detailId LEFT 
JOIN Birthdays ON Birthdays.detailId = Details.detailId LEFT JOIN 
EmailAddresses ON EmailAddresses.detailId = Details.detailId LEFT JOIN Families 
ON Families.detailId = Details.detailId LEFT JOIN GeoLocations ON 
GeoLocations.detailId = Details.detailId LEFT JOIN Guids ON Guids.detailId = 
Details.detailId LEFT JOIN Hobbies ON Hobbies.detailId = Details.detailId LEFT 
JOIN Nicknames ON Nicknames.detailId = Details.detailId LEFT JOIN Notes ON 
Notes.detailId = Details.detailId LEFT JOIN OnlineAccounts ON 
OnlineAccounts.detailId = Details.detailId LEFT JOIN Organizations ON 
Organizations.detailId = Details.detailId LEFT JOIN PhoneNumbers ON 
PhoneNumbers.detailId = Details.detailId LEFT JOIN Presences ON 
Presences.detailId = Details.detailId LEFT JOIN Ringtones ON Ringtones.detailId 
= Details.detailId LEFT JOIN Tags ON Tags.detailId = Details.detailId LEFT JOIN 
Urls ON Urls.detailId = Details.detailId LEFT JOIN OriginMetadata ON 
OriginMetadata.detailId = Details.detailId LEFT JOIN GlobalPresences ON 
GlobalPresences.detailId = Details.detailId LEFT JOIN ExtendedDetails ON 
ExtendedDetails.detailI
Oct 26 21:38:30 Jolla [1156]: [W] ContactWriter::regenerateAggregates:3652 - 
"Failed to read constituent contacts for aggregate 8487 during regenerate"



___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org