[leon@udmnet.ru: [GENERAL] Weird behavior of 'default user']

From: "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: [leon@udmnet.ru: [GENERAL] Weird behavior of 'default user']
Date: 1999-07-16 16:32:01
Message-ID: 19990716113201.B5803@wallace.ece.rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)udmnet(dot)ru> -----

X-From_: owner-pgsql-general(at)hub(dot)org Fri Jul 16 04:56:38 1999
Date: Fri, 16 Jul 1999 14:45:13 +0500
From: Leon <leon(at)udmnet(dot)ru>
Organization: Midnight greppers corp.
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.3-5 i686)
To: "'pgsql-general(at)hub(dot)org'" <pgsql-general(at)postgreSQL(dot)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(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-07-16 16:35:31 Re: [HACKERS] Contributing
Previous Message Bruce Momjian 1999-07-16 16:22:46 Re: Oversize proc sources (was Re: [BUGS] Backend dies creating plpgsql procedures (with reproducible example!))