Issue Details (XML | Word | Printable)

Key: NUCRDBMS-442
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Giambattista Bloisi
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

OracleAdapter.getExistingIndexes does not work for certain table names

Created: 23/Aug/10 02:01 PM   Updated: 20/Oct/10 09:30 AM   Resolved: 21/Sep/10 05:29 PM
Component/s: None
Affects Version/s: 1.1.6, 2.0.5, 2.1.1, 2.2.0.m1
Fix Version/s: 2.2.0.m2

File Attachments: 1. Zip Archive NUCRDBMS-442-2.zip (2 kB)
2. Text File ora-getExistingIndexes.patch (0.9 kB)


Datastore: Oracle
Severity: Production


 Description  « Hide
Oracle JDBC implementation of Connection.getMetaData().getIndexInfo seems not to work also for certain table names besides reserved keywords.

Please find attached a patch that skips the use of JDBC getIndexInfo in that case.

Giambattista Bloisi made changes - 23/Aug/10 02:02 PM
Field Original Value New Value
Attachment ora-getExistingIndexes.patch [ 11240 ]
Giambattista Bloisi added a comment - 23/Aug/10 02:17 PM
Basically it looks like JDBC enforce "simple sql name" rules (http://www.oracle-base.com/articles/10g/dbms_assert_10gR2.php#SIMPLE_SQL_NAME)

Andy Jefferson added a comment - 19/Sep/10 08:27 PM
What about a testcase that demonstrates the issue so it is understood ? (see docs for the format required)

Giambattista Bloisi added a comment - 20/Sep/10 06:09 PM
Simple test case replicating the problem

Giambattista Bloisi made changes - 20/Sep/10 06:09 PM
Attachment NUCRDBMS-442.zip [ 11250 ]
Andy Jefferson added a comment - 21/Sep/10 07:55 AM
I ran this test on Oracle 10.2.0.1 XE using the JDBC driver 10.2.0.4 and have no such problem.

07:52:01,568 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Connection] - Connection "jdbc:oracle:thin:@127.0.0.1:1521:xe, UserName=
DATANUCLEUS, Oracle JDBC driver" opened with isolation level "read-committed"
07:52:01,570 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Transaction] - Running enlist operation on resource: org.datanucleus.sto
re.rdbms.ConnectionFactoryImpl$EmulatedXAResource@157211f, error code TMNOFLAGS and transaction: [DataNucleus Transaction, ID=Xid=
, enlisted resources=[]]
07:52:01,570 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Connection] - Managed connection org.datanucleus.store.rdbms.ConnectionF
actoryImpl$EmulatedXAResource@157211f is starting for transaction Xid=
 with flags 0
07:52:01,570 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Connection] - Connection added to the pool : [org.datanucleus.store.rdbms.ConnectionFactoryImpl$ManagedConnectionImpl@82c23d, jdbc:oracle:thin:@127.0.0.1:1521:xe, UserName=DATANUCLEUS, Oracle JDBC driver]
07:52:01,570 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Datastore.Retrieve] - Retrieving PreparedStatement for connection "jdbc:oracle:thin:@127.0.0.1:1521:xe, UserName=DATANUCLEUS, Oracle JDBC driver"
07:52:01,570 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Datastore.Persist] - The requested statement "INSERT INTO "_myclass" ("message","myclass_id") VALUES (?,?)" has been made batchable
07:52:01,576 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Datastore.Persist] - Batch has been added to statement "INSERT INTO "_myclass" ("message","myclass_id") VALUES (?,?)" for processing (batch size = 1)
07:52:01,577 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Datastore] - Statement batch "INSERT INTO "_myclass" ("message","myclass_id") VALUES (?,?)" being processed (batch size = 1)
07:52:01,577 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Datastore.Native] - BATCH [INSERT INTO "_myclass" ("message","myclass_id") VALUES (<'name'>,<1>)]
07:52:01,582 (org.datanucleus.test.Main.main()) DEBUG [DataNucleus.Datastore] - Execution Time = 5 ms

