[ 
https://issues.apache.org/jira/browse/DERBY-4284?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Knut Anders Hatlen updated DERBY-4284:
--------------------------------------

    Attachment: derby-4284-1c.stat
                derby-4284-1c.diff

Here's a new patch which addresses the remaining issues. It also adds more test 
cases. All the regression tests ran cleanly with the patch.

Description of the changes:

SelectNode.java:

* bindResultColumns(): Don't make all the columns nullable just because the 
query contains an outer join.

FromList.java:

* Removed helper method hasOuterJoins() which is no longer used after the 
changes in SelectNode.

JoinNode.java:

* getMatchingColumn(): If the join is a "half" outer join, and the matching 
column is found on the logical right side of the join (logical right side == 
left side in a right outer join), make that column nullable before returning 
it. Although JoinNode already has code in buildRCL() that makes all columns on 
the logical right side nullable, getMatchingColumn() may be called before the 
RCL has been built, which causes the problem with casts mentioned in the 
previous comment.

lang/JoinTest.java:
lang/_Suite.java:

* Test cases for this bug.

dml148.out:
dml162.out:
outerjoin.out:

* Updated master with formatting changes caused by nullable column becoming 
non-nullable.

wisconsin.out:

* Updated printed query plan for an outer join because a scan stopped using 
"ordered null sematics" on a column now that it sees that it's not nullable.

> All Columns become Nullable when Using left join
> ------------------------------------------------
>
>                 Key: DERBY-4284
>                 URL: https://issues.apache.org/jira/browse/DERBY-4284
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, SQL
>    Affects Versions: 10.5.1.1
>         Environment: Microsoft Windows XP SP3, Sun JDK 6 Update 14
>            Reporter: Chua Chee Seng
>            Assignee: Knut Anders Hatlen
>         Attachments: derby-4284-1a.diff, derby-4284-1b.diff, 
> derby-4284-1b.stat, derby-4284-1c.diff, derby-4284-1c.stat, Main.java
>
>
> Consider following:-
> create table person (
>   id varchar(20) not null,
>   name varchar(100) not null
> );
> create table car (
>   id varchar(20) not null,
>   person_id varchar(20) not null,
>   model varchar(100) not null,
>   plat_no varchar(100) not null
> );
> When select :-
> select
> p.name,
> c.model,
> c.plat_no
> from person p
> left join car c on (p.id = c.person_id);
> From the ResultSet, get the ResultSetMetaData and inspect each column's 
> isNullable() value, which is always = 1 (always nullable).  Expected : column 
> 'p.name' isNullable = 0 (not nullable), but I get 'p.name' isNullable = 1 
> (nullable)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to