I stumbled across this behavior today and it seems strange if not a bug:

-- this seems wrong
vsconf=# create table foo (f1 char(1));
CREATE TABLE
vsconf=# insert into foo values(' ');
INSERT 9002011 1
vsconf=# select ascii(f1) from foo;
 ascii
-------
     0
(1 row)

-- this is what I'd expect
vsconf=# create table foo2 (f1 varchar(1));
CREATE TABLE
vsconf=# insert into foo2 values(' ');
INSERT 9002015 1
vsconf=# select ascii(f1) from foo2;
 ascii
-------
    32
(1 row)

-- this seems wrong
vsconf=# create table foo4 (f1 char(5));
CREATE TABLE
vsconf=# insert into foo4 values('     ');
INSERT 9002022 1
vsconf=# select ascii(f1) from foo4;
 ascii
-------
     0
(1 row)

I looked for a few minutes at bpcharin(), but could not see exactly why this is happening. Am I missing something wrt the char() data type, or is this a bug?

Joe


---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to