line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Otogiri::Plugin::TableInfo::PgKeywords; |
2
|
2
|
|
|
2
|
|
26
|
use 5.008005; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
63
|
|
3
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
44
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
495
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# keywords are picked from postgresql-9.3.4/src/include/parser/kwlist.h |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# COL_NAME_KEYWORD |
9
|
|
|
|
|
|
|
my @col_name_keywords = ( |
10
|
|
|
|
|
|
|
'between', |
11
|
|
|
|
|
|
|
'bigint', |
12
|
|
|
|
|
|
|
'bit', |
13
|
|
|
|
|
|
|
'boolean', |
14
|
|
|
|
|
|
|
'char', |
15
|
|
|
|
|
|
|
'character', |
16
|
|
|
|
|
|
|
'coalesce', |
17
|
|
|
|
|
|
|
'dec', |
18
|
|
|
|
|
|
|
'decimal', |
19
|
|
|
|
|
|
|
'exists', |
20
|
|
|
|
|
|
|
'extract', |
21
|
|
|
|
|
|
|
'float', |
22
|
|
|
|
|
|
|
'greatest', |
23
|
|
|
|
|
|
|
'inout', |
24
|
|
|
|
|
|
|
'int', |
25
|
|
|
|
|
|
|
'integer', |
26
|
|
|
|
|
|
|
'interval', |
27
|
|
|
|
|
|
|
'least', |
28
|
|
|
|
|
|
|
'national', |
29
|
|
|
|
|
|
|
'nchar', |
30
|
|
|
|
|
|
|
'none', |
31
|
|
|
|
|
|
|
'nullif', |
32
|
|
|
|
|
|
|
'numeric', |
33
|
|
|
|
|
|
|
'out', |
34
|
|
|
|
|
|
|
'overlay', |
35
|
|
|
|
|
|
|
'position', |
36
|
|
|
|
|
|
|
'precision', |
37
|
|
|
|
|
|
|
'real', |
38
|
|
|
|
|
|
|
'row', |
39
|
|
|
|
|
|
|
'setof', |
40
|
|
|
|
|
|
|
'smallint', |
41
|
|
|
|
|
|
|
'substring', |
42
|
|
|
|
|
|
|
'time', |
43
|
|
|
|
|
|
|
'timestamp', |
44
|
|
|
|
|
|
|
'treat', |
45
|
|
|
|
|
|
|
'trim', |
46
|
|
|
|
|
|
|
'values', |
47
|
|
|
|
|
|
|
'varchar', |
48
|
|
|
|
|
|
|
'xmlattributes', |
49
|
|
|
|
|
|
|
'xmlconcat', |
50
|
|
|
|
|
|
|
'xmlelement', |
51
|
|
|
|
|
|
|
'xmlexists', |
52
|
|
|
|
|
|
|
'xmlforest', |
53
|
|
|
|
|
|
|
'xmlparse', |
54
|
|
|
|
|
|
|
'xmlpi', |
55
|
|
|
|
|
|
|
'xmlroot', |
56
|
|
|
|
|
|
|
'xmlserialize', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# RESERVED_KEYWORD |
60
|
|
|
|
|
|
|
my @reserved_keywords = ( |
61
|
|
|
|
|
|
|
"all", |
62
|
|
|
|
|
|
|
"analyse", |
63
|
|
|
|
|
|
|
"analyze", |
64
|
|
|
|
|
|
|
"and", |
65
|
|
|
|
|
|
|
"any", |
66
|
|
|
|
|
|
|
"array", |
67
|
|
|
|
|
|
|
"as", |
68
|
|
|
|
|
|
|
"asc", |
69
|
|
|
|
|
|
|
"asymmetric", |
70
|
|
|
|
|
|
|
"both", |
71
|
|
|
|
|
|
|
"case", |
72
|
|
|
|
|
|
|
"cast", |
73
|
|
|
|
|
|
|
"check", |
74
|
|
|
|
|
|
|
"collate", |
75
|
|
|
|
|
|
|
"column", |
76
|
|
|
|
|
|
|
"constraint", |
77
|
|
|
|
|
|
|
"create", |
78
|
|
|
|
|
|
|
"current_catalog", |
79
|
|
|
|
|
|
|
"current_date", |
80
|
|
|
|
|
|
|
"current_role", |
81
|
|
|
|
|
|
|
"current_time", |
82
|
|
|
|
|
|
|
"current_timestamp", |
83
|
|
|
|
|
|
|
"current_user", |
84
|
|
|
|
|
|
|
"default", |
85
|
|
|
|
|
|
|
"deferrable", |
86
|
|
|
|
|
|
|
"desc", |
87
|
|
|
|
|
|
|
"distinct", |
88
|
|
|
|
|
|
|
"do", |
89
|
|
|
|
|
|
|
"else", |
90
|
|
|
|
|
|
|
"end", |
91
|
|
|
|
|
|
|
"except", |
92
|
|
|
|
|
|
|
"false", |
93
|
|
|
|
|
|
|
"fetch", |
94
|
|
|
|
|
|
|
"for", |
95
|
|
|
|
|
|
|
"foreign", |
96
|
|
|
|
|
|
|
"from", |
97
|
|
|
|
|
|
|
"grant", |
98
|
|
|
|
|
|
|
"group", |
99
|
|
|
|
|
|
|
"having", |
100
|
|
|
|
|
|
|
"in", |
101
|
|
|
|
|
|
|
"initially", |
102
|
|
|
|
|
|
|
"intersect", |
103
|
|
|
|
|
|
|
"into", |
104
|
|
|
|
|
|
|
"lateral", |
105
|
|
|
|
|
|
|
"leading", |
106
|
|
|
|
|
|
|
"limit", |
107
|
|
|
|
|
|
|
"localtime", |
108
|
|
|
|
|
|
|
"localtimestamp", |
109
|
|
|
|
|
|
|
"not", |
110
|
|
|
|
|
|
|
"null", |
111
|
|
|
|
|
|
|
"offset", |
112
|
|
|
|
|
|
|
"on", |
113
|
|
|
|
|
|
|
"only", |
114
|
|
|
|
|
|
|
"or", |
115
|
|
|
|
|
|
|
"order", |
116
|
|
|
|
|
|
|
"placing", |
117
|
|
|
|
|
|
|
"primary", |
118
|
|
|
|
|
|
|
"references", |
119
|
|
|
|
|
|
|
"returning", |
120
|
|
|
|
|
|
|
"select", |
121
|
|
|
|
|
|
|
"session_user", |
122
|
|
|
|
|
|
|
"some", |
123
|
|
|
|
|
|
|
"symmetric", |
124
|
|
|
|
|
|
|
"table", |
125
|
|
|
|
|
|
|
"then", |
126
|
|
|
|
|
|
|
"to", |
127
|
|
|
|
|
|
|
"trailing", |
128
|
|
|
|
|
|
|
"true", |
129
|
|
|
|
|
|
|
"union", |
130
|
|
|
|
|
|
|
"unique", |
131
|
|
|
|
|
|
|
"user", |
132
|
|
|
|
|
|
|
"using", |
133
|
|
|
|
|
|
|
"variadic", |
134
|
|
|
|
|
|
|
"when", |
135
|
|
|
|
|
|
|
"where", |
136
|
|
|
|
|
|
|
"window", |
137
|
|
|
|
|
|
|
"with", |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub new { |
141
|
0
|
|
|
0
|
0
|
|
my ($class) = @_; |
142
|
0
|
|
|
|
|
|
my @keywords = (@col_name_keywords, @reserved_keywords); |
143
|
0
|
|
|
|
|
|
my %keyword_hash = map { ($_ => 1) } @keywords; |
|
0
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my %keyword_hash_uc = map { (uc($_) => 1) } @keywords; |
|
0
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
my $self = { |
146
|
|
|
|
|
|
|
keyword => { %keyword_hash, %keyword_hash_uc }, |
147
|
|
|
|
|
|
|
}; |
148
|
0
|
|
|
|
|
|
bless $self, $class; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub quote { |
152
|
0
|
|
|
0
|
0
|
|
my ($self, $column_name) = @_; |
153
|
0
|
0
|
|
|
|
|
return '"' . $column_name . '"' if ( exists $self->{keyword}->{$column_name} ); |
154
|
0
|
|
|
|
|
|
return $column_name; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
1; |
159
|
|
|
|
|
|
|
__END__ |