Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,52 @@ SELECT HEX(0), HEX('');
+--------+--------+
| 0 | |
+--------+--------+
```

6. Whitespace characters (each byte → two hex digits)
```sql
SELECT HEX(' '), HEX('\t'), HEX('\n');
```
```text
+----------+-----------+-----------+
| HEX(' ') | HEX('\t') | HEX('\n') |
+----------+-----------+-----------+
| 20 | 09 | 0A |
+----------+-----------+-----------+
```

7. UTF-8 multi-byte strings
```sql
SELECT HEX('ṭṛì'), HEX('ḍḍumai');
```
```text
+------------------+----------------------+
| HEX('ṭṛì') | HEX('ḍḍumai') |
+------------------+----------------------+
| E1B9ADE1B99BC3AC | E1B88DE1B88D756D6169 |
+------------------+----------------------+
```

8. Negative integers (64-bit two's complement)
```sql
SELECT HEX(-128), HEX(-32768);
```
```text
+------------------+------------------+
| HEX(-128) | HEX(-32768) |
+------------------+------------------+
| FFFFFFFFFFFFFF80 | FFFFFFFFFFFF8000 |
+------------------+------------------+
```

9. Mixed alphanumeric strings
```sql
SELECT HEX('A1'), HEX('Hello!');
```
```text
+-----------+---------------+
| HEX('A1') | HEX('Hello!') |
+-----------+---------------+
| 4131 | 48656C6C6F21 |
+-----------+---------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,76 @@ SELECT INITCAP('hello hello.,HELLO123HELlo');
+---------------------------------------+
| Hello Hello.,Hello123hello |
+---------------------------------------+
```

5. Empty string
```sql
SELECT INITCAP('');
```
```text
+-------------+
| INITCAP('') |
+-------------+
| |
+-------------+
```

6. Multiple non-alphanumeric separators
```sql
SELECT INITCAP('word1@word2#word3$word4');
```
```text
+------------------------------------+
| INITCAP('word1@word2#word3$word4') |
+------------------------------------+
| Word1@Word2#Word3$Word4 |
+------------------------------------+
```

7. UTF-8 multi-byte words
```sql
SELECT INITCAP('ṭṛì ḍḍumai hello');
```
```text
+--------------------------------------+
| INITCAP('ṭṛì ḍḍumai hello') |
+--------------------------------------+
| Ṭṛì Ḍḍumai Hello |
+--------------------------------------+
```

8. Common name capitalization
```sql
SELECT INITCAP('john doe'), INITCAP('MARY JANE');
```
```text
+---------------------+----------------------+
| INITCAP('john doe') | INITCAP('MARY JANE') |
+---------------------+----------------------+
| John Doe | Mary Jane |
+---------------------+----------------------+
```

9. Sentences with mixed casing
```sql
SELECT INITCAP('the quick brown fox'), INITCAP('DATABASE management SYSTEM');
```
```text
+--------------------------------+---------------------------------------+
| INITCAP('the quick brown fox') | INITCAP('DATABASE management SYSTEM') |
+--------------------------------+---------------------------------------+
| The Quick Brown Fox | Database Management System |
+--------------------------------+---------------------------------------+
```

10. Multiple spaces and adjacent punctuation
```sql
SELECT INITCAP('word1 word2--word3'), INITCAP('hello, world! how are you?');
```
```text
+---------------------------------+---------------------------------------+
| INITCAP('word1 word2--word3') | INITCAP('hello, world! how are you?') |
+---------------------------------+---------------------------------------+
| Word1 Word2--Word3 | Hello, World! How Are You? |
+---------------------------------+---------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,51 @@ SELECT LOWER(NULL), LCASE(NULL);
| NULL | NULL |
+-------------+-------------+
```

4. Empty string
```sql
SELECT LOWER(''), LCASE('');
```
```text
+-----------+-----------+
| LOWER('') | LCASE('') |
+-----------+-----------+
| | |
+-----------+-----------+
```

5. String already lowercase or numeric-only
```sql
SELECT LOWER('already lowercase'), LCASE('abc123');
```
```text
+----------------------------+-----------------+
| LOWER('already lowercase') | LCASE('abc123') |
+----------------------------+-----------------+
| already lowercase | abc123 |
+----------------------------+-----------------+
```

6. Non-alphabetic characters are passed through unchanged
```sql
SELECT LOWER('123!@#$%'), LCASE('PRICE: $99.99');
```
```text
+-------------------+------------------------+
| LOWER('123!@#$%') | LCASE('PRICE: $99.99') |
+-------------------+------------------------+
| 123!@#$% | price: $99.99 |
+-------------------+------------------------+
```

7. UTF-8 multi-byte case folding
```sql
SELECT LOWER('ṬṚÌ TEST'), LCASE('ḌḌUMAI HELLO');
```
```text
+------------------------+---------------------------+
| LOWER('ṬṚÌ TEST') | LCASE('ḌḌUMAI HELLO') |
+------------------------+---------------------------+
| ṭṛì test | ḍḍumai hello |
+------------------------+---------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,75 @@ SELECT LTRIM(NULL), LTRIM('test', NULL);
| NULL | NULL |
+-------------+---------------------+
```

4. Empty inputs
```sql
SELECT LTRIM(''), LTRIM('test', '');
```
```text
+-----------+-------------------+
| LTRIM('') | LTRIM('test', '') |
+-----------+-------------------+
| | test |
+-----------+-------------------+
```

5. Strip a multi-character prefix
```sql
SELECT LTRIM('abcdefg', 'abc'), LTRIM('123456', '12');
```
```text
+-------------------------+-----------------------+
| LTRIM('abcdefg', 'abc') | LTRIM('123456', '12') |
+-------------------------+-----------------------+
| defg | 3456 |
+-------------------------+-----------------------+
```

6. Entire string matches the trim chars
```sql
SELECT LTRIM('aaaaa', 'a'), LTRIM(' ', ' ');
```
```text
+---------------------+-------------------+
| LTRIM('aaaaa', 'a') | LTRIM(' ', ' ') |
+---------------------+-------------------+
| | |
+---------------------+-------------------+
```

7. UTF-8 substring strip (the second arg is matched as a literal substring, not a character set)
```sql
SELECT LTRIM('ṭṛìṭṛì test', 'ṭṛì'), LTRIM('ḍḍuḍḍu hello', 'ḍu');
```
```text
+--------------------------------------------+---------------------------------------+
| LTRIM('ṭṛìṭṛì test', 'ṭṛì') | LTRIM('ḍḍuḍḍu hello', 'ḍu') |
+--------------------------------------------+---------------------------------------+
| test | ḍḍuḍḍu hello |
+--------------------------------------------+---------------------------------------+
```

8. Strip a numeric prefix
```sql
SELECT LTRIM('000123', '0'), LTRIM('123abc123', '123');
```
```text
+----------------------+---------------------------+
| LTRIM('000123', '0') | LTRIM('123abc123', '123') |
+----------------------+---------------------------+
| 123 | abc123 |
+----------------------+---------------------------+
```

9. Strip a punctuation prefix
```sql
SELECT LTRIM('---text---', '-'), LTRIM('@@hello@@', '@');
```
```text
+--------------------------+-------------------------+
| LTRIM('---text---', '-') | LTRIM('@@hello@@', '@') |
+--------------------------+-------------------------+
| text--- | hello@@ |
+--------------------------+-------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,51 @@ SELECT REPLACE('ṭṛì ḍḍumai test ṭṛì ḍḍumannàri', 'ṭṛì',
| replaced ḍḍumai test replaced ḍḍumannàri |
+-----------------------------------------------------------+
```

6. Empty-string edge cases — empty `str` returns empty; empty `old` returns `str` unchanged; empty `new` deletes every match
```sql
SELECT REPLACE('', 'old', 'new'), REPLACE('test', '', 'new'), REPLACE('test', 'old', '');
```
```text
+---------------------------+----------------------------+----------------------------+
| REPLACE('', 'old', 'new') | REPLACE('test', '', 'new') | REPLACE('test', 'old', '') |
+---------------------------+----------------------------+----------------------------+
| | test | test |
+---------------------------+----------------------------+----------------------------+
```

7. Replacement is case-sensitive (only lowercase `hello` matches)
```sql
SELECT REPLACE('Hello HELLO hello', 'hello', 'hi');
```
```text
+---------------------------------------------+
| REPLACE('Hello HELLO hello', 'hello', 'hi') |
+---------------------------------------------+
| Hello HELLO hi |
+---------------------------------------------+
```

8. `old` not present — returns `str` unchanged
```sql
SELECT REPLACE('hello world', 'xyz', 'abc');
```
```text
+--------------------------------------+
| REPLACE('hello world', 'xyz', 'abc') |
+--------------------------------------+
| hello world |
+--------------------------------------+
```

9. Overlap-free repeated match
```sql
SELECT REPLACE('123123123', '123', 'ABC');
```
```text
+------------------------------------+
| REPLACE('123123123', '123', 'ABC') |
+------------------------------------+
| ABCABCABC |
+------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ SELECT xpath_string('<a><b>1</b><b>2</b></a>', '/a/b[2]');
+----------------------------------------------------+
```

5. Handling CDATA and comments
5. NULL input
```sql
SELECT xpath_string(NULL, '/a');
```
Expand All @@ -95,6 +95,48 @@ SELECT xpath_string(NULL, '/a');
+--------------------------+
```

6. CDATA sections — the CDATA payload is returned as plain text
```sql
SELECT xpath_string('<a><![CDATA[123]]></a>', '/a');
```
```text
+----------------------------------------------+
| xpath_string('<a><![CDATA[123]]></a>', '/a') |
+----------------------------------------------+
| 123 |
+----------------------------------------------+
```

7. XML comments are skipped
```sql
SELECT xpath_string('<a><!-- comment -->123</a>', '/a');
```
```text
+--------------------------------------------------+
| xpath_string('<a><!-- comment -->123</a>', '/a') |
+--------------------------------------------------+
| 123 |
+--------------------------------------------------+
```

8. Path does not match any node — returns empty string
```sql
SELECT xpath_string('<a>123</a>', '/b');
```
```text
+----------------------------------+
| xpath_string('<a>123</a>', '/b') |
+----------------------------------+
| |
+----------------------------------+
```

9. Malformed XML — function raises an error
```sql
SELECT xpath_string('<a><!-- comment -->123/a>', '/a');
ERROR 1105 (HY000): errCode = 2, detailMessage = [INVALID_ARGUMENT]Function xpath_string failed to parse XML string: Start-end tags mismatch
```

### Keywords

XPATH_STRING, XPATH, XML