Skip to content

Commit c7c72fa

Browse files
committed
Use int for hits.width, rather than smallint
I've been getting the occasional "value [..] is out of range for type smallint" errors. There's very few of these: =# with x as ( select width, count(width) from size_stats where width >=30000 group by width ) select * from x order by count desc; width │ count ───────┼─────── 38400 │ 20 34910 │ 7 32002 │ 5 42668 │ 5 48000 │ 3 41280 │ 3 34400 │ 3 31200 │ 2 39386 │ 2 38134 │ 1 34630 │ 1 38048 │ 1 30800 │ 1 42900 │ 1 The widest screen generally available is 7680x2160. 38400 is 7680 x 5, which probably isn't a coincidence(?) Anyway, just use an int. Not worth the 2 bytes it saves, and size_stats already uses int.
1 parent 64b3141 commit c7c72fa

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alter table hits alter column width type int;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
create table hits_new (
2+
hit_id integer primary key autoincrement,
3+
site_id integer not null,
4+
path_id integer not null,
5+
ref_id integer not null default 1,
6+
7+
session blob default null,
8+
first_visit integer default 0,
9+
10+
browser_id integer not null,
11+
system_id integer not null,
12+
campaign integer default null,
13+
width int null,
14+
location varchar not null default '',
15+
language varchar,
16+
17+
created_at timestamp not null check(created_at = strftime('%Y-%m-%d %H:%M:%S', created_at))
18+
);
19+
20+
insert into hits_new (hit_id, site_id, path_id, ref_id, session, first_visit, browser_id, system_id, campaign, width, location, language, created_at)
21+
select hit_id, site_id, path_id, ref_id, session, first_visit, browser_id, system_id, campaign, width, location, language, created_at
22+
from hits;
23+
24+
drop table hits;
25+
26+
alter table hits_new rename to hits;
27+
create index "hits#site_id#created_at" on hits(site_id, created_at desc);

0 commit comments

Comments
 (0)