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] [Updated] (DERBY-4753) "ERROR 42X01: Syntax error: FALSE." during call to java.sql.DatabaseMetaData.getIndexInfo
Date Thu, 27 Dec 2012 13:50:12 GMT

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

Knut Anders Hatlen updated DERBY-4753:
--------------------------------------

    Attachment: Derby4753.java

As suggested above, newer versions accept the FALSE keyword also in non-internal queries.
However, the getIndexInfo query uses other internal syntax, so this may still fail, just with
a different syntax error.

I noticed that the stack trace contained a call to GenericPreparedStatement.rePrepare(), so
it looks like it happened after getIndexInfo() found out it was using a stale query plan and
decided to recompile. When recompilation is invoked through that path, it ends up calling
GenericStatement.prepare() with the forMetaData parameter set to false. This is the reason
why the internal syntax isn't accepted.

Following that clue, I managed to reproduce the syntax error, but only when running in soft-upgrade
mode. Presumably, soft-upgrade mode is needed because the call to rePrepare() in GenericPreparedStatement.executeStmt()
is guarded with a check for whether it is an SPS, and the SPS is not used in soft-upgrade.

The error can be reproduced by following these steps:

1) Create an empty database using Derby 10.9.1.0:

$ java -jar 10.9.1.0/derbyrun.jar ij
ij version 10.9
ij> connect 'jdbc:derby:db;create=true';
ij> exit;

2) Using the Derby development trunk, run the attached Derby4753.java program with the properties
derby.language.stalePlanCheckInterval=5 and derby.database.allowPreReleaseUpgrade=true:

$ java -Dderby.language.stalePlanCheckInterval=5 -Dderby.database.allowPreReleaseUpgrade=true
Derby4753
Exception in thread "main" java.sql.SQLSyntaxErrorException: Syntax error: org.apache.derby.catalog.IndexDescriptor.isUnique.
	at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:92)
	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256)
	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:424)
	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:353)
	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2400)
	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:82)
	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1334)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1715)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeQuery(EmbedPreparedStatement.java:287)
	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.doGetIndexInfo(EmbedDatabaseMetaData.java:2830)
	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getIndexInfo(EmbedDatabaseMetaData.java:2790)
	at Derby4753.checkIndexInfo(Derby4753.java:43)
	at Derby4753.main(Derby4753.java:26)
Caused by: java.sql.SQLException: Syntax error: org.apache.derby.catalog.IndexDescriptor.isUnique.
	at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:42)
	at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:122)
	at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:71)
	... 12 more
Caused by: ERROR 42X01: Syntax error: org.apache.derby.catalog.IndexDescriptor.isUnique.
	at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:278)
	at org.apache.derby.impl.sql.compile.MethodCallNode.resolveMethodCall(MethodCallNode.java:784)
	at org.apache.derby.impl.sql.compile.NonStaticMethodCallNode.bindExpression(NonStaticMethodCallNode.java:186)
	at org.apache.derby.impl.sql.compile.JavaToSQLValueNode.bindExpression(JavaToSQLValueNode.java:237)
	at org.apache.derby.impl.sql.compile.ConditionalNode.bindExpression(ConditionalNode.java:388)
	at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(ResultColumn.java:737)
	at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(ResultColumnList.java:831)
	at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(SelectNode.java:580)
	at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(DMLStatementNode.java:227)
	at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java:140)
	at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(CursorNode.java:267)
	at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:400)
	at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:99)
	at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:85)
	at org.apache.derby.impl.sql.GenericPreparedStatement.rePrepare(GenericPreparedStatement.java:245)
	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:425)
	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:333)
	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1242)
	... 6 more

The repro works like this:

It invokes getIndexInfo() once so that the query is compiled. Then it creates a table with
lots of columns, so that SYS.SYSCOLUMNS grows significantly. Then it re-executes getIndexInfo()
a number of times. After the fifth execution (because derby.language.stalePlanCheckInterval=5)
it checks if the query plan is stale. It discovers that SYS.SYSCOLUMNS has changed in size
since the initial compilation, and decides the query needs to be recompiled. When re-compiling,
it goes down the code path where internal syntax is not allowed.
                
> "ERROR 42X01: Syntax error: FALSE." during call to java.sql.DatabaseMetaData.getIndexInfo
> -----------------------------------------------------------------------------------------
>
>                 Key: DERBY-4753
>                 URL: https://issues.apache.org/jira/browse/DERBY-4753
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.5.3.0
>         Environment: Linux
>            Reporter: Craig Chaney
>              Labels: derby_triage10_8
>         Attachments: Derby4753.java
>
>
> We are seeing the failure below occasionally.  It does not happen every time ... with
the exact same database and call sequence it will happen about 1 out of 3 times.
> The parameters on the getIndexInfo call are
> connection.getMetaData().getIndexInfo(null, schemaName, tableName, false, false);
> schemaName and tableName are valid and definitely not null.
> Caused by: 
> java.sql.SQLException: Syntax error: FALSE.
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeQuery(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.doGetIndexInfo(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getIndexInfo(Unknown Source)
> 	at com.ibm.team.repository.service.db.provider.AbstractDbProvider.getIndexMetadata(AbstractDbProvider.java:381)
> 	at com.ibm.team.repository.service.db.provider.AbstractDbProvider.doesIndexExist(AbstractDbProvider.java:343)
> 	... 61 more
> Caused by: 
> ERROR 42X01: Syntax error: FALSE.
> 	at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.checkInternalFeature(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.literal(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.valueSpecification(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.valueExpressionPrimary(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primary(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primaryExpressionXX(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primaryExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.unaryExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.multiplicativeExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.additiveExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.thenElseExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.whenThenExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.valueSpecification(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.valueExpressionPrimary(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primary(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primaryExpressionXX(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primaryExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.unaryExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.multiplicativeExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.additiveExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.valueExpressionPrimary(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primary(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primaryExpressionXX(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.primaryExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.unaryExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.multiplicativeExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.additiveExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.derivedColumn(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.selectSublist(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.selectColumnList(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.selectList(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.querySpecification(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.simpleTable(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.nonJoinQueryPrimary(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.nonJoinQueryTerm(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.queryExpression(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.preparableSelectStatement(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.preparableSQLDataStatement(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.StatementPart(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.SQLParser.Statement(Unknown Source)
> 	at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.rePrepare(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
> 	... 68 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message