diff options
| author | 2018-03-11 11:53:28 +0100 | |
|---|---|---|
| committer | 2018-03-11 11:53:28 +0100 | |
| commit | eea69848661c6385d6c29c84c98a2315072c5e8e (patch) | |
| tree | ca27048ac282740483dcef9a6ed1e2480fd52084 | |
| parent | 23342aec30d43f078a1581f7d1d99616eb96c0e3 (diff) | |
SQLite more error logs
https://github.com/FreshRSS/FreshRSS/issues/1816
And reformat SQL, which required vertical scrolling for me :-)
| -rw-r--r-- | app/Models/EntryDAOSQLite.php | 70 | ||||
| -rw-r--r-- | app/Models/FeedDAO.php | 2 |
2 files changed, 18 insertions, 54 deletions
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php index 0f57dc1ba..90aafb200 100644 --- a/app/Models/EntryDAOSQLite.php +++ b/app/Models/EntryDAOSQLite.php @@ -7,7 +7,6 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { } protected function autoUpdateDb($errorInfo) { - Minz_Log::error('FreshRSS_EntryDAO::autoUpdateDb error: ' . print_r($errorInfo, true)); if ($tableInfo = $this->bd->query("SELECT sql FROM sqlite_master where name='entrytmp'")) { $showCreate = $tableInfo->fetchColumn(); if (stripos($showCreate, 'entrytmp') === false) { @@ -27,63 +26,28 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { public function commitNewEntries() { $sql = ' - CREATE TEMP TABLE `tmp` AS - SELECT - id, - guid, - title, - author, - content, - link, - date, - `lastSeen`, - hash, is_read, - is_favorite, - id_feed, - tags - FROM `' . $this->prefix . 'entrytmp` - ORDER BY date; - INSERT OR IGNORE INTO `' . $this->prefix . 'entry` - ( - id, - guid, - title, - author, - content, - link, - date, - `lastSeen`, - hash, - is_read, - is_favorite, - id_feed, - tags - ) - SELECT rowid + (SELECT MAX(id) - COUNT(*) FROM `tmp`) AS - id, - guid, - title, - author, - content, - link, - date, - `lastSeen`, - hash, - is_read, - is_favorite, - id_feed, - tags - FROM `tmp` - ORDER BY date; - DELETE FROM `' . $this->prefix . 'entrytmp` - WHERE id <= (SELECT MAX(id) - FROM `tmp`); - DROP TABLE `tmp`;'; +DROP TABLE IF EXISTS `tmp`; +CREATE TEMP TABLE `tmp` AS + SELECT id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags + FROM `' . $this->prefix . 'entrytmp` + ORDER BY date; +INSERT OR IGNORE INTO `' . $this->prefix . 'entry` + (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) + SELECT rowid + (SELECT MAX(id) - COUNT(*) FROM `tmp`) AS id, + guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags + FROM `tmp` + ORDER BY date; +DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= (SELECT MAX(id) FROM `tmp`); +DROP TABLE IF EXISTS `tmp`; +'; $hadTransaction = $this->bd->inTransaction(); if (!$hadTransaction) { $this->bd->beginTransaction(); } $result = $this->bd->exec($sql) !== false; + if (!$result) { + Minz_Log::error('SQL error commitNewEntries: ' . json_encode($this->bd->errorInfo())); + } if (!$hadTransaction) { $this->bd->commit(); } diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 0c25ab0ba..5c6e613d3 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -105,7 +105,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::error('SQL error updateFeed: ' . $info[2]); + Minz_Log::error('SQL error updateFeed: ' . $info[2] . ' for feed ' . $id); return false; } } |
