Thread

  1. Re: [HACKERS] varchar() troubles

    Keith Parks <emkxp01@mtcc.demon.co.uk> — 1998-01-12T18:24:00Z

    Hi,
    
    I can confirm that I see the same problem here.
    
    Maybe todo with the recent varchar() storage changes.
    
    Keith.
    
    
    "Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
    
    > I've been seeing trouble with varchar() columns for a little while, and
    > since it is still there with a fresh install of the development tree
    > it's time to report it:
    > 
    > postgres=> create table t (v varchar(80),i int);
    > CREATE
    > postgres=> insert into t values ('hi',1);
    > INSERT 18122 1
    > postgres=> select * from t;
    > v |i
    > --+-
    > hi|0
    > (1 row)
    > 
    > As you can see, the varchar() column apparently trashes the subsequent
    > column. I ran across it trying to verify the tutorial examples for the
    > documentation. If the varchar() is the last column in the table, the
    > problem does not crop up, at least in the simplest case:
    > 
    > postgres=> create table t2 (i int, v varchar(80));
    > CREATE
    > postgres=> insert into t2 values (2,'hi');
    > INSERT 18133 1
    > postgres=> select * from t2;
    > i|v
    > -+--
    > 2|hi
    > (1 row)
    > 
    > Also, I believe that if the varchar() field is substantially shorter the
    > problem does not manifest itself:
    > 
    > postgres=> create table t4 (v varchar(4), i int);
    > CREATE
    > postgres=> insert into t4 values ('hi',4);
    > INSERT 18156 1
    > postgres=> select * from t4;
    > v |i
    > --+-
    > hi|4
    > (1 row)
    > 
    > but varchar(10) still shows the problem:
    > 
    > postgres=> create table t3 (v varchar(10), i int);
    > CREATE
    > postgres=> insert into t3 values ('hi',3);
    > INSERT 18145 1
    > postgres=> select * from t3;
    > v |i
    > --+-
    > hi|0
    > (1 row)
    > 
    > This is from the development source as of around 1998-01-12 14:30 GMT
    > 
    >                                                                     -
    > Tom
    > 
    >