/*
 * DO NOT EDIT DIRECTLY.
 *
 * This file was generated automatically by sqlite-helper-gen
 * from hissqlite/hissqlite-main.sql.
 *
 * DO NOT EDIT DIRECTLY.
 */


#include "hissqlite-main.h"

#ifdef HAVE_SQLITE3

sqlite_helper_t const hissqlite_main_helper =
{
    10,

    "pragma journal_mode = wal;\n"
    "pragma synchronous = normal;\n"
    "pragma busy_timeout = 10000;\n"
    "pragma foreign_keys = off;\n"
    "\000"
    "lookup\000"
    "select arrived, posted, expires, token\n"
    "  from hist\n"
    "  where hash = ?1;\n"
    "\000"
    "check\000"
    "select 1 from hist where hash = ?1;\n"
    "\000"
    "write\000"
    "insert into hist(hash, arrived, posted, expires, token)\n"
    "  values(?1, ?2, ?3, ?4, ?5)\n"
    "  on conflict(hash) do nothing;\n"
    "\000"
    "remember\000"
    "insert into hist(hash, arrived, posted, expires, token)\n"
    "  values(?1, ?2, ?3, 0, null)\n"
    "  on conflict(hash) do nothing;\n"
    "\000"
    "replace\000"
    "insert into hist(hash, arrived, posted, expires, token)\n"
    "  values(?1, ?2, ?3, ?4, ?5)\n"
    "  on conflict(hash) do update set\n"
    "    arrived = excluded.arrived,\n"
    "    posted  = excluded.posted,\n"
    "    expires = excluded.expires,\n"
    "    token   = excluded.token;\n"
    "\000"
    "walk\000"
    "select hash, arrived, posted, expires, token from hist;\n"
    "\000"
    "expire_scan\000"
    "select hash, arrived, posted, expires, token\n"
    "  from hist\n"
    "  where token is not null\n"
    "    and hash > ?1\n"
    "  order by hash\n"
    "  limit ?2;\n"
    "\000"
    "transition_remember\000"
    "update hist set token = null, expires = 0 where hash = ?1;\n"
    "\000"
    "update_token\000"
    "update hist set token = ?2, expires = ?3 where hash = ?1;\n"
    "\000"
    "expire_remembered\000"
    "delete from hist where hash in (\n"
    "  select hash from hist\n"
    "    where token is null\n"
    "      and (case when posted > 0 then posted else arrived end) < ?1\n"
    "    limit 10000);\n"
    "\000"
};

#endif /* HAVE_SQLITE3 */

