Обсуждение: Porting from Mysql to Postgres

Поиск
Список
Период
Сортировка

Porting from Mysql to Postgres

От
Dror Matalon
Дата:
Hi,

I'm in the midst of porting Dbjay, a java based frontend, from MySQL to
Postgres. More info about dbjay can be found at http://www.dbjay.com.

1. When I insert a CHAR field and then fetch it, I find out that
the server padded it with spaces to the size of the field.  This
happens in Postgres but not in MySQL. I'm using String.trim() on
it on the Java side. Is there a better way to do this, like setting
a flag to tell the server to trim?

2. Looking at the JDBC code it looks like getTableName in a resultset
returns "" rather than the table name. This is a big problem, cause
without the tablename it's impossible to let the user update the
resultset when the table name is unknown. Seeing that php doesn't
offer it and looking at the backend code, it looks like it's both
not Java specific and not easy to implement.  Still, what are the
chances of having this available?

3. Once Dbjay is available what are the appropriate newsgroups and
mailing lists to announce it to the Postgres community.

Thanks,

Dror

Dror Matalon


Re: Porting from Mysql to Postgres

От
Bob Kline
Дата:
On Thu, 1 Feb 2001, Dror Matalon wrote:

> 1. When I insert a CHAR field and then fetch it, I find out that the
> server padded it with spaces to the size of the field.

This is correct behavior, according to the SQL standard.

> This happens in Postgres but not in MySQL.

Actually, it happens in MySQL, too, sometimes, but it's not always easy
to predict intuitively when it will happen.

> I'm using String.trim() on it on the Java side. Is there a better
> way to do this, like setting a flag to tell the server to trim?

You could use VARCHAR instead of CHAR, but the approach you're using is
probably fine, because most (all?) Java runtimes perform that operation
very efficiently, without any unnecessary allocation/copying.

--
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com


Re: Porting from Mysql to Postgres

От
Peter T Mount
Дата:
Quoting Dror Matalon <dror@matal.com>:

>
> Hi,
>
> I'm in the midst of porting Dbjay, a java based frontend, from MySQL to
> Postgres. More info about dbjay can be found at http://www.dbjay.com.
>
> 1. When I insert a CHAR field and then fetch it, I find out that
> the server padded it with spaces to the size of the field.  This
> happens in Postgres but not in MySQL. I'm using String.trim() on
> it on the Java side. Is there a better way to do this, like setting
> a flag to tell the server to trim?

CHAR's are meant to pad. VARCHAR's don't pad.

> 2. Looking at the JDBC code it looks like getTableName in a resultset
> returns "" rather than the table name. This is a big problem, cause
> without the tablename it's impossible to let the user update the
> resultset when the table name is unknown. Seeing that php doesn't
> offer it and looking at the backend code, it looks like it's both
> not Java specific and not easy to implement.  Still, what are the
> chances of having this available?

Possibly by 7.1, but I've yet to find out how to do it. I was going to post a
question to the hackers list about this at the weekend. This is needed for the
implementation of UpdateableResultSet.

> 3. Once Dbjay is available what are the appropriate newsgroups and
> mailing lists to announce it to the Postgres community.

The announce list, and as it's jdbc the jdbc list.

Peter

--
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/