- PFU.target, PFU.device,
- null as ohash,
- printf('%s:%s:%s:%s', PFU.filetype, PFU.mode, PFU.username, PFU.groupname) as mds,
- null as omds
-from packagefiles PFU
-join packages PU
-on PFU.package = PU.package and PFU.version = PU.version and PFU.release = PU.release
--- inner join because the installing package must exist or this shouldn't
--- be an 'updating' package
-join packages P on PU.package = P.package and P.status = 'installing'
-left join packagefiles PFI on
- PFI.package = P.package
- and PFI.version = P.version
- and PFI.release = P.release
- and PFI.path = PFU.path
-
--- handle paths owned by other installed packages
-left join packages PI on PI.status = 'installed'
-left join packagefiles PFC
-on PFC.package = PI.package and PFC.version = PI.version and PFC.release = PI.release and PFC.path = PFU.path
+ PFI.target, PFI.device, PFC.hash as ohash,
+ printf('%s:%s:%s:%s', PFI.filetype, PFI.mode, PFI.username, PFI.groupname) as mds,
+ printf('%s:%s:%s:%s', PFC.filetype, PFC.mode, PFC.username, PFC.groupname) as omds
+from
+
+packagefiles PFI
+join packages P
+on PFI.package = P.package and PFI.version = P.version and PFI.release = P.release
+
+join packagefiles PFC on PFI.path = PFC.path
+
+join packages PC
+on (PFI.package is not PC.package or PFI.release is not PC.release or PC.version is not PFI.version)
+-- er, no, it's a conflict if it's in installed and it doesn't match
+and PC.status in ('installed','updating','removing')
+and PFC.package = PC.package and PFC.version = PC.version and PFC.release = PC.release