Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 88d2d71

Browse files
author
kuba--
committed
Update docs (custom functions)
Signed-off-by: kuba-- <[email protected]>
1 parent adcea8c commit 88d2d71

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,21 @@ go get gopkg.in/src-d/go-mysql-server.v0
5050

5151
We are continuously adding more functionality to go-mysql-server. We support a subset of what is supported in MySQL, to see what is currently included check the [SUPPORTED](./SUPPORTED.md) file.
5252

53-
# Third-party clients
53+
## Third-party clients
5454

5555
We support and actively test against certain third-party clients to ensure compatibility between them and go-mysql-server. You can check out the list of supported third party clients in the [SUPPORTED_CLIENTS](./SUPPORTED_CLIENTS.md) file along with some examples on how to connect to go-mysql-server using them.
5656

5757
## Custom functions
5858

59+
- `COUNT(expr)`: Returns a count of the number of non-NULL values of expr in the rows retrieved by a SELECT statement.
60+
- `MIN(expr)`: Returns the minimum value of expr.
61+
- `MAX(expr)`: Returns the maximum value of expr.
62+
- `AVG(expr)`: Returns the average value of expr.
63+
- `SUM(expr)`: Returns the sum of expr.
5964
- `IS_BINARY(blob)`: Returns whether a BLOB is a binary file or not.
60-
- `SUBSTRING(str, pos)`, `SUBSTRING(str, pos, len)`: Return a substring from the provided string.
65+
- `SUBSTRING(str, pos)`, `SUBSTRING(str, pos, len)` : Return a substring from the provided string.
66+
- `SUBSTR(str, pos)`, `SUBSTR(str, pos, len)` : Return a substring from the provided string.
67+
- `MID(str, pos)`, `MID(str, pos, len)` : Return a substring from the provided string.
6168
- Date and Timestamp functions: `YEAR(date)`, `MONTH(date)`, `DAY(date)`, `WEEKDAY(date)`, `HOUR(date)`, `MINUTE(date)`, `SECOND(date)`, `DAYOFWEEK(date)`, `DAYOFYEAR(date)`.
6269
- `ARRAY_LENGTH(json)`: If the json representation is an array, this function returns its size.
6370
- `SPLIT(str,sep)`: Receives a string and a separator and returns the parts of the string split by the separator as a JSON array of strings.
@@ -70,6 +77,23 @@ We support and actively test against certain third-party clients to ensure compa
7077
- `ROUND(number, decimals)`: Round the `number` to `decimals` decimal places.
7178
- `CONNECTION_ID()`: Return the current connection ID.
7279
- `SOUNDEX(str)`: Returns the soundex of a string.
80+
- `JSON_EXTRACT(json_doc, path, ...)`: Extracts data from a json document using json paths.
81+
- `LN(X)`: Return the natural logarithm of X.
82+
- `LOG2(X)`: Returns the base-2 logarithm of X.
83+
- `LOG10(X)`: Returns the base-10 logarithm of X.
84+
- `LOG(X), LOG(B, X)`: If called with one parameter, this function returns the natural logarithm of X. If called with two parameters, this function returns the logarithm of X to the base B. If X is less than or equal to 0, or if B is less than or equal to 1, then NULL is returned.
85+
- `RPAD(str, len, padstr)`: Returns the string str, right-padded with the string padstr to a length of len characters.
86+
- `LPAD(str, len, padstr)`: Return the string argument, left-padded with the specified string.
87+
- `SQRT(X)`: Returns the square root of a nonnegative number X.
88+
- `POW(X, Y)`, `POWER(X, Y)`: Returns the value of X raised to the power of Y.
89+
- `TRIM(str)`: Returns the string str with all spaces removed.
90+
- `LTRIM(str)`: Returns the string str with leading space characters removed.
91+
- `RTRIM(str)`: Returns the string str with trailing space characters removed.
92+
- `REVERSE(str)`: Returns the string str with the order of the characters reversed.
93+
- `REPEAT(str, count)`: Returns a string consisting of the string str repeated count times.
94+
- `REPLACE(str,from_str,to_str)`: Returns the string str with all occurrences of the string from_str replaced by the string to_str.
95+
- `IFNULL(expr1, expr2)`: If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2.
96+
- `NULLIF(expr1, expr2)`: Returns NULL if expr1 = expr2 is true, otherwise returns expr1.
7397

7498
## Example
7599

sql/expression/function/registry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ var Defaults = sql.Functions{
4141
"split": sql.Function2(NewSplit),
4242
"concat": sql.FunctionN(NewConcat),
4343
"concat_ws": sql.FunctionN(NewConcatWithSeparator),
44+
"coalesce": sql.FunctionN(NewCoalesce),
4445
"lower": sql.Function1(NewLower),
4546
"upper": sql.Function1(NewUpper),
4647
"ceiling": sql.Function1(NewCeil),
4748
"ceil": sql.Function1(NewCeil),
4849
"floor": sql.Function1(NewFloor),
4950
"round": sql.FunctionN(NewRound),
50-
"coalesce": sql.FunctionN(NewCoalesce),
51-
"json_extract": sql.FunctionN(NewJSONExtract),
5251
"connection_id": sql.Function0(NewConnectionID),
5352
"soundex": sql.Function1(NewSoundex),
53+
"json_extract": sql.FunctionN(NewJSONExtract),
5454
"ln": sql.Function1(NewLogBaseFunc(float64(math.E))),
5555
"log2": sql.Function1(NewLogBaseFunc(float64(2))),
5656
"log10": sql.Function1(NewLogBaseFunc(float64(10))),

0 commit comments

Comments
 (0)