db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4671) Embedded driver does not work with jbossCache
Date Fri, 21 May 2010 21:23:16 GMT

    [ https://issues.apache.org/jira/browse/DERBY-4671?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12870168#action_12870168
] 

Knut Anders Hatlen commented on DERBY-4671:
-------------------------------------------

> I'm not completely sure I understand why this case is legal and the DERBY-4672  case
> is an error.
[...]
> I suppose what I'm saying is that it seems like this statement should be illegal, too
> (though it shouldn't throw a NPE, obviously) 

I think we have two different classes of statements here:

1) INSERT INTO ... SELECT FROM statements that have untyped parameter
markers in their top-level select lists. Inferring the type of the
parameter from the context is easy, because it's directly available
from the target column list. Derby has always accepted statements that
fall into this category.

2) INSERT INTO ... SELECT FROM statements that have untyped parameter
markers in the select list of one of the sub-queries. Inferring the
type of the parameter from the context is trickier, because the target
column list is not on the same nesting level in the query. Derby has
always rejected statements that fall into this category.

DERBY-4671 belongs to category (1), whereas DERBY-4672 belongs to
category (2).

You may be right that category 1 statements are not conforming to the
standard and should be illegal too. It may even be the case that it
was unintentional that those statements were accepted by Derby in the
first place. However, since they have always been accepted, and there
apparently are applications that depend on this feature, I think it's
safer to keep the behaviour.

So I guess my take on this is

- DERBY-4671 - this statement worked until DERBY-4420 broke it, so the
  correct fix is to make it work again. If there are compelling
  reasons to disallow the statement, and the benefits outweigh the
  disadvantage of breaking existing apps, we could consider
  disallowing it and document the changed behaviour in a release
  note. Currently, I don't see any compelling reasons to disallow it.

- DERBY-4672 - this statement has never worked, so making it fail
  gracefully is an improvement. Further improvement is possible
  later, though, if someone thinks it should be accepted.

> What sorts of setXXX calls are allowed to be used with
>
>     insert into t select ? from t
>
> Can I substitute a simple literal value into that statement? Can I substitute a column
> name into that statement? Can I substitute a sub-query into that statement?

Only literals.

The type will be taken from the context, so if T has one INT column,
as in the example above, the statement will be equivalent to

    insert into t select cast(? as int) from t

(which is also accepted syntax, by the way). Then you can use
setInt(), setLong(), setString(), or any other of the setters we
accept for an INT parameter, to tell which value to insert into T.

For example, the following code fragment

    ps = c.prepareStatement("insert into t select ? from t");
    ps.setInt(1, 77);
    ps.executeUpdate();

will double the number of rows in the table, and all the new rows will
have X=77. This is the same result as you get from this statement:

    s.executeUpdate("insert into t select 77 from t");

Note also that we allow parameters in the select list of plain SELECT
statements too, just not untyped ones, since there we don't have
context to get the type information from:

ij> prepare ps as 'select ? from t';
ERROR 42X34: There is a ? parameter in the select list.  This is not allowed.
ij> prepare ps as 'select cast(? as varchar(10)) from t';
ij> execute ps using 'values ''hello''';
1         
----------
hello     
hello     
hello     

3 rows selected
ij> prepare ps as 'select x+? from t';
ij> execute ps using 'values 1';
1          
-----------
2          
3          
4          

3 rows selected

> Embedded driver does not work with jbossCache
> ---------------------------------------------
>
>                 Key: DERBY-4671
>                 URL: https://issues.apache.org/jira/browse/DERBY-4671
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.1, 10.6.1.0
>         Environment: ------------------ Java Information ------------------
> Java Version:    1.5.0_12
> Java Vendor:     Sun Microsystems Inc.
> Java home:       c:\FDE\JDK1.5.0_12\jre
> Java classpath:  .;C:\Program Files\Java\jre1.5.0_06\lib\ext\QTJava.zip;C:\FDE\db-derby-10.6.1.0-bin/lib/derby.jar;C:\FDE\db-derby-10.6.1.0-bin/lib/derbynet.jar;C:\FDE\db-derby-10
> 6.1.0-bin/lib/derbyclient.jar;C:\FDE\db-derby-10.6.1.0-bin/lib/derbytools.jar
> OS name:         Windows XP
> OS architecture: x86
> OS version:      5.1
> Java user name:  rayohagan
> Java user home:  C:\Documents and Settings\rayohagan.FUTRIX
> Java user dir:   C:\FDE\db-derby-10.6.1.0-bin\bin
> java.specification.name: Java Platform API Specification
> java.specification.version: 1.5
> java.runtime.version: 1.5.0_12-b04
> --------- Derby Information --------
> JRE - JDBC: J2SE 5.0 - JDBC 3.0
> [C:\FDE\db-derby-10.6.1.0-bin\lib\derby.jar] 10.6.1.0 - (938214)
> [C:\FDE\db-derby-10.6.1.0-bin\lib\derbytools.jar] 10.6.1.0 - (938214)
> [C:\FDE\db-derby-10.6.1.0-bin\lib\derbynet.jar] 10.6.1.0 - (938214)
> [C:\FDE\db-derby-10.6.1.0-bin\lib\derbyclient.jar] 10.6.1.0 - (938214)
> ------------------------------------------------------
> ----------------- Locale Information -----------------
> Current Locale :  [English/New Zealand [en_NZ]]
> Found support for locale: [cs]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [de_DE]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [es]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [fr]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [hu]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [it]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [ja_JP]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [ko_KR]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [pl]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [pt_BR]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [ru]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [zh_CN]
>          version: 10.6.1.0 - (938214)
> Found support for locale: [zh_TW]
>          version: 10.6.1.0 - (938214)
> ------------------------------------------------------
>            Reporter: Ray O'Hagan
>            Assignee: Knut Anders Hatlen
>         Attachments: cache-config.xml, CacheIssue-eclipseProject.zip, CacheIssue.java,
derby-4671-1a.diff, repro.sql
>
>
> When trying to use jbossCache (version 3.2.5) and an embedded derby driver the following
exception is thrown when jbossCache tries to persist information to the database
> 48610 [AsyncCacheLoader-0] ERROR org.jboss.cache.loader.JDBCCacheLoader [] - Failed to
insert node :Java exception: ': java.lang.NullPointerException'.
>  48610 [AsyncCacheLoader-0] WARN  org.jboss.cache.loader.AsyncCacheLoader [] - Failed
to process async modifications: java.lang.IllegalStateException: Failed to insert node: Java
e
> xception: ': java.lang.NullPointerException'.
>  48610 [AsyncCacheLoader-0] DEBUG org.jboss.cache.loader.AsyncCacheLoader [] - Exception:
>  java.lang.IllegalStateException: Failed to insert node: Java exception: ': java.lang.NullPointerException'.
>         at org.jboss.cache.loader.AdjListJDBCCacheLoader.insertNode(AdjListJDBCCacheLoader.java:562)
>         at org.jboss.cache.loader.JDBCCacheLoader.addNewSubtree(JDBCCacheLoader.java:367)
>         at org.jboss.cache.loader.JDBCCacheLoader.put(JDBCCacheLoader.java:110)
>         at org.jboss.cache.loader.AbstractCacheLoader.put(AbstractCacheLoader.java:303)
>         at org.jboss.cache.loader.AbstractDelegatingCacheLoader.put(AbstractDelegatingCacheLoader.java:110)
>         at org.jboss.cache.loader.AsyncCacheLoader.access$601(AsyncCacheLoader.java:105)
>         at org.jboss.cache.loader.AsyncCacheLoader$AsyncProcessor.put(AsyncCacheLoader.java:417)
>         at org.jboss.cache.loader.AsyncCacheLoader$AsyncProcessor.run0(AsyncCacheLoader.java:409)
>         at org.jboss.cache.loader.AsyncCacheLoader$AsyncProcessor.run(AsyncCacheLoader.java:371)
>         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:619)
> Caused by: java.sql.SQLException: Java exception: ': java.lang.NullPointerException'.
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
>         at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:142)
>         at org.apache.derby.impl.jdbc.Util.javaException(Util.java:299)
>         at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403)
>         at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:346)
>         at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2269)
>         at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java:148)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(EmbedPreparedStatement20.java:82)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(EmbedPreparedStatement30.java:63)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement40.<init>(EmbedPreparedStatement40.java:40)
>         at org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Driver40.java:105)
>         at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:1607)
>         at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:1435)
>         at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:213)
>         at org.jboss.cache.loader.AdjListJDBCCacheLoader.prepareAndLogStatement(AdjListJDBCCacheLoader.java:90)
>         at org.jboss.cache.loader.AdjListJDBCCacheLoader.insertNode(AdjListJDBCCacheLoader.java:545)
>         ... 14 more
> Caused by: java.sql.SQLException: Java exception: ': java.lang.NullPointerException'.
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:119)
>         at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70)
>         ... 30 more
> Caused by: java.lang.NullPointerException
>         at org.apache.derby.impl.sql.compile.CharTypeCompiler.convertible(CharTypeCompiler.java:54)
>         at org.apache.derby.impl.sql.compile.CharTypeCompiler.storable(CharTypeCompiler.java:100)
>         at org.apache.derby.impl.sql.compile.ResultColumn.checkStorableExpression(ResultColumn.java:887)
>         at org.apache.derby.impl.sql.compile.ResultColumn.checkStorableExpression(ResultColumn.java:879)
>         at org.apache.derby.impl.sql.compile.ResultColumnList.checkStorableExpressions(ResultColumnList.java:953)
>         at org.apache.derby.impl.sql.compile.InsertNode.bindStatement(InsertNode.java:456)
>         at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:324)
>         at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:90)
>         at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:828)
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java:130)
>         ... 23 more
> It works fine using ClientDriver.
> Sample code and configuration files are attached.

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


Mime
View raw message