dynamobi/dynamobi — Issue #785: [FRG-85] Fennel calc codegen for overlay is wrong for mixed char/varchar operands
Author: dynamobi-build
Created: 2011-12-30 03:48:47+00:00
State: closed
Labels: Fennel Calc Codegen, FRG

[reporter="jvs", created="Wed, 22 Mar 2006 12:23:49 -0500 (GMT-05:00)"]
The query below demonstrates the problem. (I added the explicit cast to

char(2)

so that the bug can be verified with old broken code which treats string

literals as varchar instead of char.)

The generated code pads the results as if they were char(128). The reason is

that in CalcRexImplementorTableImpl, overlayFunc is registered with

BinaryStringMakeSametypeImplementor, which calls implementConversionIfNeeded,

which combines varchar(128) with char(2) to get char(128), which is just wrong

in this context.

0: jdbc:farrago:> select overlay(name placing cast('??' as char(2)) from 2 for

1) from sales.emps order by 1;

+------------------------------------------------------------------------------+|

EXPR$0

|+------------------------------------------------------------------------------+|

E??ic||

F??ed||

J??hn||

W??lma

|+------------------------------------------------------------------------------+4

rows selected (2.541 seconds)