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