Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: sync ddl's for objects in the allowlist (#6359)

Danny Xuca95f41963a3
diff --git a/backend/plugin/db/oracle/dump.go b/backend/plugin/db/oracle/dump.go
index 1d115693ba..94d4a53cfe 100644
--- a/backend/plugin/db/oracle/dump.go
+++ b/backend/plugin/db/oracle/dump.go
@@ -42,53 +42,17 @@ func (driver *Driver) Dump(ctx context.Context, out io.Writer, _ bool) (string,
}
func dumpTxn(ctx context.Context, txn *sql.Tx, schemas []string, out io.Writer) error {
- // https://stackoverflow.com/questions/10886450/how-to-generate-entire-ddl-of-an-oracle-schema-scriptable
+ // Exclude nested tables, their DDL is part of their parent table.
+ // Exclude overflow segments, their DDL is part of their parent table.
query := fmt.Sprintf(`
-select dbms_metadata.get_ddl(object_type, object_name, owner)
-from
-(
- --Convert DBA_OBJECTS.OBJECT_TYPE to DBMS_METADATA object type:
- select
- owner,
- --Java object names may need to be converted with DBMS_JAVA.LONGNAME.
- --That code is not included since many database don't have Java installed.
- object_name,
- decode(object_type,
- 'DATABASE LINK', 'DB_LINK',
- 'JOB', 'PROCOBJ',
- 'RULE SET', 'PROCOBJ',
- 'RULE', 'PROCOBJ',
- 'EVALUATION CONTEXT', 'PROCOBJ',
- 'CREDENTIAL', 'PROCOBJ',
- 'CHAIN', 'PROCOBJ',
- 'PROGRAM', 'PROCOBJ',
- 'PACKAGE', 'PACKAGE_SPEC',
- 'PACKAGE BODY', 'PACKAGE_BODY',
- 'TYPE', 'TYPE_SPEC',
- 'TYPE BODY', 'TYPE_BODY',
- 'MATERIALIZED VIEW', 'MATERIALIZED_VIEW',
- 'QUEUE', 'AQ_QUEUE',
- 'JAVA CLASS', 'JAVA_CLASS',
- 'JAVA TYPE', 'JAVA_TYPE',
- 'JAVA SOURCE', 'JAVA_SOURCE',
- 'JAVA RESOURCE', 'JAVA_RESOURCE',
- 'XML SCHEMA', 'XMLSCHEMA',
- object_type
- ) object_type
- from dba_objects
- where owner in (%s)
- --These objects are included with other object types.
- and object_type not in ('INDEX PARTITION','INDEX SUBPARTITION',
- 'LOB','LOB PARTITION','TABLE PARTITION','TABLE SUBPARTITION')
- --Ignore system-generated types that support collection processing.
- and not (object_type = 'TYPE' and object_name like 'SYS_PLSQL_%%')
- --Exclude nested tables, their DDL is part of their parent table.
- and (owner, object_name) not in (select owner, table_name from dba_nested_tables)
- --Exclude overflow segments, their DDL is part of their parent table.
- and (owner, object_name) not in (select owner, table_name from dba_tables where iot_type = 'IOT_OVERFLOW')
-)
-order by owner, object_type, object_name
- `, strings.Join(schemas, ","))
+ SELECT
+ DBMS_METADATA.GET_DDL(u.OBJECT_TYPE, u.OBJECT_NAME, u.OWNER)
+ FROM DBA_OBJECTS u
+ WHERE OWNER IN (%s)
+ AND u.OBJECT_TYPE IN ('TABLE','INDEX','SEQUENCE','DIRECTORY','VIEW','FUNCTION','PROCEDURE','TABLE PARTITION','INDEX PARTITION','TRIGGER','SCHEDULE','JOB','QUEUE','WINDOW')
+ AND (owner, object_name) not in (select owner, table_name from dba_nested_tables)
+ AND (owner, object_name) not in (select owner, table_name from dba_tables where iot_type = 'IOT_OVERFLOW')`,
+ strings.Join(schemas, ","))
rows, err := txn.QueryContext(ctx, query)
if err != nil {
@@ -116,7 +80,6 @@ order by owner, object_type, object_name
return err
}
}
-
return err
}