"Fossies" - the Fresh Open Source Software Archive

Member "bareos-Release-20.0.2/core/src/cats/dml/0035_select_recent_version_with_basejob_and_delta" (10 Jun 2021, 1862 Bytes) of package /linux/misc/bareos-Release-20.0.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # We do the same thing than the query "select_recent_version_with_basejob",
    2 # but we include all delta parts.
    3 # If the file has been deleted, we can have irrelevant parts.
    4 #
    5 # The code that uses results should control the delta sequence with
    6 # the following rules:
    7 # First Delta = 0
    8 # Delta = Previous Delta + 1
    9 #
   10 # If we detect a gap, we can discard further pieces
   11 # If a file starts at 1 instead of 0, the file has been deleted, and further
   12 # pieces are useless.
   13 #
   14 # This control should be reset for each new file
   15 SELECT FileId,
   16        Job.JobId AS JobId,
   17        FileIndex,
   18        File.PathId AS PathId,
   19        File.Name AS Name,
   20        LStat,
   21        MD5,
   22        File.DeltaSeq AS DeltaSeq,
   23        File.Fhinfo AS Fhinfo,
   24        File.Fhnode AS Fhnode,
   25        Job.JobTDate AS JobTDate
   26 FROM Job,
   27      File,
   28 
   29   ( SELECT MAX(JobTDate) AS JobTDate,
   30            PathId,
   31            FileName,
   32            DeltaSeq,
   33            Fhinfo,
   34            Fhnode
   35    FROM
   36      ( SELECT JobTDate,
   37               PathId,
   38               File.Name AS FileName,
   39               DeltaSeq,
   40               Fhinfo,
   41               Fhnode
   42       FROM File
   43       JOIN Job USING (JobId)
   44       WHERE File.JobId IN (%s)
   45         UNION ALL
   46         SELECT JobTDate,
   47                PathId,
   48                File.Name AS FileName,
   49                DeltaSeq,
   50                Fhinfo,
   51                Fhnode
   52         FROM BaseFiles
   53         JOIN File USING (FileId)
   54         JOIN Job ON (BaseJobId = Job.JobId) WHERE BaseFiles.JobId IN (%s) ) AS tmp
   55    GROUP BY PathId,
   56             FileName,
   57             DeltaSeq,
   58             Fhinfo,
   59             Fhnode) AS T1
   60 WHERE (Job.JobId IN
   61          (SELECT DISTINCT BaseJobId
   62           FROM BaseFiles
   63           WHERE JobId IN (%s))
   64        OR Job.JobId IN (%s))
   65   AND T1.JobTDate = Job.JobTDate
   66   AND Job.JobId = File.JobId
   67   AND T1.PathId = File.PathId
   68   AND T1.FileName = File.Name