copy
jose' soares <sferac@bo.nettuno.it>
From: Sferacarta Software <sferac@bo.nettuno.it>
To: pgsql-hackers@postgresql.org
Date: 1998-11-27T13:46:45Z
Lists: pgsql-hackers
Hi all,
I have a strange behavior while copying from a text file, I don't know
if this will be considered a bug or a feature.
I have this text file:
------------------------
XXX|QWERTYUIOPASDFGHJKLA
A01|BAIO
A02|BAIO CHIARO
A03|BAIO OSCURO
------------------------
and this table:
Table = mantelli
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| m_codice | char() | 3 |
| m_descr | char() | 20 |
+----------------------------------+----------------------------------+-------+
Index: i5_mantelli
prova=> copy mantelli from '/tmp/mantelli.load' using delimiters '|';
COPY
prova=> select * from mantelli;
m_codice|m_descr
--------+--------------------
XXX |QWERTYUIOPASDFGHJKLA
|BAIO CHIARO
|BAIO OSCURO
(4 rows)
prova=> select m_descr,m_codice from mantelli ;
m_descr |m_codice
--------------------+--------
QWERTYUIOPASDFGHJKLA|XXX
|A01
|A02
|A03
(4 rows)
prova=> select m_codice from mantelli ;
m_codice
--------
XXX
A01
A02
A03
(4 rows)
prova=> select m_descr from mantelli ;
m_descr
--------------------
QWERTYUIOPASDFGHJKLA
ARO
URO
(4 rows)
Seems that COPY expects that last field is 20 char long and if it is less than 20
it becomes crazy.
-Jose'-