1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>ctags-lang-sql — Universal Ctags 0.3.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/classic.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="ctags-incompatibilities" href="ctags-incompatibilities.7.html" />
<link rel="prev" title="ctags-lang-r" href="ctags-lang-r.7.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="ctags-incompatibilities.7.html" title="ctags-incompatibilities"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="ctags-lang-r.7.html" title="ctags-lang-r"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Universal Ctags 0.3.0 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="../man-pages.html" accesskey="U">Man pages</a> »</li>
<li class="nav-item nav-item-this"><a href="">ctags-lang-sql</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="ctags-lang-sql">
<span id="ctags-lang-sql-7"></span><h1>ctags-lang-sql<a class="headerlink" href="#ctags-lang-sql" title="Permalink to this headline">¶</a></h1>
<p>The man page of the SQL parser for Universal Ctags</p>
<dl class="field-list simple">
<dt class="field-odd">Version</dt>
<dd class="field-odd"><p>5.9.0</p>
</dd>
<dt class="field-even">Manual group</dt>
<dd class="field-even"><p>Universal Ctags</p>
</dd>
<dt class="field-odd">Manual section</dt>
<dd class="field-odd"><p>7</p>
</dd>
</dl>
<section id="synopsis">
<h2>SYNOPSIS<a class="headerlink" href="#synopsis" title="Permalink to this headline">¶</a></h2>
<div class="line-block">
<div class="line"><strong>ctags</strong> … [--extras={guest}] --languages=+SQL …</div>
</div>
</section>
<section id="description">
<h2>DESCRIPTION<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2>
<p>The SQL parser supports various SQL dialects. PostgreSQL is one of them.</p>
<p>PostgreSQL allows user-defined functions to be written in other
languages (<em>procedural languages</em>) besides SQL and C <a class="reference internal" href="#pl" id="id1"><span>[PL]</span></a>.</p>
<p>The SQL parser makes tags for language objects in the user-defined
functions written in the procedural languages if the <code class="docutils literal notranslate"><span class="pre">guest</span></code> extra
is enabled.</p>
<p>The SQL parser looks for a token coming after <code class="docutils literal notranslate"><span class="pre">LANGUAGE</span></code> keyword in
the source code to choose a proper guest parser.</p>
<div class="highlight-SQL notranslate"><div class="highlight"><pre><span></span>... LANGUAGE plpythonu AS '... user-defined function ' ...
... AS $$ user-defined function $$ LANGUAGE plv8 ...
</pre></div>
</div>
<p>In the above examples, <code class="docutils literal notranslate"><span class="pre">plpythonu</span></code> and <code class="docutils literal notranslate"><span class="pre">plv8</span></code> are the names of
procedural languages. The SQL parser trims <cite>pl</cite> at the start and <cite>u</cite>
at the end of the name before finding a parser ctags having. For
<code class="docutils literal notranslate"><span class="pre">plpythonu</span></code> and <code class="docutils literal notranslate"><span class="pre">`plv8</span></code>, the SQL parser extracts <code class="docutils literal notranslate"><span class="pre">python</span></code> and
<code class="docutils literal notranslate"><span class="pre">v8</span></code> as the candidates of guest parsers.</p>
<p>For <code class="docutils literal notranslate"><span class="pre">plpythonu</span></code>, ctags can run its Python parser. ctags doesn’t
have a parser named <code class="docutils literal notranslate"><span class="pre">v8</span></code>. However, JavaScript parser of ctags has
<code class="docutils literal notranslate"><span class="pre">v8</span></code> as an alias. So ctags can run the JavaScript parser as the
guest parser for <code class="docutils literal notranslate"><span class="pre">plv8</span></code>.</p>
</section>
<section id="examples">
<h2>EXAMPLES<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
<p>tagging code including a user-defined function in a string literal <a class="reference internal" href="#gh3006" id="id2"><span>[GH3006]</span></a>:</p>
<p>“input.sql”</p>
<div class="highlight-SQL notranslate"><div class="highlight"><pre><span></span><span class="k">CREATE</span> <span class="k">OR</span> <span class="k">REPLACE</span> <span class="k">FUNCTION</span> <span class="n">fun1</span><span class="p">()</span> <span class="k">RETURNS</span> <span class="nb">VARCHAR</span> <span class="k">AS</span> <span class="s1">'</span>
<span class="s1">DECLARE</span>
<span class="s1"> test1_var1 VARCHAR(64) := $$ABC$$;</span>
<span class="s1"> test1_var2 VARCHAR(64) := $xyz$XYZ$xyz$;</span>
<span class="s1"> test1_var3 INTEGER := 1;</span>
<span class="s1">BEGIN</span>
<span class="s1"> RETURN TO_CHAR(test_var3, ''000'') || test1_var1 || test1_var2;</span>
<span class="s1">END;</span>
<span class="s1">'</span> <span class="k">LANGUAGE</span> <span class="n">plpgsql</span><span class="p">;</span>
</pre></div>
</div>
<p>“output.tags”
with “--options=NONE -o - --sort=no --extras=+{guest} input.sql”</p>
<div class="highlight-tags notranslate"><div class="highlight"><pre><span></span>fun1 input.sql /^CREATE OR REPLACE FUNCTION fun1() RETURNS VARCHAR AS '$/;" f
test1_var1 input.sql /^ test1_var1 VARCHAR(64) := $$ABC$$;$/;" v
test1_var2 input.sql /^ test1_var2 VARCHAR(64) := $xyz$XYZ$xyz$;$/;" v
test1_var3 input.sql /^ test1_var3 INTEGER := 1;$/;" v
</pre></div>
</div>
<p>tagging code including a user-defined function in a dollar quote <a class="reference internal" href="#gh3006" id="id3"><span>[GH3006]</span></a>:</p>
<p>“input.sql”</p>
<div class="highlight-SQL notranslate"><div class="highlight"><pre><span></span>CREATE OR REPLACE FUNCTION fun2() RETURNS VARCHAR LANGUAGE plpgsql AS $$
DECLARE
test2_var1 VARCHAR(64) := 'ABC2';
test2_var2 VARCHAR(64) := 'XYZ2';
test2_var3 INTEGER := 2;
BEGIN
RETURN TO_CHAR(test2_var3, '000') || test2_var1 || test2_var2;
END;
$$;
</pre></div>
</div>
<p>“output.tags”
with “--options=NONE -o - --sort=no --extras=+{guest} input.sql”</p>
<div class="highlight-tags notranslate"><div class="highlight"><pre><span></span>fun2 input.sql /^CREATE OR REPLACE FUNCTION fun2() RETURNS VARCHAR LANGUAGE plpgsql AS $\$$/;" f
test2_var1 input.sql /^ test2_var1 VARCHAR(64) := 'ABC2';$/;" v
test2_var2 input.sql /^ test2_var2 VARCHAR(64) := 'XYZ2';$/;" v
test2_var3 input.sql /^ test2_var3 INTEGER := 2;$/;" v
</pre></div>
</div>
<p>tagging code including a user-defined written in JavaScript:</p>
<div class="highlight-SQL notranslate"><div class="highlight"><pre><span></span>-- Derived from https://github.com/plv8/plv8/blob/r3.0alpha/sql/plv8.sql
CREATE FUNCTION test(keys text[], vals text[]) RETURNS text AS
$$
var o = {};
for (var i = 0; i < keys.length; i++)
o[keys[i]] = vals[i];
return JSON.stringify(o);
$$
LANGUAGE plv8 IMMUTABLE STRICT;
</pre></div>
</div>
<p>“output.tags”
with “--options=NONE -o - --sort=no --extras=+{guest} input.sql”</p>
<div class="highlight-tags notranslate"><div class="highlight"><pre><span></span>test input.sql /^CREATE FUNCTION test(keys text[], vals text[]) RETURNS text AS$/;" f
o input.sql /^ var o = {};$/;" v
</pre></div>
</div>
</section>
<section id="known-bugs">
<h2>KNOWN BUGS<a class="headerlink" href="#known-bugs" title="Permalink to this headline">¶</a></h2>
<p>Escape sequences (<cite>‘’</cite>) in a string literal may make a guest parser confused.</p>
</section>
<section id="see-also">
<h2>SEE ALSO<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="ctags.1.html#ctags-1"><span class="std std-ref">ctags(1)</span></a>, <a class="reference internal" href="ctags-client-tools.7.html#ctags-client-tools-7"><span class="std std-ref">ctags-client-tools(7)</span></a></p>
</section>
<section id="references">
<h2>REFERENCES<a class="headerlink" href="#references" title="Permalink to this headline">¶</a></h2>
<dl class="citation">
<dt class="label" id="pl"><span class="brackets"><a class="fn-backref" href="#id1">PL</a></span></dt>
<dd><p>PostgreSQL 9.5.25 Documentation, “Chapter 39. Procedural Languages”, <a class="reference external" href="https://www.postgresql.org/docs/9.5/xplang.html">https://www.postgresql.org/docs/9.5/xplang.html</a></p>
</dd>
<dt class="label" id="gh3006"><span class="brackets">GH3006</span><span class="fn-backref">(<a href="#id2">1</a>,<a href="#id3">2</a>)</span></dt>
<dd><p>@bagl’s comment submitted to <a class="reference external" href="https://github.com/universal-ctags/ctags/issues/3006">https://github.com/universal-ctags/ctags/issues/3006</a></p>
</dd>
</dl>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">ctags-lang-sql</a><ul>
<li><a class="reference internal" href="#synopsis">SYNOPSIS</a></li>
<li><a class="reference internal" href="#description">DESCRIPTION</a></li>
<li><a class="reference internal" href="#examples">EXAMPLES</a></li>
<li><a class="reference internal" href="#known-bugs">KNOWN BUGS</a></li>
<li><a class="reference internal" href="#see-also">SEE ALSO</a></li>
<li><a class="reference internal" href="#references">REFERENCES</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="ctags-lang-r.7.html"
title="previous chapter">ctags-lang-r</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="ctags-incompatibilities.7.html"
title="next chapter">ctags-incompatibilities</a></p>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="ctags-incompatibilities.7.html" title="ctags-incompatibilities"
>next</a> |</li>
<li class="right" >
<a href="ctags-lang-r.7.html" title="ctags-lang-r"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Universal Ctags 0.3.0 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="../man-pages.html" >Man pages</a> »</li>
<li class="nav-item nav-item-this"><a href="">ctags-lang-sql</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2015, Universal Ctags Team.
Last updated on 11 Jun 2021.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.0.2.
</div>
</body>
</html>
|