mariadb/mysql-test/main/func_numconv_debug.result
Alexander Barkov 6ba83565f0 MDEV-20022 sql_mode="oracle" does not support TO_NUMBER() function
This patch implements an Oracle style function to_number()
with the following signatures:

- to_number(number_or_string_subject)
- to_number(string_subject, string_format)

The function is implemented in sql/item_numconvfunc.cc.

The function returns the DOUBLE data type for
all signatures and input data types.

The format parser understands the following components:

- Digits: 0, 9
- Hex digits: X
- Group separators: comma (,) and G
- Decimal delimiers: period (.) and D
- Approximate number signature: EEEE
- Currency/numeric flags: $ and B
- Currency signatures: C, L, U
- Sign signatures: S, MI, PR
- Special format signatures: V, TM, TM9, TME
- Format flag: FM

Note, the parser was implemented assuming that we'll also have the
oppostite function to_char() soon for numeric input.
So it parser all known components.
However, the function to_number() does not support:
- Formats V, TM, TM9, TME. to_number() returns NULL if the format
  string has these components.
  These componens are supported only by to_char() in Oracle.

Features not inclided into this patch:
- The ON CONVERSION ERROR clause
- The third parameter (nlsparam)
- Internationalized components: G, D, C, L, U.
These features will be implemented later, under terms of MDEV-36978.

Notable changes in the other files:

- item_func.h: adding Item_handled_func::Handler_double

- simple_parser.h: adding a number of *CONTAINER* templates
  They help to save on duplicate code when creating classes
  suitable for passing into parsing templates such as OPT, OR2C, OR3C, etc

- simple_parser.h: Adding parsing templates OR4C and OR5C

- simple_parser.h: Moving the template "OPT" towars the beginning of the file
  Rule parsing templates TOKEN, TokenChoice, AND2, OR2C, OR3C, OR4C, OR5C, LIST
  now provide a sub-class Opt, to parse its optional rule.

- simple_parser.h: Adding "explicit" to all "operator bool" definitions

- Renaming Parser_templates::TOKEN to Parser_templates::TokenParser

- Adding "explicit" to all "operator bool()" templates/classes,
  to avoid hidden implicit conversion (to int, void*, etc).

- Renaming the LIST template parameter ELEMENT to ELEMENT_PARSER,
  to make it clearer what it is for.

- Renaming the OPT template parameter RULE to RULE_PARSER,
  to make it clearer what it is for.
2025-08-08 12:39:58 +04:00

125 lines
2.6 KiB
Text

#
# MDEV-20022 sql_mode="oracle" does not support TO_NUMBER() function
#
SET debug_dbug='+d,numconv_format';
SELECT to_number('', '9') AS c;
c
0
Warnings:
Note 1105 A='9'
SELECT to_number('', '0') AS c;
c
0
Warnings:
Note 1105 A='0'
SELECT to_number('', '9.9') AS c;
c
0
Warnings:
Note 1105 A='9[.]9'
SELECT to_number('', '0.0') AS c;
c
0
Warnings:
Note 1105 A='0[.]0'
SELECT to_number('', '.9') AS c;
c
0
Warnings:
Note 1105 A='[.]9'
SELECT to_number('', '.0') AS c;
c
0
Warnings:
Note 1105 A='[.]0'
SELECT to_number('', '9$9') AS c;
c
0
Warnings:
Note 1105 A='9$9'
SELECT to_number('', '0$0') AS c;
c
0
Warnings:
Note 1105 A='0$0'
SELECT to_number('', '9B9') AS c;
c
0
Warnings:
Note 1105 A='9B9'
SELECT to_number('', '0B0') AS c;
c
0
Warnings:
Note 1105 A='0B0'
SELECT to_number('', '9.9$') AS c;
c
0
Warnings:
Note 1105 A='9[.]9$'
SELECT to_number('', '9.9B') AS c;
c
0
Warnings:
Note 1105 A='9[.]9B'
SELECT to_number('', '9C9') AS c;
ERROR 42000: This version of MariaDB doesn't yet support '<number format>='9C9''
SHOW WARNINGS;
Level Code Message
Note 1105 A='9[C]9'
Error 1235 This version of MariaDB doesn't yet support '<number format>='9C9''
SELECT to_number('', '9.9C') AS c;
ERROR 42000: This version of MariaDB doesn't yet support '<number format>='9.9C''
SHOW WARNINGS;
Level Code Message
Note 1105 A='9[.]9'RC='C'
Error 1235 This version of MariaDB doesn't yet support '<number format>='9.9C''
SELECT to_number('', '$9') AS c;
c
0
Warnings:
Note 1105 CFl='$'A='9'
SELECT to_number('', '$0') AS c;
c
0
Warnings:
Note 1105 CFl='$'A='0'
SELECT to_number('', 'B9') AS c;
c
0
Warnings:
Note 1105 CFl='B'A='9'
SELECT to_number('', 'B0') AS c;
c
0
Warnings:
Note 1105 CFl='B'A='0'
SELECT to_number('', 'C9') AS c;
ERROR 42000: This version of MariaDB doesn't yet support '<number format>='C9''
SHOW WARNINGS;
Level Code Message
Note 1105 LC='C'A='9'
Error 1235 This version of MariaDB doesn't yet support '<number format>='C9''
SELECT to_number('', 'L0') AS c;
ERROR 42000: This version of MariaDB doesn't yet support '<number format>='L0''
SHOW WARNINGS;
Level Code Message
Note 1105 LC='L'A='0'
Error 1235 This version of MariaDB doesn't yet support '<number format>='L0''
SELECT to_number('', '9PR') AS c;
c
0
Warnings:
Note 1105 A='9'RS='PR'
SELECT to_number('', 'FMS9') AS c;
c
0
Warnings:
Note 1105 FFl='FM'LS='S'A='9'
SELECT to_number('', 'FMTM') AS c;
ERROR 42000: This version of MariaDB doesn't yet support '<number format>='FMTM''
SHOW WARNINGS;
Level Code Message
Note 1105 FFl='FM'A=''TM='TM'
Error 1235 This version of MariaDB doesn't yet support '<number format>='FMTM''
SET debug_dbug=DEFAULT;