Added sql query.

This commit is contained in:
Michael Herzberg 2017-08-16 21:32:09 +01:00
parent 116c76a719
commit b81a80e564
1 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,51 @@
select extid as e,name,min(date),permission
from extension natural join crx natural join permission
-- Ensure we have at least two different crx files, otherwise we have an empty permission
-- set in the previous where clause
where (
select count(*)
from (
select *
from extension
where crx_etag not null
and extid=e
-- Ensure we have seen two different crx_etags of this extensions within the last two runs
and date in (
select date
from extension
where extid=e
order by date desc
limit 2
)
group by extid,crx_etag
-- order by date desc
limit 2
)
) = 2
-- Select newest crx file
and crx_etag=(
select crx_etag
from extension
where crx_etag not null
and extid=e
group by extid,crx_etag
order by date desc
limit 1
)
-- Ensure permission is not present in previous crx
and permission not in (
select permission
from permission
-- Select the second newest crx that we have
where crx_etag=(
select crx_etag
from extension
where crx_etag not null
and extid=e
group by extid,crx_etag
order by date desc
limit 1
offset 1
)
)
group by extid,permission;