Project

General

Profile

Bug #6446

temp-table:create-like adds add before-table, too

Added by Constantin Asofiei almost 2 years ago. Updated almost 2 years ago.

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

100%

billable:
No
vendor_id:
GCD
case_num:

History

#2 Updated by Constantin Asofiei almost 2 years ago

This test shows that a create-like adds the before-table, too, if the source has it.

def temp-table tt1 before-table btt1 field f1 as int index ix1 is unique f1.
def dataset ds1 for tt1.

temp-table tt1:tracking-changes = true.
create tt1.
tt1.f1 = 100.

find first btt1.
message btt1.f1.
temp-table tt1:tracking-changes = false.

def var htt as handle.
create temp-table htt.
htt:create-like(temp-table tt1:handle).
htt:temp-table-prepare("tt1").
htt:copy-temp-table(temp-table tt1:handle, no, yes).

def var hb as handle.
hb = htt:before-table:default-buffer-handle.
hb:find-first().
message hb valid-handle(hb) hb::f1 hb:name.

This patch solves my issue for the test:

### Eclipse Workspace Patch 1.0
#P p2j6129a
Index: src/com/goldencode/p2j/persist/TempTableBuilder.java
===================================================================
--- src/com/goldencode/p2j/persist/TempTableBuilder.java    (revision 3633)
+++ src/com/goldencode/p2j/persist/TempTableBuilder.java    (working copy)
@@ -231,6 +231,8 @@

    /** Flag indicating the delete was explicitly called for a BY-REFERENCE handle. */
    private boolean postponedDelete = false;
+
+   private boolean implicitBeforeTable;

    static
    {
@@ -2384,7 +2386,7 @@
     */
    public logical tempTablePrepare(String name)
    {
-      return tempTablePrepareImpl(name, null);
+      return implicitBeforeTable ? tempTablePrepare(name, true) : tempTablePrepareImpl(name, null);
    }

    /**
@@ -2400,7 +2402,7 @@
    public logical tempTablePrepare(character name)
    {
       String tableName = name.toJavaType();
-      return tempTablePrepareImpl(tableName, null);
+      return implicitBeforeTable ? tempTablePrepare(name, true) : tempTablePrepareImpl(tableName, null);
    }

    /**
@@ -3138,6 +3140,10 @@
          return new logical(false);
       }

+      // check before-table
+      BufferImpl buf = (BufferImpl) recordBuffer.getDMOProxy();
+      implicitBeforeTable = (buf.isAfterBuffer() && buf.peerBuffer != null);
+
       addAllFields(getExistingFields(recordBuffer));

       if (handleIndex)

What I couldn't test in OE is the temp-table-prepare("tt1", no). - to check if the before-table from the source can be 'discarded' during prepare. This syntax is not accepted by my OE install.

#3 Updated by Constantin Asofiei almost 2 years ago

This is committed in 6129a/13897. Ovidiu, if there are no concerns, I'll close the task.

#4 Updated by Ovidiu Maxiniuc almost 2 years ago

  • % Done changed from 0 to 100
  • Status changed from New to WIP

The patch is good. You can close the task.

#5 Updated by Constantin Asofiei almost 2 years ago

  • Status changed from WIP to Test

Also available in: Atom PDF