@@ -2579,129 +2579,243 @@ Apply a built-in function to one or more expressions and return a scalar value.
2579
2579
2580
2580
Tarantool supports 32 built-in functions.
2581
2581
2582
- ``CHAR([numeric-expression [,numeric-expression...]) ``
2583
- Return the characters whose Unicode code point values are equal
2584
- to the numeric expressions.
2585
-
2586
- Short example:
2587
- The first 128 Unicode characters are the "ASCII" characters,
2588
- so CHAR(65,66,67) is 'ABC'.
2589
-
2590
- Long example:
2591
- For the current list of Unicode characters,
2592
- in order by code point, see
2593
- `www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt <http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt >`_.
2594
- In that list, there is a line for a Linear B ideogram |br |
2595
- ``100CC;LINEAR B IDEOGRAM B240 WHEELED CHARIOT ... `` |br |
2596
- Therefore, for a string with a chariot in the middle,
2597
- use the concatenation operator ``|| `` and the CHAR function
2598
- ``'start of string ' || CHAR(0X100CC) || ' end of string' ``.
2599
-
2600
- ``COALESCE(expression, expression [, expression ...]) ``
2601
- Return the value of the first non-NULL expression, or, if all
2602
- expression values are NULL, return NULL.
2603
-
2604
- Example: ``COALESCE(NULL, 17, 32) `` is 17
2605
-
2606
- ``HEX(expression) ``
2607
- Return the hexadecimal code for each byte in *expression *,
2608
- which may be either a string or a byte sequence.
2609
- For ASCII characters, this
2610
- is straightforward because the encoding is
2611
- the same as the code point value. For
2612
- non-ASCII characters, since character strings
2613
- are usually encoded in UTF-8, each character
2614
- will require two or more bytes.
2615
-
2616
- Examples:
2617
-
2618
- * ``HEX('A') `` will return '41'
2619
- * ``HEX('Д') `` will return 'D094'
2620
-
2621
- ``IFNULL(expression, expression) ``
2622
- Return the value of the first non-NULL expression, or, if both
2623
- expression values are NULL, return NULL. Thus
2624
- ``IFNULL(expression,expression) `` is the same as
2625
- ``COALESCE(expression, expression) ``.
2626
-
2627
- Example: ``IFNULL(NULL, 17) `` is 17
2628
-
2629
- ``LENGTH(expression) ``
2630
- Return the number of characters in the *expression *,
2631
- or the number of bytes in the *expression *.
2632
- It depends on the data type:
2633
- strings with data type STRING are counted in characters,
2634
- byte sequences with data type VARBINARY
2635
- are counted in bytes and are not ended by the nul character.
2636
- There are two aliases for ``LENGTH(expression) `` -- ``CHAR_LENGTH(expression) ``
2637
- and ``CHARACTER_LENGTH(expression) `` do the same thing.
2638
-
2639
- Examples:
2640
-
2641
- * ``LENGTH('ДД') `` is 2, the string has 2 characters
2642
- * ``LENGTH(CAST('ДД' AS VARBINARY)) `` is 4, the string has 4 bytes
2643
- * ``LENGTH(CHAR(0,65)) `` is 2, '\0 ' does not mean 'end of string'
2644
- * ``LENGTH(X'410041') `` is 3, X'...' byte sequences have type VARBINARY
2645
-
2646
- ``NULLIF(expression-1, expression-2) ``
2647
- Return *expression-1 * if *expression-1 * <> *expression-2 *,
2648
- otherwise return NULL.
2649
-
2650
- Examples:
2651
-
2652
- * ``NULLIF('a','A') `` is 'a'
2653
- * ``NULLIF(1.00, 1) `` is NULL
2654
-
2655
- ``PRINTF(string-expression [, expression ...]) ``
2656
- Return a string formatted according to the rules of the C
2657
- ``sprintf() `` function, where ``%d%s `` means the next two arguments
2658
- are a number and a string, etc.
2659
-
2660
- If an argument is missing or is NULL, it becomes:
2661
-
2662
- * '0' if the format requires an integer,
2663
- * '0.0' if the format requires a decimal number,
2664
- * '' if the format requires a string.
2665
-
2666
- Example: ``PRINTF('%da', 5) `` is '5a'
2667
-
2668
- ``QUOTE(string-literal) ``
2669
- Return a string with enclosing quotes if necessary,
2670
- and with quotes inside the enclosing quotes if necessary.
2671
- This function is useful for creating strings
2672
- which are part of SQL statements, because of SQL's rules that
2673
- string literals are enclosed by single quotes, and single quotes
2674
- inside such strings are shown as two single quotes in a row.
2675
-
2676
- Example: ``QUOTE('a') `` is '''a'''
2677
-
2678
- ``SOUNDEX(string-expression) ``
2679
- Return a four-character string which represents the sound
2680
- of ``string-expression ``. Often words and names which have
2681
- different spellings will have the same Soundex representation
2682
- if they are pronounced similarly,
2683
- so it is possible to search by what they sound like.
2684
- The algorithm works with characters in the Latin alphabet
2685
- and works best with English words.
2686
-
2687
- Example: ``SOUNDEX('Crater') `` and ``SOUNDEX('Creature') `` both return 'C636'.
2688
-
2689
- ``UNICODE(string-expression) ``
2690
- Return the Unicode code point value of the first character of
2691
- *string-expression *.
2692
- If *string-expression * is empty, the return is NULL.
2693
- This is the reverse of CHAR(integer).
2694
-
2695
- Example: ``UNICODE('Щ') `` is 1065 (hexadecimal 0429)
2696
-
2697
- ``UPPER(string-expression) ``
2698
- Return the expression, with lower-case characters converted
2699
- to upper case.
2700
- This is the reverse of LOWER(string-expression).
2582
+ .. _sql_function_char :
2701
2583
2702
- Example: ``UPPER('-4щl') `` is '-4ЩL'
2584
+ ***********************************************
2585
+ CHAR
2586
+ ***********************************************
2587
+
2588
+ Syntax:
2589
+
2590
+ :samp: `CHAR([numeric-expression [,numeric-expression...]) `
2591
+
2592
+ Return the characters whose Unicode code point values are equal
2593
+ to the numeric expressions.
2594
+
2595
+ Short example:
2596
+
2597
+ The first 128 Unicode characters are the "ASCII" characters,
2598
+ so CHAR(65,66,67) is 'ABC'.
2599
+
2600
+ Long example:
2601
+
2602
+ For the current list of Unicode characters,
2603
+ in order by code point, see
2604
+ `www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
2605
+ <http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt> `_.
2606
+ In that list, there is a line for a Linear B ideogram
2607
+
2608
+ ``100CC;LINEAR B IDEOGRAM B240 WHEELED CHARIOT ... ``
2609
+
2610
+ Therefore, for a string with a chariot in the middle,
2611
+ use the concatenation operator ``|| `` and the CHAR function
2612
+
2613
+ ``'start of string ' || CHAR(0X100CC) || ' end of string' ``.
2614
+
2615
+ .. _sql_function_coalesce :
2616
+
2617
+ ***********************************************
2618
+ COALESCE
2619
+ ***********************************************
2620
+
2621
+ Syntax:
2622
+
2623
+ :samp: `COALESCE(expression, expression [, expression ...]) `
2624
+
2625
+ Return the value of the first non-NULL expression, or, if all
2626
+ expression values are NULL, return NULL.
2627
+
2628
+ Example:
2629
+ ``COALESCE(NULL, 17, 32) `` is 17.
2630
+
2631
+ .. _sql_function_hex :
2632
+
2633
+ ***********************************************
2634
+ HEX
2635
+ ***********************************************
2636
+
2637
+ Syntax:
2638
+
2639
+ :samp: `HEX(expression) `
2640
+
2641
+ Return the hexadecimal code for each byte in **expression **,
2642
+ which may be either a string or a byte sequence.
2643
+ For ASCII characters, this
2644
+ is straightforward because the encoding is
2645
+ the same as the code point value. For
2646
+ non-ASCII characters, since character strings
2647
+ are usually encoded in UTF-8, each character
2648
+ will require two or more bytes.
2649
+
2650
+ Examples:
2651
+
2652
+ * ``HEX('A') `` will return ``41 ``.
2653
+ * ``HEX('Д') `` will return ``D094 ``.
2654
+
2655
+ .. _sql_function_ifnull :
2656
+
2657
+ ***********************************************
2658
+ IFNULL
2659
+ ***********************************************
2660
+
2661
+ Syntax:
2662
+
2663
+ :samp: `IFNULL(expression, expression) `
2664
+
2665
+ Return the value of the first non-NULL expression, or, if both
2666
+ expression values are NULL, return NULL. Thus
2667
+ ``IFNULL(expression, expression) `` is the same as
2668
+ ``COALESCE(expression, expression) ``.
2669
+
2670
+ Example:
2671
+ ``IFNULL(NULL, 17) `` is 17
2672
+
2673
+ .. _sql_function_length :
2674
+
2675
+ ***********************************************
2676
+ LENGTH
2677
+ ***********************************************
2678
+
2679
+ Syntax:
2680
+
2681
+ :samp: `LENGTH(expression) `
2682
+
2683
+ Return the number of characters in the **expression **,
2684
+ or the number of bytes in the **expression **.
2685
+ It depends on the data type:
2686
+ strings with data type STRING are counted in characters,
2687
+ byte sequences with data type VARBINARY
2688
+ are counted in bytes and are not ended by the nul character.
2689
+ There are two aliases for ``LENGTH(expression) `` -- ``CHAR_LENGTH(expression) ``
2690
+ and ``CHARACTER_LENGTH(expression) `` do the same thing.
2691
+
2692
+ Examples:
2693
+
2694
+ * ``LENGTH('ДД') `` is 2, the string has 2 characters.
2695
+ * ``LENGTH(CAST('ДД' AS VARBINARY)) `` is 4, the string has 4 bytes.
2696
+ * ``LENGTH(CHAR(0,65)) `` is 2, '\0 ' does not mean 'end of string'.
2697
+ * ``LENGTH(X'410041') `` is 3, X'...' byte sequences have type VARBINARY.
2698
+
2699
+ .. _sql_function_nullif :
2700
+
2701
+ ***********************************************
2702
+ NULLIF
2703
+ ***********************************************
2704
+
2705
+ Syntax:
2706
+
2707
+ :samp: `NULLIF(expression-1, expression-2) `
2708
+
2709
+ Return *expression-1 * if *expression-1 * <> *expression-2 *,
2710
+ otherwise return NULL.
2711
+
2712
+ Examples:
2713
+
2714
+ * ``NULLIF('a','A') `` is 'a'.
2715
+ * ``NULLIF(1.00, 1) `` is NULL.
2716
+
2717
+ .. _sql_function_printf :
2718
+
2719
+ ***********************************************
2720
+ PRINTF
2721
+ ***********************************************
2722
+
2723
+ Syntax:
2724
+
2725
+ :samp: `PRINTF(string-expression [, expression ...]) `
2726
+
2727
+ Return a string formatted according to the rules of the C
2728
+ ``sprintf() `` function, where ``%d%s `` means the next two arguments
2729
+ are a number and a string, etc.
2730
+
2731
+ If an argument is missing or is NULL, it becomes:
2732
+
2733
+ * '0' if the format requires an integer,
2734
+ * '0.0' if the format requires a decimal number,
2735
+ * '' if the format requires a string.
2736
+
2737
+ Example: ``PRINTF('%da', 5) `` is '5a'.
2738
+
2739
+ .. _sql_function_quote :
2740
+
2741
+ ***********************************************
2742
+ QUOTE
2743
+ ***********************************************
2744
+
2745
+ Syntax:
2746
+
2747
+ :samp: `QUOTE(string-literal) `
2748
+
2749
+ Return a string with enclosing quotes if necessary,
2750
+ and with quotes inside the enclosing quotes if necessary.
2751
+ This function is useful for creating strings
2752
+ which are part of SQL statements, because of SQL's rules that
2753
+ string literals are enclosed by single quotes, and single quotes
2754
+ inside such strings are shown as two single quotes in a row.
2755
+
2756
+ Example: ``QUOTE('a') `` is ``'a' ``.
2757
+
2758
+ .. _sql_function_soundex :
2759
+
2760
+ ***********************************************
2761
+ SOUNDEX
2762
+ ***********************************************
2763
+
2764
+ Syntax:
2765
+
2766
+ :samp: `SOUNDEX(string-expression) `
2767
+
2768
+ Return a four-character string which represents the sound
2769
+ of ``string-expression ``. Often words and names which have
2770
+ different spellings will have the same Soundex representation
2771
+ if they are pronounced similarly,
2772
+ so it is possible to search by what they sound like.
2773
+ The algorithm works with characters in the Latin alphabet
2774
+ and works best with English words.
2775
+
2776
+ Example: ``SOUNDEX('Crater') `` and ``SOUNDEX('Creature') `` both return ``C636 ``.
2777
+
2778
+ .. _sql_function_unicode :
2779
+
2780
+ ***********************************************
2781
+ UNICODE
2782
+ ***********************************************
2783
+
2784
+ Syntax:
2785
+
2786
+ :samp: `UNICODE(string-expression) `
2787
+
2788
+ Return the Unicode code point value of the first character of **string-expression **.
2789
+ If *string-expression * is empty, the return is NULL.
2790
+ This is the reverse of CHAR(integer).
2791
+
2792
+ Example: ``UNICODE('Щ') `` is 1065 (hexadecimal 0429).
2793
+
2794
+ .. _sql_function_upper :
2795
+
2796
+ ***********************************************
2797
+ UPPER
2798
+ ***********************************************
2799
+
2800
+ Syntax:
2801
+
2802
+ :samp: `UPPER(string-expression) `
2803
+
2804
+ Return the expression, with lower-case characters converted to upper case.
2805
+ This is the reverse of LOWER(string-expression).
2806
+
2807
+ Example: ``UPPER('-4щl') `` is '-4ЩL'.
2808
+
2809
+ .. _sql_function_version :
2810
+
2811
+ ***********************************************
2812
+ VERSION
2813
+ ***********************************************
2814
+
2815
+ Syntax:
2816
+
2817
+ :samp: `VERSION() `
2818
+
2819
+ Return the Tarantool version.
2703
2820
2704
- ``VERSION() ``
2705
- Return the Tarantool version.
2706
-
2707
- Example: for a March 2019 build VERSION() is '2.1.1-374-g27283debc'
2821
+ Example: for a March 2019 build VERSION() is ``2.1.1-374-g27283debc ``.
0 commit comments