Project

General

Profile

Bug #2101

multi-buffer FOR loop with rowid and to-rowid functions in WHERE clause not converting properly

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

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

100%

billable:
No
vendor_id:
GCD
case_num:

ecf_upd20130323a.zip (6.57 KB) Eric Faulhaber, 03/23/2013 08:23 PM

History

#1 Updated by Eric Faulhaber about 11 years ago

This issue was first reported in note 192 of #2068.

The following converts badly:

def temp-table tt1 field f1 as char.

for each tt1,
    first person where rowid(person) = to-rowid(tt1.f1):
end.

I think the FOR EACH, FIRST loop should convert to:

query0 = new CompoundQuery(false, false);
query0.addComponent(new AdaptiveQuery(tt1, (String) null, null, "tt1.id asc"));
RecordBuffer.prepare(person);
query0.addComponent(new RandomAccessQuery(person, "person.id = toRowid(?)", null, "person.siteId asc, person.empNum asc", new Object[]
{
   new FieldReference(tt1, "f1")
}), QueryConstants.FIRST);

Consider that:

def temp-table tt1 field f1 as rowid.

for each tt1,
    first person where rowid(person) = tt1.f1:
end.

already converts properly to:

query0 = new CompoundQuery(false, false);
query0.addComponent(new AdaptiveQuery(tt1, (String) null, null, "tt1.id asc"));
RecordBuffer.prepare(person);
query0.addComponent(new RandomAccessQuery(person, "person.id = ?", null, "person.siteId asc, person.empNum asc", new Object[]
{
   new FieldReference(tt1, "f1")
}), QueryConstants.FIRST);

The difference between the two is the data type of tt1.f1 and the use of the to-rowid builtin function in the where clause. I believe the latter is driving us down the path of a client-side where clause when we don't need to go there.

#2 Updated by Eric Faulhaber about 11 years ago

Although I'm not the assignee, in having to think through the problem for the above post, I took a quick look at the related rules and made a fix candidate, which is attached. It is going through conversion regression testing now.

#3 Updated by Eric Faulhaber about 11 years ago

  • Project changed from Liberty to Database

#4 Updated by Eric Faulhaber about 11 years ago

  • % Done changed from 0 to 80
  • Status changed from WIP to Review

Update ecf_upd20130323a.zip has passed conversion regression testing and is committed to bzr rev. 10325.

#5 Updated by Eric Faulhaber about 11 years ago

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

I've compared conversions of the customer's server project with and without this fix and it seems correct in all the locations which differ as a result of the fix. It simplifies the conversion of a number of cases similar to the originally reported problem, reducing the use of client-side where clauses considerably.

I am closing this issue accordingly.

#6 Updated by Greg Shah over 7 years ago

  • Target version changed from Milestone 4 to Conversion Support for Server Features

Also available in: Atom PDF