db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "A B (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-1784) When qualifying a column name with its synonym name in the select list, Derby throws SQLSTATE 42X04.
Date Fri, 15 Sep 2006 20:57:25 GMT
    [ http://issues.apache.org/jira/browse/DERBY-1784?page=comments#action_12435117 ] 
            
A B commented on DERBY-1784:
----------------------------

I reviewed derby1784-trunk-diff03a.txt and the changes look good overall.  I confirmed that
the patch applies and builds, and I ran the new test cases with and without the code changes--as
expected, they fail without the fix and pass with it.

I do have two questions/comments about the patch.  I don't think either of these is worthy
of blocking the patch, but I'm nonetheless curious...

1)  FromBaseTable.java:

There are two places where uses of "tableName" have been replaced with
calls to getOrigTableName():

-					(correlationName != null) ? correlationName : tableName.getTableName(), 
+					(correlationName != null) ? correlationName : getOrigTableName().getTableName(), 

...

-			return tableName.getFullTableName();
+			return getOrigTableName().getFullTableName();

...

-		return getResultColumnsForList(allTableName, resultColumns, tableName);
+		return getResultColumnsForList(allTableName, resultColumns, 
+				getOrigTableName());

But all other occurrences of "tableName" are left as they are.  Can you perhaps explain the
distinction between when one should be used over the other?  Or put another way, can you explain
why these three--and only these three--occurrences were changed but the rest were left alone?
 If possible, I think it'd be good to add comments--perhaps as part of the javadoc for the
new "getOrigTableName()" method?--explaining when that method should be used (as opposed to
just using the tableName field).  That might help developers down the road avoid using the
method incorrectly.  The other option is to simply add comments to the places where you used
"getOrigTableName()--you could perhaps just use what you wrote in your previous comment for
this Jira, which I think gives a good enough explanation...

2)  DMLModStatementNode.java:

In the following code:

+			ResultColumn column = (ResultColumn) rcl.elementAt( i );
+			ColumnReference	reference = column.getReference();
+			String crTableName = reference.getTableName();
+
+			if ( reference != null && crTableName != null)
+			{

There's a check to see if "reference" is null, but that check happens AFTER "reference" is
used.  This seems to suggest to me that either 1) reference can never be null, in which case
there's no need to check for it, or 2) reference CAN be null but there aren't any test cases
for such a situation.  Do you know which of these is true?  I *think* it's the former--i.e.that
in case of updates or inserts, the result column will be for the target base table and thus
cannot have a reference that is null...but can you confirm this?

> When qualifying a column name with its synonym name in the select list, Derby throws
SQLSTATE 42X04.
> ----------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-1784
>                 URL: http://issues.apache.org/jira/browse/DERBY-1784
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.2.1.0, 10.3.0.0, 10.1.3.1
>         Environment: Any environment
>            Reporter: Yip Ng
>         Assigned To: Yip Ng
>         Attachments: derby1784-trunk-diff01.txt, derby1784-trunk-diff02.txt, derby1784-trunk-diff03a.txt,
derby1784-trunk-stat01.txt, derby1784-trunk-stat02.txt, derby1784-trunk-stat03a.txt
>
>
> When qualifying a synonym with its name in the select list, Derby throws SQLSTATE 42X04
but if there is no qualification of the column, then the select statement executes successfully.
> ij version 10.3
> ij> connect 'jdbc:derby:wombat;create=true' user 'user1' as user1;
> WARNING 01J01: Database 'wombat' not created, connection made to existing database instead.
> ij> create schema test1;
> 0 rows inserted/updated/deleted
> ij> create schema test2;
> 0 rows inserted/updated/deleted
> ij> create table test1.t1 ( id bigint not null );
> 0 rows inserted/updated/deleted
> ij> create synonym test2.t1 for test1.t1;
> 0 rows inserted/updated/deleted
> ij> set schema test1;
> 0 rows inserted/updated/deleted
> ij> select t1.id from t1;
> ID
> --------------------
> 0 rows selected
> ij> set schema test2;
> 0 rows inserted/updated/deleted
> ij> select t1.id from t1;
> ERROR 42X04: Column 'T1.ID' is either not in any table in the FROM list or appears within
a join specification and is outside the scope of the join specification or appears in a HAVING
clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then
'T1.ID' is not a column in the target table
> ij> select id from t1;
> ID
> --------------------
> 0 rows selected
> ------------------ Java Information ------------------
> Java Version:    1.4.2_12
> Java Vendor:     Sun Microsystems Inc.
> Java home:       C:\Program Files\Java\j2re1.4.2_12
> Java classpath:  classes;.
> OS name:         Windows XP
> OS architecture: x86
> OS version:      5.1
> Java user name:  Yip
> Java user home:  C:\Documents and Settings\Yip
> Java user dir:   C:\work3\derby\trunk
> java.specification.name: Java Platform API Specification
> java.specification.version: 1.4
> --------- Derby Information --------
> JRE - JDBC: J2SE 1.4.2 - JDBC 3.0
> [C:\work3\derby\trunk\classes] 10.3.0.0 alpha - (438358)
> ------------------------------------------------------
> ----------------- Locale Information -----------------
> Current Locale :  [English/United States [en_US]]
> Found support for locale: [de_DE]
>          version: 10.3.0.0 alpha - (438358)
> Found support for locale: [es]
>          version: 10.3.0.0 alpha - (438358)
> Found support for locale: [fr]
>          version: 10.3.0.0 alpha - (438358)
> Found support for locale: [it]
>          version: 10.3.0.0 alpha - (438358)
> Found support for locale: [ja_JP]
>          version: 10.3.0.0 alpha - (438358)
> Found support for locale: [ko_KR]
>          version: 10.3.0.0 alpha - (438358)
> Found support for locale: [pt_BR]
>          version: 10.3.0.0 alpha - (438358)
> Found support for locale: [zh_CN]
>          version: 10.3.0.0 alpha - (438358)
> Found support for locale: [zh_TW]
>          version: 10.3.0.0 alpha - (438358)
> ------------------------------------------------------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message