Hi all,
I've found what appears to be a bug in SQLite 3.7.9 (as found in
the DBD::SQLite perl module version 1.35).
Running the tests included with DBD::SQLite, I saw test failures and perl
crashing with a bus error while creating an index.
Running the failing test under dbx, I observed the following:
(dbx) run t/27_metadata.t
Running: perl t/27_metadata.t
(process id 12132)
Reading libc_psr.so.1
1..21
Reading DBI.so
Reading Util.so
Reading SQLite.so
ok 1 - The object isa DBI::db
ok 2 - Create table meta1
ok 3 - Create table meta2
ok 4 - Create table meta3
ok 5 - Get primary_key_info for meta1
ok 6 - Correct primary_key_info returned for meta1
ok 7 - Get primary_key_info for meta2
ok 8 - Correct primary_key_info returned for meta2
ok 9 - Get primary_key_info for meta3
ok 10 - Correct primary_key_info returned for meta3
t@1 (l@1) signal BUS (invalid address alignment) in sqlite3CreateIndex at
line 82187 in file "sqlite3.c"
82187 pIndex->azColl[i] = zColl;
Examining the data in more detail showed:
(dbx) print *pIndex
*pIndex = {
zName = 0x10074d966 "sqlite_autoindex_meta4_1"
nColumn = 2
aiColumn = 0x10074d95c
aiRowEst = 0x10074d940
pTable = 0x100779558
tnum = 0
onError = 'c'
autoIndex = '\001'
bUnordered = '\0'
zColAff = (nil)
pNext = (nil)
pSchema = 0x1007390d8
aSortOrder = 0x10074d964 ""
azColl = 0x10074d94c
}
Note that pIndex->azColl is not aligned to an 8-byte boundary as required
by the sparc64 architecture.
The following (ugly) patch resolves the problem for me, allowing
DBD::SQLite to pass all tests. Hopefuly an sqlite developer can make this
into something a bit prettier:
--- DBD-SQLite-1.35/sqlite3.c~ 2011-11-28 18:05:51.000000000 -0600
+++ DBD-SQLite-1.35/sqlite3.c 2011-12-14 01:29:41.523322000 -0600
@@ -82103,7 +82103,7 @@
nCol = pList->nExpr;
pIndex = sqlite3DbMallocZero(db,
sizeof(Index) + /* Index structure */
- sizeof(tRowcnt)*(nCol+1) + /* Index.aiRowEst */
+ sizeof(tRowcnt)*(nCol+1+((nCol+1)%2)) + /* Index.aiRowEst */
sizeof(int)*nCol + /* Index.aiColumn */
sizeof(char *)*nCol + /* Index.azColl */
sizeof(u8)*nCol + /* Index.aSortOrder */
@@ -82114,7 +82114,7 @@
goto exit_create_index;
}
pIndex->aiRowEst = (tRowcnt*)(&pIndex[1]);
- pIndex->azColl = (char**)(&pIndex->aiRowEst[nCol+1]);
+ pIndex->azColl = (char**)(&pIndex->aiRowEst[nCol+1+((nCol+1)%2)]);
pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]);
pIndex->aSortOrder = (u8 *)(&pIndex->aiColumn[nCol]);
pIndex->zName = (char *)(&pIndex->aSortOrder[nCol]);
Thanks and regards,
--
Tod McQuillin
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users