Feature #12195
migrating a single-byte OpenEdge database to a UTF-8 converted database
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:
0%
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:
History
#1 Updated by Greg Shah 7 days ago
Problem¶
A project whose OpenEdge database is single-byte (for example ISO8859-1) may choose to create the converted PostgreSQL database with UTF-8 encoding. The basic path exists: the import reads each .d file in the codepage of its cpstream footer (or the configured default) and writes Java strings, so the character data arrives in a UTF-8 database correctly converted.
What is missing is the handling of large objects and mixed content, and a defined, tested procedure:
- CLOB columns may already declare their own codepage. A
CLOBfield declaredCLOB-CODEPAGE "UTF-8"holds UTF-8 bytes even in a single-byte database, and must not be converted again. OtherCLOBfields inherit the database codepage. - Content can be in the wrong encoding for its declaration. Applications commonly store text received from outside (XML, JSON, email bodies) in a
CLOBdeclared with the database codepage, but containing UTF-8 bytes. Converting that content from the declared codepage corrupts it ("é" for "é"). - BLOBs must never be transcoded.
- Values that depend on the session codepage. Data that was encrypted or hashed after a conversion that used
CPINTERNAL(for exampleENCRYPTof aCHARACTERvalue converted to aMEMPTR) decrypts to different bytes whenCPINTERNALchanges. Such values need to be decrypted with the old codepage and encrypted again with the new one during migration; which fields hold them is known only to the application.
Work¶
- Document and test the procedure for importing a single-byte database into a UTF-8 PostgreSQL database: database creation and locale,
cpstreamhandling for.dfiles without a footer, the import settings, and checks afterwards. - Large objects: read each
CLOBfile in the codepage its field declares (CLOB-CODEPAGE, otherwise the database codepage), and copyBLOBfiles byte for byte. Verify this in the import and fix where it does not hold. - Mixed content detection: add an import option that checks
CLOB(and optionallyCHARACTER) values declared in a single-byte codepage for byte sequences that are valid, non-ASCII UTF-8. Values that are UTF-8 are stored as decoded UTF-8 instead of being converted again. Write a report listing table, field, record key and the decision taken, so the project can review it. Make the check configurable per table and field (on, off, or report only). - Provide a hook in the import, or a documented post-import step, for a project to re-encrypt or re-hash values that depend on the session codepage, given the old and new codepages.
- Collation: the converted database and temp-tables need a collation that is compatible with the original for sorting and comparison, which is #6441. Sessions that run with
CPINTERNALUTF-8 are #6431. This task depends on both and does not repeat them. - Write up the expected behaviour differences when moving from a single-byte codepage to UTF-8 (sort order, comparisons,
LENGTHin bytes versus characters, fixed-width export formats), so a project can review its code.
Testcases¶
- Import of a single-byte test database with accented characters in
CHARACTERfields,CLOBfields with no codepage,CLOBfields declared UTF-8, andBLOBfields, into a UTF-8 database; verify every value against the OpenEdge source. - A
CLOBdeclared in the single-byte codepage that holds UTF-8 text: with the detection option on, off and in report mode. .dfiles with and without thecpstreamfooter.- A value encrypted with
ENCRYPTafter aCPINTERNAL-dependent conversion, re-encrypted through the hook, decrypted correctly in a UTF-8 session.