dynamobi/dynamobi — Issue #405: [FRG-385] INSERT does not trim CHAR values when inserted into VARCHAR columns
Author: dynamobi-build
Created: 2011-12-30 03:12:41+00:00
State: closed
Labels: FRG

[reporter="jhyde", created="Thu, 29 Oct 2009 22:01:33 -0500 (GMT-05:00)"]
INSERT does not trim CHAR values when inserted into VARCHAR columns. It doesn't show up on a single-row INSERT, but it does show up when there are multiple rows and columns have different lengths, because values are promoted to the CHAR type of the longest value.

For example, in the following, both values come out with length 4, but one of the values should come out with length 3.

0: jdbc:farrago:> set schema 'sales';

No rows affected (4.189 seconds)

0: jdbc:farrago:> create table foo(i int not null primary key, v varchar(6));

No rows affected (1.01 seconds)

0: jdbc:farrago:> insert into foo values (1, 'red'), (2, 'blue');

2 rows affected (1.273 seconds)

0: jdbc:farrago:> select char_length(v) from foo;

+---------+

| EXPR$0 |

+---------+

| 4 |

| 4 |

+---------+

2 rows selected (1.616 seconds)