Received: from bologna.nettuno.it (bologna.nettuno.it [193.43.2.1]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA29478 for ; Tue, 11 May 1999 10:50:54 -0400 (EDT) (envelope-from jose@sferacarta.com) Received: from proxy.sferacarta.com (mail@sfcabop1.nettuno.it [193.207.10.213]) by bologna.nettuno.it (8.8.6/8.8.6/NETTuno 3.1) with ESMTP id QAA10346; Tue, 11 May 1999 16:50:12 +0200 (MDT) Received: from rosso.sferacarta.com (sferacarta.com) [10.20.30.5] by proxy.sferacarta.com with esmtp (Exim 2.05 #1 (Debian)) id 10hEWl-0002e9-00; Tue, 11 May 1999 15:33:03 +0000 Message-ID: <3738316B.47CED3BB@sferacarta.com> Date: Tue, 11 May 1999 15:32:28 +0200 From: =?iso-8859-1?Q?Jos=E9?= Soares X-Mailer: Mozilla 4.5 [it] (Win95; I) X-Accept-Language: it MIME-Version: 1.0 To: Bruce Tong CC: leif@danmos.dk, pgsql-interfaces@postgresql.org Subject: Re: [INTERFACES] Bug in psql? References: Content-Type: multipart/alternative; boundary="------------4009AC20F320F371CB464933" --------------4009AC20F320F371CB464933 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit The error is about name lenght. Max. 31 char. SERIAL types automatically creates an index name like: globalafvigelse_globalafviggelse_key which is longer than 31 char. You have to cut the table/key name to fit into 26 char (the sum of both). take a look: $ psql prova < 1 create table globalafvigelse ( globalafvigelse serial , startdato date, slutdato date, dagskema varchar(50), primary key (globalafvigelse) ); ERROR: CREATE TABLE/SERIAL implicit sequence name must be less than 32 characte rs Sum of lengths of 'globalafvigelse' and 'globalafvigelse' must be less t han 27 create table globalafvigelse ( globalafvig serial , startdato date, slutdato date, dagskema varchar(50), primary key (globalafvig) ); NOTICE: CREATE TABLE will create implicit sequence globalafvigelse_globalafvig_ seq for SERIAL column globalafvigelse.globalafvig NOTICE: CREATE TABLE/UNIQUE will create implicit index globalafvigelse_globalaf vig_key for table globalafvigelse NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index globalafvigelse_pke y for table globalafvigelse CREATE EOF $ psql -c '\d globalafvigelse' Table = globalafvigelse +----------------------------------+----------------------------------+-------+ | Field | Type | Length| +----------------------------------+----------------------------------+-------+ | globalafvig | int4 not null default nextval('g | 4 | | startdato | date | 4 | | slutdato | date | 4 | | dagskema | varchar() | 50 | +----------------------------------+----------------------------------+-------+ Indices: globalafvigelse_globalafvig_key globalafvigelse_pkey Jose' Bruce Tong ha scritto: > > I tried to create the table below using psql, but it bombed out > > with a message about loosing the backend, though the backend was > > still running nicely. It seems to be a problem with the long > > field name of the serial (and primary key) column. > > Have you tried putting the following into a file and using... > > # psql -f foo.sql > > ... to run it? I _think_ this sometimes gives different messages than > entering it directly on the psql command line, although I'm not sure why. > I could be way off here, but its worth a try. > > > create table globalafvigelse > > ( > > globalafvigelse serial , > > startdato date, > > slutdato date, > > dagskema varchar(50), > > primary key (globalafvigelse) > > ); > > What is type "serial"? It probably not incorrect, but I've not heard of it > before. > > Bruce Tong | Got me an office; I'm there late at night. > Systems Programmer | Just send me e-mail, maybe I'll write. > Electronic Vision / FITNE | > zztong@laxmi.ev.net | -- Joe Walsh for the 21st Century -- ______________________________________________________________ PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Jose' --------------4009AC20F320F371CB464933 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit The error is about name lenght. Max. 31 char.
SERIAL types automatically creates an index name like:
       globalafvigelse_globalafviggelse_key
which is longer than 31 char.
You have to cut the table/key name to fit into 26 char (the sum of both).
take a look:
 

$ psql prova < 1
 create table globalafvigelse
   (
     globalafvigelse serial ,
     startdato date,
     slutdato date,
     dagskema varchar(50),
     primary key (globalafvigelse)
   );
ERROR:  CREATE TABLE/SERIAL implicit sequence name must be less than 32 characte
rs
        Sum of lengths of 'globalafvigelse' and 'globalafvigelse' must be less t
han 27

create table globalafvigelse
   (
     globalafvig serial ,
     startdato date,
     slutdato date,
     dagskema varchar(50),
     primary key (globalafvig)
   );
NOTICE:  CREATE TABLE will create implicit sequence globalafvigelse_globalafvig_
seq for SERIAL column globalafvigelse.globalafvig
NOTICE:  CREATE TABLE/UNIQUE will create implicit index globalafvigelse_globalaf
vig_key for table globalafvigelse
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index globalafvigelse_pke
y for table globalafvigelse
CREATE
EOF

$ psql -c '\d globalafvigelse'
Table    = globalafvigelse
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                | Length|
+----------------------------------+----------------------------------+-------+
| globalafvig                      | int4 not null default nextval('g |     4 |
| startdato                        | date                             |     4 |
| slutdato                         | date                             |     4 |
| dagskema                         | varchar()                        |    50 |
+----------------------------------+----------------------------------+-------+
Indices:  globalafvigelse_globalafvig_key
          globalafvigelse_pkey
 

Jose'
 

Bruce Tong ha scritto:

>  I tried to create the table below using psql, but it bombed out
> with a message about loosing the backend, though the backend was
> still running nicely. It seems to be a problem with the long
> field name of the serial (and primary key) column.

Have you tried putting the following into a file and using...

# psql -f foo.sql

... to run it? I _think_ this sometimes gives different messages than
entering it directly on the psql command line, although I'm not sure why.
I could be way off here, but its worth a try.

> create table globalafvigelse
>   (
>     globalafvigelse serial ,
>     startdato date,
>     slutdato date,
>     dagskema varchar(50),
>     primary key (globalafvigelse)
>   );

What is type "serial"? It probably not incorrect, but I've not heard of it
before.

Bruce Tong                 |  Got me an office; I'm there late at night.
Systems Programmer         |  Just send me e-mail, maybe I'll write.
Electronic Vision / FITNE  |
zztong@laxmi.ev.net        |  -- Joe Walsh for the 21st Century

--
______________________________________________________________
PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jose'
  --------------4009AC20F320F371CB464933--