bug with long serial names

Started by Nat Howardover 27 years ago4 messageshackers
Jump to latest
#1Nat Howard
Nat.Howard@cello-us.com

Apologies if this has been raised before.

This:

create table a12345678901234567890 ( b1234567890 serial );

causes this:

pqReadData() -- backend closed the channel unexpectedly.
This probably means the backend terminated abnormally before or
while processing the request.
We have lost the connection to the backend, so further processing is
impossible. Terminating.

This is on postgres 6.4.1 (the "fixed" 6.4.1, not the accidental
snapshot) on BSDI.

The same problem exists in 6.4 on FreeBSD.

#2Thomas Lockhart
lockhart@alumni.caltech.edu
In reply to: Nat Howard (#1)
Re: [HACKERS] bug with long serial names

create table a12345678901234567890 ( b1234567890 serial );
causes this:
pqReadData() -- backend closed the channel unexpectedly.

I hadn't heard about this. Will look at it. In the meantime, don't do
that :)

The upper limit on names is probably something like

<table name length> + <column name length> + 5 <= 31

- Tom

#3Thomas Lockhart
lockhart@alumni.caltech.edu
In reply to: Nat Howard (#1)
Re: [HACKERS] bug with long serial names

create table a12345678901234567890 ( b1234567890 serial );
causes this:
pqReadData() -- backend closed the channel unexpectedly.

The upper limit on names is probably something like
<table name length> + <column name length> + 5 <= 31

Here is a patch which should catch the problem:

pg=> create table a12345678901234567890 ( b1234567890 serial );
ERROR: CREATE TABLE/SERIAL implicit sequence name must be less than 32
characters
Sum of lengths of 'a12345678901234567890' and 'b1234567890' must
be less than 27

Will be in the next release. Apply the patch by putting it into the
backend/parser/ directory, then typing:

patch < analyze.c.patch

btw, the patch should apply cleanly but with offsets since my source
code has some other changes you will not want (yet).

- Tom

Attachments:

analyze.c.patchtext/plain; charset=us-ascii; name=analyze.c.patchDownload+38-0
#4PostgreSQL pseudo-user
pgsql@s2.cello-us.com
In reply to: Thomas Lockhart (#3)
RE: [PATCHES] Re: [HACKERS] bug with long serial names

Hi,

This appears to have worked, but required a patch to your patch -- which I've attached.
The new version passes regression tests in a manner very similar to the old,
so I'm assuming all is well, here, and that you mistakenly sent me one
of the features I'm not ready for yet... (CONSTR_NULL was undefined).

I'm just a novice here, so please, please, correct it if necessary!

Thanks very much for the quick service!

*** analyze.c	1998/12/29 18:43:50	1.2
--- analyze.c	1998/12/29 18:48:53
***************
*** 7,13 ****
   *
   *
   * IDENTIFICATION
!  *	  $Header: /usr/local/ports/databases/postgres-6.4.1/work/postgresql-6.4.1/src/backend/parser/RCS/analyze.c,v 1.2 1998/12/29 18:43:50 pgsql Exp $
   *
   *-------------------------------------------------------------------------
   */
--- 7,13 ----
   *
   *
   * IDENTIFICATION
!  *	  $Header: /usr/local/ports/databases/postgres-6.4.1/work/postgresql-6.4.1/src/backend/parser/RCS/analyze.c,v 1.3 1998/12/29 18:48:50 pgsql Exp $
   *
   *-------------------------------------------------------------------------
   */
***************
*** 592,606 ****
  						constraint = lfirst(clist);
  						switch (constraint->contype)
  						{
- 							case CONSTR_NULL:
- 								/* We should mark this explicitly,
- 								 * so we can tell if NULL and NOT NULL are both specified
- 								 */
- 								if (column->is_not_null)
- 									elog(ERROR, "CREATE TABLE/(NOT) NULL conflicting declaration"
- 										 " for %s.%s", stmt->relname, column->colname);
- 								column->is_not_null = FALSE;
- 								break;
  							case CONSTR_NOTNULL:
  								if (column->is_not_null)
--- 592,597 ----