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

COPY of a foreign table throws error #441

Closed
Aliya55 opened this issue Dec 10, 2020 · 6 comments
Closed

COPY of a foreign table throws error #441

Aliya55 opened this issue Dec 10, 2020 · 6 comments

Comments

@Aliya55
Copy link

Aliya55 commented Dec 10, 2020

I did import schema for one table and wanted records from a specific column(account-id)
The below query was run.
COPY(select * from where account_id = '23') To '23.csv' With CSV DELIMITER ',' HEADER;

After running for a while I observed the following errors for two different account-ids

ERROR: error fetching result: OCIStmtFetch2 failed to fetch next result row DETAIL: ORA-01555: snapshot too old: rollback segment number 1 with name "_SYSSMU1_2176836045$" too small

The csv file generated after the above error has similar number of counts when compared with oracle.

"error- ERROR: invalid byte sequence for encoding ""UTF8"": 0x00
CONTEXT: converting column ""user_id"" for foreign table scan of """", row 141007627"

The csv file generated after the above error has a huge difference in counts when compared to oracle.

ERROR: error executing query: OCIStmtExecute failed to execute remote query DETAIL: ORA-01652: unable to extend temp segment by 128 in tablespace TEMP

Though the copy for other account-ids is a success in postgres, some are failing with the errors mentioned.

Could it be because of any issue in postgres which is not letting the oracle data to copy or issue from oracle side itself?

Hope this explanation suffices to answer my question.
Thanks in advance.

@laurenz
Copy link
Owner

laurenz commented Dec 10, 2020

These are three different, unrelated problems.

The ORA-01555 and the ORA-01652 are caused by Oracle because the UNDO and the TEMP space are too small.
You will have to consult with your Oracle DBA what to do about those.

The invalid byte 0x00 is a zero byte, which is allowed in strings in Oracle, but not in PostgreSQL. If you cannot fix those on the Oracle side, you can use the strip_zeros column option, as detailed in the documentation.

@Aliya55
Copy link
Author

Aliya55 commented Dec 10, 2020

Thanks for this useful info.
I want to include the strip_zeros option in the import schema query.

IMPORT FOREIGN SCHEMA "tpn" LIMIT TO (tpn.table) FROM SERVER pst INTO tpn OPTIONS(strip_zeros 'true');

Since the byte sequence error occurs only in one column. Will this work? or I need to run create foreign table query.

@laurenz laurenz changed the title COPY OF A FOREIGN TABLE THROWS ERROR. COPY of a foreign table throws error Dec 10, 2020
@laurenz
Copy link
Owner

laurenz commented Dec 10, 2020

No, you cannot use this option with IMPORT FOREIGN SCHEMA.

Once you know which column of which table has the problem, you can run the following after IMPORT FOREIGN SCHEMA:

ALTER FOREIGN TABLE ftab ALTER col OPTIONS (ADD strip_zeros 'true');

@laurenz
Copy link
Owner

laurenz commented Jan 13, 2021

Can I close this issue?

@Aliya55
Copy link
Author

Aliya55 commented Jan 13, 2021

Yeah sure. And thanks for the help.

@laurenz laurenz closed this as completed Jan 13, 2021
Repository owner locked as resolved and limited conversation to collaborators Jan 13, 2021
@laurenz
Copy link
Owner

laurenz commented Dec 5, 2022

Just for the record, I'll mark this as a duplicate of #114.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants