Thread: DatabaseMetaData.getImportedKeys returning duplicate rows
I am having a problem with the DatabaseMetaData.getImportedKeys() function. I am asking for the keys with respect to a specific table. All is fine, except when I have two columns in a table that are both foreign keys to another table, ie: Table A Table B ------- ------- col1 -----------pk col2 -----------/ The ResultSet returned from getImportedKeys is structured: col1 col2 col1 col2 If I execute the query that is generated behind the scenes in the psql command-line program, adding the DISTINCT keyword to the query causes it to return the proper number of rows. Is that a valid fix, or will that break something else? Should the duplicate-reduction be done inside the java code that creates the ResultSet? I have no problem making the fix, I just don't know enough about the jdbc internals (nor postgres itself, I'm a new user) to be confident enough to know exactly *what* to fix. Anyways great work thus far, I look forward to helping improve the driver! -pete -- peter royal -> proyal@pace2020.com
Anyone? Is a specific testcase needed? Is no-one else using this metadata? thanks. -pete On Monday, March 3, 2003, at 09:27 PM, Peter Royal wrote: > I am having a problem with the DatabaseMetaData.getImportedKeys() > function. I am asking for the keys with respect to a specific table. > All is fine, except when I have two columns in a table that are both > foreign keys to another table, ie: > > Table A Table B > ------- ------- > col1 -----------pk > col2 -----------/ > > The ResultSet returned from getImportedKeys is structured: > > col1 > col2 > col1 > col2 > > If I execute the query that is generated behind the scenes in the psql > command-line program, adding the DISTINCT keyword to the query causes > it to return the proper number of rows. Is that a valid fix, or will > that break something else? Should the duplicate-reduction be done > inside the java code that creates the ResultSet? I have no problem > making the fix, I just don't know enough about the jdbc internals (nor > postgres itself, I'm a new user) to be confident enough to know > exactly *what* to fix. > > Anyways great work thus far, I look forward to helping improve the > driver! > -pete > > -- > peter royal -> proyal@pace2020.com > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >
Peter, I didn't see your first message ?? Yes this is a valid fix. Dave On Sun, 2003-03-16 at 21:39, Peter Royal wrote: > Anyone? Is a specific testcase needed? Is no-one else using this > metadata? > thanks. > -pete > > On Monday, March 3, 2003, at 09:27 PM, Peter Royal wrote: > > > I am having a problem with the DatabaseMetaData.getImportedKeys() > > function. I am asking for the keys with respect to a specific table. > > All is fine, except when I have two columns in a table that are both > > foreign keys to another table, ie: > > > > Table A Table B > > ------- ------- > > col1 -----------pk > > col2 -----------/ > > > > The ResultSet returned from getImportedKeys is structured: > > > > col1 > > col2 > > col1 > > col2 > > > > If I execute the query that is generated behind the scenes in the psql > > command-line program, adding the DISTINCT keyword to the query causes > > it to return the proper number of rows. Is that a valid fix, or will > > that break something else? Should the duplicate-reduction be done > > inside the java code that creates the ResultSet? I have no problem > > making the fix, I just don't know enough about the jdbc internals (nor > > postgres itself, I'm a new user) to be confident enough to know > > exactly *what* to fix. > > > > Anyways great work thus far, I look forward to helping improve the > > driver! > > -pete > > > > -- > > peter royal -> proyal@pace2020.com > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) -- Dave Cramer <davec@fastcrypt.com> Cramer Consulting -- Dave Cramer <Dave@micro-automation.net>
On Monday, March 17, 2003, at 04:07 AM, Dave Cramer wrote: > I didn't see your first message ?? I got a copy back when I sent it.. but it was the first message I had sent since subscribing. o well. > Yes this is a valid fix. Thanks. Should I submit a patch for this, since it is a trivial one-line change. -pete > > Dave > On Sun, 2003-03-16 at 21:39, Peter Royal wrote: >> Anyone? Is a specific testcase needed? Is no-one else using this >> metadata? >> thanks. >> -pete >> >> On Monday, March 3, 2003, at 09:27 PM, Peter Royal wrote: >> >>> I am having a problem with the DatabaseMetaData.getImportedKeys() >>> function. I am asking for the keys with respect to a specific table. >>> All is fine, except when I have two columns in a table that are both >>> foreign keys to another table, ie: >>> >>> Table A Table B >>> ------- ------- >>> col1 -----------pk >>> col2 -----------/ >>> >>> The ResultSet returned from getImportedKeys is structured: >>> >>> col1 >>> col2 >>> col1 >>> col2 >>> >>> If I execute the query that is generated behind the scenes in the >>> psql >>> command-line program, adding the DISTINCT keyword to the query causes >>> it to return the proper number of rows. Is that a valid fix, or will >>> that break something else? Should the duplicate-reduction be done >>> inside the java code that creates the ResultSet? I have no problem >>> making the fix, I just don't know enough about the jdbc internals >>> (nor >>> postgres itself, I'm a new user) to be confident enough to know >>> exactly *what* to fix. >>> >>> Anyways great work thus far, I look forward to helping improve the >>> driver! >>> -pete >>> >>> -- >>> peter royal -> proyal@pace2020.com >>> >>> >>> ---------------------------(end of >>> broadcast)--------------------------- >>> TIP 4: Don't 'kill -9' the postmaster >>> >> >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to >> majordomo@postgresql.org) > -- > Dave Cramer <davec@fastcrypt.com> > Cramer Consulting > -- > Dave Cramer <Dave@micro-automation.net> > > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to > majordomo@postgresql.org) >
Peter, I didn't see your first message ?? Yes this is a valid fix. Dave On Sun, 2003-03-16 at 21:39, Peter Royal wrote: > Anyone? Is a specific testcase needed? Is no-one else using this > metadata? > thanks. > -pete > > On Monday, March 3, 2003, at 09:27 PM, Peter Royal wrote: > > > I am having a problem with the DatabaseMetaData.getImportedKeys() > > function. I am asking for the keys with respect to a specific table. > > All is fine, except when I have two columns in a table that are both > > foreign keys to another table, ie: > > > > Table A Table B > > ------- ------- > > col1 -----------pk > > col2 -----------/ > > > > The ResultSet returned from getImportedKeys is structured: > > > > col1 > > col2 > > col1 > > col2 > > > > If I execute the query that is generated behind the scenes in the psql > > command-line program, adding the DISTINCT keyword to the query causes > > it to return the proper number of rows. Is that a valid fix, or will > > that break something else? Should the duplicate-reduction be done > > inside the java code that creates the ResultSet? I have no problem > > making the fix, I just don't know enough about the jdbc internals (nor > > postgres itself, I'm a new user) to be confident enough to know > > exactly *what* to fix. > > > > Anyways great work thus far, I look forward to helping improve the > > driver! > > -pete > > > > -- > > peter royal -> proyal@pace2020.com > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) -- Dave Cramer <davec@fastcrypt.com> Cramer Consulting
Patch applied, to 7.2.3, and HEAD Thanks, Dave On Mon, 2003-03-17 at 10:53, Peter Royal wrote: > On Monday, March 17, 2003, at 04:07 AM, Dave Cramer wrote: > > I didn't see your first message ?? > > I got a copy back when I sent it.. but it was the first message I had > sent since subscribing. o well. > > > Yes this is a valid fix. > > Thanks. Should I submit a patch for this, since it is a trivial > one-line change. > -pete > > > > > Dave > > On Sun, 2003-03-16 at 21:39, Peter Royal wrote: > >> Anyone? Is a specific testcase needed? Is no-one else using this > >> metadata? > >> thanks. > >> -pete > >> > >> On Monday, March 3, 2003, at 09:27 PM, Peter Royal wrote: > >> > >>> I am having a problem with the DatabaseMetaData.getImportedKeys() > >>> function. I am asking for the keys with respect to a specific table. > >>> All is fine, except when I have two columns in a table that are both > >>> foreign keys to another table, ie: > >>> > >>> Table A Table B > >>> ------- ------- > >>> col1 -----------pk > >>> col2 -----------/ > >>> > >>> The ResultSet returned from getImportedKeys is structured: > >>> > >>> col1 > >>> col2 > >>> col1 > >>> col2 > >>> > >>> If I execute the query that is generated behind the scenes in the > >>> psql > >>> command-line program, adding the DISTINCT keyword to the query causes > >>> it to return the proper number of rows. Is that a valid fix, or will > >>> that break something else? Should the duplicate-reduction be done > >>> inside the java code that creates the ResultSet? I have no problem > >>> making the fix, I just don't know enough about the jdbc internals > >>> (nor > >>> postgres itself, I'm a new user) to be confident enough to know > >>> exactly *what* to fix. > >>> > >>> Anyways great work thus far, I look forward to helping improve the > >>> driver! > >>> -pete > >>> > >>> -- > >>> peter royal -> proyal@pace2020.com > >>> > >>> > >>> ---------------------------(end of > >>> broadcast)--------------------------- > >>> TIP 4: Don't 'kill -9' the postmaster > >>> > >> > >> > >> ---------------------------(end of > >> broadcast)--------------------------- > >> TIP 2: you can get off all lists at once with the unregister command > >> (send "unregister YourEmailAddressHere" to > >> majordomo@postgresql.org) > > -- > > Dave Cramer <davec@fastcrypt.com> > > Cramer Consulting > > -- > > Dave Cramer <Dave@micro-automation.net> > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to > > majordomo@postgresql.org) > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Dave Cramer <davec@fastcrypt.com> Cramer Consulting -- Dave Cramer <Dave@micro-automation.net>
Patch applied, to 7.2.3, and HEAD Thanks, Dave On Mon, 2003-03-17 at 10:53, Peter Royal wrote: > On Monday, March 17, 2003, at 04:07 AM, Dave Cramer wrote: > > I didn't see your first message ?? > > I got a copy back when I sent it.. but it was the first message I had > sent since subscribing. o well. > > > Yes this is a valid fix. > > Thanks. Should I submit a patch for this, since it is a trivial > one-line change. > -pete > > > > > Dave > > On Sun, 2003-03-16 at 21:39, Peter Royal wrote: > >> Anyone? Is a specific testcase needed? Is no-one else using this > >> metadata? > >> thanks. > >> -pete > >> > >> On Monday, March 3, 2003, at 09:27 PM, Peter Royal wrote: > >> > >>> I am having a problem with the DatabaseMetaData.getImportedKeys() > >>> function. I am asking for the keys with respect to a specific table. > >>> All is fine, except when I have two columns in a table that are both > >>> foreign keys to another table, ie: > >>> > >>> Table A Table B > >>> ------- ------- > >>> col1 -----------pk > >>> col2 -----------/ > >>> > >>> The ResultSet returned from getImportedKeys is structured: > >>> > >>> col1 > >>> col2 > >>> col1 > >>> col2 > >>> > >>> If I execute the query that is generated behind the scenes in the > >>> psql > >>> command-line program, adding the DISTINCT keyword to the query causes > >>> it to return the proper number of rows. Is that a valid fix, or will > >>> that break something else? Should the duplicate-reduction be done > >>> inside the java code that creates the ResultSet? I have no problem > >>> making the fix, I just don't know enough about the jdbc internals > >>> (nor > >>> postgres itself, I'm a new user) to be confident enough to know > >>> exactly *what* to fix. > >>> > >>> Anyways great work thus far, I look forward to helping improve the > >>> driver! > >>> -pete > >>> > >>> -- > >>> peter royal -> proyal@pace2020.com > >>> > >>> > >>> ---------------------------(end of > >>> broadcast)--------------------------- > >>> TIP 4: Don't 'kill -9' the postmaster > >>> > >> > >> > >> ---------------------------(end of > >> broadcast)--------------------------- > >> TIP 2: you can get off all lists at once with the unregister command > >> (send "unregister YourEmailAddressHere" to > >> majordomo@postgresql.org) > > -- > > Dave Cramer <davec@fastcrypt.com> > > Cramer Consulting > > -- > > Dave Cramer <Dave@micro-automation.net> > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to > > majordomo@postgresql.org) > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Dave Cramer <davec@fastcrypt.com> Cramer Consulting