Skip to content

Commit

Permalink
Merge #38863
Browse files Browse the repository at this point in the history
38863: sql: fix substring builtin documentation r=nvanbenschoten a=nvanbenschoten

The docs were claiming that the third (optional) arg for the substring
builtin was an end position, but it's actually (correctly) a length.
This commit fixes that.

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
  • Loading branch information
craig[bot] and nvanbenschoten committed Jul 13, 2019
2 parents 092e60a + 37a70c4 commit 02d52a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/generated/sql/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -911,17 +911,17 @@ has no relationship with the commit order of concurrent transactions.</p>
</span></td></tr>
<tr><td><code>substr(input: <a href="string.html">string</a>, regex: <a href="string.html">string</a>, escape_char: <a href="string.html">string</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> that matches the regular expression <code>regex</code> using <code>escape_char</code> as your escape character instead of <code>\</code>.</p>
</span></td></tr>
<tr><td><code>substr(input: <a href="string.html">string</a>, start_pos: <a href="int.html">int</a>, end_pos: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> between <code>start_pos</code> and <code>end_pos</code> (count starts at 1).</p>
<tr><td><code>substr(input: <a href="string.html">string</a>, start_pos: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> starting at <code>start_pos</code> (count starts at 1).</p>
</span></td></tr>
<tr><td><code>substr(input: <a href="string.html">string</a>, substr_pos: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> starting at <code>substr_pos</code> (count starts at 1).</p>
<tr><td><code>substr(input: <a href="string.html">string</a>, start_pos: <a href="int.html">int</a>, length: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> starting at <code>start_pos</code> (count starts at 1) and including up to <code>length</code> characters.</p>
</span></td></tr>
<tr><td><code>substring(input: <a href="string.html">string</a>, regex: <a href="string.html">string</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> that matches the regular expression <code>regex</code>.</p>
</span></td></tr>
<tr><td><code>substring(input: <a href="string.html">string</a>, regex: <a href="string.html">string</a>, escape_char: <a href="string.html">string</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> that matches the regular expression <code>regex</code> using <code>escape_char</code> as your escape character instead of <code>\</code>.</p>
</span></td></tr>
<tr><td><code>substring(input: <a href="string.html">string</a>, start_pos: <a href="int.html">int</a>, end_pos: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> between <code>start_pos</code> and <code>end_pos</code> (count starts at 1).</p>
<tr><td><code>substring(input: <a href="string.html">string</a>, start_pos: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> starting at <code>start_pos</code> (count starts at 1).</p>
</span></td></tr>
<tr><td><code>substring(input: <a href="string.html">string</a>, substr_pos: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> starting at <code>substr_pos</code> (count starts at 1).</p>
<tr><td><code>substring(input: <a href="string.html">string</a>, start_pos: <a href="int.html">int</a>, length: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns a substring of <code>input</code> starting at <code>start_pos</code> (count starts at 1) and including up to <code>length</code> characters.</p>
</span></td></tr>
<tr><td><code>to_english(val: <a href="int.html">int</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>This function enunciates the value of its argument using English cardinals.</p>
</span></td></tr>
Expand Down
9 changes: 5 additions & 4 deletions pkg/sql/sem/builtins/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -3093,7 +3093,7 @@ var substringImpls = makeBuiltin(tree.FunctionProperties{Category: categoryStrin
tree.Overload{
Types: tree.ArgTypes{
{"input", types.String},
{"substr_pos", types.Int},
{"start_pos", types.Int},
},
ReturnType: tree.FixedReturnType(types.String),
Fn: func(_ *tree.EvalContext, args tree.Datums) (tree.Datum, error) {
Expand All @@ -3109,13 +3109,13 @@ var substringImpls = makeBuiltin(tree.FunctionProperties{Category: categoryStrin

return tree.NewDString(string(runes[start:])), nil
},
Info: "Returns a substring of `input` starting at `substr_pos` (count starts at 1).",
Info: "Returns a substring of `input` starting at `start_pos` (count starts at 1).",
},
tree.Overload{
Types: tree.ArgTypes{
{"input", types.String},
{"start_pos", types.Int},
{"end_pos", types.Int},
{"length", types.Int},
},
ReturnType: tree.FixedReturnType(types.String),
Fn: func(_ *tree.EvalContext, args tree.Datums) (tree.Datum, error) {
Expand Down Expand Up @@ -3147,7 +3147,8 @@ var substringImpls = makeBuiltin(tree.FunctionProperties{Category: categoryStrin

return tree.NewDString(string(runes[start:end])), nil
},
Info: "Returns a substring of `input` between `start_pos` and `end_pos` (count starts at 1).",
Info: "Returns a substring of `input` starting at `start_pos` (count starts at 1) and " +
"including up to `length` characters.",
},
tree.Overload{
Types: tree.ArgTypes{
Expand Down

0 comments on commit 02d52a6

Please sign in to comment.