Re: [HACKERS] TCL_ARRAYS code in libpgtcl is pretty seriously broken

From: Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it>
To: hackers(at)postgreSQL(dot)org (PostgreSQL Hackers)
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane)
Subject: Re: [HACKERS] TCL_ARRAYS code in libpgtcl is pretty seriously broken
Date: 1998-10-11 12:04:47
Message-ID: 199810111204.OAA02106@nikita.wizard.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it> writes:
> >> [ my gripes about TCL_ARRAYS code snipped ]
>
> > I wrote this code and used it for two years without any problem. All
> > the bugs you mentioned disappear if you use the proper string output
> > functions which C-like escapes (code in contrib/string-io).
>
> Well, not the bug involving overwriting libpq's PGresult storage.
> But still, this explains a good deal.

I didn't realize it could be called more than once for the same tuple.
We must allocate and free a new string for each value. I will write a patch.

> I guess my gripe here is that the TCL_ARRAYS option is enabled *by
> default* in the Postgres distribution, but the code does not work
> properly unless one plugs in a contrib function in the backend
> (and if the connection between the two is documented anywhere, I sure
> didn't see it). This is not a reasonable default setup.

I submitted the two patches at the same time but one of them was put in the
contribs.

> As a short-term fix I suggest that we just turn off TCL_ARRAYS in
> the distributed config.h.in --- does that sound reasonable to you?

Given the situation I agree that TCL_ARRAYS should be disabled by default.

> In the longer term, there needs to be some way of applying the
> TCL_ARRAYS conversion code only when your contrib stuff is being used.
> Backing the conversion code out of pg_result and making it a separate
> function might do, but that is a low-tech solution that puts the
> responsibility on the application programmer to combine the right bits
> of frontend and backend functionality. Perhaps someone can think of a
> better way?
>
> Ultimately I would like the text I/O functions to be completely 8-bit
> clean and able to deal with arbitrary byte strings. That is not
> something we can hope to shoehorn into 6.4, though.

I completely agree on the last thing. It is something I have been asking
from a long time but apparently nobody cared bout it.

--
Massimo Dal Zotto

+----------------------------------------------------------------------+
| Massimo Dal Zotto email: dz(at)cs(dot)unitn(dot)it |
| Via Marconi, 141 phone: ++39-461-534251 |
| 38057 Pergine Valsugana (TN) www: http://www.cs.unitn.it/~dz/ |
| Italy pgp: finger dz(at)tango(dot)cs(dot)unitn(dot)it |
+----------------------------------------------------------------------+

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Massimo Dal Zotto 1998-10-11 12:24:14 Re: [HACKERS] backslash in psql output
Previous Message Tom Ivar Helbekkmo 1998-10-11 11:11:48 Error messages crash backend