[leon@udmnet.ru: [GENERAL] Weird behavior of 'default user'] - Mailing list pgsql-hackers

From Ross J. Reedstrom
Subject [leon@udmnet.ru: [GENERAL] Weird behavior of 'default user']
Date
Msg-id 19990716113201.B5803@wallace.ece.rice.edu
Whole thread Raw
Responses Re: [HACKERS] [leon@udmnet.ru: [GENERAL] Weird behavior of 'default user']
Re: [HACKERS] [leon@udmnet.ru: [GENERAL] Weird behavior of 'default user']
List pgsql-hackers
Forwarding this to the hackers list, since I can confirm the problem
still exists in 6.5.0. Looks like the functional extension of the
earlier problem reported with default constant values being longer
than the field. Note trhat it is causing corruption, Leon's username 
was just too short to make it visible in his example. The constant bug
is squashed, BTW: Here's my example:

test=> create table hh (dd char(2) default user, ff int4);
CREATE
test=>  insert into hh (ff) values (5);
INSERT 259723 1
test=>  select * from hh;
dd      |        ff
--------+----------
reedstrm|1836217459
(1 row)

test=> drop table hh;
DROP
test=> create table hh (dd char(2) default 'fred', ff int4);
CREATE
test=>  insert into hh (ff) values (5);
INSERT 259735 1
test=>  select * from hh;
dd|ff
--+--
fr| 5
(1 row)

test=> select version();
version                                                       
--------------------------------------------------------------
PostgreSQL 6.5.0 on i686-pc-linux-gnu, compiled by gcc 2.7.2.3
(1 row)



----- Forwarded message from Leon <leon@udmnet.ru> -----

X-From_: owner-pgsql-general@hub.org  Fri Jul 16 04:56:38 1999
Date: Fri, 16 Jul 1999 14:45:13 +0500
From: Leon <leon@udmnet.ru>
Organization: Midnight greppers corp.
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.3-5 i686)
To: "'pgsql-general@hub.org'" <pgsql-general@postgreSQL.org>
Subject: [GENERAL] Weird behavior of 'default user'
Precedence: bulk

Hello!

Look at this:

------------------
adb=> create table hh (dd char(2) default user, ff int4);
CREATE
adb=> insert into hh (ff) values (5);
INSERT 572034 1
adb=> select * from hh;
dd  |ff
----+--
leon| 5
(1 row)
------------------

How can I understand that? Column dd is of type char(2), whereas
'leon' is four characters! Even more, look here:

------------------
adb=> insert into hh  values (user, 7);
INSERT 572045 1
adb=> select * from hh;
dd  |ff
----+--
leon| 5
le  | 7
(2 rows)
------------------

This absolutely beyond my mind. This means that user, being
inserted explicitly, is correctly truncated. If it is inserted
by default, it is wider than column! Seems something very strange
is going on here.

-- 
Leon.

----- End forwarded message -----

-- 
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Oversize proc sources (was Re: [BUGS] Backend dies creating plpgsql procedures (with reproducible example!))
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Contributing