Skip site navigation (1) Skip section navigation (2)

Re: char(0)

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: char(0)
Date: 2011-10-17 13:44:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
2011-10-17 14:28 keltezéssel, Susanne Ebrecht írta:
> On 17.10.2011 10:30, Simon Riggs wrote:
>> On Mon, Oct 17, 2011 at 8:31 AM, Susanne Ebrecht
>> <susanne(at)2ndquadrant(dot)com> wrote:
>>> PostgreSQL isn't supporting CHAR(0).
>> What does the SQL Standard say?
> Document: 02-Foundation
> Section: 4.2.1 Introduction to character strings
> Begin quoting
> A character string is a sequence of characters. All the characters in a character string 
> are taken from a single
> character set. A character string has a length, which is the number of characters in the 
> sequence. The length is
> 0 (zero) or a positive integer.
> End quoting

I am looking at 6WD2_02_Foundation_2007-12.pdf.
Search for "<character length>" that is used in section "6.1 <data type>":

<character length> := <unsigned integer> [ <char length units> ]

Section 6.1 doesn't talk about limiting the definition to > 0 values

But in page 157, section "5.3 <literal>":

17) The declared type of a <character string literal> is fixed-length character string. 
The length of a <character
string literal> is the number of <character representation>s that it contains. Each <quote 
symbol> contained
in <character string literal> represents a single <quote> in both the value and the length 
of the <character
string literal>. The two <quote>s contained in a <quote symbol> shall not be separated by 
any <separator>.

NOTE 92 — <character string literal>s are allowed to be zero-length strings (i.e., to 
contain no characters) even though it is
not permitted to declare a <data type> that is CHARACTER with <character length> 0 (zero).

So, a table column is not allowed to be char(0) or varchar(0). It's explicit in NOTE 92.

Best regards,
Zoltán Böszörményi

Zoltán Böszörményi
Cybertec Schönig&  Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria

In response to

  • Re: char(0) at 2011-10-17 12:28:14 from Susanne Ebrecht


  • Re: char(0) at 2011-10-17 13:57:20 from Susanne Ebrecht

pgsql-bugs by date

Next:From: Susanne EbrechtDate: 2011-10-17 13:57:20
Subject: Re: char(0)
Previous:From: Laerson KelerDate: 2011-10-17 13:08:01
Subject: BUG #6258: Lock Sequence

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group