Project

General

Profile

Feature #6457

finish COPY-LOB support

Added by Eric Faulhaber about 4 years ago. Updated 6 months ago.

Status:
Closed
Priority:
High
Assignee:
Target version:
-
Start date:
Due date:
% Done:

80%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
production:
No
env_name:
topics:

Related issues

Related to Base Language - Bug #6623: validate the memptr bytes in "copy-lob from memptr to clob/longchar" statement New
Related to Base Language - Bug #4766: fix CHR and ASC WIP

History

#1 Updated by Eric Faulhaber about 4 years ago

The remaining work:

  • Encoding behavior needs better testing (at least #6623 must be fixed).
  • BOM handling for file source/target not implemented yet
  • Some remaining issues (see #4768-8)

#2 Updated by Greg Shah about 4 years ago

  • Related to Bug #6623: validate the memptr bytes in "copy-lob from memptr to clob/longchar" statement added

#3 Updated by Greg Shah almost 4 years ago

  • Assignee set to Stanislav Lomany

#4 Updated by Greg Shah almost 4 years ago

The BOM handling has a testcase already written. See testcases/copy_lob/tests/bom.p.

#5 Updated by Stanislav Lomany almost 4 years ago

The BOM handling has a testcase already written. See testcases/copy_lob/tests/bom.p.

OK, the first issue I met in bom.p surprisingly was that the following sequence leads to invalid output file content in 4GL because it runs some conversion due to convert option. FWD doesn't do it and the output file is fine UTF-8.

inputLongchar = ?.
fix-codepage(inputLongchar) = 'UTF-8'.
inputLongchar = "A" + CHR(14844588, "UTF-8", "UTF-8") + "A".
copy-lob from inputLongchar to file 'copy_lob/output/out.tmp' convert target codepage 'UTF-8' no-error.

#6 Updated by Stanislav Lomany almost 4 years ago

  • Status changed from New to WIP

Guys, I don't quite understand how 4GL produces output. Consider the following UTF-16 output example:

inputLongchar = ?.
fix-codepage(inputLongchar) = 'utf-8'.
inputLongchar = "A" + CHR(14844588, "UTF-8", "UTF-8") + "A".
copy-lob from inputLongchar to file 'copy_lob/output/out16.tmp' convert target codepage 'UTF-16' no-error.

4GL produces this for A€A:

ff fe 41 00 e2 00 82 00 ac 00 41 00   
BOM   A     Euro????          A  

While normal UTF-16 output is

ff fe 41 00 ac 20 41 00   
BOM   A     Euro  A

Do you have any idea what and how 4GL produces?

#7 Updated by Constantin Asofiei almost 4 years ago

Stanislav, looking at the 14844588 value, in hex is e282ac. See this: https://community.progress.com/s/article/P181822 Please experiment with -cpstream and see what happens. More, in the docs https://documentation.progress.com/output/ua/OpenEdge_latest/pdsoe/PLUGINS_ROOT/com.openedge.pdt.langref.help/rfi1424920632352.html it states:

If either the source or the target object is a file, the target's code page defaults to -cpstream.

On a side note, test abends in OE on Windows if the target path does not exist on disk.

#8 Updated by Ovidiu Maxiniuc almost 4 years ago

Stanislav Lomany wrote:

Do you have any idea what and how 4GL produces?

Try launching the 4GL using -cpinternal utf8 command-line parameter. This may shed some light on how it works. In my opinion, it assigns the representation in UTF-8 to longchar variable using some UTF to default CP conversion which breaks the content, ignoring the previous fix-codepage statement.

#9 Updated by Stanislav Lomany almost 4 years ago

Guys, I've been trying to experiment with -cpstream and -cpinternal parameters and found that when it comes to setting them to UTF-16/UTF-32 I can set -cpstream to to UTF-16 and that's it. For other cases it produces "Case table for code page UTF-16 and case name BASIC was not found in convmap.cp (1038)" error message or silenlty abends.
Do you have any idea how to fix it?

#10 Updated by Ovidiu Maxiniuc almost 4 years ago

I know, I had the same problems :(.
Try setting the same value for all these cp parameters, unless having them different is your goal.

#11 Updated by Stanislav Lomany almost 4 years ago

Try setting the same value for all these cp parameters

Errors are the same for this case too.

#12 Updated by Stanislav Lomany almost 4 years ago

I cannot change -cpstream/-cpinternal parameters on a customer's VM either, so I cannot experiment with it.
Moreover, testcases/copy_lob/tests/bom.p fails on this VM because output produced for UTF-8 is different (using default -cpstream/-cpinternal).

Greg, what should we do about these parameters if we cannot be sure how they work?

#13 Updated by Greg Shah almost 4 years ago

I cannot change -cpstream/-cpinternal parameters on a customer's VM either, so I cannot experiment with it.

Is the testing issue caused by the virtual machine not having the needed codepages installed? Otherwise I don't understand why OE would not honor these command line specifications.

#14 Updated by Stanislav Lomany almost 4 years ago

Is the testing issue caused by the virtual machine not having the needed codepages installed?

Some cases claim that "case table" for this particular case is missing in convmap.cp (quick googling didn't tell me how to add something to it). Some cases abend. And some lead to artefacts in screen output.

#15 Updated by Greg Shah almost 4 years ago

Please provide the list of codepages/scenarios which need testing (and which you cannot test).

Marian: I think we need your team to do this testing.

#16 Updated by Marian Edu almost 4 years ago

Greg Shah wrote:

Please provide the list of codepages/scenarios which need testing (and which you cannot test).

Marian: I think we need your team to do this testing.

Not sure what need to be tested here, the codepage/collation support might be different from a version to another and some customisation can be done but we've made some procedures that list:
  • the supported codepages/collation combinations: i18n/4gl/cp_collation.xml
  • the accepted conversion between codepages for codepage-convert: i18n/4gl/cp_conversion.xml
  • the accepted conversion between codepages for chr: i18n/4gl/chr_conversion.xml
  • the accepted conversion between codepages for input stream: i18n/4gl/is_conversion.xml

#17 Updated by Stanislav Lomany almost 4 years ago

i18n/4gl/cp_collation.xml i18n/4gl/cp_conversion.xml i18n/4gl/chr_conversion.xml i18n/4gl/is_conversion.xml

Marian, these are theoretically allowed conversions. The problem is that I cannot set -cpstream/-cpinternal parameters to test how they work. I either get an error that "case table" for this particular case is missing in convmap.cp or it just abends.
Do you think you'll be able to set -cpstream/-cpinternal with a working result? If so, I'll make a testcase to be tested with all -cpstream/-cpinternal combinations.

#18 Updated by Marian Edu almost 4 years ago

Stanislav Lomany wrote:

i18n/4gl/cp_collation.xml i18n/4gl/cp_conversion.xml i18n/4gl/chr_conversion.xml i18n/4gl/is_conversion.xml

Marian, these are theoretically allowed conversions. The problem is that I cannot set -cpstream/-cpinternal parameters to test how they work. I either get an error that "case table" for this particular case is missing in convmap.cp or it just abends.

What are the values you're trying to use for the codepages/collation tables - for cpstream and cpinternal?

Do you think you'll be able to set -cpstream/-cpinternal with a working result? If so, I'll make a testcase to be tested with all -cpstream/-cpinternal combinations.

Yes, the idea is that if the combination is valid then there shouldn't be any error although is quite rare to have different codepages exactly because of the conversion overhead - the client uses the codepage appropriate for the user, the server often use the same codepage as client or at times some UTF if the database needs to support various codepages.

#19 Updated by Stanislav Lomany almost 4 years ago

What are the values you're trying to use for the codepages/collation tables - for cpstream and cpinternal?

I want to test this ones:
UTF-8
UTF-16
UTF-16LE
UTF-16BE
UTF-32
UTF-32LE
UTF-32BE

#20 Updated by Constantin Asofiei about 1 year ago

  • Priority changed from Normal to High
  • Assignee changed from Stanislav Lomany to Eduard Soltan

Stanislav: please summarize any work done for this task

Eduard: please look into the xfer testcase, run them in FWD and see what happens.

#21 Updated by Stanislav Lomany about 1 year ago

Stanislav: please summarize any work done for this task

I didn't produce any testcases and used the existing ones listed here. The problems I encountered are mentioned here - I didn't manage to find answers.

#22 Updated by Eduard Soltan about 1 year ago

Greg Shah wrote:

The BOM handling has a testcase already written. See testcases/copy_lob/tests/bom.p.

Greg/Stanislav, I don't see any testcases/copy_lob/tests/bom.p testcases in testcases/copy_lob. There are 6 tests classes in testcases/copy_lob/memptr. Is this task referring to the uast testacases project?

Edit:

Never mind, found the tests cases in testcases/tests/copy_lob

#23 Updated by Eduard Soltan about 1 year ago

Got the following after running testcases/tests/copy_lob/

Test run finished after 9879 ms
[       113 containers found      ]
[         0 containers skipped    ]
[       113 containers started    ]
[         0 containers aborted    ]
[       113 containers successful ]
[         0 containers failed     ]
[       736 tests found           ]
[         0 tests skipped         ]
[       736 tests started         ]
[         0 tests aborted         ]
[       209 tests successful      ]
[       527 tests failed          ]

#24 Updated by Eduard Soltan about 1 year ago

After creating the following path in deploy/client/tests/copy_lob/support/data, I get the following results:

Test run finished after 6680 ms
[       113 containers found      ]
[         0 containers skipped    ]
[       113 containers started    ]
[         0 containers aborted    ]
[       113 containers successful ]
[         0 containers failed     ]
[       736 tests found           ]
[         0 tests skipped         ]
[       736 tests started         ]
[         0 tests aborted         ]
[       390 tests successful      ]
[       346 tests failed          ]

#25 Updated by Greg Shah about 1 year ago

As you work through issues in these tests, please update LOB Tests with details of the test status and how to run them in FWD.

#26 Updated by Eduard Soltan about 1 year ago

After solving all configuration issues, I was left only with assertion errors which should be investigated.

Test run finished after 17719 ms
[       113 containers found      ]
[         0 containers skipped    ]
[       113 containers started    ]
[         0 containers aborted    ]
[       113 containers successful ]
[         0 containers failed     ]
[       736 tests found           ]
[         0 tests skipped         ]
[       736 tests started         ]
[         0 tests aborted         ]
[       523 tests successful      ]
[       213 tests failed          ]

However there is still a configuration issue which I don't know how to solve with the following class TestFileInvalidSrc, TestFileInvalidSrcDB, TestFileInvalidTrg and TestFileInvalidTrgDB, there are hard coded Windows paths in 4gl code.

Also update the LOB Tests wiki.

#27 Updated by Greg Shah about 1 year ago

From the wiki:

All files from tests/copy_lob/support/data should be moved to deploy/client/tests/copy_lob/support/data.

Even with this idea, we should still change any Windows style pathnames to use relative paths and / as the path separator. / works on Windows and Linux so it is more portable. Please change the 4GL code as needed and check it in.

#28 Updated by Eduard Soltan about 1 year ago

Greg Shah wrote:

From the wiki:

All files from tests/copy_lob/support/data should be moved to deploy/client/tests/copy_lob/support/data.

Even with this idea, we should still change any Windows style pathnames to use relative paths and / as the path separator. / works on Windows and Linux so it is more portable. Please change the 4GL code as needed and check it in.

Looking at the tests more closely, I think there is an actual intend in adding an invalid path.

copy-lob from file 'E:/temp/invalid_file.txt' to oHandle::logo no-error. this operation should raise, 2 errors: Cannot find or open file E:/temp/invalid_file.txt, errno = 2. (43), Copy-lob failed to copy file 'E:/temp/invalid_file.txt' to large object.

But assertion fails because this only one error thrown. So this is a actual problem with fwd that should be investigated.

#29 Updated by Eduard Soltan about 1 year ago

First major problem found, it is common for around 100 tests.

copy-lob from emptyMemptr to customer.logo no-error.

When trying to write to a buffer field, the following error will be raised com.goldencode.p2j.util.ErrorConditionException: Update of buffer field object requires a transaction. (7369)

#30 Updated by Eduard Soltan 12 months ago

  • % Done changed from 0 to 50

Committed on 6457a, rev. 16066.

- Emit Transaction.FULL parameter when target of copy-lob operation is a persistent buffer.

- different error handling logic.

With this changes manage to drop number of failing tests to 72.

[       736 tests started         ]
[         0 tests aborted         ]
[       664 tests successful      ]
[        72 tests failed          ]

#31 Updated by Constantin Asofiei 12 months ago

Eduard Soltan wrote:

Committed on 6457a, rev. 16066.

- Emit Transaction.FULL parameter when target of copy-lob operation is a persistent buffer.

Can't this be done by runtime when the target is a persistent buffer?

#32 Updated by Eduard Soltan 12 months ago

Constantin Asofiei wrote:

Eduard Soltan wrote:

Committed on 6457a, rev. 16066.

- Emit Transaction.FULL parameter when target of copy-lob operation is a persistent buffer.

Can't this be done by runtime when the target is a persistent buffer?

I will look into it. I observed how transaction is handled in buffer-copy or other similar operation, and in all the transaction is open at block level.

#33 Updated by Constantin Asofiei 12 months ago

Eduard Soltan wrote:

I will look into it. I observed how transaction is handled in buffer-copy or other similar operation, and in all the transaction is open at block level.

Ah, you mean at the surrounding block, and not at COPY-LOB. That makes sense.

#34 Updated by Eduard Soltan 12 months ago

  • % Done changed from 50 to 80

Committed on 6457a, rev. 16069.

- Added NO-CONVERT conversion support + plus error handling. From the docs:

The NO-CONVERT option specifies that no conversions occur. However, if the target is a LONGCHAR or a CLOB, the AVM validates the character data based on the target object's code page. For a CLOB, this is the code page of the CLOB.

Looking at the code this validation is already implemented in fwd.

- handled edge case for empty data source and target longchar with a overlay, StringHelper.rightAlignText("", rightFill)) was not working properly.

- handled edge cases with target as a file, and empty source data. In append mode the file is not created, when not append mode file is always created.

- diverse error handling logic, multiple error handling logic depending of the copy-lob parameters.

With the latest revision of 6457a, manage to drop the number of failing tests down to 12.

[       736 tests started         ]
[         0 tests aborted         ]
[       724 tests successful      ]
[        12 tests failed          ]

Remaining problems

The problem that is still remaining is the same problem that Stanislav had:

inputLongchar = ?.
fix-codepage(inputLongchar) = 'UTF-8'.
inputLongchar = "A" + CHR(14844588, "UTF-8", "UTF-8") + "A".
copy-lob from inputLongchar to file 'copy_lob/output/out.tmp' convert target codepage 'UTF-8' no-error.

More specifically with how 4gl will output the following character CHR(14844588, "UTF-8", "UTF-8")

In UTF-8: Java on 3 BYTES, in 4GL on 6 BYTES
In UTF-16: Java on 4 BYTES, in 4GL on 8 BYTES

Another problem

assign
  iErrNums[1] = 12008
  iErrNums[2] = 11275
  iErrNums[3] = 11300
  cErrMsgs[1] = "Invalid character code found in data for codepage ISO8859-1 (12008)" 
  cErrMsgs[2] = "Failed to create/update blob from file 'tests/copy_lob/support/data/binary_16.data'. (11275)" 
  cErrMsgs[3] = "Copy-lob failed to copy file 'tests/copy_lob/support/data/binary_16.data' to large object. (11300)".

copy-lob from file 'tests/copy_lob/support/data/binary_16.data' for 32 to ttStatic.fieldClob no-error.

binary_16.data contains only 16 BYTES, and normally this should throw the following error Source file does not contain sufficient data starting at 1 to copy 32 bytes (14500) because the source is smaller then the specified length.

However if in those 16 BYTES there is an invalid character to be copied in target lob, the following error is raised Invalid character code found in data for codepage. This give me the impression the 4GL starts reading the data, and only then it validates the source length and offset.

This is a problem because in fwd the it firsts stars with validation of source lob (offset, length) and only then proceeds with data validation.

#35 Updated by Eduard Soltan 12 months ago

I am not really sure how the conversion happens in UTF-8 character to ISO-8859-1 in 4GL.

Test 1

-Cpinternal iso8859-1, Cpstream iso8859-1

define variable inputLongchar1   as longchar no-undo.
inputLongchar1 = "CHR(14844588, "UTF-8", "UTF-8").

copy-lob from inputLongchar1 to file 'out.data' no-error.

The output in 'out.data' is size 3 bytes E2 | 82 | AC

Test 2

-Cpinternal iso8859-1, Cpstream iso8859-1

define variable inputLongchar1   as longchar no-undo.
inputLongchar1 = "CHR(14844588, "UTF-8", "UTF-8").

copy-lob from inputLongchar1 to file 'out.data' convert target codepage 'utf-8' no-error.

The output in 'out.data' is size 6 bytes C3 | A2 | C2 | 82 | C2 | AC

Test 3

-Cpinternal iso8859-1, Cpstream utf-8

define variable inputLongchar1   as longchar no-undo.
inputLongchar1 = "CHR(14844588, "UTF-8", "UTF-8").

copy-lob from inputLongchar1 to file 'out.data' no-error.

The output in 'out.data' is size 6 bytes C3 | A2 | C2 | 82 | C2 | AC

Test 4

-Cpinternal iso8859-1, Cpstream utf-8

define variable inputLongchar1   as longchar no-undo.
inputLongchar1 = "CHR(14844588, "UTF-8", "UTF-8").

copy-lob from inputLongchar1 to file 'out.data' convert target codepage 'utf-8' no-error.

The output in 'out.data' is size 6 bytes E2 | 82 | AC

#36 Updated by Eduard Soltan 12 months ago

  • Related to Bug #4766: fix CHR and ASC added

#37 Updated by Constantin Asofiei 12 months ago

  • Status changed from WIP to Review

I'll review the first pass and we'll work on the codepage problems in a second branch.

#38 Updated by Constantin Asofiei 12 months ago

  • reviewer Constantin Asofiei added

#39 Updated by Constantin Asofiei 12 months ago

  • Status changed from Review to WIP
Review for 6457a rev 16070:
  • missing history entry or copyright year update: block_properties.rules, copy_lob.rules, LargeObject.java, LobCopy.java, LobCopyInput.java, LobCopyOutput.java, SourceLobFile.java,
  • block_properties.rules -
          <rule>(type == prog.field_blob or type == prog.field_clob) and 
                ancestor(prog.kw_to, -1) and
                ancestor(prog.kw_cpy_lob, -1)
                <action>level = prog.transaction</action>
          </rule>
    
    • please be more specific with the parent rule for kw_cpy_lob - I assume the blob/clob field must be only on target, and not on source, also
    • you need also to call <action>reasons = execLib("reasons_set_implicit_get_exclusive_read", reasons)</action> and update reasons_set_implicit_get_exclusive_read for this case
  • Stream.java - why the reason for the commented code?
  • TargetLobFile.java method write(byte[]) and others - why call clearPending() twice?
  • longchar.java
    • missing javadoc for codePage in write method
    • why "" + StringHelper. ?

#40 Updated by Eduard Soltan 12 months ago

Constantin Asofiei wrote:

Review for 6457a rev 16070:

  • Stream.java - why the reason for the commented code?
define variable auxMemptr         as memptr  no-undo.
set-size (auxMemptr) = 5.
put-string(auxMemptr, 1) = "test".

copy-lob from auxMemptr to file 'out.tmp' no-error.

In fwd the copy-lob executes correctly, writing 5 bytes in the target file and the last one is null. And because of the nullQuirk, read from the file does not happen correctly. I will try to look the original testcase, why it was added.

  • longchar.java
    • why "" + StringHelper. ?

Because if value was null, after this operation we would get something very weird in longchar value (ex: null ).

#41 Updated by Constantin Asofiei 12 months ago

Eduard Soltan wrote:

  • longchar.java
    • why "" + StringHelper. ?

Because if value was null, after this operation we would get something very weird in longchar value (ex: null ).

rightAlignText can not return null. So "" + is no-op.

#42 Updated by Eduard Soltan 11 months ago

  • Status changed from WIP to Review

Constantin Asofiei wrote:

Because if value was null, after this operation we would get something very weird in longchar value (ex: null ).

rightAlignText can not return null. So "" + is no-op.

Yes, you are right the rightAlignText could not return NULL. But what I was reffering is the that the value property from longchar class could be null.

Because of this assign(value + StringHelper.rightAlignText("", rightFill)); could result with some wired results.

For example:

if value is null and rightFill = 10, we would assign to longchar a value like null (null and 10 spaces after that.).

Stream.java - why the reason for the commented code?

There are some tests in which follows the small scenario from #6457-40, and judging by the test logic they should finish successfully. However the mentioned scenario work in OE ans FWD in the same way. So I set up the copy-lob testcases in OE, and those tests indeed fail in OE. So these change is unnecessary.

Committed on 6457a, rev. 16071.

#43 Updated by Constantin Asofiei 11 months ago

Review of 6457a rev 16071:
  • block_properties.rules has the XML prolog removed.
  • LobCopy - no history entry
  • longchar.write - what if the existing longchar instance already has the codepage set - does this get changed?

Please fix the above, rebase and start conversion and runtime testing.

#44 Updated by Eduard Soltan 11 months ago

Constantin Asofiei wrote:

  • longchar.write - what if the existing longchar instance already has the codepage set - does this get changed?

No, it doesn't. If I already have a code page on the target longchar, and a different code page in convert target codepage 'ISO8859-1'. phrase I should get an error. target codepage conflicts with the longchars's fixed code page

#45 Updated by Constantin Asofiei 10 months ago

Eduard, please address the review and - is there anything else for this task?

#46 Updated by Eduard Soltan 9 months ago

Constantin Asofiei wrote:

Eduard, please address the review and - is there anything else for this task?

I addressed the review and tested conversion and runtime on Chui regression test project and on a large GUI application. I think another gui application should be tested.

Otherwise there are 7 tests that require some code-page changes.

#47 Updated by Constantin Asofiei 9 months ago

Eduard Soltan wrote:

Otherwise there are 7 tests that require some code-page changes.

You mean there is still work for standalone unit tests for this task?

#48 Updated by Eduard Soltan 9 months ago

Constantin Asofiei wrote:

Eduard Soltan wrote:
You mean there is still work for standalone unit tests for this task?

Not on this task, the root case of the remaining tests failures is the same as #4766.

#49 Updated by Radu Apetrii 9 months ago

Another customer application converts and runs successfully with 6457a. ✅

#50 Updated by Eduard Soltan 9 months ago

conversion and runtime on Chui regression passed ✅
large GUI application conversion and unit tests and smoke tests passed ✅

Is any other tests necessary?

#51 Updated by Constantin Asofiei 6 months ago

  • Status changed from Review to Internal Test

#52 Updated by Eduard Soltan 6 months ago

6457a was rebased to trunk rev. 16358.

#54 Updated by Constantin Asofiei 6 months ago

6457a rev 16365 fixes a XML header problem.

#55 Updated by Constantin Asofiei 6 months ago

  • Status changed from Internal Test to Merge Pending

Merge to trunk after 10716a

#56 Updated by Eduard Soltan 6 months ago

  • Status changed from Merge Pending to Test

Constantin Asofiei wrote:

Merge to trunk after 10716a

6457a was merged into trunk rev. 16383 and archived.

#57 Updated by Constantin Asofiei 6 months ago

  • Status changed from Test to Closed

Also available in: Atom PDF