Bug #10956
Wrong primary index selection on FOR EACH table
100%
Related issues
History
#1 Updated by Teodor Gorghe 8 months ago
Suppose we have the following simple case:
DEFINE TEMP-TABLE tt1 NO-UNDO
FIELD f1 AS INTEGER
FIELD f2 AS INTEGER
INDEX f2_idx IS UNIQUE PRIMARY f2.
DEFINE TEMP-TABLE tt2 NO-UNDO LIKE tt1
INDEX f1_idx IS UNIQUE PRIMARY f1.
CREATE tt2.
tt2.f1 = 1.
tt2.f2 = 2.
RELEASE tt2.
CREATE tt2.
tt2.f1 = 2.
tt2.f2 = 1.
RELEASE tt2.
FOR EACH tt2:
DISPLAY tt2.
END.
Please note that after conversion, the temp-table tt2 has 2 primary indexes, the one inherited from tt1 and the another one from the temp-table definition.
When iterating through records, eg. FOR EACH, the tt1 primary index is used instead of f1_idx. (4GL uses f1_idx, FWD uses f2_idx).
- FWD shows (2 1 / 1 2)
- 4GL shows (1 2 / 2 1)
#3 Updated by Constantin Asofiei 8 months ago
Teodor, do a WRITE-XML on tt2, with schema included, and see what indexes are reported there.
#4 Updated by Teodor Gorghe 8 months ago
The customer uses WRITE-JSON, which the order is not the same, because of this issue.
I am testing with WRITE-JSON/WRITE-XML right now.
#5 Updated by Teodor Gorghe 8 months ago
- the order of WRITE-JSON/WRITE-XML is the same as for the
FOR EACHexecution:
WRITE-JSON and WRITE-XML: 4GL (1 2 / 2 1), FWD (2 1 / 1 2)
#6 Updated by Constantin Asofiei 8 months ago
Teodor, the goal of WRITE-XML with schema included is to see which indexes are reported. Please post the .xml file here.
#7 Updated by Teodor Gorghe 8 months ago
WRITE-XMLSCHEMA:
- 4GL
<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001"> <xsd:element name="tt2" prodata:proTempTable="true"> <xsd:complexType> <xsd:sequence> <xsd:element name="tt2Row" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="f1" type="xsd:int" nillable="true"/> <xsd:element name="f2" type="xsd:int" nillable="true"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:unique name="f2_idx"> <xsd:selector xpath=".//tt2Row"/> <xsd:field xpath="f2"/> </xsd:unique> <xsd:unique name="f1_idx" prodata:primaryIndex="true"> <xsd:selector xpath=".//tt2Row"/> <xsd:field xpath="f1"/> </xsd:unique> </xsd:element> </xsd:schema> - FWD
<?xml version='1.0'?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001"> <xsd:element name="tt2" prodata:proTempTable="true"> <xsd:complexType> <xsd:sequence> <xsd:element name="tt2Row" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="f1" type="xsd:int" nillable="true" prodata:columnLabel="f1"/> <xsd:element name="f2" type="xsd:int" nillable="true" prodata:columnLabel="f2"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:unique name="f2_idx" prodata:primaryIndex="true"> <xsd:selector xpath=".//tt2Row"/> <xsd:field xpath="f2"/> </xsd:unique> <xsd:unique name="f1_idx" prodata:primaryIndex="true"> <xsd:selector xpath=".//tt2Row"/> <xsd:field xpath="f1"/> </xsd:unique> </xsd:element> </xsd:schema>
#8 Updated by Constantin Asofiei 8 months ago
OK, so this is a conversion issue: if the model table has a primary index, and the definition also has one, then the one from the model is no longer primary.
#9 Updated by Teodor Gorghe 8 months ago
- Status changed from New to WIP
- Assignee set to Teodor Gorghe
I will assign this to me and I will work on this in parallel.
#10 Updated by Teodor Gorghe 8 months ago
- Status changed from WIP to Review
- % Done changed from 0 to 100
- reviewer Constantin Asofiei added
Created task branch 10956a
Committed revision 16299 on task branch 10956a:
- Don't copy the KW_PRIMARY property from source index if the destination table already has an PRIMARY index.
#11 Updated by Constantin Asofiei 8 months ago
Teodor Gorghe wrote:
Created task branch 10956a
Committed revision 16299 on task branch 10956a:
- Don't copy theKW_PRIMARYproperty from source index if the destination table already has anPRIMARYindex.
The change looks good.
#12 Updated by Constantin Asofiei 8 months ago
- Related to Bug #10978: Conversion NPE when creating a temp-table with LIKE that uses a different primary index added
#13 Updated by Constantin Asofiei 7 months ago
10956a rev 16300 fixes a NPE.
#14 Updated by Constantin Asofiei 6 months ago
- Status changed from Review to Internal Test
#15 Updated by Teodor Gorghe 6 months ago
Rebased to trunk rev 16358
#16 Updated by Constantin Asofiei 6 months ago
- Status changed from Internal Test to Merge Pending
Merge to trunk after 10925a
#17 Updated by Teodor Gorghe 6 months ago
- Status changed from Merge Pending to Test
Branch 10956a was merged to trunk rev. 16389 and archived.
#18 Updated by Constantin Asofiei 6 months ago
- Status changed from Test to Closed