Sqlite data file on Linux and OS X incompatible?

I create a table and populate it by following these steps on an ARM Linux machine

~ # sqlite3 /mnt/mmc/test.db
SQLite version 3.6.12
sqlite> create table a (d);
sqlite> insert into a values (1.5);
sqlite> select * from a;
1.5

Then I transfer the file to my Mac and do the following

themac:~ me$ sqlite3 test.db 
SQLite version 3.6.12
sqlite> select * from a;
5.30239915051991e-315

Whaaat? I thought the data file was platform independent.

+3
source share
2 answers

I don’t have much SQLite knowledge, but this points to a problem when two 32-bit words of the 64-bit IEEE 754 format doubleare swapped, as you can see in this example (which was launched using gccthe x86 machine):

$ cat test.c
#include <stdio.h>

int main(void)
{
    union {
        double d;
        unsigned long long ull;
    } u;

    u.d = 1.5;
    printf("%016llx\n", u.ull);

    u.d = 5.30239915051991e-315;
    printf("%016llx\n", u.ull);

    return 0;
}
$ gcc -Wall -o test test.c
$ ./test
3ff8000000000000
000000003ff80000
$ 
+5
source

, , http://www.sqlite.org/onefile.html

SQLite - . , -. , , . SQLite 32- 64- big-endian little-endian .

, ? md5sum , ?

0

Source: https://habr.com/ru/post/1793985/


All Articles