Thread: isNullable()

isNullable()

From
Tomisław Kityński
Date:
Hello there,

could someone tell me, please, do I have any chance to get
proper implementation of above method in JDBC (1.1+) soon?

Current "return 1" works fine on most tables, however it seems
to be a little bit incorrect with some of them ;)

--
===] Internet Designers SA, Programming Dept., senior programmer [===
 ==] ul. Przedmiejska 6--10, 54-201 Wrocław,   http://www.id.pl/ [==
  =] tel: 0048-71-350-04-45-(42) [=    =] fax: 0048-71-373-59-46 [=




Re: isNullable()

From
Rene Pijlman
Date:
On Fri, 14 Sep 2001 17:53:50 +0200, you wrote:
>could someone tell me, please, do I have any chance to get
>proper implementation of above method in JDBC (1.1+) soon?

This is a volunteer project. You don't "get", you "bring" :-)

>Current "return 1" works fine on most tables, however it seems
>to be a little bit incorrect with some of them ;)

ResultSetMetaData.isNullable() is currently unimplemented and
always returns ResultSetMetaData.columnNullable. This is
obviously incorrect when a column is defined with NOT NULL or
PRIMARY KEY. And we have to think of check constraints, views,
functions etc.

I propose to change it to return
ResultSetMetaData.columnNullableUnknown until someone comes up
with a real implementation.

Any objections?

Regards,
René Pijlman <rene@lab.applinet.nl>

Re: isNullable()

From
Rene Pijlman
Date:
Attached is a patch that fixes ResultSetMetaData.isNullable() in
the JDBC driver.

This method is currently unimplemented and always returns
ResultSetMetaData.columnNullable. This is obviously incorrect
when a column is defined with NOT NULL or PRIMARY KEY. And we
have to think of check constraints, views, functions etc.

The patch simply changes the return value to
ResultSetMetaData.columnNullableUnknown. This is until someone
comes up with a real implementation of course.

On Fri, 14 Sep 2001 17:53:50 +0200, Tomisaw Kityñski wrote:
>Hello there,
>
>could someone tell me, please, do I have any chance to get
>proper implementation of above method in JDBC (1.1+) soon?
>
>Current "return 1" works fine on most tables, however it seems
>to be a little bit incorrect with some of them ;)


Regards,
René Pijlman <rene@lab.applinet.nl>

Attachment

Re: isNullable()

From
Bruce Momjian
Date:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> Attached is a patch that fixes ResultSetMetaData.isNullable() in
> the JDBC driver.
>
> This method is currently unimplemented and always returns
> ResultSetMetaData.columnNullable. This is obviously incorrect
> when a column is defined with NOT NULL or PRIMARY KEY. And we
> have to think of check constraints, views, functions etc.
>
> The patch simply changes the return value to
> ResultSetMetaData.columnNullableUnknown. This is until someone
> comes up with a real implementation of course.
>
> On Fri, 14 Sep 2001 17:53:50 +0200, Tomisaw Kity?ski wrote:
> >Hello there,
> >
> >could someone tell me, please, do I have any chance to get
> >proper implementation of above method in JDBC (1.1+) soon?
> >
> >Current "return 1" works fine on most tables, however it seems
> >to be a little bit incorrect with some of them ;)
>
>
> Regards,
> Ren? Pijlman <rene@lab.applinet.nl>

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: [PATCHES] isNullable()

From
Barry Lind
Date:
Patch looks good.

thanks,
--Barry

