~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/functions/string.rst

  • Committer: Stewart Smith
  • Date: 2010-08-12 16:48:46 UTC
  • mto: This revision was merged to the branch mainline in revision 1707.
  • Revision ID: stewart@flamingspork.com-20100812164846-s9bhy47g60bvqs41
bug lp:611379 Equivalent queries with Impossible where return different results

The following two equivalent queries return different results in maria 5.2 and 5.3 (and identical results in mysql 5.5.5) :

SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` ;

SELECT * FROM ( SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` );

MariaDB returns 0 on the second query and NULL on the first, whereas MySQL returns NULL on both. In MariaDB, both EXPLAIN plans agree that "Impossible WHERE noticed after reading const tables"



We have some slightly different output in drizzle:

main.bug_lp611379 [ fail ]
drizzletest: At line 9: query 'explain select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a)
as t' failed: 1048: Column 'sum(distinct t1.a)' cannot be null

but the fix gets us the correct query results, although with slightly different execution plans.



This fix is directly ported from MariaDB.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
String Functions and Operators
2
 
===============================
3
 
 
4
 
.. toctree::
5
 
   :maxdepth: 2
6
 
 
7
 
   string/comparative
8
 
   string/conversion
9
 
   string/length 
10
 
   string/modification
11
 
   string/position
12
 
   string/other
13
 
 
14
 
 
15
 
List of string operators and descriptions by type of function:
16
 
 
17
 
 
18
 
Comparative and regular functions
19
 
---------------------------------
20
 
 
21
 
===================     ====================================================================================================
22
 
Operator                  Description
23
 
===================     ==================================================================================================== 
24
 
LIKE                      Matches a simple pattern
25
 
NOT LIKE                  Negation of simple pattern matching
26
 
STRCMP()                  Compare two strings
27
 
NOT REGEXP                Negation of REGEXP
28
 
REGEXP                    Returns values that match a regular expression pattern
29
 
RLIKE                     Synonym for REGEXP
30
 
===================     ====================================================================================================
31
 
 
32
 
 
33
 
Conversion and translation functions
34
 
------------------------------------
35
 
===================     ====================================================================================================
36
 
Operator                  Description
37
 
===================     ====================================================================================================
38
 
ASCII()                   Return numeric value of left-most character
39
 
BIN()                     Return a string representation of the argument
40
 
CHAR()                    Return the character for each integer passed
41
 
HEX()                     Return a hexadecimal representation of a decimal or string value
42
 
LOWER()                   Return the argument in lowercase
43
 
LCASE()                   Synonym for LOWER()
44
 
UCASE()                   Synonym for UPPER()
45
 
UNHEX()                   Convert each pair of hexadecimal digits to a character
46
 
UPPER()                   Convert to uppercase
47
 
===================     ====================================================================================================
48
 
 
49
 
 
50
 
Length and size functions
51
 
-------------------------
52
 
===================     ====================================================================================================
53
 
Operator                  Description
54
 
===================     ====================================================================================================
55
 
BIT_LENGTH()              Return length of argument in bits
56
 
CHAR_LENGTH()             Return number of characters in argument
57
 
LENGTH()                  Return the length of a string in bytes
58
 
OCTET_LENGTH()            A synonym for LENGTH()
59
 
===================     ====================================================================================================
60
 
 
61
 
 
62
 
Formatting and modification functions
63
 
-------------------------------------
64
 
===================     ====================================================================================================
65
 
Operator                  Description
66
 
===================     ====================================================================================================
67
 
CONCAT()                  Returns a concatenated string
68
 
TRIM()                    Remove leading and trailing spaces
69
 
LTRIM()                   Remove leading spaces
70
 
RTRIM()                   Remove trailing spaces
71
 
===================     ====================================================================================================
72
 
 
73
 
 
74
 
Position functions
75
 
-------------------
76
 
 
77
 
===================     ====================================================================================================
78
 
Operator                  Description
79
 
===================     ==================================================================================================== 
80
 
FIELD()                   Return the index (position) of the first argument in the sequent arguments
81
 
FIND_IN_SET()             Return the index position of the first argument within the second argument
82
 
INSTR()                   Return the index of the first occurrence of substring
83
 
LEFT()                    Return the leftmost number of characters as specified
84
 
INSERT()                  Insert a substring at the specified position up to the specified number of characters
85
 
LOCATE()                  Return the position of the first occurrence of substring
86
 
POSITION()                A synonym for LOCATE()
87
 
===================     ==================================================================================================== 
88
 
 
89
 
 
90
 
Other string functions
91
 
----------------------
92
 
 
93
 
===================     ====================================================================================================
94
 
Operator                  Description
95
 
===================     ==================================================================================================== 
96
 
ELT()                     Return string at index number
97
 
EXPORT_SET()              Return a string
98
 
FORMAT()                  Return a number formatted to specified number of decimal places
99
 
LOAD_FILE()               Load the named file
100
 
LPAD()                    Return the string argument, left-padded with the specified string
101
 
MAKE_SET()                Return a set of comma-separated strings that have the corresponding bit in bits set
102
 
MATCH                     Perform full-text search
103
 
MID()                     Return a substring starting from the specified position
104
 
ORD()                     Return character code for leftmost character of the argument
105
 
QUOTE()                   Escape the argument for use in an SQL statement
106
 
REPEAT()                  Repeat a string the specified number of times
107
 
REPLACE()                 Replace occurrences of a specified string
108
 
REVERSE()                 Reverse the characters in a string
109
 
RIGHT()                   Return the specified rightmost number of characters
110
 
RPAD()                    Append string the specified number of times
111
 
SOUNDEX()                 Return a soundex string
112
 
SUBSTR()                  Return the substring as specified
113
 
SUBSTRING_INDEX()         Return a substring from a string before the specified number of occurrences of the delimiter
114
 
SUBSTRING()               Return the substring as specified
115
 
===================     ====================================================================================================
116