Giambattista Bloisi added a comment - 21/Sep/10 11:14 AM
I obtain instead the console output below (I added also a trace for the full stack). I'm using datanucleus 2.1.1 release jars and Oracle 11.2.0.1.0 ojdbc6.jar driver.
Can I do anything else to help? Shall I check against up-to-date svn code?

Sep 21, 2010 12:07:44 PM org.datanucleus.PersistenceConfiguration setProperty
INFO: Property javax.jdo.option.spi.ResourceName unknown - will be ignored
Sep 21, 2010 12:07:44 PM org.datanucleus.ObjectManagerFactoryImpl logConfiguration
INFO: ================= Persistence Configuration ===============
Sep 21, 2010 12:07:44 PM org.datanucleus.ObjectManagerFactoryImpl logConfiguration
INFO: DataNucleus Persistence Factory - Vendor: "DataNucleus" Version: "2.1.1"
Sep 21, 2010 12:07:44 PM org.datanucleus.ObjectManagerFactoryImpl logConfiguration
INFO: DataNucleus Persistence Factory initialised for datastore URL="jdbc:oracle:thin:@compton:1521:XE" driver="oracle.jdbc.driver.OracleDriver" userName="system"
Sep 21, 2010 12:07:44 PM org.datanucleus.ObjectManagerFactoryImpl logConfiguration
INFO: ===========================================================
Sep 21, 2010 12:07:45 PM org.datanucleus.store.rdbms.RDBMSStoreManager initialiseSchema
INFO: Initialising Catalog "", Schema "SYSTEM" using "None" auto-start option
Sep 21, 2010 12:07:45 PM org.datanucleus.store.rdbms.RDBMSStoreManager initialiseSchema
INFO: Catalog "", Schema "SYSTEM" initialised - managing 0 classes
Sep 21, 2010 12:07:45 PM org.datanucleus.jdo.metadata.JDOMetaDataManager <init>
INFO: Registering listener for metadata initialisation
Sep 21, 2010 12:07:45 PM org.datanucleus.jdo.metadata.JDOMetaDataManager$MetaDataRegisterClassListener registerClass
INFO: Listener found initialisation for persistable class org.datanucleus.test.MyClass
Sep 21, 2010 12:07:45 PM org.datanucleus.store.StoreDataManager registerStoreData
INFO: Managing Persistence of Class : org.datanucleus.test.MyClass [Table : "_myclass", InheritanceStrategy : new-table]
Sep 21, 2010 12:07:46 PM org.datanucleus.test.Main main
INFO: >> Exception thrown persisting objects : Exception thrown while querying indices for table=_myclass
javax.jdo.JDODataStoreException: Exception thrown while querying indices for table=_myclass
at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:319)
at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:668)
at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:688)
at org.datanucleus.test.Main.main(Main.java:27)
NestedThrowablesStackTrace:
java.sql.SQLException: Invalid argument(s) in call
at oracle.jdbc.OracleDatabaseMetaData.getIndexInfo(OracleDatabaseMetaData.java:4092)
at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getRDBMSTableIndexInfoForTable(RDBMSSchemaHandler.java:616)
at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getRDBMSTableIndexInfoForTable(RDBMSSchemaHandler.java:585)
at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getSchemaData(RDBMSSchemaHandler.java:202)
at org.datanucleus.store.rdbms.table.TableImpl.getExistingCandidateKeys(TableImpl.java:1099)
at org.datanucleus.store.rdbms.table.TableImpl.validateCandidateKeys(TableImpl.java:698)
at org.datanucleus.store.rdbms.table.TableImpl.validateConstraints(TableImpl.java:400)
at org.datanucleus.store.rdbms.table.ClassTable.validateConstraints(ClassTable.java:3298)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.performTablesValidation(RDBMSStoreManager.java:2816)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.addClassTablesAndValidate(RDBMSStoreManager.java:2546)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.run(RDBMSStoreManager.java:2191)
at org.datanucleus.store.rdbms.AbstractSchemaTransaction.execute(AbstractSchemaTransaction.java:113)
at org.datanucleus.store.rdbms.RDBMSStoreManager.addClasses(RDBMSStoreManager.java:966)
at org.datanucleus.store.AbstractStoreManager.addClass(AbstractStoreManager.java:914)
at org.datanucleus.store.mapped.MappedStoreManager.getDatastoreClass(MappedStoreManager.java:356)
at org.datanucleus.store.rdbms.RDBMSStoreManager.getPropertiesForGenerator(RDBMSStoreManager.java:1468)
at org.datanucleus.store.AbstractStoreManager.getStrategyValue(AbstractStoreManager.java:1282)
at org.datanucleus.jdo.state.JDOStateManagerImpl.populateStrategyFields(JDOStateManagerImpl.java:784)
at org.datanucleus.jdo.state.JDOStateManagerImpl.initialiseForPersistentNew(JDOStateManagerImpl.java:416)
at org.datanucleus.state.StateManagerFactory.newStateManagerForPersistentNew(StateManagerFactory.java:152)
at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1453)
at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1281)
at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:663)
at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:688)
at org.datanucleus.test.Main.main(Main.java:27)

