More char()/ascii()

Started by Gregory Starkalmost 18 years ago4 messages
#1Gregory Stark
stark@enterprisedb.com

Also, I thought we said this would be an error:

postgres=# select length("char"(0));
length
--------
0
(1 row)

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

#2Andrew Dunstan
andrew@dunslane.net
In reply to: Gregory Stark (#1)
Re: More char()/ascii()

Gregory Stark wrote:

Also, I thought we said this would be an error:

postgres=# select length("char"(0));
length
--------
0
(1 row)

IIRC, we said chr(0) would give you an error, and it does. I don't
recall any discussion of "char"(0), but no doubt a few brain cells have
died since then.

Fixing it would be trivial, I'm sure, but is it really a problem?

cheers

andrew

#3Gregory Stark
stark@enterprisedb.com
In reply to: Andrew Dunstan (#2)
Re: More char()/ascii()

"Andrew Dunstan" <andrew@dunslane.net> writes:

Gregory Stark wrote:

Also, I thought we said this would be an error:

postgres=# select length("char"(0));
length --------
0
(1 row)

IIRC, we said chr(0) would give you an error, and it does. I don't recall any
discussion of "char"(0), but no doubt a few brain cells have died since then.

Ah, that explains my confusion. I knew it seemed weird to have to quote it.

Fixing it would be trivial, I'm sure, but is it really a problem?

The "char" data type which I was mistakenly using is enough of a wart that it
probably doesn't matter what we do with it. There aren't any security holes
with the current behaviour (I don't think).

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gregory Stark (#3)
Re: More char()/ascii()

Gregory Stark <stark@enterprisedb.com> writes:

"Andrew Dunstan" <andrew@dunslane.net> writes:

Fixing it would be trivial, I'm sure, but is it really a problem?

The "char" data type which I was mistakenly using is enough of a wart that it
probably doesn't matter what we do with it. There aren't any security holes
with the current behaviour (I don't think).

The "char" type seems to be partly intended to serve as a poor man's
int1 --- at one time it even had arithmetic operators, if memory serves.
So we shouldn't disallow zero or mess with the fact that it's a signed
rather than unsigned byte.

regards, tom lane