[ https://issues.apache.org/jira/browse/DERBY-3181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15271696#comment-15271696 ]
Bryan Pendleton commented on DERBY-3181: ---------------------------------------- I had completely misunderstood that this job involved the behavior when the "scope" argument was invalid -- thanks for pointing that out! Frankly, I don't understand why we are returning a ResultSet at all when the scope is invalid. Why not throw a SQLException instead? I looked through the Subversion history, and that behavior of getBestRowIdentifier is present in the original version of EmbedDatabaseMetaData.java in the original contribution from IBM. So this is very old behavior. It would be interesting, though, to try this experiment: 1) Try changing EmbedDatabaseMetaData.getBestRowIdentifier to throw a SQLException if the scope is out of range, rather than executing getBestRowIdentifierEmpty 2) Run all the regression tests (ant junit-core) and see if any of the regression tests fails due to this change That might give us some clues about which sorts of applications, if any, depend on being able to call getBestRowIdentifier with an invalid scope value. > isNullable on ResultSetMetaData from DatabaseMetaData.getBestRowIdentifier > values are opposite when there is no rows in ResultSet vs. when there is a > row. > ---------------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: DERBY-3181 > URL: https://issues.apache.org/jira/browse/DERBY-3181 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.4.1.3 > Reporter: Myrna van Lunteren > Assignee: Danoja Dias > Priority: Trivial > Labels: derby_triage10_5_2 > Attachments: repro.java > > > With code like the following: > DatabaseMetaData dmd = conn.getMetaData(); > ResultSet rs = dmd.getBestRowIdentifier(null,"APP","a",3,true); > ResultSetMetaData rsmd = rs.getMetaData(); > int actualCols = rsmd.getColumnCount(); > for (int i = 0; i < actualCols; i++) > { > System.out.print("getColumnName: " + rsmd.getColumnName(i+1) > + ", isNullable: "); > System.out.println(rsmd.isNullable(i+1)); > } > The printed values for isNullable returned are opposite of what they are when > the getBestRowIdentifier call looks like this: > ResultSet rs = dmd.getBestRowIdentifier(null,"APP","a",1,true); > In the latter case, the values are: > getColumnName: SCOPE, isNullable: 0 > getColumnName: COLUMN_NAME, isNullable: 1 > getColumnName: DATA_TYPE, isNullable: 0 > getColumnName: TYPE_NAME, isNullable: 1 > getColumnName: COLUMN_SIZE, isNullable: 0 > getColumnName: BUFFER_LENGTH, isNullable: 0 > getColumnName: DECIMAL_DIGITS, isNullable: 0 > getColumnName: PSEUDO_COLUMN, isNullable: 0 > In the first case, the values are: > getColumnName: SCOPE, isNullable: 1 > getColumnName: COLUMN_NAME, isNullable: 0 > getColumnName: DATA_TYPE, isNullable: 1 > getColumnName: TYPE_NAME, isNullable: 1 > getColumnName: COLUMN_SIZE, isNullable: 1 > getColumnName: BUFFER_LENGTH, isNullable: 1 > getColumnName: DECIMAL_DIGITS, isNullable: 1 > getColumnName: PSEUDO_COLUMN, isNullable: 1 > The isNullable value should be stable. > It's probably worthwhile verifying what the value *should* be in the first > place. -- This message was sent by Atlassian JIRA (v6.3.4#6332)