[MDEV-16482] MariaDB Oracle mode misses Synonyms Created: 2018-06-13  Updated: 2024-01-31

Status: Open
Project: MariaDB Server
Component/s: Parser
Fix Version/s: None

Type: New Feature Priority: Major
Reporter: Oli Sennhauser Assignee: Unassigned
Resolution: Unresolved Votes: 6
Labels: Compatibility, package, pl/sql, procedure, synonym


 Description   

Oracle knows an object type called Synonyms:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7001.htm

"Use the CREATE SYNONYM statement to create a synonym, which is an alternative name for a table, view, sequence, procedure, stored function, package, materialized view, Java class schema object, user-defined object type, or another synonym.

Synonyms provide both data independence and location transparency. Synonyms permit applications to function without modification regardless of which user owns the table or view and regardless of which database holds the table or view. However, synonyms are not a substitute for privileges on database objects. Appropriate privileges must be granted to a user before the user can use the synonym."

This is still lacking in MariaDB 10.3 oracle mode. IMHO this is crucial for oracle portability because it allows to have packages (e.g. dbms_output) only once per instance instead of once per schema (see also example here (at the very end): http://www.fromdual.com/select-hello-world-fromdual-with-mariadb-pl-sql



 Comments   
Comment by Oli Sennhauser [ 2018-06-13 ]

SQL> SELECT * FROM dba_objects WHERE object_name IN ('DUAL', 'DBMS_OUTPUT');

OWNER OBJECT_NAME SUBOBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE CREATED LAST_DDL TIMESTAMP STATUS T G S NAMESPACE EDITION_NAME SHARING E O
------ ----------- -------------- ---------- -------------- ----------- -------- -------- ------------------- ------- - - - ---------- ----------- ------- - -
SYS DUAL 142 142 TABLE 21.03.16 21.03.16 2016-03-21:11:57:46 VALID N N N 1 NONE Y
PUBLIC DUAL 143 SYNONYM 21.03.16 21.03.16 2016-03-21:11:57:46 VALID N N N 1 NONE N Y
SYS DBMS_OUTPUT 999 999 PACKAGE 21.03.16 21.03.16 2016-03-21:11:57:46 VALID N N N 1 NONE Y
PUBLIC DBMS_OUTPUT 1000 SYNONYM 21.03.16 21.03.16 2016-03-21:11:57:46 VALID N N N 1 NONE N Y

SQL> desc dual
Name Null? Type
----- ----- -----------
DUMMY VARCHAR2(1)

SQL> SELECT * FROM dba_tables WHERE table_name = 'DUAL';

OWNER TABLE_NAME TABLESPACE_NAME CLUSTER_NAME IOT_NAME STATUS PCT_FREE PCT_USED INI_TRANS MAX_TRANS INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE FREELISTS FREELIST_GROUPS LOG B NUM_ROWS BLOCKS EMPTY_BLOCKS AVG_SPACE CHAIN_CNT AVG_ROW_LEN AVG_SPACE_FREELIST_BLOCKS NUM_FREELIST_BLOCKS DEGREE INSTANCES CACHE TABLE_LO SAMPLE_SIZE LAST_ANA PAR IOT_TYPE T S NES BUFFER_ FLASH_C CELL_FL ROW_MOVE GLO USE DURATION SKIP_COR MON CLUSTER_OWNER DEPENDEN COMPRESS COMPRESS_FOR DRO REA SEG RESULT_ CLU ACTIVITY_TRACKING DML_TIMESTAMP HAS CON INMEMORY INMEMORY INMEMORY_DISTRI INMEMORY_COMPRESS INMEMORY_DUPL
----- ---------- --------------- ------------ -------- -------- -------- -------- --------- --------- -------------- ----------- ----------- ----------- ------------ ---------- --------------- — - -------- ------ ------------ --------- --------- ----------- ------------------------- ------------------- ------ ---------- ----- -------- ----------- -------- — ------------ - - — ------- ------- ------- -------- — --- -------- -------- — ------------- -------- -------- ------------ — --- — ------- — ----------------- ------------- — --- -------- -------- --------------- ----------------- -------------
SYS DUAL SYSTEM VALID 10 40 1 255 32768 1048576 1 2147483645 1 1 YES N 1 1 0 0 0 2 0 0 1 1 N ENABLED 1 23.10.17 NO N N NO DEFAULT DEFAULT DEFAULT DISABLED YES NO DISABLED YES DISABLED DISABLED NO NO YES DEFAULT NO NO NO DISABLED

Comment by Alexander Barkov [ 2021-02-09 ]

We briefly discussed this task with cvicentiu. Synonyms can fit well into mysql.proc table:

MariaDB [test]> select * from mysql.proc\G
*************************** 1. row ***************************
                  db: test
                name: AddGeometryColumn
                type: SYNONYM_PROCEDURE
                body: AddGeometryColumn FOR mysql.AddGeometryColumn
...
*************************** 2. row ***************************
                  db: test
                name: proc
                type: SYNONYM_TABLE
                body: proc FOR mysql.proc
...
*************************** 3. row ***************************
                  db: test
                name: user
                type: SYNONYM_VIEW
                body: user FOR mysql.user
...

This way we get authentication and mysqldump support for synonyms almost for free (with very little changes needed).

Comment by Federico Razzoli [ 2021-04-06 ]

This would be a desirable feature even for those who don't use PL/SQL.

Comment by Roger Eisentrager [ 2021-08-16 ]

We have several potential clients asking for this, and yes, there are work arounds such as creating a veiw, but these are messy. Please, raise this up to Product Management.

Generated at Thu Feb 08 08:29:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.