Details
-
Task
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
None
Description
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow:
- Better compatibility with sys/performance_schema
- Nice functions to have natively in any case for formatting reasons or even as a virtual column
- Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+
- Better performance by being C rather than user functions/SQL
https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/
MySQL implementation
- MySQL has native implementation of function:
1. format_bytes,
2. format_pico_time
3. ps_thread_id
4. ps_current_thread_id
- As well as sys schema defined functions [that are marked as deprecated and will be removed]:
1. format_bytes
2. ps_thread_id
3. format_time
- In MySQL all native functions are defined in file item_pfs_func.h, where source code declaration is item_pfs_func.cc . Definition of native functions format_pico_time for example is item_create.cc
- Commit and author that introduced native function is
commit 260e09ea654a9688f588c13f5303bcc34dfc4a7d
Author: Christopher Powers <chris.powers@oracle.com>
Date: Thu Dec 13 01:33:24 2018 +0100
WL#7803 Performance Schema, Native Functions
Added native functions:
ps_current_thread_id()
ps_thread_id()
format_bytes()
format_pico_time()
- Test are added to perfschema suite suite/perfschema/t/
1. native_func_format_time
2. native_func_format_bytes
3. native_func_thread_id
4. native_func_thread_id_no_ps
5. native_func_thread_id_null
MariaDB implementation
- MariaDB doesn't have any native functions
- MariaDB has sys schema function format_bytes, as stated in sysschema.format_bytes documentation.
- This change is introduced from 10.6.0 with commits and author
commit aa2ff62082c4eb09b1d505af0d0327278c9f7d08
Author: Vladislav Vaintroub <wlad@mariadb.com>
Date: Wed Mar 3 10:30:29 2021 +0100
MDEV-9077 Use sys schema in bootstrapping, incl. mtr
and second commit
commit 4bac804c90c6f8d101ef32aef39813c3d13283ff
Author: Vladislav Vaintroub <wlad@mariadb.com>
Date: Wed Mar 17 17:57:11 2021 +0100
MDEV-9077 add sys_schema from https://github.com/mysql/mysql-sys
- Tasks:
The task can be divided into 3 steps by backporting the patch from MySQL if possible in single commit and if not in separate commits: Create native function format_pico_time- task done as contribution with PR 2558 on 11.0, commit d9808f79- Create native function ps_thread_id
- Create native function ps_current_thread_id
- Create native function for format_bytes
Attachments
Issue Links
- causes
-
MDEV-36020 ASAN errors in Binary_string::replace upon using format_pico_time in view
-
- Open
-
- includes
-
MDEV-31736 Create native function for format_bytes
-
- Closed
-
- is part of
-
MDEV-28906 MySQL 8.0 desired compatibility
-
- Open
-
- relates to
-
MDEV-33703 Negative numbers and differnce of behaviour between sys.format_time() and FORMAT_PICO_TIME()
-
- Open
-
1.
|
Create native function format_pico_time |
![]() |
Closed | Anel Husakovic |
2.
|
Create native function ps_thread_id |
![]() |
Open | Unassigned |
3.
|
Create native function ps_current_thread_id |
![]() |
Open | Unassigned |
Activity
Field | Original Value | New Value |
---|---|---|
Affects Version/s | 10.4 [ 22408 ] | |
Issue Type | Bug [ 1 ] | Task [ 3 ] |
Labels | upsteam | upstream-fixed |
Workflow | MariaDB v3 [ 97108 ] | MariaDB v4 [ 131095 ] |
Link | This issue is part of MDEV-28906 [ MDEV-28906 ] |
Summary | Implement MySQL 8.0 native functions: format_bytes(), format_time() and ps_thread_id() | Implement MySQL 8.0 native functions: format_bytes(), format_pico_time() and ps_thread_id() |
Labels | upstream-fixed | beginner-friendly upstream-fixed |
Labels | beginner-friendly upstream-fixed | beginner-friendly compat80 upstream-fixed |
Description |
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow: * Better compatibility with sys/performance_schema * Nice functions to have natively in any case for formatting reasons or even as a virtual column * Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+ * Better performance by being C rather than user functions/SQL https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/ |
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow: * Better compatibility with sys/performance_schema * Nice functions to have natively in any case for formatting reasons or even as a virtual column * Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+ * Better performance by being C rather than user functions/SQL https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/ h4. MySQL implementation - MySQL has native implementation of function: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-bytes], 2. [format_pico_time|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-pico-time] 3. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-thread-id] 4. [ps_current_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-current-thread-id] - As well as {{sys}} schema defined functions \[that are marked as deprecated and will be removed\]: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/sys-format-bytes.html] 2. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/sys-ps-thread-id.html] 3. [format_time|https://dev.mysql.com/doc/refman/8.0/en/sys-format-time.html] - In MySQL all native functions are defined in file [item_pfs_func.h|https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.h], where source code declaration is [item_pfs_func.cc |https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.cc]. Definition of native functions {{format_pico_time}} for example is [item_create.cc|https://github.com/mysql/mysql-server/blob/8.0/sql/item_create.cc#L1416] - Commit and author that introduced native function is {code:noformat} commit 260e09ea654a9688f588c13f5303bcc34dfc4a7d Author: Christopher Powers <chris.powers@oracle.com> Date: Thu Dec 13 01:33:24 2018 +0100 WL#7803 Performance Schema, Native Functions Added native functions: ps_current_thread_id() ps_thread_id() format_bytes() format_pico_time() {code} - Test are added to {{perfschema}} suite {{suite/perfschema/t/}} 1. [native_func_format_time|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_time.test] 2. [native_func_format_bytes|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_bytes.test] 3. [native_func_thread_id|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id.test] 4. [native_func_thread_id_no_ps|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_no_ps.test] 5. [native_func_thread_id_null|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_null.test] h4. MariaDB implementation - MariaDB doesn't have any native functions - MariaDB has {{sys}} schema function {{format_bytes}}, as stated in [sysschema.format_bytes|https://mariadb.com/kb/en/format_bytes/] documentation. - This change is introduced from {{10.6.0}} with commit and author {code:noformat} {code} |
Description |
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow: * Better compatibility with sys/performance_schema * Nice functions to have natively in any case for formatting reasons or even as a virtual column * Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+ * Better performance by being C rather than user functions/SQL https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/ h4. MySQL implementation - MySQL has native implementation of function: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-bytes], 2. [format_pico_time|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-pico-time] 3. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-thread-id] 4. [ps_current_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-current-thread-id] - As well as {{sys}} schema defined functions \[that are marked as deprecated and will be removed\]: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/sys-format-bytes.html] 2. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/sys-ps-thread-id.html] 3. [format_time|https://dev.mysql.com/doc/refman/8.0/en/sys-format-time.html] - In MySQL all native functions are defined in file [item_pfs_func.h|https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.h], where source code declaration is [item_pfs_func.cc |https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.cc]. Definition of native functions {{format_pico_time}} for example is [item_create.cc|https://github.com/mysql/mysql-server/blob/8.0/sql/item_create.cc#L1416] - Commit and author that introduced native function is {code:noformat} commit 260e09ea654a9688f588c13f5303bcc34dfc4a7d Author: Christopher Powers <chris.powers@oracle.com> Date: Thu Dec 13 01:33:24 2018 +0100 WL#7803 Performance Schema, Native Functions Added native functions: ps_current_thread_id() ps_thread_id() format_bytes() format_pico_time() {code} - Test are added to {{perfschema}} suite {{suite/perfschema/t/}} 1. [native_func_format_time|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_time.test] 2. [native_func_format_bytes|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_bytes.test] 3. [native_func_thread_id|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id.test] 4. [native_func_thread_id_no_ps|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_no_ps.test] 5. [native_func_thread_id_null|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_null.test] h4. MariaDB implementation - MariaDB doesn't have any native functions - MariaDB has {{sys}} schema function {{format_bytes}}, as stated in [sysschema.format_bytes|https://mariadb.com/kb/en/format_bytes/] documentation. - This change is introduced from {{10.6.0}} with commit and author {code:noformat} {code} |
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow: * Better compatibility with sys/performance_schema * Nice functions to have natively in any case for formatting reasons or even as a virtual column * Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+ * Better performance by being C rather than user functions/SQL https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/ h4. MySQL implementation - MySQL has native implementation of function: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-bytes], 2. [format_pico_time|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-pico-time] 3. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-thread-id] 4. [ps_current_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-current-thread-id] - As well as {{sys}} schema defined functions \[that are marked as deprecated and will be removed\]: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/sys-format-bytes.html] 2. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/sys-ps-thread-id.html] 3. [format_time|https://dev.mysql.com/doc/refman/8.0/en/sys-format-time.html] - In MySQL all native functions are defined in file [item_pfs_func.h|https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.h], where source code declaration is [item_pfs_func.cc |https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.cc]. Definition of native functions {{format_pico_time}} for example is [item_create.cc|https://github.com/mysql/mysql-server/blob/8.0/sql/item_create.cc#L1416] - Commit and author that introduced native function is {code:noformat} commit 260e09ea654a9688f588c13f5303bcc34dfc4a7d Author: Christopher Powers <chris.powers@oracle.com> Date: Thu Dec 13 01:33:24 2018 +0100 WL#7803 Performance Schema, Native Functions Added native functions: ps_current_thread_id() ps_thread_id() format_bytes() format_pico_time() {code} - Test are added to {{perfschema}} suite {{suite/perfschema/t/}} 1. [native_func_format_time|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_time.test] 2. [native_func_format_bytes|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_bytes.test] 3. [native_func_thread_id|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id.test] 4. [native_func_thread_id_no_ps|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_no_ps.test] 5. [native_func_thread_id_null|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_null.test] h4. MariaDB implementation - MariaDB doesn't have any native functions - MariaDB has {{sys}} schema function {{format_bytes}}, as stated in [sysschema.format_bytes|https://mariadb.com/kb/en/format_bytes/] documentation. - This change is introduced from {{10.6.0}} with commits and author {code:noformat} commit aa2ff62082c4eb09b1d505af0d0327278c9f7d08 Author: Vladislav Vaintroub <wlad@mariadb.com> Date: Wed Mar 3 10:30:29 2021 +0100 {code} |
Description |
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow: * Better compatibility with sys/performance_schema * Nice functions to have natively in any case for formatting reasons or even as a virtual column * Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+ * Better performance by being C rather than user functions/SQL https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/ h4. MySQL implementation - MySQL has native implementation of function: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-bytes], 2. [format_pico_time|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-pico-time] 3. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-thread-id] 4. [ps_current_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-current-thread-id] - As well as {{sys}} schema defined functions \[that are marked as deprecated and will be removed\]: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/sys-format-bytes.html] 2. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/sys-ps-thread-id.html] 3. [format_time|https://dev.mysql.com/doc/refman/8.0/en/sys-format-time.html] - In MySQL all native functions are defined in file [item_pfs_func.h|https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.h], where source code declaration is [item_pfs_func.cc |https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.cc]. Definition of native functions {{format_pico_time}} for example is [item_create.cc|https://github.com/mysql/mysql-server/blob/8.0/sql/item_create.cc#L1416] - Commit and author that introduced native function is {code:noformat} commit 260e09ea654a9688f588c13f5303bcc34dfc4a7d Author: Christopher Powers <chris.powers@oracle.com> Date: Thu Dec 13 01:33:24 2018 +0100 WL#7803 Performance Schema, Native Functions Added native functions: ps_current_thread_id() ps_thread_id() format_bytes() format_pico_time() {code} - Test are added to {{perfschema}} suite {{suite/perfschema/t/}} 1. [native_func_format_time|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_time.test] 2. [native_func_format_bytes|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_bytes.test] 3. [native_func_thread_id|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id.test] 4. [native_func_thread_id_no_ps|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_no_ps.test] 5. [native_func_thread_id_null|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_null.test] h4. MariaDB implementation - MariaDB doesn't have any native functions - MariaDB has {{sys}} schema function {{format_bytes}}, as stated in [sysschema.format_bytes|https://mariadb.com/kb/en/format_bytes/] documentation. - This change is introduced from {{10.6.0}} with commits and author {code:noformat} commit aa2ff62082c4eb09b1d505af0d0327278c9f7d08 Author: Vladislav Vaintroub <wlad@mariadb.com> Date: Wed Mar 3 10:30:29 2021 +0100 {code} |
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow: * Better compatibility with sys/performance_schema * Nice functions to have natively in any case for formatting reasons or even as a virtual column * Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+ * Better performance by being C rather than user functions/SQL https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/ h4. MySQL implementation - MySQL has native implementation of function: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-bytes], 2. [format_pico_time|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-pico-time] 3. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-thread-id] 4. [ps_current_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-current-thread-id] - As well as {{sys}} schema defined functions \[that are marked as deprecated and will be removed\]: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/sys-format-bytes.html] 2. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/sys-ps-thread-id.html] 3. [format_time|https://dev.mysql.com/doc/refman/8.0/en/sys-format-time.html] - In MySQL all native functions are defined in file [item_pfs_func.h|https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.h], where source code declaration is [item_pfs_func.cc |https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.cc]. Definition of native functions {{format_pico_time}} for example is [item_create.cc|https://github.com/mysql/mysql-server/blob/8.0/sql/item_create.cc#L1416] - Commit and author that introduced native function is {code:noformat} commit 260e09ea654a9688f588c13f5303bcc34dfc4a7d Author: Christopher Powers <chris.powers@oracle.com> Date: Thu Dec 13 01:33:24 2018 +0100 WL#7803 Performance Schema, Native Functions Added native functions: ps_current_thread_id() ps_thread_id() format_bytes() format_pico_time() {code} - Test are added to {{perfschema}} suite {{suite/perfschema/t/}} 1. [native_func_format_time|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_time.test] 2. [native_func_format_bytes|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_bytes.test] 3. [native_func_thread_id|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id.test] 4. [native_func_thread_id_no_ps|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_no_ps.test] 5. [native_func_thread_id_null|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_null.test] h4. MariaDB implementation - MariaDB doesn't have any native functions - MariaDB has {{sys}} schema function {{format_bytes}}, as stated in [sysschema.format_bytes|https://mariadb.com/kb/en/format_bytes/] documentation. - This change is introduced from {{10.6.0}} with commits and author {code:noformat} commit aa2ff62082c4eb09b1d505af0d0327278c9f7d08 Author: Vladislav Vaintroub <wlad@mariadb.com> Date: Wed Mar 3 10:30:29 2021 +0100 {code} and second commit {code:noformat} commit 4bac804c90c6f8d101ef32aef39813c3d13283ff Author: Vladislav Vaintroub <wlad@mariadb.com> Date: Wed Mar 17 17:57:11 2021 +0100 {code} - *Tasks*: The task can be divided into 3 steps by backporting the patch from {{MySQL}} if possible in single commit and if not in separate commits: - Create native function {{format_pico_time}} - Create native function {{ps_thread_id}} - Create native function {{ps_current_thread_id}} - Create native function for {{format_bytes}} |
Assignee | Anel Husakovic [ anel ] |
Description |
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow: * Better compatibility with sys/performance_schema * Nice functions to have natively in any case for formatting reasons or even as a virtual column * Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+ * Better performance by being C rather than user functions/SQL https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/ h4. MySQL implementation - MySQL has native implementation of function: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-bytes], 2. [format_pico_time|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-pico-time] 3. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-thread-id] 4. [ps_current_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-current-thread-id] - As well as {{sys}} schema defined functions \[that are marked as deprecated and will be removed\]: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/sys-format-bytes.html] 2. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/sys-ps-thread-id.html] 3. [format_time|https://dev.mysql.com/doc/refman/8.0/en/sys-format-time.html] - In MySQL all native functions are defined in file [item_pfs_func.h|https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.h], where source code declaration is [item_pfs_func.cc |https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.cc]. Definition of native functions {{format_pico_time}} for example is [item_create.cc|https://github.com/mysql/mysql-server/blob/8.0/sql/item_create.cc#L1416] - Commit and author that introduced native function is {code:noformat} commit 260e09ea654a9688f588c13f5303bcc34dfc4a7d Author: Christopher Powers <chris.powers@oracle.com> Date: Thu Dec 13 01:33:24 2018 +0100 WL#7803 Performance Schema, Native Functions Added native functions: ps_current_thread_id() ps_thread_id() format_bytes() format_pico_time() {code} - Test are added to {{perfschema}} suite {{suite/perfschema/t/}} 1. [native_func_format_time|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_time.test] 2. [native_func_format_bytes|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_bytes.test] 3. [native_func_thread_id|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id.test] 4. [native_func_thread_id_no_ps|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_no_ps.test] 5. [native_func_thread_id_null|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_null.test] h4. MariaDB implementation - MariaDB doesn't have any native functions - MariaDB has {{sys}} schema function {{format_bytes}}, as stated in [sysschema.format_bytes|https://mariadb.com/kb/en/format_bytes/] documentation. - This change is introduced from {{10.6.0}} with commits and author {code:noformat} commit aa2ff62082c4eb09b1d505af0d0327278c9f7d08 Author: Vladislav Vaintroub <wlad@mariadb.com> Date: Wed Mar 3 10:30:29 2021 +0100 {code} and second commit {code:noformat} commit 4bac804c90c6f8d101ef32aef39813c3d13283ff Author: Vladislav Vaintroub <wlad@mariadb.com> Date: Wed Mar 17 17:57:11 2021 +0100 {code} - *Tasks*: The task can be divided into 3 steps by backporting the patch from {{MySQL}} if possible in single commit and if not in separate commits: - Create native function {{format_pico_time}} - Create native function {{ps_thread_id}} - Create native function {{ps_current_thread_id}} - Create native function for {{format_bytes}} |
While this functions can be implemented as user SQL functions, they have become native on MySQL 8.0.16. They are simple and independent enough that backport them should be easy.
Implementing them on MariaDB would allow: * Better compatibility with sys/performance_schema * Nice functions to have natively in any case for formatting reasons or even as a virtual column * Better MySQL compatibility, and avoiding user pain when migrating from MySQL from 8.0.16+ * Better performance by being C rather than user functions/SQL https://mysql.wisborg.dk/2019/05/28/performance-schema-functions/ h4. MySQL implementation - MySQL has native implementation of function: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-bytes], 2. [format_pico_time|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-pico-time] 3. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-thread-id] 4. [ps_current_thread_id|https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_ps-current-thread-id] - As well as {{sys}} schema defined functions \[that are marked as deprecated and will be removed\]: 1. [format_bytes|https://dev.mysql.com/doc/refman/8.0/en/sys-format-bytes.html] 2. [ps_thread_id|https://dev.mysql.com/doc/refman/8.0/en/sys-ps-thread-id.html] 3. [format_time|https://dev.mysql.com/doc/refman/8.0/en/sys-format-time.html] - In MySQL all native functions are defined in file [item_pfs_func.h|https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.h], where source code declaration is [item_pfs_func.cc |https://github.com/mysql/mysql-server/blob/8.0/sql/item_pfs_func.cc]. Definition of native functions {{format_pico_time}} for example is [item_create.cc|https://github.com/mysql/mysql-server/blob/8.0/sql/item_create.cc#L1416] - Commit and author that introduced native function is {code:noformat} commit 260e09ea654a9688f588c13f5303bcc34dfc4a7d Author: Christopher Powers <chris.powers@oracle.com> Date: Thu Dec 13 01:33:24 2018 +0100 WL#7803 Performance Schema, Native Functions Added native functions: ps_current_thread_id() ps_thread_id() format_bytes() format_pico_time() {code} - Test are added to {{perfschema}} suite {{suite/perfschema/t/}} 1. [native_func_format_time|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_time.test] 2. [native_func_format_bytes|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_format_bytes.test] 3. [native_func_thread_id|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id.test] 4. [native_func_thread_id_no_ps|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_no_ps.test] 5. [native_func_thread_id_null|https://github.com/mysql/mysql-server/blob/8.0/mysql-test/suite/perfschema/t/native_func_thread_id_null.test] h4. MariaDB implementation - MariaDB doesn't have any native functions - MariaDB has {{sys}} schema function {{format_bytes}}, as stated in [sysschema.format_bytes|https://mariadb.com/kb/en/format_bytes/] documentation. - This change is introduced from {{10.6.0}} with commits and author {code:noformat} commit aa2ff62082c4eb09b1d505af0d0327278c9f7d08 Author: Vladislav Vaintroub <wlad@mariadb.com> Date: Wed Mar 3 10:30:29 2021 +0100 {code} and second commit {code:noformat} commit 4bac804c90c6f8d101ef32aef39813c3d13283ff Author: Vladislav Vaintroub <wlad@mariadb.com> Date: Wed Mar 17 17:57:11 2021 +0100 {code} - *Tasks*: The task can be divided into 3 steps by backporting the patch from {{MySQL}} if possible in single commit and if not in separate commits: - -Create native function {{format_pico_time}}- - task done as contribution with [PR 2558|https://github.com/MariaDB/server/pull/2558] on 11.0, commit [d9808f79|https://github.com/MariaDB/server/commit/d9808f79de992964ed802d27984c9031d72e7b9a] - Create native function {{ps_thread_id}} - Create native function {{ps_current_thread_id}} - Create native function for {{format_bytes}} |
Link | This issue relates to MDEV-33703 [ MDEV-33703 ] |
Link |
This issue includes |
Assignee | Anel Husakovic [ anel ] |
Link | This issue causes MDEV-36020 [ MDEV-36020 ] |
Is any one working on "Create native function for format_bytes" ? I would like to start working on it.
I found out that "format_bytes" is deprecated according to this https://dev.mysql.com/doc/refman/8.0/en/sys-format-bytes.html , and there's a new version https://dev.mysql.com/doc/refman/8.0/en/performance-schema-functions.html#function_format-bytes , which one should I work on ? the difference is minimal anyways and it would be easy to implement.