google-code-export / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

NullPointerException in IndexCondition.getMask() when source is FunctionTable #323

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The getMask method in IndexCondition is vulnerable to a NullPointerException if 
the table returns null for getTableType().  FunctionTables always return null.

What steps will reproduce the problem?
1. Test Function Table
public static ResultSet sqlIndexConditionOnFunctionTable(Connection con) throws 
SQLException {
  SimpleResultSet result = new SimpleResultSet();
  result.addColumn("A", Types.INTEGER, 0, 0);        
  result.addColumn("B", Types.CHAR, 0, 0);           
  result.addRow(42, 'X');                                
  return result;        
}

2. CREATE ALIAS TESTINDEX FOR 
"org.h2.test.db.TestIndex.sqlIndexConditionOnFunctionTable";

3. SELECT * FROM TESTINDEX() WHERE A>0 AND B IN ('X', 'Y');

What is the expected output? What do you see instead?
I expect a result set.  A NullPointerException is thrown instead.

H2 Version: 1.3.155

Operating System: Linux dustbowl 2.6.35-28-generic #50-Ubuntu SMP Fri Mar 18 
18:42:20 UTC 2011 x86_64 GNU/Linux

Do you know a workaround?
No, had to create a patch.  FunctionTable always returns null for 
getTableType().

What is your use case, meaning why do you need this feature?
FunctionTables are critical to how I am accessing my application's data.

How important/urgent is the problem for you?
Important enough that I'm providing a patch and test.

Original issue reported on code.google.com by josephalevin on 14 Jun 2011 at 7:11

Attachments:

GoogleCodeExporter commented 9 years ago
Remade the patch file.  First attempt had an unused import.

Original comment by josephalevin on 14 Jun 2011 at 7:13

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by thomas.t...@gmail.com on 17 Jun 2011 at 10:48

GoogleCodeExporter commented 9 years ago
Fixed in version 1.3.157

Original comment by thomas.t...@gmail.com on 25 Jun 2011 at 1:10