Project

General

Profile

Bug #3026

BUFFER-DELETE() method does not account for table-level delete validation

Added by Eric Faulhaber about 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:

History

#1 Updated by Eric Faulhaber about 8 years ago

Our implementation of the BUFFER-DELETE() method is incomplete. If the table containing the target record has schema-level delete validation, the BUFFER-DELETE() method must fail with the error:

Table <table name> is defined with schema delete validation and may only be deleted by the DELETE statement. (7347)

#2 Updated by Eric Faulhaber about 8 years ago

  • Assignee set to Stanislav Lomany

#3 Updated by Stanislav Lomany about 8 years ago

  • Status changed from New to WIP

Eric, could you please clear something for me?

1. How do I define a schema delete validation - is that a correct definition?

ADD TABLE "Book" 
  ...
  VALEXP "book-title <> ""Bogus Programming""" 
  VALMSG "Bogus Programming may not be deleted!!!" 
  ...

2. I can see that during conversion message text is missing - is something wrong with my configuration or is it a bug?

book.deleteRecord(new Validation0());
...
class Validation0
extends BufferValidator
{
   public logical validateExpression()
   {
      return isNotEqual(book.getBookTitle(), "Bogus Programming");
   }

   public character validateMessage()
   {
      return new character("");
   }
}

3. Is information about presence of validation is recorded somewhere (e.g. in some xml file)?

#4 Updated by Eric Faulhaber about 8 years ago

Stanislav Lomany wrote:

Eric, could you please clear something for me?

1. How do I define a schema delete validation - is that a correct definition?
[...]

Yes, your example is correct.

2. I can see that during conversion message text is missing - is something wrong with my configuration or is it a bug?
[...]

This is a bug. Please try it with the following patch:

=== modified file 'src/com/goldencode/p2j/uast/progress.g'
--- src/com/goldencode/p2j/uast/progress.g    2016-03-25 16:40:27 +0000
+++ src/com/goldencode/p2j/uast/progress.g    2016-04-29 03:09:52 +0000
@@ -1615,6 +1615,7 @@
 **                           parsing can fail (because it thinks it is seeing a widget instead
 **                           of an object instance).
 ** 316 EVK 20141212          Properly handle terminal streams when specified as a string literal.
+** 317 ECF 20160428          Fixed attachment of table-level validation message.
 */

 header
@@ -4800,7 +4801,7 @@
          return;
       }

-      Aast valMsg = schemaRef.getImmediateChild(VALMSG, null);
+      Aast valMsg = props.getImmediateChild(VALMSG, null);
       String schemaName = (String) recordRef.getAnnotation("schemaname");
       String bufName = (String) recordRef.getAnnotation("bufname");

If that works for you, please include it with your task branch.

3. Is information about presence of validation is recorded somewhere (e.g. in some xml file)?

No, that is part of what needs to be done for this task. I think the best place for this is in the corresponding DMO, as a Java annotation. We can surface this via TableMapper at runtime to test whether a table has delete validation and disallow the BUFFER-DELETE accordingly. If we find this to be a performance problem, we can store this information directly in BufferImpl, but I don't think this will be necessary.

#5 Updated by Stanislav Lomany about 8 years ago

I think the best place for this is in the corresponding DMO, as a Java annotation.

Should we extend LegacyTable like this?

@LegacyTable(name = "book", table = "book" hasDeleteValidation = true) 
public class BookImpl
...

#6 Updated by Eric Faulhaber about 8 years ago

Stanislav Lomany wrote:

I think the best place for this is in the corresponding DMO, as a Java annotation.

Should we extend LegacyTable like this?
[...]

How about just hasValidation, since there is only one type of validation at the table level (delete is implicit)?

#7 Updated by Stanislav Lomany about 8 years ago

The button in 4GL Data Dictinonary interface which calls validation editor is called "Validation..." so let's call it just hasValidation!

#8 Updated by Eric Faulhaber about 8 years ago

Agreed.

#9 Updated by Stanislav Lomany about 8 years ago

Created task branch 3026a from P2J trunk revision 11019.

#10 Updated by Stanislav Lomany about 8 years ago

I was wondering if delete validation can be applied to a temp-table. All I found is VALIDATE option for DEFINE TEMP-TABLE ... LIKE, but it doesn't copy table-level validation:

VALIDATE
The temp-table fields inherit, from the dictionary, validation expressions and validation messages from the database table.

Let me know if you aware of a way to define validation for a temp-table.

#11 Updated by Eric Faulhaber almost 8 years ago

I know of no way to define schema table-level validation for a temp-table. I would have guessed the only way would be with the LIKE option, but you've confirmed that doesn't inherit the validation. AFAIK, this is only an issue for permanent tables.

#12 Updated by Stanislav Lomany almost 8 years ago

Eric, the "Table <table name> is defined with schema delete validation..." error is displayed as a message box in GUI and in message area in ChUI. I think we don't want to add UI dependency to BufferImpl or ErrorManager, so as a solution I suggest to do the following:
  1. Add chuiModal boolean parameter to ErrorManager.recordOrShowError which sets how messsage should be displayed in ChUI.
  2. Add ErrorWriter.messageOrMessageBox(boolean modal, boolean chuiModal) method which conditionaly calls message or messageBox.

Let me know if you have a better idea.

#13 Updated by Eric Faulhaber almost 8 years ago

Stanislav Lomany wrote:

Eric, the "Table <table name> is defined with schema delete validation..." error is displayed as a message box in GUI and in message area in ChUI. I think we don't want to add UI dependency to BufferImpl or ErrorManager, so as a solution I suggest to do the following:
  1. Add chuiModal boolean parameter to ErrorManager.recordOrShowError which sets how messsage should be displayed in ChUI.
  2. Add ErrorWriter.messageOrMessageBox(boolean modal, boolean chuiModal) method which conditionaly calls message or messageBox.

Let me know if you have a better idea.

Greg, this one is more in your wheelhouse.

#14 Updated by Greg Shah almost 8 years ago

"Table <table name> is defined with schema delete validation..." error is displayed as a message box in GUI and in message area in ChUI.

Did you run the test from the procedure editor? Programs run that way in GUI will have their messages appear in an alert box instead of the message area. Running from the command line (with -p usually doesn't show the same behavior).

#15 Updated by Stanislav Lomany almost 8 years ago

You are correct, with -p key this message is in the message area in both ChUI and GUI.

Rebased task branch 3026a from P2J trunk revision 11024.

Please review revision 11026 of branch 3026a.

#16 Updated by Eric Faulhaber almost 8 years ago

Code review 3026a/11026:

Very nice! Please regression test.

#17 Updated by Stanislav Lomany almost 8 years ago

Rebased task branch 3026a from P2J trunk revision 11025.

#18 Updated by Eric Faulhaber almost 8 years ago

The ETF testing had some trouble for other reasons, but enough of the testing did well that I'm comfortable with this update. Please rebase to the latest trunk revision and then merge this update to trunk. Retesting after the rebase is not necessary, just a compile; there should be no conflicts.

#19 Updated by Stanislav Lomany almost 8 years ago

Rebased task branch 3026a from P2J trunk revision 11028.

#20 Updated by Stanislav Lomany almost 8 years ago

  • Status changed from WIP to Review

Сommitted into the trunk as bzr revision 11029.

#21 Updated by Eric Faulhaber almost 8 years ago

  • % Done changed from 0 to 100
  • Status changed from Review to Closed

#22 Updated by Greg Shah over 7 years ago

  • Target version changed from Milestone 11 to Cleanup and Stablization for Server Features

Also available in: Atom PDF