Giambattista Bloisi added a comment - 21/Sep/10 11:31 AM
I obtain similar error also when using Oracle 10.2.0.4 ojdbc14_g.jar driver.

Sep 21, 2010 12:29:04 PM org.datanucleus.PersistenceConfiguration setProperty
INFO: Property javax.jdo.option.spi.ResourceName unknown - will be ignored
Sep 21, 2010 12:29:04 PM org.datanucleus.ObjectManagerFactoryImpl logConfiguration
INFO: ================= Persistence Configuration ===============
Sep 21, 2010 12:29:04 PM org.datanucleus.ObjectManagerFactoryImpl logConfiguration
INFO: DataNucleus Persistence Factory - Vendor: "DataNucleus" Version: "2.1.1"
Sep 21, 2010 12:29:04 PM org.datanucleus.ObjectManagerFactoryImpl logConfiguration
INFO: DataNucleus Persistence Factory initialised for datastore URL="jdbc:oracle:thin:@compton:1521:XE" driver="oracle.jdbc.driver.OracleDriver" userName="system"
Sep 21, 2010 12:29:04 PM org.datanucleus.ObjectManagerFactoryImpl logConfiguration
INFO: ===========================================================
Sep 21, 2010 12:29:04 PM org.datanucleus.store.rdbms.RDBMSStoreManager initialiseSchema
INFO: Initialising Catalog "", Schema "SYSTEM" using "None" auto-start option
Sep 21, 2010 12:29:04 PM org.datanucleus.store.rdbms.RDBMSStoreManager initialiseSchema
INFO: Catalog "", Schema "SYSTEM" initialised - managing 0 classes
Sep 21, 2010 12:29:04 PM org.datanucleus.jdo.metadata.JDOMetaDataManager <init>
INFO: Registering listener for metadata initialisation
Sep 21, 2010 12:29:04 PM org.datanucleus.jdo.metadata.JDOMetaDataManager$MetaDataRegisterClassListener registerClass
INFO: Listener found initialisation for persistable class org.datanucleus.test.MyClass
Sep 21, 2010 12:29:04 PM org.datanucleus.store.StoreDataManager registerStoreData
INFO: Managing Persistence of Class : org.datanucleus.test.MyClass [Table : "_myclass", InheritanceStrategy : new-table]
Sep 21, 2010 12:29:05 PM org.datanucleus.test.Main main
INFO: >> Exception thrown persisting objects : Exception thrown while querying indices for table=_myclass
javax.jdo.JDODataStoreException: Exception thrown while querying indices for table=_myclass
at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:319)
at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:668)
at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:688)
at org.datanucleus.test.Main.main(Main.java:27)
NestedThrowablesStackTrace:
java.sql.SQLException: Invalid argument(s) in call
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:190)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:286)
at oracle.jdbc.OracleDatabaseMetaData.getIndexInfo(OracleDatabaseMetaData.java:4884)
at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getRDBMSTableIndexInfoForTable(RDBMSSchemaHandler.java:616)
at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getRDBMSTableIndexInfoForTable(RDBMSSchemaHandler.java:585)
at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getSchemaData(RDBMSSchemaHandler.java:202)
at org.datanucleus.store.rdbms.table.TableImpl.getExistingCandidateKeys(TableImpl.java:1099)
at org.datanucleus.store.rdbms.table.TableImpl.validateCandidateKeys(TableImpl.java:698)
at org.datanucleus.store.rdbms.table.TableImpl.validateConstraints(TableImpl.java:400)
at org.datanucleus.store.rdbms.table.ClassTable.validateConstraints(ClassTable.java:3298)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.performTablesValidation(RDBMSStoreManager.java:2816)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.addClassTablesAndValidate(RDBMSStoreManager.java:2546)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.run(RDBMSStoreManager.java:2191)
at org.datanucleus.store.rdbms.AbstractSchemaTransaction.execute(AbstractSchemaTransaction.java:113)
at org.datanucleus.store.rdbms.RDBMSStoreManager.addClasses(RDBMSStoreManager.java:966)
at org.datanucleus.store.AbstractStoreManager.addClass(AbstractStoreManager.java:914)
at org.datanucleus.store.mapped.MappedStoreManager.getDatastoreClass(MappedStoreManager.java:356)
at org.datanucleus.store.rdbms.RDBMSStoreManager.getPropertiesForGenerator(RDBMSStoreManager.java:1468)
at org.datanucleus.store.AbstractStoreManager.getStrategyValue(AbstractStoreManager.java:1282)
at org.datanucleus.jdo.state.JDOStateManagerImpl.populateStrategyFields(JDOStateManagerImpl.java:784)
at org.datanucleus.jdo.state.JDOStateManagerImpl.initialiseForPersistentNew(JDOStateManagerImpl.java:416)
at org.datanucleus.state.StateManagerFactory.newStateManagerForPersistentNew(StateManagerFactory.java:152)
at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1453)
at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1281)
at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:663)
at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:688)
at org.datanucleus.test.Main.main(Main.java:27)

