You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Geoff hendrey <ge...@yahoo.com> on 2008/12/24 07:01:02 UTC

Re: why is column being returned?

Hi Bryan,

This bug snuck up and bit me again...Per your suggestion, here is a reproducible script:
(your original email is at the bottom. I will log a Jira issue would be created as this bug keeps coming back to haunt me)

 CREATE TABLE "REVIEWS"."GEOFF__REVIEWS__REVIEW"
(
   PK INTEGER PRIMARY KEY not null,
   numstars BIGINT,
   body VARCHAR(32672),
   title VARCHAR(32672),
   authoremail VARCHAR(32672)
);

INSERT INTO "REVIEWS"."GEOFF__REVIEWS__REVIEW" (PK,numstars,body,title,authoremail) VALUES (0 /*not nullable*/,0,'s','s','s');

SELECT  "review"."numstars"
FROM
    "GEOFF__REVIEWS__REVIEW" AS "review"
WHERE
        "review"."PK" = 1 
ORDER BY
    "review".PK 





________________________________
From: Bryan Pendleton <bp...@amberpoint.com>
To: Derby Discussion <de...@db.apache.org>
Sent: Wednesday, July 2, 2008 5:53:12 PM
Subject: Re: why is column being returned?

Geoff hendrey wrote:
> Hi,
> 
> I am doing something like:
> 
> SELECT
>     "A"."C1" AS "A.C1",
>     "A"."C2" AS "A.C2"
> FROM
>     ATABLE AS "A"
> WHERE
>     "A"."C1" = "X"
> ORDER BY
>     PK
> 
> Does it make sense that PK should be returned in the result set? I expected ONLY "A.C1" and "A.C2" to be the column names returned by JDBC...but I see "PK" as well. It may be a bug in my code somewhere else, or is it possible that the ORDER BY is forcing "PK" to be returned?

I think that it *is* due to the ORDER BY, and I think that it is
incorrect behavior. I noticed this myself a while back and tried
to pin it down, but I was having trouble isolating a standalone
reproducible test case.

If you can construct a simple standalone test program which demonstrates
this behavior, I think it would be great if you could log it into JIRA
so we can track it and study it more.

thanks,

bryan