File Coverage

blib/lib/SQL/ReservedWords/SQLServer.pm
Criterion Covered Total %
statement 29 29 100.0
branch 6 6 100.0
condition 2 2 100.0
subroutine 12 12 100.0
pod 6 6 100.0
total 55 55 100.0


line stmt bran cond sub pod time code
1             package SQL::ReservedWords::SQLServer;
2              
3 2     2   2802 use strict;
  2         3  
  2         77  
4 2     2   11 use warnings;
  2         3  
  2         76  
5 2     2   12 use vars '$VERSION';
  2         38  
  2         124  
6              
7             $VERSION = '0.8';
8              
9 2     2   22 use constant SQLSERVER7 => 0x01;
  2         4  
  2         111  
10 2     2   11 use constant SQLSERVER2000 => 0x02;
  2         3  
  2         82  
11 2     2   18 use constant SQLSERVER2005 => 0x04;
  2         3  
  2         8233  
12              
13             {
14             require Sub::Exporter;
15              
16             my @exports = qw[
17             is_reserved
18             is_reserved_by_sqlserver7
19             is_reserved_by_sqlserver2000
20             is_reserved_by_sqlserver2005
21             reserved_by
22             words
23             ];
24              
25             Sub::Exporter->import( -setup => { exports => \@exports } );
26             }
27              
28             {
29             my %WORDS = (
30             ADD => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
31             ALL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
32             ALTER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
33             AND => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
34             ANY => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
35             AS => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
36             ASC => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
37             AUTHORIZATION => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
38             AVG => SQLSERVER7,
39             BACKUP => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
40             BEGIN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
41             BETWEEN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
42             BREAK => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
43             BROWSE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
44             BULK => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
45             BY => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
46             CASCADE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
47             CASE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
48             CHECK => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
49             CHECKPOINT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
50             CLOSE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
51             CLUSTERED => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
52             COALESCE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
53             COLLATE => SQLSERVER2000 | SQLSERVER2005,
54             COLUMN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
55             COMMIT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
56             COMMITTED => SQLSERVER7,
57             COMPUTE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
58             CONFIRM => SQLSERVER7,
59             CONSTRAINT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
60             CONTAINS => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
61             CONTAINSTABLE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
62             CONTINUE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
63             CONTROLROW => SQLSERVER7,
64             CONVERT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
65             COUNT => SQLSERVER7,
66             CREATE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
67             CROSS => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
68             CURRENT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
69             CURRENT_DATE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
70             CURRENT_TIME => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
71             CURRENT_TIMESTAMP => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
72             CURRENT_USER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
73             CURSOR => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
74             DATABASE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
75             DBCC => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
76             DEALLOCATE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
77             DECLARE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
78             DEFAULT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
79             DELETE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
80             DENY => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
81             DESC => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
82             DISK => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
83             DISTINCT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
84             DISTRIBUTED => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
85             DOUBLE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
86             DROP => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
87             DUMMY => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
88             DUMP => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
89             ELSE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
90             END => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
91             ERRLVL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
92             ERROREXIT => SQLSERVER7,
93             ESCAPE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
94             EXCEPT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
95             EXEC => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
96             EXECUTE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
97             EXISTS => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
98             EXIT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
99             FETCH => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
100             FILE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
101             FILLFACTOR => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
102             FLOPPY => SQLSERVER7,
103             FOR => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
104             FOREIGN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
105             FREETEXT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
106             FREETEXTTABLE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
107             FROM => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
108             FULL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
109             FUNCTION => SQLSERVER2000 | SQLSERVER2005,
110             GOTO => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
111             GRANT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
112             GROUP => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
113             HAVING => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
114             HOLDLOCK => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
115             IDENTITY => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
116             IDENTITYCOL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
117             IDENTITY_INSERT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
118             IF => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
119             IN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
120             INDEX => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
121             INNER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
122             INSERT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
123             INTERSECT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
124             INTO => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
125             IS => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
126             ISOLATION => SQLSERVER7,
127             JOIN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
128             KEY => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
129             KILL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
130             LEFT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
131             LEVEL => SQLSERVER7,
132             LIKE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
133             LINENO => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
134             LOAD => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
135             MAX => SQLSERVER7,
136             MIN => SQLSERVER7,
137             MIRROREXIT => SQLSERVER7,
138             NATIONAL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
139             NOCHECK => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
140             NONCLUSTERED => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
141             NOT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
142             NULL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
143             NULLIF => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
144             OF => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
145             OFF => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
146             OFFSETS => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
147             ON => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
148             ONCE => SQLSERVER7,
149             ONLY => SQLSERVER7,
150             OPEN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
151             OPENDATASOURCE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
152             OPENQUERY => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
153             OPENROWSET => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
154             OPENXML => SQLSERVER2000 | SQLSERVER2005,
155             OPTION => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
156             OR => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
157             ORDER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
158             OUTER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
159             OVER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
160             PERCENT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
161             PERM => SQLSERVER7,
162             PERMANENT => SQLSERVER7,
163             PIPE => SQLSERVER7,
164             PLAN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
165             PRECISION => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
166             PREPARE => SQLSERVER7,
167             PRIMARY => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
168             PRINT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
169             PRIVILEGES => SQLSERVER7,
170             PROC => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
171             PROCEDURE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
172             PROCESSEXIT => SQLSERVER7,
173             PUBLIC => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
174             RAISERROR => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
175             READ => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
176             READTEXT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
177             RECONFIGURE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
178             REFERENCES => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
179             REPEATABLE => SQLSERVER7,
180             REPLICATION => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
181             RESTORE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
182             RESTRICT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
183             RETURN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
184             REVOKE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
185             RIGHT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
186             ROLLBACK => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
187             ROWCOUNT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
188             ROWGUIDCOL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
189             RULE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
190             SAVE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
191             SCHEMA => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
192             SELECT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
193             SERIALIZABLE => SQLSERVER7,
194             SESSION_USER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
195             SET => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
196             SETUSER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
197             SHUTDOWN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
198             SOME => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
199             STATISTICS => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
200             SUM => SQLSERVER7,
201             SYSTEM_USER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
202             TABLE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
203             TAPE => SQLSERVER7,
204             TEMP => SQLSERVER7,
205             TEMPORARY => SQLSERVER7,
206             TEXTSIZE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
207             THEN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
208             TO => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
209             TOP => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
210             TRAN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
211             TRANSACTION => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
212             TRIGGER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
213             TRUNCATE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
214             TSEQUAL => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
215             UNCOMMITTED => SQLSERVER7,
216             UNION => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
217             UNIQUE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
218             UPDATE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
219             UPDATETEXT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
220             USE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
221             USER => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
222             VALUES => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
223             VARYING => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
224             VIEW => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
225             WAITFOR => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
226             WHEN => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
227             WHERE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
228             WHILE => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
229             WITH => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
230             WORK => SQLSERVER7,
231             WRITETEXT => SQLSERVER7 | SQLSERVER2000 | SQLSERVER2005,
232             );
233              
234             sub is_reserved {
235 25   100 25 1 201 return $WORDS{ uc(pop || '') } || 0;
236             }
237            
238             sub is_reserved_by_sqlserver7 {
239 5     5 1 15 return &is_reserved & SQLSERVER7;
240             }
241            
242             sub is_reserved_by_sqlserver2000 {
243 5     5 1 10 return &is_reserved & SQLSERVER2000;
244             }
245              
246             sub is_reserved_by_sqlserver2005 {
247 5     5 1 13 return &is_reserved & SQLSERVER2005;
248             }
249            
250             sub reserved_by {
251 4     4 1 11 my $flags = &is_reserved;
252 4         9 my @reserved_by = ();
253              
254 4 100       14 push @reserved_by, 'SQL Server 7' if $flags & SQLSERVER7;
255 4 100       11 push @reserved_by, 'SQL Server 2000' if $flags & SQLSERVER2000;
256 4 100       12 push @reserved_by, 'SQL Server 2005' if $flags & SQLSERVER2005;
257              
258 4         28 return @reserved_by;
259             }
260              
261             sub words {
262 2     2 1 6745 return sort keys %WORDS;
263             }
264             }
265              
266             1;
267              
268             __END__