Hi, Thanks for the patch! It looks good, I will commit it.
Regards, Thomas On Saturday, April 18, 2015, Jared White <[email protected]> wrote: > Greetings, > > When a LinkedTable is defined to point to a table in Oracle with a > function-based index, H2 throws a NullPointerException when attempting to > model that index as a LinkedIndex. > > The problem is that a column reported > by OracleDatabaseMetaData.getIndexInfo for this index is system-generated > (e.g. "SYS_NC00021$"), which is not among the table's columns, so the > column map returns null for this column. > > As best as I can tell, a function-based index is reported through > DatabaseMetaData exactly like a regular index, so they can't be filtered > out directly (as H2 does with tableIndexStatistic). > > I suppose entire index can be skipped if it contains a null column, but I > propose the following optimization to take advantage of any leading columns > we do recognize: > > // in class TableLink > > private void addIndex(List<Column> list, IndexType indexType) { > > // bind the index to the leading recognized columns in the index > // null columns might come from a function-based index > int firstNull = list.indexOf(null); > if (firstNull == 0) { > trace.info("Omitting linked index - prefix has no recognized > columns."); > return; > } else if (firstNull > 0) { > trace.info("Unrecognized columns in linked index. Registering the > index against the leading {0} recognized columns of {1} total columns.", > firstNull, list.size()); > list = list.subList(0, firstNull); > } > > Column[] cols = new Column[list.size()]; > list.toArray(cols); > Index index = new LinkedIndex(this, 0, IndexColumn.wrap(cols), > indexType); > indexes.add(index); > } > > > Hopefully this generalizes well enough for other databases, but there may > be desirable null columns I don't have an intuition about. > > Thank you for considering this bug report and proposed solution. I look > forward to discussion and feedback from the community. > > Yours, > > Jared > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