Rene Pijlman wrote:
> Attached is a patch that fixes ResultSetMetaData.isNullable() in
> the JDBC driver.
>
> This method is currently unimplemented and always returns
> ResultSetMetaData.columnNullable. This is obviously incorrect
> when a column is defined with NOT NULL or PRIMARY KEY. And we
> have to think of check constraints, views, functions etc.
>
> The patch simply changes the return value to
> ResultSetMetaData.columnNullableUnknown. This is until someone
> comes up with a real implementation of course.
>
> On Fri, 14 Sep 2001 17:53:50 +0200, Tomisaw Kityñski wrote:
>
>>Hello there,
>>
>>could someone tell me, please, do I have any chance to get
>>proper implementation of above method in JDBC (1.1+) soon?
>>
>>Current "return 1" works fine on most tables, however it seems
>>to be a little bit incorrect with some of them ;)
>>
>
>
> Regards,
> René Pijlman <rene@lab.applinet.nl
>
>>
>>------------------------------------------------------------------------
>>
>>Index: org/postgresql/jdbc1/ResultSetMetaData.java
>>===================================================================
>>RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java,v
>>retrieving revision 1.5
>>diff -c -r1.5 ResultSetMetaData.java
>>*** org/postgresql/jdbc1/ResultSetMetaData.java    2001/09/06 20:43:39    1.5
>>--- org/postgresql/jdbc1/ResultSetMetaData.java    2001/09/15 19:35:09
>>***************
>>*** 136,144 ****
>>    }
>>
>>    /**
>>!    * Can you put a NULL in this column?  I think this is always
>>!    * true in 6.1's case.  It would only be false if the field had
>>!    * been defined NOT NULL (system catalogs could be queried?)
>>     *
>>     * @param column the first column is 1, the second is 2...
>>     * @return one of the columnNullable values
>>--- 136,142 ----
>>    }
>>
>>    /**
>>!    * Indicates the nullability of values in the designated column.
>>     *
>>     * @param column the first column is 1, the second is 2...
>>     * @return one of the columnNullable values
>>***************
>>*** 146,154 ****
>>     */
>>    public int isNullable(int column) throws SQLException
>>    {
>>!     return columnNullable;    // We can always put NULL in
>>    }
>>!
>>    /**
>>     * Is the column a signed number? In PostgreSQL, all numbers
>>     * are signed, so this is trivial.  However, strings are not
>>--- 144,157 ----
>>     */
>>    public int isNullable(int column) throws SQLException
>>    {
>>!     /*
>>!      * TODO This needs a real implementation, taking into account columns
>>!      * defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
>>!      * functions etc.
>>!      */
>>!     return columnNullableUnknown;
>>    }
>>!
>>    /**
>>     * Is the column a signed number? In PostgreSQL, all numbers
>>     * are signed, so this is trivial.  However, strings are not
>>Index: org/postgresql/jdbc2/ResultSetMetaData.java
>>===================================================================
>>RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java,v
>>retrieving revision 1.5
>>diff -c -r1.5 ResultSetMetaData.java
>>*** org/postgresql/jdbc2/ResultSetMetaData.java    2001/09/06 20:43:39    1.5
>>--- org/postgresql/jdbc2/ResultSetMetaData.java    2001/09/15 19:35:09
>>***************
>>*** 131,139 ****
>>    }
>>
>>    /**
>>!    * Can you put a NULL in this column?  I think this is always
>>!    * true in 6.1's case.  It would only be false if the field had
>>!    * been defined NOT NULL (system catalogs could be queried?)
>>     *
>>     * @param column the first column is 1, the second is 2...
>>     * @return one of the columnNullable values
>>--- 131,137 ----
>>    }
>>
>>    /**
>>!    * Indicates the nullability of values in the designated column.
>>     *
>>     * @param column the first column is 1, the second is 2...
>>     * @return one of the columnNullable values
>>***************
>>*** 141,147 ****
>>     */
>>    public int isNullable(int column) throws SQLException
>>    {
>>!     return columnNullable;    // We can always put NULL in
>>    }
>>
>>    /**
>>--- 139,150 ----
>>     */
>>    public int isNullable(int column) throws SQLException
>>    {
>>!     /*
>>!      * TODO This needs a real implementation, taking into account columns
>>!      * defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
>>!      * functions etc.
>>!      */
>>!     return columnNullableUnknown;
>>    }
>>
>>    /**
>>
>>
>>------------------------------------------------------------------------
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 2: you can get off all lists at once with the unregister command
>>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>>
>> isNullable.diff
>>
>> Content-Type:
>>
>> text/plain
>> Content-Encoding:
>>
>> quoted-printable
>>
>>
>> ------------------------------------------------------------------------
>> Part 1.3
>>
>> Content-Type:
>>
>> text/plain
>> Content-Encoding:
>>
>> binary
>>
>>



Re: isNullable()

From
Bruce Momjian
Date:
Patch applied.  Thanks.

> Attached is a patch that fixes ResultSetMetaData.isNullable() in
> the JDBC driver.
>
> This method is currently unimplemented and always returns
> ResultSetMetaData.columnNullable. This is obviously incorrect
> when a column is defined with NOT NULL or PRIMARY KEY. And we
> have to think of check constraints, views, functions etc.
>
> The patch simply changes the return value to
> ResultSetMetaData.columnNullableUnknown. This is until someone
> comes up with a real implementation of course.
>
> On Fri, 14 Sep 2001 17:53:50 +0200, Tomisaw Kity?ski wrote:
> >Hello there,
> >
> >could someone tell me, please, do I have any chance to get
> >proper implementation of above method in JDBC (1.1+) soon?
> >
> >Current "return 1" works fine on most tables, however it seems
> >to be a little bit incorrect with some of them ;)
>
>
> Regards,
> Ren? Pijlman <rene@lab.applinet.nl>

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026