File Coverage

blib/lib/auto/share/dist/App-Dochazka-REST/sql/privhistory_Config.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             # *************************************************************************
2             # Copyright (c) 2014-2015, SUSE LLC
3             #
4             # All rights reserved.
5             #
6             # Redistribution and use in source and binary forms, with or without
7             # modification, are permitted provided that the following conditions are met:
8             #
9             # 1. Redistributions of source code must retain the above copyright notice,
10             # this list of conditions and the following disclaimer.
11             #
12             # 2. Redistributions in binary form must reproduce the above copyright
13             # notice, this list of conditions and the following disclaimer in the
14             # documentation and/or other materials provided with the distribution.
15             #
16             # 3. Neither the name of SUSE LLC nor the names of its contributors may be
17             # used to endorse or promote products derived from this software without
18             # specific prior written permission.
19             #
20             # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21             # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22             # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23             # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24             # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25             # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26             # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27             # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28             # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29             # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30             # POSSIBILITY OF SUCH DAMAGE.
31             # *************************************************************************
32             #
33             # sql/privhistory_Config.pm
34             #
35             # SQL statements related to privhistory
36              
37             #
38             # SQL_PRIVHISTORY_INSERT
39             # SQL to insert a single row in privhistory table
40             #
41             set( 'SQL_PRIVHISTORY_INSERT', q/
42             INSERT INTO privhistory (eid, priv, effective, remark)
43             VALUES (?, ?, ?, ?)
44             RETURNING phid, eid, priv, effective, remark
45             / );
46              
47             #
48             # SQL_PRIVHISTORY_UPDATE
49             # SQL to update a single row from privhistory table
50             #
51             set( 'SQL_PRIVHISTORY_UPDATE', q/
52             UPDATE privhistory
53             SET priv = ?, effective = ?, remark = ?
54             WHERE phid = ?
55             RETURNING phid, eid, priv, effective, remark
56             / );
57              
58             #
59             # SQL_PRIVHISTORY_DELETE
60             # SQL to delete a single row from privhistory table
61             #
62             set( 'SQL_PRIVHISTORY_DELETE', q/
63             DELETE FROM privhistory WHERE phid = ?
64             RETURNING phid, eid, priv, effective, remark
65             / );
66              
67             #
68             # SQL_PRIVHISTORY_SELECT_ARBITRARY
69             # SQL to select from privhistory based on EID and arbitrary timestamp
70             #
71             set( 'SQL_PRIVHISTORY_SELECT_ARBITRARY', q/
72             SELECT phid, eid, priv, effective, remark FROM privhistory
73             WHERE eid = ? and effective <= ?
74             ORDER BY effective DESC
75             FETCH FIRST ROW ONLY
76             / );
77              
78             #
79             # SQL_PRIVHISTORY_SELECT_CURRENT
80             # SQL to select from privhistory based on EID and current timestamp
81             #
82             set( 'SQL_PRIVHISTORY_SELECT_CURRENT', q/
83             SELECT phid, eid, priv, effective, remark FROM privhistory
84             WHERE eid = ? and effective <= current_timestamp
85             ORDER BY effective DESC
86             FETCH FIRST ROW ONLY
87             / );
88              
89             #
90             # SQL_PRIVHISTORY_SELECT_BY_PHID
91             # SQL to select a privhistory record by its phid
92             set( 'SQL_PRIVHISTORY_SELECT_BY_PHID', q/
93             SELECT phid, eid, priv, effective, remark FROM privhistory
94             WHERE phid = ?
95             / );
96              
97             #
98             # SQL_PRIVHISTORY_SELECT_RANGE_BY_EID
99             # SQL to select a range of privhistory records
100             set( 'SQL_PRIVHISTORY_SELECT_RANGE_BY_EID', q/
101             SELECT phid, eid, priv, effective, remark FROM privhistory
102             WHERE eid = ? AND effective <@ CAST( ? AS tstzrange )
103             ORDER BY effective
104             / );
105              
106             #
107             # SQL_PRIVHISTORY_SELECT_RANGE_BY_NICK
108             # SQL to select a range of privhistory records
109             set( 'SQL_PRIVHISTORY_SELECT_RANGE_BY_NICK', q/
110             SELECT ph.phid AS phid, ph.eid AS eid, ph.priv AS priv, ph.effective AS effective, ph.remark AS remark
111             FROM privhistory ph, employees em
112             WHERE ph.eid = em.eid AND em.nick = ? AND ph.effective <@ CAST( ? AS tstzrange )
113             ORDER BY ph.effective
114             / );
115              
116             # -----------------------------------
117             # DO NOT EDIT ANYTHING BELOW THIS LINE
118             # -----------------------------------
119 41     41   22492 use strict;
  41         96  
  41         1083  
120 41     41   211 use warnings;
  41         88  
  41         1050  
121              
122             1;