You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 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.
COMMENT '\n Description\n Gets a random number greater than or equal to 0 and less than 1,\n with 38 digits to the right of the decimal point (38-digit\n precision)\n Raises\n '
37
+
;
38
+
FUNCTION random RETURN INT
39
+
SQL SECURITY INVOKER
40
+
COMMENT '\n Description\n Generates a random number\n Raises\n '
41
+
;
42
+
END
43
+
routine_name dbms_sql
44
+
routine_type PACKAGE
45
+
routine_definition AS
46
+
FUNCTION open_cursor RETURN INT
47
+
SQL SECURITY INVOKER
48
+
COMMENT '\n Description\n This function opens a new cursor.\n Raises\n '
COMMENT '\n Description\n This procedure parses the given statement in the given cursor. All statements are parsed immediately. In addition, DDL statements are run immediately when parsed.\n Raises\n '
53
+
;
54
+
FUNCTION execute (cursor_id INT) RETURN INT
55
+
SQL SECURITY INVOKER
56
+
COMMENT '\n Description\n This function executes a given cursor. This function accepts the ID number of the cursor and returns the number of rows processed.\n Raises\n '
57
+
;
58
+
PROCEDURE close_cursor (cursor_id INT)
59
+
SQL SECURITY INVOKER
60
+
COMMENT '\n Description\n When you no longer need a cursor for a session, close the cursor by calling the CLOSE_CURSOR Procedure.\n Raises\n '
61
+
;
62
+
END
63
+
routine_name dbms_utility
64
+
routine_type PACKAGE
65
+
routine_definition AS
66
+
FUNCTION format_error_backtrace RETURN VARCHAR(65532)
67
+
SQL SECURITY INVOKER
68
+
COMMENT '\n Description\n This procedure displays 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.\n Raises\n '
69
+
;
70
+
FUNCTION format_error_stack RETURN VARCHAR(65532)
71
+
SQL SECURITY INVOKER
72
+
COMMENT '\n Description\n This function formats the current error stack. It can be used in exception handlers to look at the full error stack\n Raises\n '
73
+
;
74
+
FUNCTION get_time RETURN INT
75
+
SQL SECURITY INVOKER
76
+
COMMENT '\n Description\n This function returns a measure of current time in hundredths of a second\n Raises\n '
77
+
;
78
+
END
23
79
routine_name pkg1
24
80
routine_type PACKAGE
25
81
routine_definition AS
@@ -234,6 +290,77 @@ BEGIN
234
290
RETURN 1;
235
291
END;
236
292
END
293
+
routine_name UTL_I18N
294
+
routine_type PACKAGE BODY
295
+
routine_definition AS
296
+
FUNCTION transliterate(val VARCHAR2(255) CHARACTER SET ANY_CS, name VARCHAR2(255)) RETURN VARCHAR2(255) CHARACTER SET ANY_CS
297
+
SQL SECURITY INVOKER
298
+
COMMENT '\n Description\n This function performs script transliteration.\n Parameters\n val (VARCHAR2):\n Specifies the data to be converted.\n name (VARCHAR2):\n Specifies the transliteration name string.\n Returns\n The converted string.\n '
299
+
AS
300
+
BEGIN
301
+
RETURN transliterate(val, name);
302
+
END;
303
+
FUNCTION raw_to_char(jc RAW, charset_or_collation VARCHAR(255)) RETURN VARCHAR2
304
+
SQL SECURITY INVOKER
305
+
COMMENT '\n Description\n This function converts RAW data from a valid character set to a\n VARCHAR2 string in the database character set.\n Parameters\n jc (RAW):\n Specifies the RAW data to be converted to a VARCHAR2 string\n charset_or_collation (VARCHAR):\n Specifies the character set that the RAW data was derived from.\n Returns\n the VARCHAR2 string equivalent in the database character set of\n the RAW data.\n '
306
+
IS
307
+
BEGIN
308
+
DECLARE
309
+
dst_charset VARCHAR(65532);
310
+
sourced_jc VARCHAR(65532);
311
+
targeted_sourced_jc VARCHAR(65532);
312
+
unhexed_hexed_data BLOB;
313
+
BEGIN
314
+
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME = 'character_set_results' into dst_charset;
315
+
CASE charset_or_collation
316
+
WHEN 'utf8' THEN
317
+
CASE dst_charset
318
+
WHEN 'utf8mb3' THEN
319
+
BEGIN
320
+
SET sourced_jc = CONVERT(jc USING utf8);
321
+
SET targeted_sourced_jc = CONVERT(sourced_jc USING utf8mb3);
322
+
END;
323
+
ELSE
324
+
RETURN NULL;
325
+
END CASE;
326
+
WHEN 'utf8mb3' THEN
327
+
CASE dst_charset
328
+
WHEN 'utf8mb4' THEN
329
+
BEGIN
330
+
SET sourced_jc = CONVERT(jc USING utf8mb3);
331
+
SET targeted_sourced_jc = CONVERT(sourced_jc USING utf8mb4);
332
+
END;
333
+
ELSE
334
+
RETURN NULL;
335
+
END CASE;
336
+
ELSE
337
+
RETURN NULL;
338
+
END CASE;
339
+
SET unhexed_hexed_data = UNHEX(HEX(targeted_sourced_jc));
340
+
CASE dst_charset
341
+
WHEN 'utf8mb3' THEN
342
+
RETURN CONVERT(unhexed_hexed_data USING utf8mb3);
343
+
WHEN 'utf8mb4' THEN
344
+
RETURN CONVERT(unhexed_hexed_data USING utf8mb4);
345
+
END CASE;
346
+
RETURN NULL;
347
+
END;
348
+
END;
349
+
FUNCTION string_to_raw(jc VARCHAR2, charset_or_collation VARCHAR(255)) RETURN RAW
350
+
SQL SECURITY INVOKER
351
+
COMMENT '\n Description\n This function converts a VARCHAR2 string to another valid\n character set and returns the result as RAW data.\n Parameters\n jc (VARCHAR2):\n Specifies the VARCHAR2 or NVARCHAR2 string to convert.\n charset_or_collation (VARCHAR):\n Specifies the destination character set.\n Returns\n RAW data representation of the input string in the new character set\n '
COMMENT '\n Description\n Gets a random number greater than or equal to 0 and less than 1,\n with 38 digits to the right of the decimal point (38-digit\n precision)\n Raises\n '
398
+
;
399
+
FUNCTION random RETURN INT
400
+
SQL SECURITY INVOKER
401
+
COMMENT '\n Description\n Generates a random number\n Raises\n '
402
+
;
403
+
END
404
+
routine_name dbms_sql
405
+
routine_type PACKAGE
406
+
routine_definition AS
407
+
FUNCTION open_cursor RETURN INT
408
+
SQL SECURITY INVOKER
409
+
COMMENT '\n Description\n This function opens a new cursor.\n Raises\n '
COMMENT '\n Description\n This procedure parses the given statement in the given cursor. All statements are parsed immediately. In addition, DDL statements are run immediately when parsed.\n Raises\n '
414
+
;
415
+
FUNCTION execute (cursor_id INT) RETURN INT
416
+
SQL SECURITY INVOKER
417
+
COMMENT '\n Description\n This function executes a given cursor. This function accepts the ID number of the cursor and returns the number of rows processed.\n Raises\n '
418
+
;
419
+
PROCEDURE close_cursor (cursor_id INT)
420
+
SQL SECURITY INVOKER
421
+
COMMENT '\n Description\n When you no longer need a cursor for a session, close the cursor by calling the CLOSE_CURSOR Procedure.\n Raises\n '
422
+
;
423
+
END
424
+
routine_name dbms_utility
425
+
routine_type PACKAGE
426
+
routine_definition AS
427
+
FUNCTION format_error_backtrace RETURN VARCHAR(65532)
428
+
SQL SECURITY INVOKER
429
+
COMMENT '\n Description\n This procedure displays 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.\n Raises\n '
430
+
;
431
+
FUNCTION format_error_stack RETURN VARCHAR(65532)
432
+
SQL SECURITY INVOKER
433
+
COMMENT '\n Description\n This function formats the current error stack. It can be used in exception handlers to look at the full error stack\n Raises\n '
434
+
;
435
+
FUNCTION get_time RETURN INT
436
+
SQL SECURITY INVOKER
437
+
COMMENT '\n Description\n This function returns a measure of current time in hundredths of a second\n Raises\n '
438
+
;
439
+
END
257
440
routine_name pkg1
258
441
routine_type PACKAGE
259
442
routine_definition AS
@@ -471,6 +654,77 @@ BEGIN
471
654
SET @a=10;
472
655
SET @a=f1();
473
656
END
657
+
routine_name UTL_I18N
658
+
routine_type PACKAGE BODY
659
+
routine_definition AS
660
+
FUNCTION transliterate(val VARCHAR2(255) CHARACTER SET ANY_CS, name VARCHAR2(255)) RETURN VARCHAR2(255) CHARACTER SET ANY_CS
661
+
SQL SECURITY INVOKER
662
+
COMMENT '\n Description\n This function performs script transliteration.\n Parameters\n val (VARCHAR2):\n Specifies the data to be converted.\n name (VARCHAR2):\n Specifies the transliteration name string.\n Returns\n The converted string.\n '
663
+
AS
664
+
BEGIN
665
+
RETURN transliterate(val, name);
666
+
END;
667
+
FUNCTION raw_to_char(jc RAW, charset_or_collation VARCHAR(255)) RETURN VARCHAR2
668
+
SQL SECURITY INVOKER
669
+
COMMENT '\n Description\n This function converts RAW data from a valid character set to a\n VARCHAR2 string in the database character set.\n Parameters\n jc (RAW):\n Specifies the RAW data to be converted to a VARCHAR2 string\n charset_or_collation (VARCHAR):\n Specifies the character set that the RAW data was derived from.\n Returns\n the VARCHAR2 string equivalent in the database character set of\n the RAW data.\n '
670
+
IS
671
+
BEGIN
672
+
DECLARE
673
+
dst_charset VARCHAR(65532);
674
+
sourced_jc VARCHAR(65532);
675
+
targeted_sourced_jc VARCHAR(65532);
676
+
unhexed_hexed_data BLOB;
677
+
BEGIN
678
+
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME = 'character_set_results' into dst_charset;
679
+
CASE charset_or_collation
680
+
WHEN 'utf8' THEN
681
+
CASE dst_charset
682
+
WHEN 'utf8mb3' THEN
683
+
BEGIN
684
+
SET sourced_jc = CONVERT(jc USING utf8);
685
+
SET targeted_sourced_jc = CONVERT(sourced_jc USING utf8mb3);
686
+
END;
687
+
ELSE
688
+
RETURN NULL;
689
+
END CASE;
690
+
WHEN 'utf8mb3' THEN
691
+
CASE dst_charset
692
+
WHEN 'utf8mb4' THEN
693
+
BEGIN
694
+
SET sourced_jc = CONVERT(jc USING utf8mb3);
695
+
SET targeted_sourced_jc = CONVERT(sourced_jc USING utf8mb4);
696
+
END;
697
+
ELSE
698
+
RETURN NULL;
699
+
END CASE;
700
+
ELSE
701
+
RETURN NULL;
702
+
END CASE;
703
+
SET unhexed_hexed_data = UNHEX(HEX(targeted_sourced_jc));
704
+
CASE dst_charset
705
+
WHEN 'utf8mb3' THEN
706
+
RETURN CONVERT(unhexed_hexed_data USING utf8mb3);
707
+
WHEN 'utf8mb4' THEN
708
+
RETURN CONVERT(unhexed_hexed_data USING utf8mb4);
709
+
END CASE;
710
+
RETURN NULL;
711
+
END;
712
+
END;
713
+
FUNCTION string_to_raw(jc VARCHAR2, charset_or_collation VARCHAR(255)) RETURN RAW
714
+
SQL SECURITY INVOKER
715
+
COMMENT '\n Description\n This function converts a VARCHAR2 string to another valid\n character set and returns the result as RAW data.\n Parameters\n jc (VARCHAR2):\n Specifies the VARCHAR2 or NVARCHAR2 string to convert.\n charset_or_collation (VARCHAR):\n Specifies the destination character set.\n Returns\n RAW data representation of the input string in the new character set\n '
0 commit comments