Re: longjmp in psql considered harmful

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: longjmp in psql considered harmful
Date: 2006-06-13 08:31:08
Message-ID: 20060613083108.GA19212@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 12, 2006 at 08:14:01PM -0400, Tom Lane wrote:
> I had interpreted the readline documentation to mean that readline would
> discard a partially typed line upon catching SIGINT. Experimentation
> shows that this is not so, at least not with the version of readline I
> use here. It does catch the signal and reset some internal state, but
> the partially typed line is NOT discarded. Grumble.

Yeah, the documentation in readline there was pretty obtuse, but since
it didn't explicitly include typed characters as state, I figured it
didn't clear the line.

> I'll work on reviewing and applying the patch. I don't much like the
> side-effects on the /scripts directory though ... there must be a better
> way than that. Is it sane to declare the flag variable in print.c?

The problem is basically that some of those files are symlinked across
the tree and included from various different places. Some places
include print.c but don't include the signal handler stuff, which left
we with linker errors about undefined symbols.

In psql the symbol comes from common.c and so I also added it to
scripts/common.c, which cleared up all the errors. This would allow
psql to work and all other programs that included print.c would only
ever see zero in that variable.

Maybe some other arrangement is possible. Maybe like you suggest,
declare the symbol in print.c and make the declaration in common.c an
extern. The end result is the same though.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Luke Lonergan 2006-06-13 11:54:05 Re: Running a query twice to ensure cached results.
Previous Message Simon Riggs 2006-06-13 08:27:05 Re: [PATCHES] Non-transactional pg_class, try 2