On Fri, Oct 26, 2001 at 09:52:11AM -0700, Barry Lind wrote:
Jason,
Can you explain what this patch is attempting to fix? Given that we are
in beta with 7.2, I want to fully understand the problem here before
applying this patch. (Especially given that the diff is pretty large and
not a one or two line change).
I guess fix is slightly misleading. This patch implements
DatabaseMetaData.getExportedKeys() which was previously not implemented, and provides
a better implementation of DatabaseMetaData.getImportedKeys() which was previously
half-implemented.
The methods are identical for both jdbc1 and jdbc2 so that's why the diff is quite
large. Perhaps identical code should be put into a single class and have the code
which differs in jdbc1 and jdbc2 in subclasses?
Also what testing have you done on this? (When you ask us to 'check
that it works', it doesn't give me a high level of confidence that this
is well tested).
:-) I have tested it but only with 7.1.3 at the moment. What I meant to say is please
:check in case something major has been changed in 7.2. Also if the queries I'm using
:can be optimized in any way that would be great.
At the moment a value for PK_NAME (primary key name) is not returned but the main part
is implemented.
Sorry for the lack of info, I'll try and be more helpful next time :)
Jason Davies
thanks,
--Barry
Jason Davies wrote:
Hi,
Here is a diff for DatabaseMetaData.getImportedKeys() and
DatabaseMetaData.getExportedKeys(). Please check that it works :)
Thanks,
Jason Davies
[EMAIL PROTECTED]
Index: jdbc1/DatabaseMetaData.java
===
RCS file:
/projects/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java,v
retrieving revision 1.35
diff -c -r1.35 DatabaseMetaData.java
*** jdbc1/DatabaseMetaData.java 2001/10/25 05:59:59 1.35
--- jdbc1/DatabaseMetaData.java 2001/10/26 01:21:02
***
*** 2260,2345
);
}
! private void importLoop(Vector tuples, java.sql.ResultSet keyRelation) throws
SQLException
! {
! String s, s2;
! String origTable = null, primTable = new String(), schema;
! int i;
! Vector v = new Vector();
!
! s = keyRelation.getString(1);
! s2 = s;
! //System.out.println(s);
!
! for (i = 0;;i++)
! {
! s = s.substring(s.indexOf(\\000) + 4);
! if (s.compareTo() == 0)
! {
! //System.out.println();
! break;
! }
! s2 = s.substring(0, s.indexOf(\\000));
! switch (i)
! {
! case 0:
! origTable = s2;
! break;
! case 1:
! primTable = s2;
! break;
! case 2:
! schema = s2;
! break;
! default:
! v.addElement(s2);
! }
! }
!
! java.sql.ResultSet rstmp = connection.ExecSQL(select * from +
origTable + where 1=0);
! java.sql.ResultSetMetaData origCols = rstmp.getMetaData();
!
! String stmp;
! // Vector tuples=new Vector();
! byte tuple[][];
!
! // the foreign keys are only on even positions in the Vector.
! for (i = 0;i v.size();i += 2)
{
! stmp = (String)v.elementAt(i);
!
! for (int j = 1;j = origCols.getColumnCount();j++)
{
! if (stmp.compareTo(origCols.getColumnName(j)) == 0)
{
! tuple = new byte[14][0];
!
! for (int k = 0;k 14;k++)
! tuple[k] = null;
!
! //PKTABLE_NAME
! tuple[2] = primTable.getBytes();
! //PKTABLE_COLUMN
! stmp = (String)v.elementAt(i + 1);
! tuple[3] = stmp.getBytes();
! //FKTABLE_NAME
! tuple[6] = origTable.getBytes();
! //FKCOLUMN_NAME
! tuple[7] =
origCols.getColumnName(j).getBytes