darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
1.01k stars 342 forks source link

Data export uses the table name of a table in Oracle's recycle bin and fails to export #1561

Closed axelsean closed 1 year ago

axelsean commented 1 year ago

This is the error (with debug turned on):

` [2022-12-06 23:44:57] Extracted records from table ASSET_VW_CHANGES: total_records = 0 (avg: 0 recs/sec)

[2022-12-06 23:44:57] Renaming temporary file /data/tmp_ASSET_VW_CHANGES_output.sql into /data/ASSET_VW_CHANGES_output.sql

[2022-12-06 23:44:57] Exporting data of table BIN$7qb+/AFdB8PgU5IkCArTiw==$0...

[2022-12-06 23:44:57] Applying DELETE global clause: 1=1

[2022-12-06 23:44:57] Dumping data from BIN$7qb+/AFdB8PgU5IkCArTiw==$0 to file: tmp_BIN$7qb+/AFdB8PgU5IkCArTiw==$0_output.sql

[2022-12-06 23:44:57] FATAL: Can't open /data/tmp_BIN$7qb+/AFdB8PgU5IkCArTiw==$0_output.sql: No such file or directory Aborting export... `

When getting the list of tables we see this - earlier in the output file.

` [2022-12-06 23:44:46] [27] Scanning table ASSET_TYPE_PM_TRIGGER (0 rows)...

[2022-12-06 23:44:46] [28] Scanning table ASSET_VW_CHANGES (0 rows)...

[2022-12-06 23:44:46] [29] Scanning table BING_MAP_KEYS (4 rows)...

[2022-12-06 23:44:46] [30] Scanning table BMS_INSPECTION_TEAM (0 rows)... `

However

When we looked in ALL_TAB_COLUMNS in the datatabase we saw some columns that had a TABLE_NAME of BIN$7qb+/AFdB8PgU5IkCArTiw==$0. These were from a table that was in the Oracle Recycle bin

axelsean commented 1 year ago

Workaround for this is to empty the Oracle recycle bin

PURGE RECYCLEBIN;

axelsean commented 1 year ago

Note for self -

Oracle.pm _column_info - get's table_name from $self->{prefix}_TAB_COLUMNS, which looks to be the root cause here, possible needs to join to $self->{prefix}_TABLES (not sure about mviews)

From log, the regular expression was * [2022-12-06 23:44:37] DEBUG, SELECT A.COLUMN_NAME, A.DATA_TYPE, A.DATA_LENGTH, A.NULLABLE, A.DATA_DEFAULT, A.DATA_PRECISION, A.DATA_SCALE, A.CHAR_LENGTH, A.TABLE_NAME, A.OWNER FROM ALL_TAB_COLUMNS A WHERE 1=1 AND A.OWNER='PMS_CA' AND (REGEXP_LIKE(UPPER(A.TABLE_NAME), ?)) ORDER BY A.COLUMN_ID

darold commented 1 year ago

Commit 5ef97e9 fixes this issue.