Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean improvements for Oracle (2nd try) #1573

Merged
merged 12 commits into from Mar 30, 2017
Merged

Conversation

@voidunit
Copy link
Contributor

@voidunit voidunit commented Mar 26, 2017

This PR is to address some flaws mentioned in issue #1550. It partially supersedes canceled PR #1572. Some changes are stroke out.

The main goals of this PR are:

  • to simplify OracleSchema.doClean() method: make it easily extensible with more object types;
  • to provide support for proper cleaning of non-default schemas;
  • to improve cleaning performance;
  • to fix some faulty places in the code.

The full change is split into a chain of non-breaking smaller commits, so they could be reviewed easier.

The list of changes done:

  • optimization:

    1. checks with count(*) > 0 replaced with exists();
    2. the number of data dictionary scans reduced;
    3. method for retrieving the list of tables in a proper drop order improved significantly;
  • refactoring:

    1. checkers for available database options and user privileges moved from OracleSchema to OracleDbSupport;
    2. logic of finding and dropping of objects of certain types encapsulated into corresponding OracleSchemaObjectType enum values;
  • other fixes:

    1. some edits in methods for FBA tracked tables and Spatial (Locator) metadata;
    2. proper clean for scheduler jobs, queue tables and FBA tracked tables in non-default schemas;
    3. revised order of cleaning by types;
    4. domain indexes get dropped as a separate step, so there's no need to exclude table names with NOT LIKE name filters (which is faulty);
    5. small fixes in medium tests.

These changes have been successfully tested on Oracle 10.2.0.1 XE, 10.2.0.5 EE, 11.2.0.4 EE. To be tested on 11 XE, 12 EE.

Originally I had intention to extend Clean method with more schema-owned object types:

  • PROGRAM
  • SCHEDULER GROUP
  • SCHEDULE
  • CHAIN
  • INDEXTYPE
  • OPERATOR
  • REWRITE EQUIVALENCE
  • LIBRARY
  • JAVA CLASS
  • JAVA RESOURCE
  • DIMENSION
  • CONTEXT
  • XML SCHEMA
  • RULE
  • RULE SET
  • EVALUATION CONTEXT
  • FILE GROUP
  • MINING MODEL
  • FILE WATCHER
  • DESTINATION
  • SQL TRANSLATION PROFILE
  • DATABASE LINK

and others that can be cleaned but ignored.

But now I see there's a flaw in SchemaObject's OO design, which should be fixed in a separate change. So I removed my refactoring changes from this PR (I didn't like them after a fresh morning look) and kept only those related to performance and bugs. So the goal of simplifying doClean() hasn't been achieved yet.

vosolovskiy added 12 commits Mar 19, 2017
…ount

Oracle use exists instead of count
FORCE option is not needed here and appeared only in Oracle 11.

(cherry picked from commit ae307ec)
(cherry picked from commit fe567c6)
FBA create/drop. Got rid of quotation confusion.

(cherry picked from commit 373cacf)
Where possible, changed the current schema to FLYWAY_AUX in order to ensure that create/clean scripts work correctly for non-default schemas.

(cherry picked from commit 748bdd0)
(cherry picked from commit 099efab)
Disabling of FBA can be done on another schema's objects. Edited some comments and variable/method names in order to avoid confusing with other Flashback features.

Renamed Spatial to Locator whenever occurred. Spatial is a separate paid option, while Locator is free and available even on XE and is actually meant in the code (see Oracle white paper on Spatial). Only metadata is cleaned, and domain indexes should be dropped along with other objects.

(cherry picked from commit d32fc97)
Fixed support for FBA tracked tables, queue tables, scheduler jobs in non-default schemas. Removed faulty filters on object names to exclude wrong objects - replaced with proper conditions, revised drop order and separate steps for MV logs and domain indexes.

Merge remote-tracking branch 'remotes/origin/oracle-improve-clean' into oracle-improve-clean-2
Prefetched lists of objects used in order to reduce the number of vain data dictionary scans.
@axelfontaine axelfontaine merged commit a3d9d4d into flyway:master Mar 30, 2017
axelfontaine added a commit to flyway/flywaydb.org that referenced this pull request Mar 30, 2017
@axelfontaine axelfontaine added this to the Flyway 4.2.0 milestone Mar 30, 2017
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Mar 30, 2017

Truly excellent work Victor! I really appreciated your thorough pull requests. Well thought out, clean code, polished tests, necessary docs to clarify reasoning, ... Top class!

Keep them coming!

@voidunit voidunit deleted the voidunit:oracle-improve-clean-2 branch Mar 30, 2017
dohrayme pushed a commit to dohrayme/flyway that referenced this pull request Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants