Re: Bug in postgresql7.1 jdbc2 DatabaseMetaData class

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Robert Weiler <rweiler(at)perfectsense(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug in postgresql7.1 jdbc2 DatabaseMetaData class
Date: 2001-06-04 13:39:32
Message-ID: 200106041339.f54DdW007655@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


I see your fix in the current sources so we should be OK:

tuple[0] = null; // Catalog name
tuple[1] = null; // Schema name
tuple[2] = r.getBytes(1); // Table name
tuple[3] = (relKind==null) ? null : relKind.getBytes(); // Table type
tuple[4] = remarks; // Remarks
v.addElement(tuple);

> On line 1707 there is a dereference of 'relKind' which may very likely
> be set to null. This can cause a null pointer exception. I've include
> dthe workaround I am using, though there is almost certainly somethig
> better.
>
> Bob Weiler
>
> String relKind;
> switch (r.getBytes(3)[0]) {
> case 'r':
> relKind = "TABLE";
> break;
> case 'i':
> relKind = "INDEX";
> break;
> case 'S':
> relKind = "SEQUENCE";
> break;
> default:
> relKind = null;
> }
>
> tuple[0] = null; // Catalog name
> tuple[1] = null; // Schema name
> tuple[2] = r.getBytes(1); // Table name
> tuple[3] = relKind != null ? relKind.getBytes() : null; // Table type
> tuple[4] = remarks; // Remarks
> v.addElement(tuple);
> }
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2001-06-04 13:42:16 Re: bug in (plpgsql) parser?
Previous Message Bruce Momjian 2001-06-04 13:36:39 Re: psql dumps core on \d<invalid table> command (7.1.1)