Andy Jefferson added a comment - 21/Sep/10 01:39 PM
Well you don't state what version of Oracle, or its O/S. I'm on Oracle 10.2 XE on Linux. Maybe on Windows it introduces platform-specific case sensitivity nonsense ?

Andy Jefferson added a comment - 21/Sep/10 02:06 PM
Also you don't define if you provided the catalog/schema names to DataNucleus. If you have multiple schemas then you ought to

Giambattista Bloisi added a comment - 21/Sep/10 02:10 PM
My oracle server is installed on linux too (Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production).
My understanding of the problem is that Oracle JDBC driver getIndexInfo implementation statically checks table names before performing any actions on the server. So if the name is a reserved keyword or does not matches the "[a-zA-Z]{1}\\w*(\\$|\\#)*\\w*" regexp pattern, it throws that exception.
I think I should be able to isolate that in JDBC-only test case: may be this of help?

Giambattista Bloisi added a comment - 21/Sep/10 04:59 PM
I just realized that the exception is not thrown the first time the test is launched. The exception is only thrown when the index is already existing.
This test performs the same action twice. The second time the index is already existing and so the exception is thrown.

Giambattista Bloisi made changes - 21/Sep/10 04:59 PM
Attachment NUCRDBMS-442-2.zip [ 11252 ]
Giambattista Bloisi made changes - 21/Sep/10 04:59 PM
Attachment NUCRDBMS-442.zip [ 11250 ]
Andy Jefferson added a comment - 21/Sep/10 05:29 PM
Reproduced when running test twice with my version of Oracle, and fix committed. Thx

Andy Jefferson made changes - 21/Sep/10 05:29 PM
Status Open [ 1 ] Resolved [ 5 ]
Assignee Andy Jefferson [ andy ]
Fix Version/s 2.2.0.m2 [ 11023 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 20/Oct/10 09:30 AM
Status Resolved [ 5 ] Closed [ 6 ]