Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V6F6M-00009f-NI for pgsql-jdbc@arkaria.postgresql.org; Mon, 05 Aug 2013 07:21:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V6F6M-000378-68 for pgsql-jdbc@arkaria.postgresql.org; Mon, 05 Aug 2013 07:21:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V6F6K-00035b-Eu for pgsql-jdbc@postgresql.org; Mon, 05 Aug 2013 07:21:08 +0000 Received: from 9.mo5.mail-out.ovh.net ([178.32.96.204] helo=mo5.mail-out.ovh.net) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V6F6G-0002EG-V6 for pgsql-jdbc@postgresql.org; Mon, 05 Aug 2013 07:21:08 +0000 Received: from mail629.ha.ovh.net (gw6.ovh.net [213.251.189.206]) by mo5.mail-out.ovh.net (Postfix) with SMTP id 9D927104C0F7 for ; Mon, 5 Aug 2013 09:21:00 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 5 Aug 2013 09:22:03 +0200 Received: from 89-156-201-190.rev.numericable.fr (HELO ?192.168.28.52?) (sylvain%ilm-informatique.fr@89.156.201.190) by ns0.ovh.net with SMTP; 5 Aug 2013 09:22:02 +0200 Message-ID: <51FF5259.1050003@ilm-informatique.fr> Date: Mon, 05 Aug 2013 09:20:57 +0200 From: Sylvain Cuaz User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org X-Ovh-Mailout: 178.32.228.5 (mo5.mail-out.ovh.net) Subject: Re: DatabaseMetaData getImportedKeys() order References: <51ED4DBC.7020307@ilm-informatique.fr> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 5952069858219143026 X-Ovh-Remote: 89.156.201.190 (89-156-201-190.rev.numericable.fr) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: 50 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeijedrieejucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecuogetvdelhedqtdekucdlhedtmd X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 50 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeijedrieejucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecuogetvdelhedqtdekucdlhedtmd X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Le 29/07/2013 15:46, Dave Cramer a écrit : > Sylvain, > > I made the changes and added this test case > > https://github.com/davecramer/pgjdbc/compare/REL9_2_STABLE, can you check > it to see if it makes sense ? Your patch isn't right : the first pos.n must be removed so that the order is "nspname,relname,con.conname,pos.n". Your test doesn't use the order so it works equally before and after the patch. Replace the for loop with this snippet : final List fkNames = new ArrayList(); int lastFieldCount = -1; while (rs.next()) { // destination table (all foreign keys point to the same) String pkTableName = rs.getString("PKTABLE_NAME"); assertEquals(tableName, pkTableName); // destination fields String pkColumnName = rs.getString("PKCOLUMN_NAME"); assertTrue("FIRST_NAME".equals(pkColumnName) || "LAST_NAME".equals(pkColumnName)); // source table (all foreign keys are in the same) String fkTableName = rs.getString("FKTABLE_NAME"); assertEquals(tableName, fkTableName); // foreign key name String fkName = rs.getString("FK_NAME"); // sequence number within the foreign key int seq = rs.getInt("KEY_SEQ"); if (seq == 1) { // begin new foreign key assertFalse(fkNames.contains(fkName)); fkNames.add(fkName); // all foreign keys have 2 fields assertTrue(lastFieldCount < 0 || lastFieldCount == 2); } else { // continue foreign key, i.e. fkName matches the last foreign key assertEquals(fkNames.get(fkNames.size() - 1), fkName); // seq always increases by 1 assertTrue(seq == lastFieldCount + 1); } lastFieldCount = seq; } // there's more than one foreign key from a table to another assertEquals(2, fkNames.size()); Cheers, Sylvain -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc