Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMTwN-0005u7-4r for pgsql-jdbc@postgresql.org; Fri, 12 Oct 2012 01:21:27 +0000 Received: from mail-pb0-f46.google.com ([209.85.160.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMTwH-00024K-VY for pgsql-jdbc@postgresql.org; Fri, 12 Oct 2012 01:21:26 +0000 Received: by mail-pb0-f46.google.com with SMTP id rr4so2419786pbb.19 for ; Thu, 11 Oct 2012 18:21:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:x-gm-message-state; bh=ZNPodKY0xzOze9Ro09PWaMdxOr2+qZSudK15bF9Rwsk=; b=TNorF3kM6RwBV+80jJj9vQSzqVV4Mtf9OrutWIC8uYUcPj9vTjZ5m4M9s9fJJHqFtJ F6Rdw4jHjmd/XV0QExaEzRbcGBzqJoafaPnQN8D2zuvcvgiY/cIF9Sj8YHyXuMmCPueS Doer8P5qN8TZeE3GmoBnrdq2qAeyMTvsxvmjwstdZnBU6kvhaoJfIj2ErcAvUDnKpLuM XbD+N3el+tYNOtTWw+ME6Xq4pNIfpb95aSrAREBOgMOo9yjCDLo/GiAWLzNJn8HA5dfE ohy0pLv1+8BVSzOzxvfaHjJCHYCyJ9TceJemB6Y8pKzqloWDLcx5FFJE/mltT2LXlOIF VTyA== Received: by 10.68.204.137 with SMTP id ky9mr8835065pbc.90.1350004878940; Thu, 11 Oct 2012 18:21:18 -0700 (PDT) Received: from ayaki.localdomain ([211.29.169.132]) by mx.google.com with ESMTPS id pw2sm3547449pbb.59.2012.10.11.18.21.07 (version=SSLv3 cipher=OTHER); Thu, 11 Oct 2012 18:21:18 -0700 (PDT) Message-ID: <5077707F.6090502@ringerc.id.au> Date: Fri, 12 Oct 2012 09:21:03 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Thor_Michael_St=F8re?= CC: pgsql-jdbc@postgresql.org Subject: Re: ResultSetMetaData.isNullable(i) and outer joined columns References: <63DBC81F-2AB0-4C02-AC08-2B05C31FFCA6@gmail.com> In-Reply-To: <63DBC81F-2AB0-4C02-AC08-2B05C31FFCA6@gmail.com> Content-Type: multipart/alternative; boundary="------------030805060506000005000107" X-Gm-Message-State: ALoCoQmcamW/8XE8caOIs9Ejq4RlZXqsIPnrZ3dXD8z+pOgPfouwH2b22Yu3Aze+pCJGA31onaj6 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/51 X-Sequence-Number: 23375 This is a multi-part message in MIME format. --------------030805060506000005000107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit On 10/12/2012 01:25 AM, Thor Michael Støre wrote: > Hello, > > I've just noticed that ResultSetMetaData.isNullable(/i/) in the > PostgreSQL JDBC driver doesn't reflect whether fields of result set > column /i/ may be null, but the nullability of the table column it's > selected from. These may differ for result set columns that originate > from a outer joined table, in which case fields may of course be null > even if the source table column is not nullable, but in such cases > isNullable still indicates the column is not nullable. Surely this > isn't right? > > http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html#isNullable(int) > > > Although the spec doesn't explicitly distinguish between result set > and source table only the former seems sensible to me -- what I expect > the isNullable return value to reflect is whether an invocation of the > ResultSet.getXXX(/i/) methods always returns an object (or sensible > primitive), if they may return null or if that's unknown. It'll be interesting to see how other major vendors' drivers handle this. Thanks for the test case; I'll try to find some other DBs to run it on. -- Craig Ringer --------------030805060506000005000107 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 10/12/2012 01:25 AM, Thor Michael Støre wrote:
Hello,

I've just noticed that ResultSetMetaData.isNullable(i) in the PostgreSQL JDBC driver doesn't reflect whether fields of result set column i may be null, but the nullability of the table column it's selected from. These may differ for result set columns that originate from a outer joined table, in which case fields may of course be null even if the source table column is not nullable, but in such cases isNullable still indicates the column is not nullable. Surely this isn't right?


Although the spec doesn't explicitly distinguish between result set and source table only the former seems sensible to me -- what I expect the isNullable return value to reflect is whether an invocation of the ResultSet.getXXX(i) methods always returns an object (or sensible primitive), if they may return null or if that's unknown.

It'll be interesting to see how other major vendors' drivers handle this.

Thanks for the test case; I'll try to find some other DBs to run it on.

--
Craig Ringer
--------------030805060506000005000107--