Re: [GENERAL] Boolean type storage format

2012-11-01 Thread Marti Raudsepp
On Wed, Oct 31, 2012 at 8:08 PM, Raghavendra wrote: > False represented by zero bytes and True by 1 byte with value 1. This is not true AFAIK. Both boolean TRUE and FALSE values require 1 byte. A NULL value is zero bytes (though it still consumes 1 bit in the null bitmap). This is true for all t

Re: [GENERAL] Boolean type storage format

2012-11-01 Thread Craig Ringer
On 11/01/2012 02:25 AM, Mike Christensen wrote: > It would also matter what columns were next to it, correct? It doesn't look like PostgreSQL packs booleans. It still matters what's next to it because of the alignment requirements of other data types, but you still have a minimum of one byte per bo

Re: [GENERAL] Boolean type storage format

2012-10-31 Thread Mike Christensen
It would also matter what columns were next to it, correct? For example, if you had 4 bools in a row, that could also be 1 byte.. On Wed, Oct 31, 2012 at 11:08 AM, Raghavendra < raghavendra@enterprisedb.com> wrote: > On Wed, Oct 31, 2012 at 8:52 PM, Alexander Gataric wrote: > >> What is the

Re: [GENERAL] Boolean type storage format

2012-10-31 Thread Raghavendra
On Wed, Oct 31, 2012 at 8:52 PM, Alexander Gataric wrote: > What is the data physically stored as for boolean type? I know that it is > one byte but is it char, int, or something else? > False represented by zero bytes and True by 1 byte with value 1. --- Regards, Raghavendra EnterpriseDB Corp

Re: [GENERAL] Boolean partition constraint behaving strangely

2010-02-25 Thread Tom Lane
Dominik Sander writes: > I have an issue with a table partitioned by one boolean column. The > query planner only seems to skip the non matching table if expired > (the column I use for the partition) is true. Hm, interesting case. The reason it's behaving asymmetrically is the fix for this bug:

Re: [GENERAL] Boolean storage takes up 1 byte?

2009-10-02 Thread Tom Lane
Simon Riggs writes: > It might be possible to make BOOLEAN NOT NULL use the null bit to > represent the actual data value and then have the column use no > additional bytes, except when we don't store the null bitmap at all. > Just needs people to make it happen cleanly, if that's possible. I rea

Re: [GENERAL] Boolean storage takes up 1 byte?

2009-10-02 Thread Simon Riggs
On Thu, 2009-10-01 at 12:03 +0100, Sam Mason wrote: > > However, I see that a boolean takes up 1 > > byte of storage, which is 8 bits. Is this due to the fact that the value > > can be null? > > I believe it's more to do with the fact that if you add a boolean column > and then subsequently an

Re: [GENERAL] Boolean storage takes up 1 byte?

2009-10-01 Thread Thom Brown
2009/10/1 Sam Mason > > bool_or and bool_and are aggregates that work over boolean data types. > > Ah yes, that makes total sense! I knew max wouldn't be logical in such as case, but couldn't think of the alternative. Thanks! > > I believe it's more to do with the fact that if you add a boole

Re: [GENERAL] Boolean storage takes up 1 byte?

2009-10-01 Thread Sam Mason
On Thu, Oct 01, 2009 at 11:37:40AM +0100, Thom Brown wrote: > I've read the PostgreSQL documentation page on the boolean datatype ( > http://www.postgresql.org/docs/8.4/static/datatype-boolean.html) to find out > what PostgreSQL's definition of a boolean is, as I believe it is distinctive > from a

Re: [GENERAL] boolean short-circuiting in plpgsql

2008-07-31 Thread Kevin Field
> Kev <[EMAIL PROTECTED]> writes: > > ...because the case should force it to only evaluate 'old' when > > TG_OP > > = 'UPDATE' and otherwise ('INSERT') skip through to 't'. But this > > causes the same error on insert. I suspect it's because the select > > query gets parameterized and at that p

Re: [GENERAL] boolean short-circuiting in plpgsql

2008-07-30 Thread Tom Lane
Kev <[EMAIL PROTECTED]> writes: > ...because the case should force it to only evaluate 'old' when TG_OP > = 'UPDATE' and otherwise ('INSERT') skip through to 't'. But this > causes the same error on insert. I suspect it's because the select > query gets parameterized and at that point the 'old'

Re: [GENERAL] boolean operator on interval producing strange results

2007-02-20 Thread Merlin Moncure
On 2/20/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Merlin Moncure" <[EMAIL PROTECTED]> writes: > On 2/19/07, Tom Lane <[EMAIL PROTECTED]> wrote: >> "Merlin Moncure" <[EMAIL PROTECTED]> writes: >>> # select ((now() - '1 day'::interval)::timestamp - now()) < 0; >>> ?column? >>> -- >>> f <--

Re: [GENERAL] boolean operator on interval producing strange results

2007-02-20 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > On 2/19/07, Tom Lane <[EMAIL PROTECTED]> wrote: >> "Merlin Moncure" <[EMAIL PROTECTED]> writes: >>> # select ((now() - '1 day'::interval)::timestamp - now()) < 0; >>> ?column? >>> -- >>> f <-- looks busted to me >>> (1 row) >> >> If you'd ca

Re: [GENERAL] boolean operator on interval producing strange results

2007-02-20 Thread Adam Rich
--Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merlin Moncure Sent: Tuesday, February 20, 2007 8:30 AM To: Tom Lane Cc: postgres general Subject: Re: [GENERAL] boolean operator on interval producing strange results On 2/19/07, Tom Lane <[EMAIL P

Re: [GENERAL] boolean operator on interval producing strange results

2007-02-20 Thread Merlin Moncure
On 2/19/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Merlin Moncure" <[EMAIL PROTECTED]> writes: > # select ((now() - '1 day'::interval)::timestamp - now()) < 0; > ?column? > -- > f <-- looks busted to me > (1 row) If you'd casted to timestamptz then I'd agree this is busted. As-is, it m

Re: [GENERAL] boolean operator on interval producing strange results

2007-02-19 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > # select ((now() - '1 day'::interval)::timestamp - now()) < 0; > ?column? > -- > f <-- looks busted to me > (1 row) If you'd casted to timestamptz then I'd agree this is busted. As-is, it might have something to do with your timezone setti

Re: [GENERAL] boolean default value

2005-08-28 Thread Michael Schmidt
Mr. Fuhr, Thanks for your quick response.  In fact, the problem doesn't occur in psql or in EMS PostgreSQL Manager.  It appears unique to pgAdmin III.  In the future, I'll check such things with psql before asking a (potentially dumb) question.  Again, thanks!   Michael Schmidt

Re: [GENERAL] boolean default value

2005-08-28 Thread Michael Fuhr
On Sun, Aug 28, 2005 at 03:31:17PM -0600, Michael Schmidt wrote: > I've not been able to find anything on this in the groups or by > Google. I have a table with several boolean columns, all not null and > with either 'true' or 'false' as default values. I've been testing the > system in pgAdmin I

Re: [GENERAL] Boolean error

2004-11-28 Thread Greg Stark
Tom Lane <[EMAIL PROTECTED]> writes: > There was some talk awhile ago of preventing flattening when the > subquery targetlist contains volatile functions, but we didn't > have any consensus that the cure would be better than the disease. > (In particular, since user-defined functions default to be

Re: [GENERAL] Boolean error

2004-11-27 Thread Tom Lane
Fabien Fournier <[EMAIL PROTECTED]> writes: > We are experiencing a strange error with the following request : > select cmp > from (select random () < 0.5 as cmp from pg_type) as tmp > where cmp; > With this request even false results are shown. I think the planner will flatten this into

Re: [GENERAL] Boolean

2004-10-14 Thread Thomas F . O'Connell
http://www.postgresql.org/docs/7.4/static/datatype-boolean.html CASE WHEN its THEN 'true' ELSE 'false' END -tfo On Oct 14, 2004, at 3:43 PM, Bambero wrote: Postgres returns me 't' or 'f' from boolean field How to change that it returns me 'true' or 'false' replace(its, 'f', 'false') AS its doesn't

Re: [GENERAL] boolean to int

2004-03-15 Thread Alex Satrapa
Pavel Stehule wrote: create or replace function int2bool (integer) returns boolean as ' select case when $1=1 then ''t''::boolean else ''f''::boolean end; ' language sql; I'd do it slightly differently, if only to cater to the principle of least surprise: create or replace function int2bool (int

Re: [GENERAL] boolean to int

2004-03-15 Thread V i s h a l Kashyap @ [Sai Hertz And Control Systems]
Dear Mage , I'm wondering why pgsql doesn't support boolean typecasts like select true::int; Many client applications including php assign 1 to true and 0 to false This was a issue PHP < 4.2 + < PostgreSQL 7.3.x and supports it till now for backward compatibility -- Best Regards, Vishal Kash

Re: [GENERAL] boolean to int

2004-03-15 Thread Mage
Pavel Stehule wrote: Hello, you can use own cast. I think I have to create an own type too, because I don't want to use typecast in every select. You gave me the idea, thank you. Mage ---(end of broadcast)--- TIP 7: don't forget to i

Re: [GENERAL] boolean to int

2004-03-15 Thread Pavel Stehule
Hello, you can use own cast. create or replace function int2bool (integer) returns boolean as ' select case when $1=1 then ''t''::boolean else ''f''::boolean end; ' language sql; create or replace function bool2int (boolean) returns integer as ' select case when $1 then 0 else 1 end; ' langua

Re: [GENERAL] boolean isn't boolean?

2000-06-24 Thread Ross J. Reedstrom
On Sat, Jun 24, 2000 at 12:29:14PM -0400, Bruce Momjian wrote: > [ Charset ISO-8859-1 unsupported, converting... ] > > Thomas Lockhart writes: > > > > > Do you have a reference for an SQL99 document? Preferably on-line or in > > > a form similar to what we've found for SQL3-1999? > > > > ftp://j

Re: [GENERAL] boolean isn't boolean?

2000-06-24 Thread Bruce Momjian
[ Charset ISO-8859-1 unsupported, converting... ] > Thomas Lockhart writes: > > > Do you have a reference for an SQL99 document? Preferably on-line or in > > a form similar to what we've found for SQL3-1999? > > ftp://jerry.ece.umassd.edu/isowg3/x3h2/Standards/ansi-iso-9075-[12345]-1999.txt > >

Re: [GENERAL] boolean isn't boolean?

2000-06-24 Thread Peter Eisentraut
Thomas Lockhart writes: > Do you have a reference for an SQL99 document? Preferably on-line or in > a form similar to what we've found for SQL3-1999? ftp://jerry.ece.umassd.edu/isowg3/x3h2/Standards/ansi-iso-9075-[12345]-1999.txt This seems to be the real copyrighted deal, so get yours while it

RE: [GENERAL] boolean isn't boolean?

2000-06-24 Thread Peter Eisentraut
Marc Britten writes: > language-lawyer version.. you used the wrong version of the lang, the docs > say it complies to SQL3, which has completely different wording than SQL99 SQL3 isn't a standard, the term used to be employed to mean "the potential successor to ISO/IEC 9075:1992", which turned