Bug in getImportedExportedKeys(), DatabaseMetaData class
От | Todd Cornett |
---|---|
Тема | Bug in getImportedExportedKeys(), DatabaseMetaData class |
Дата | |
Msg-id | 3E93040E.B57AFE@mitre.org обсуждение исходный текст |
Ответы |
Re: Bug in getImportedExportedKeys(), DatabaseMetaData class
|
Список | pgsql-jdbc |
All: In our work with PostgreSQL 7.3.2 and the JDBC drivers, we have discovered a bug in the DatabaseMetaData class, or more specifically the AbstractJdbc1DatabaseMetaData class in the getImportedExportedKeys() (about line number 3100) . We found that the current use of the StringTokenizer to parse out the response from the database acheieves the desired result only when the returning column and table names do not contain either '\' or '0'. We believe that the intent was to treat the string parameter as a literal string and not as a collection of characters, as Java interprets it. To fix this, we used the split function, available in JDK1.4, to split the string. The sample of the code is attached below. Unfortunately, this fix only works in JDK1.4 but hopefully this will fix someone's problem if they come across it or at least bring it to the attention of the development team. Thank you for your time, Todd Cornett The MITRE Corporation /***********************************************/ // args look like this //<unnamed>\000ww\000vv\000UNSPECIFIED\000m\000a\000n\000b\000 // we are primarily interested in the column names which are the last items in the string // StringTokenizer st = new StringTokenizer(targs, "\\000"); String[] str_array = targs.split( "\\\\000" ); int advance = 4 + (keySequence - 1) * 2; /* for ( int i = 0; st.hasMoreTokens() && i < advance ; i++ ) { st.nextToken(); // advance to the key column of interest } if ( st.hasMoreTokens() ) { fkeyColumn = st.nextToken(); } if ( st.hasMoreTokens() ) { pkeyColumn = st.nextToken(); } */ if( str_array.length >= advance ) { fkeyColumn = str_array[ advance ]; if( str_array.length >= ( advance + 1 ) ) { pkeyColumn = str_array[ advance + 1 ]; } } tuple[3] = pkeyColumn.getBytes(); //PKCOLUMN_NAME tuple[7] = fkeyColumn.getBytes(); //FKCOLUMN_NAME
В списке pgsql-jdbc по дате отправления: