From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
Cc: | peter_e(at)gmx(dot)net, laurenz(dot)albe(at)wien(dot)gv(dot)at, jianggq(at)cn(dot)fujitsu(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Patch to fix a crash of psql |
Date: | 2012-11-30 19:41:04 |
Message-ID: | 22262.1354304464@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tatsuo Ishii <ishii(at)postgresql(dot)org> writes:
>> TBH I think that a message here is unnecessary; it's sufficient to
>> ensure psql doesn't crash. The backend will produce a better message
>> than this anyway once the data gets there, and that way we don't have to
>> invent a new error recovery path inside psql. As-is, the patch just
>> creates the question of what to do after issuing the error.
> Problem is, backend does not always detect errors.
The reason it doesn't produce an error in Jiang Guiqing's example is
that the encoding error is in a comment and thus is never transmitted
to the backend at all. I don't see a big problem with that. If we
did have a problem with it, I think the better fix would be to stop
having psql strip comments from what it sends. (I've considered
proposing such a change anyway, in order that logged statements look
more like what the user typed.)
> IMO it is a benefit for users to detect such errors earlier.
It is not a benefit for users to get randomly different (and less
informative) messages and different error behaviors for the same
problem.
I think we should just do this and call it good:
diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l
index d32a12c63c856625aa42c708b24d4b58e3cdd677..6c1429815f2eec597f735d18ea86d9c8c9f1f3a2 100644
*** a/src/bin/psql/psqlscan.l
--- b/src/bin/psql/psqlscan.l
*************** prepare_buffer(const char *txt, int len,
*** 1807,1813 ****
/* first byte should always be okay... */
newtxt[i] = txt[i];
i++;
! while (--thislen > 0)
newtxt[i++] = (char) 0xFF;
}
}
--- 1807,1813 ----
/* first byte should always be okay... */
newtxt[i] = txt[i];
i++;
! while (--thislen > 0 && i < len)
newtxt[i++] = (char) 0xFF;
}
}
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2012-11-30 19:41:14 | Re: [PATCH] make -jN check fails / unset MAKEFLAGS in pg_regress.c |
Previous Message | Robert Haas | 2012-11-30 19:39:17 | Re: Proposal for Allow postgresql.conf values to be changed via SQL |