Skip to content

Conversation

@sumanmichael
Copy link

Found an issue where some of the special output files weren't being created in the right directories when using OUTPUT_DIR or when the main output file had a path.

The problem was that files like INDEXES_* , AUTOINCREMENT_* , LOGICAL_*, etc. were using simple string concatenation instead of proper path handling. This would cause errors like:

ora2pg -c /etc/ora2pg/ora2pg.conf.dist -t TABLE --input /tmp/input.sql --out /tmp/output.sql --no_header -O DEFAULT_NUMERIC=numeric -O EXPORT_SCHEMA=1

FATAL: Can't open AUTOINCREMENT_/tmp/output.sql: No such file or directory

When processing tables with identity columns like:

CREATE TABLE test_schema.sample_table (
    id NUMBER GENERATED BY DEFAULT AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOKEEP NOSCALE,
    name VARCHAR2(100) COLLATE USING_NLS_COMP,
    created_date DATE
) DEFAULT COLLATION USING_NLS_COMP;

The issue was simple string concatenation creating invalid paths like AUTOINCREMENT_/tmp/output.sql instead of /tmp/AUTOINCREMENT_output.sql.

Fixed it by fileparse() to split the path properly and File::Spec->catfile() to put it back together correctly.

This affects these files:

  • TBSP_INDEXES_*
  • PARTITION_INDEXES_*
  • AUTOINCREMENT_*
  • LOGICAL_*
  • INDEXES_*
  • FTS_INDEXES_*

Should be backward compatible since it's just fixing the path construction, not changing what gets generated. Tested with different output directory scenarios and it works as expected now.

- Use proper file path construction with fileparse() and File::Spec->catfile()
  for all INDEXES_, AUTOINCREMENT_, and LOGICAL_ output files
- Ensures correct directory handling when OUTPUT_DIR is specified
- Fixes potential issues with file creation in different directory structures
- Affects TBSP_INDEXES_, PARTITION_INDEXES_, AUTOINCREMENT_, LOGICAL_,
  INDEXES_, and FTS_INDEXES_ file generation
- Improves consistency with existing file handling patterns in the codebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant