Commit Graph

28 Commits

Author SHA1 Message Date
Thiago Marcos P. Santos
939864cb90 [core] Do not throw on dtors
Fix build on GCC6 + Ubuntu 16.04.
2017-04-01 12:57:06 +03:00
Jason Wray
c7975e6a18 [ios] Clean-up conditionals for iOS <8 2017-02-21 16:10:00 -05:00
Bruno de Oliveira Abinader
b8863a6dca [core] Move sqlite::Statement::check to pimpl 2017-01-23 19:06:53 +02:00
Bruno de Oliveira Abinader
80d72123df [core] Move lastInsertRowId/changes to sqlite::Statement 2017-01-23 19:06:53 +02:00
Bruno de Oliveira Abinader
97b433edc9 [core] Private implementation for SQLite interface 2017-01-23 19:06:53 +02:00
Konstantin Käfer
e76de05402 [build] move logging to util 2016-11-22 20:58:51 +01:00
Jason Wray
e26fa4dd4c [core] Move SQLite logging setup to before database initialization
- Ensure that sqlite3_config() is always called before db init.
- Should only be called once, now.
- Move sqliteVersionCheck into mapbox::sqlite namespace.
2016-09-09 05:42:20 -04:00
Jason Wray
4ef8f815c9 [core] Implement SQLite error logging (#6291) 2016-09-08 13:01:19 -04:00
Konstantin Käfer
cd65a43855 [core] move from microsecond precision timestamp to integer second precision 2016-05-13 17:24:22 +02:00
John Firebaugh
c1ad321485 [linux] Build with GCC 5 (#4901)
* [linux] Build with GCC 5

* [build] -fabi-version=0 is the default for GCC 5
2016-04-29 09:57:21 -07:00
John Firebaugh
c3bed1dab8 [core] Fix race condition that could lead to a UNIQUE constraint failure (#4677) 2016-04-11 19:46:45 -07:00
John Firebaugh
1bdeddab2c [core] Fix subtle bug in OfflineDatabase with updated resources
SQLite REPLACE is *not* UPSERT. If a conflict occurs, it first deletes the existing row, then inserts a new row. This means that AUTOINCREMENT primary keys change. This will break foreign keys to that value, which we use.

Instead we must try an UPDATE, and fall back to an INSERT if the UPDATE changes zero rows.
2016-02-24 13:38:14 -08:00
John Firebaugh
db3620c58f [core] Implement an eviction policy for OfflineDatabase
When inserting an cached resource, or removing a region, remove least-recently used resources and tiles, not used by offline regions, until the used database size, as calculated by multiplying the number of in-use pages by the page size, is less than the maximum cache size minus 5 times the page size.

In addition, OfflineDatabase may be configured to ignore cache puts of individual resources larger than a certain size.

This policy is similar but not identical to the former SQLiteCache policy:

* It accounts for offline, by exempting resources required by offline regions from eviction.
* It must delete from two tables (resources and tiles), rather than one. Currently the strategy is naive: evict 50 rows at a time from each table.
* It makes maximumCacheSize and maximumCacheEntrySize completely independent. The SQLiteCache implementation evicted when `usedSize > maximumCacheSize - 2 * maximumCacheEntrySize`. This evicts when `usedSize > maximumCacheSize - 5 * pageSize`.
* It uses a non-unlimited default value for maximumCacheSize: 50 MB. We should have always had a limit in place; "a cache without an eviction policy is a resource leak".
2016-02-10 15:40:20 -08:00
John Firebaugh
5910124010 [core] Reset SQLite statements after use in order to release locks 2016-02-10 15:40:20 -08:00
John Firebaugh
96e0e5252e [core] Disable SQLite busy timeouts so that multiple readers can access the same database 2016-02-10 15:40:20 -08:00
John Firebaugh
c3c4c7b9a6 [core] Interface and implementation for offline 2016-02-10 15:40:20 -08:00
John Firebaugh
cdedb66387 [core] Reimplement existing caching within an offline-capable database schema 2016-02-10 15:40:20 -08:00
John Firebaugh
1c21d0fd4c [core] Use better types for modified / expires / etag 2016-01-21 11:22:11 -08:00
John Firebaugh
dbfa932ed1 [core] Eliminate macros in sqlite3.cpp 2016-01-19 13:39:18 -08:00
Konstantin Käfer
c279fb1717 [core] throw values, catch references 2015-12-03 15:38:36 +01:00
Konstantin Käfer
d5fb535058 [core] add namespace comment to closing brace 2015-12-03 15:38:36 +01:00
Konstantin Käfer
dc620f48de [core] Fix std::move() misuse that disables copy elision 2015-12-03 15:38:36 +01:00
Thomas Voß
3f786c7171 Fix GCC5 complaining about -Wunused-variable. 2015-11-25 14:23:13 +01:00
Konstantin Käfer
78ec33320f don't use certain STL functions
some functions defined in <cmath>, as well as std::to_string aren't available on GNU's STL for some platforms, e.g. Android
2015-08-04 14:08:19 +02:00
Konstantin Käfer
7d58a41de5 make sqlite storage more resilient to sporadic errors
- catch SQLite exceptions and report them
- failed statements are ignored, we're really just caching here, so if it fails we're handling it gracefully elsewhere
- handle cases where the database file goes away after we opened it
- handle cases where the schema wasn't created after the database file was opened successfully
- add tests
2015-04-07 18:04:23 +02:00
John Firebaugh
bb73dbcd30 Relax sqlite version check to major version only
iOS 8.2 updates the included SQLite version to 3.8.4, while iOS 7.0 up
to iOS 8.1 provides version 3.7.13. When compiling with the 8.2 SDK and
running on 8.1 or below, or vice versa, a strict check fails.

Fixes #968.
2015-03-11 10:21:26 -07:00
Konstantin Käfer
12341ce0ee add missing headers 2015-02-04 10:49:08 +01:00
Konstantin Käfer
272fa8935e make storage lib separate so we can build without storage libs 2015-02-04 10:49:07 +01:00