Skip to content

Conversation

@talili-rsec
Copy link

@talili-rsec talili-rsec commented Nov 10, 2025

  • The Jira issue number for this PR is: MDEV-34327
  • The Jira issue number for this PR is: MDEV-34330
  • The Jira issue number for this PR is: MDEV-34331
  • The Jira issue number for this PR is: MDEV-19635

Description

MDEV-34327

This patch is the implementation of Oracle’s DBMS_RANDOM package for sql_mode=ORACLE. The random number generator can be seeded with a constant value by calling the INITIALIZE procedure with the seed number.

The following functions were added for the ticket:

INITIALIZE - Initialize the seed
VALUE - Get a random number greater than or equal to 0 and less than 1, with 38 digits to the right of the decimal point (38-digit precision)
RANDOM - Generate a random number
TERMINATE – Terminate the package

MDEV-34330

This patch is the implementation of Oracle’s DBMS_UTILITY package for sql_mode=ORACLE.

The following functions were added for the ticket:

GET_TIME - Return a measure of current time in hundredths of a second
FORMAT_ERROR_BACKTRACE - Display the call stack at the point where an exception was raised, even if the procedure is called from an exception handler in an outer scope
FORMAT_ERROR_STACK - Format the current error stack

For the FORMAT_XXXX functions, resulting line numbers of SQL statement lines of interest, in package routines are based on the line numbers of the "SHOW CREATE" command for the package body.

TODOs:
The error stack formatting differs from Oracle's implementation. In Oracle, FORMAT_ERROR_STACK and FORMAT_ERROR_BACKTRACE can display output from any point in the call stack (bottom, middle, or top). This implementation always formats output as if the request originates from the bottom-most function in the stack, regardless of where the function is actually called from.

MDEV-34331

This patch is the implementation of Oracle’s UTL_I18N package for sql_mode=ORACLE. The package is a set of services that provides additional globalization functionality.

The ANY_CS character set was also implemented so that the character set set by "set names" command or the character set of the database as the character set of the variable set with ANY_CS, especially for the transliterate function.

The following functions were added for the ticket:

TRANSLITERATE - Perform script transliteration
RAW_TO_CHAR - Convert RAW data from a valid character set to a VARCHAR2 string in the database character set
STRING_TO_RAW - Convert a VARCHAR2 string to another valid character set and returns the result as RAW data

MDEV-19635

This patch adds support for dynamic SQL to parse any data manipulation language (DML) or data definition language (DDL) statement using PL/SQL.

The following functions were added for the ticket:

OPEN_CURSOR - Open a new cursor
PARSE - Parse the given statement in the given cursor
EXECUTE - Execute a given cursor
CLOSE_CURSOR - Close the cursor when no longer needed for a session

TODOs:
As of the moment, '1', corresponding to Oracle's NATIVE DBMS_SQL constant, as PARSE's procedure's (language_flag) 3rd argument, is the only one accepted.

Release Notes

  • MDEV-34327: N/A
  • MDEV-34330: N/A
  • MDEV-34331: N/A
  • MDEV-19635: N/A, but new kb page should be created for this dynamic SQL.

How can this PR be tested?

  • MDEV-34327:
    • mysql-test/mtr pkg_dbms_random
  • MDEV-34330:
    • mysql-test/mtr pkg_dbms_utility
  • MDEV-34331:
    • mysql-test/mtr pkg_utl_i18n
    • mysql-test/mtr pkg_utl_i18n-sjis
    • mysql-test/mtr pkg_utl_i18n-ujis
    • mysql-test/mtr pkg_utl_i18n-non_xliterate
  • MDEV-19635:
    • mysql-test/mtr pkg_dbms_sql

If the changes are not amenable to automated testing, please explain why not and carefully describe how to test manually.

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@CLAassistant
Copy link

CLAassistant commented Nov 10, 2025

CLA assistant check
All committers have signed the CLA.

@svoj svoj added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Nov 10, 2025
@talili-rsec talili-rsec force-pushed the talili-tickets branch 2 times, most recently from 24e850b to 09d4bac Compare November 18, 2025 06:52
  - MDEV-34327: System package SYS.DBMS_RANDOM

Added the following procedures:
- INITIALIZE - Initialize the seed
- TERMINATE - Terminate the package

Added the following functions:
- VALUE - Get a random number greater than or equal to 0 and less than 1,
with 38 digits to the right of the decimal point (38-digit precision)
- RANDOM - Generate a random number

The random number generator can be seeded with a constant value by calling
the INITIALIZE procedure with the seed number.
  - MDEV-34330: System package SYS.DBMS_UTILITY

Added the following functions:
- GET_TIME - Return a measure of current time in hundredths of a second
- FORMAT_ERROR_BACKTRACE - Display the call stack at the point where an
exception was raised, even if the procedure is called from an exception
handler in an outer scope
- FORMAT_ERROR_STACK - Format the current error stack

Resulting line numbers of desired SQL statement lines in package
routines are based on the line numbers of the "SHOW CREATE" command for
the package body.

Known limitation:
Outputs similar to those of Oracle, in requesting for the strings not just
from the stack's bottom function, but also those in the middle, are not
accommodated. Output is always, as if the request is coming from the stack's
bottom function.
 - MDEV-34331: System package SYS.UTL_I18N

The package is a set of services that provides additional globalization
functionality.

The ANY_CS character set was also implemented so that the character set set by
"set names" command or the character set of the database as the character set of
the variable set with ANY_CS, especially for the transliterate function.

Added the following functions:
- TRANSLITERATE - Perform script transliteration
- RAW_TO_CHAR - Convert RAW data from a valid character set to a VARCHAR2 string
in the database character set
- STRING_TO_RAW - Convert a VARCHAR2 string to another valid character set and
returns the result as RAW data
 - MDEV-19635: System package SYS.DBMS_SQL

This patch adds support for dynamic SQL to parse any data manipulation
language (DML) or data definition language (DDL) statement using PL/SQL.

Added the following functions:
- OPEN_CURSOR - Open a new cursor
- EXECUTE - Execute a given cursor

Added the following procedures:
- PARSE - Parse the given statement in the given cursor
- CLOSE_CURSOR - Close the cursor when no longer needed for a session

As of the moment, '1', corresponding to Oracle's NATIVE DBMS_SQL constant,
as PARSE's procedure's (language_flag) 3rd argument, is the only one
accepted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

3 participants