pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Is this a bug????
9+ messages / 6 participants
[nested] [flat]

* Is this a bug????
@ 2005-12-04 22:29 Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  2005-12-04 23:10 ` Re: Is this a bug???? Qingqing Zhou <zhouqq@cs.toronto.edu>
  2005-12-05 00:24 ` Re: Is this a bug???? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 9+ messages in thread

From: Joost Kraaijeveld @ 2005-12-04 22:29 UTC (permalink / raw)
  To: pgsql-bugs

If I run this query:

select objectid,defaulttermsofpayment from prototype.customers 
where 
objectid = '336A0451-D9E8-7C11-6333-C17DF18E8979'

I get the following answer:

"336A0451-D9E8-7C11-6333-C17DF18E8979";"null"

If I run this query I get *no* results:

select objectid,defaulttermsofpayment from prototype.customers 
where 
defaulttermsofpayment is null

Is this a bug?


-- 
Groeten,

Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl 





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Is this a bug????
  2005-12-04 22:29 Is this a bug???? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
@ 2005-12-04 23:10 ` Qingqing Zhou <zhouqq@cs.toronto.edu>
  1 sibling, 0 replies; 9+ messages in thread

From: Qingqing Zhou @ 2005-12-04 23:10 UTC (permalink / raw)
  To: pgsql-bugs


"Joost Kraaijeveld" <J.Kraaijeveld@Askesis.nl> wrote
>
> select objectid,defaulttermsofpayment from prototype.customers
> where
> objectid = '336A0451-D9E8-7C11-6333-C17DF18E8979'
>
> I get the following answer:
>
> "336A0451-D9E8-7C11-6333-C17DF18E8979";"null"
>

test=# create table m (c1 char(10), c2 char(10));
CREATE TABLE
test=# insert into m values('hello', null);
INSERT 0 1
test=# select * from m where c1 = 'hello';
     c1     | c2
------------+----
 hello      |
(1 row)
test=# select * from m where c2 is null;
     c1     | c2
------------+----
 hello      |
(1 row)

Notice if an column is null, then nothing is shown. So the strange thing is 
how you get "null"?

Regards,
Qingqing 





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Is this a bug????
  2005-12-04 22:29 Is this a bug???? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
@ 2005-12-05 00:24 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 9+ messages in thread

From: Tom Lane @ 2005-12-05 00:24 UTC (permalink / raw)
  To: Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>; +Cc: pgsql-bugs

Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl> writes:
> If I run this query:
> select objectid,defaulttermsofpayment from prototype.customers 
> where 
> objectid = '336A0451-D9E8-7C11-6333-C17DF18E8979'

> I get the following answer:

> "336A0451-D9E8-7C11-6333-C17DF18E8979";"null"

> If I run this query I get *no* results:

> select objectid,defaulttermsofpayment from prototype.customers 
> where 
> defaulttermsofpayment is null

> Is this a bug?

Not unless you can prove that the defaulttermsofpayment field is
actually null, and not the string "null" as it appears to be.

(What client-side software are you using?  psql wouldn't display
the row like that, nor anything else I'm familiar with.)

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Is this a bug?
@ 2014-07-30 22:11 Davide Gonnella <davide.gonnella@gmail.com>
  2014-07-31 15:57 ` Re: Is this a bug? desmodemone <desmodemone@gmail.com>
  2014-07-31 16:19 ` Re: Is this a bug? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 9+ messages in thread

From: Davide Gonnella @ 2014-07-30 22:11 UTC (permalink / raw)
  To: pgsql-bugs

Hi guys,

I've received this warning with the note to forward it to this address so
 I am writing you.

"warning: Could not determine encoding for locale "en_US-UTF-8" codeset is
"646"

I've init the DB with the following command, perhaps is this the cause? (I
would like to SE UTF-8 as codeset)

initdb --pgdata=/var/postgresql/data -E 'UTF-8' --lc-collate='en_US-UTF-8'
--lc-ctype='en_US-UTF-8'

Btw I've done is before on test env and I haven't see this error on
"create database"

Thank you.

Best Regards,
Davide

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Is this a bug?
  2014-07-30 22:11 Is this a bug? Davide Gonnella <davide.gonnella@gmail.com>
@ 2014-07-31 15:57 ` desmodemone <desmodemone@gmail.com>
  1 sibling, 0 replies; 9+ messages in thread

From: desmodemone @ 2014-07-31 15:57 UTC (permalink / raw)
  To: Davide Gonnella <davide.gonnella@gmail.com>; +Cc: pgsql-bugs

2014-07-31 0:11 GMT+02:00 Davide Gonnella <davide.gonnella@gmail.com>:

> Hi guys,
>
> I've received this warning with the note to forward it to this address so
>  I am writing you.
>
> "warning: Could not determine encoding for locale "en_US-UTF-8" codeset is
> "646"
>
> I've init the DB with the following command, perhaps is this the cause? (I
> would like to SE UTF-8 as codeset)
>
> initdb --pgdata=/var/postgresql/data -E 'UTF-8' --lc-collate='en_US-UTF-8'
> --lc-ctype='en_US-UTF-8'
>
> Btw I've done is before on test env and I haven't see this error on
> "create database"
>
> Thank you.
>
> Best Regards,
> Davide
>
>
Hi Davide,
                    I not think en_US-UTF-8 is a valid locale naming,
could you try with en_US.UTF-8  ?

Thanks

Mat

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Is this a bug?
  2014-07-30 22:11 Is this a bug? Davide Gonnella <davide.gonnella@gmail.com>
@ 2014-07-31 16:19 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 9+ messages in thread

From: Tom Lane @ 2014-07-31 16:19 UTC (permalink / raw)
  To: Davide Gonnella <davide.gonnella@gmail.com>; +Cc: pgsql-bugs

Davide Gonnella <davide.gonnella@gmail.com> writes:
> "warning: Could not determine encoding for locale "en_US-UTF-8" codeset is
> "646"

Are you sure that locale name is actually defined on your system?
"locale -a" will list the known names.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Is this a bug?
@ 2016-01-22 23:58 Prateek Sanyal <sanyal.prateek@gmail.com>
  2016-01-23 02:09 ` Re: Is this a bug? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Prateek Sanyal @ 2016-01-22 23:58 UTC (permalink / raw)
  To: pgsql-bugs

I discovered a difference between sqlite3 and psql and I am not sure if it
is intentional but it is definitely inconvenient.

If you use an alias for an aggregate function and then do a GROUP BY with
HAVING, you can't use that alias in the HAVING and you have to type in the
entire function again.

This is not the case with sqlite3 where you can just use the alias. Why
doesn't psql allow this? It seems more efficient.

Take a look at the following example:

-- Schema for sample table named "invoices":

-- id => int

-- customer_id => int

-- total_sale => decimal
Here is the query:
********************

SELECT SUM(total_sale) AS sum_sales FROM invoices GROUP BY customer_id
HAVING sum_sales > 20 ORDER BY sum_sales DESC;

********************

This code above works in sqlite3 but not psql. For psql I have to do the
following:

********************

SELECT SUM(total_sale) AS sum_sales FROM invoices GROUP BY customer_id
HAVING SUM(total_sale) > 20 ORDER BY sum_sales DESC;

********************

Regards,
Prateek.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Is this a bug?
  2016-01-22 23:58 Is this a bug? Prateek Sanyal <sanyal.prateek@gmail.com>
@ 2016-01-23 02:09 ` Tom Lane <tgl@sss.pgh.pa.us>
  2016-01-23 02:28   ` Re: Is this a bug? Prateek Sanyal <sanyal.prateek@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2016-01-23 02:09 UTC (permalink / raw)
  To: Prateek Sanyal <sanyal.prateek@gmail.com>; +Cc: pgsql-bugs

Prateek Sanyal <sanyal.prateek@gmail.com> writes:
> I discovered a difference between sqlite3 and psql and I am not sure if it
> is intentional but it is definitely inconvenient.

> If you use an alias for an aggregate function and then do a GROUP BY with
> HAVING, you can't use that alias in the HAVING and you have to type in the
> entire function again.

> This is not the case with sqlite3 where you can just use the alias. Why
> doesn't psql allow this?

Because it is contrary to both the letter and the spirit of the SQL
standard.  The SELECT's result list is logically computed after every
operation except ORDER BY, so it's really not sensible for clauses
like GROUP BY or HAVING to refer to outputs of the SELECT list.
What's more, it's ambiguous, because the same name might mean
different things depending on whether you consider it to be an
input column name or a result column name.

PG deviates from the spec to the extent of allowing GROUP BY items
to be output column names *as long as they are just that, and not
expressions*.  (To my mind, that's probably a long-ago mistake,
but it's handy enough that there's never been any serious move to
remove it.)  Even if we applied that policy to HAVING, which
we don't, your example wouldn't work because the reference is
within an expression.

> SELECT SUM(total_sale) AS sum_sales FROM invoices GROUP BY customer_id
> HAVING SUM(total_sale) > 20 ORDER BY sum_sales DESC;

This code is correct per spec and should work in any SQL DBMS.  At least
as far as PG is concerned, there's no performance penalty, since the
common SUM() expression is evaluated only once anyway.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Is this a bug?
  2016-01-22 23:58 Is this a bug? Prateek Sanyal <sanyal.prateek@gmail.com>
  2016-01-23 02:09 ` Re: Is this a bug? Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-01-23 02:28   ` Prateek Sanyal <sanyal.prateek@gmail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Prateek Sanyal @ 2016-01-23 02:28 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

I was going to present my argument until I saw who signed off this email.
Thank you Mr. Lane. Now I will send a bug report to Microsoft and hope that
Bill Gates responds.

Regards,
Prateek.

On Fri, Jan 22, 2016 at 9:09 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Prateek Sanyal <sanyal.prateek@gmail.com> writes:
> > I discovered a difference between sqlite3 and psql and I am not sure if
> it
> > is intentional but it is definitely inconvenient.
>
> > If you use an alias for an aggregate function and then do a GROUP BY with
> > HAVING, you can't use that alias in the HAVING and you have to type in
> the
> > entire function again.
>
> > This is not the case with sqlite3 where you can just use the alias. Why
> > doesn't psql allow this?
>
> Because it is contrary to both the letter and the spirit of the SQL
> standard.  The SELECT's result list is logically computed after every
> operation except ORDER BY, so it's really not sensible for clauses
> like GROUP BY or HAVING to refer to outputs of the SELECT list.
> What's more, it's ambiguous, because the same name might mean
> different things depending on whether you consider it to be an
> input column name or a result column name.
>
> PG deviates from the spec to the extent of allowing GROUP BY items
> to be output column names *as long as they are just that, and not
> expressions*.  (To my mind, that's probably a long-ago mistake,
> but it's handy enough that there's never been any serious move to
> remove it.)  Even if we applied that policy to HAVING, which
> we don't, your example wouldn't work because the reference is
> within an expression.
>
> > SELECT SUM(total_sale) AS sum_sales FROM invoices GROUP BY customer_id
> > HAVING SUM(total_sale) > 20 ORDER BY sum_sales DESC;
>
> This code is correct per spec and should work in any SQL DBMS.  At least
> as far as PG is concerned, there's no performance penalty, since the
> common SUM() expression is evaluated only once anyway.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2016-01-23 02:28 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-12-04 22:29 Is this a bug???? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
2005-12-04 23:10 ` Qingqing Zhou <zhouqq@cs.toronto.edu>
2005-12-05 00:24 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-07-30 22:11 Is this a bug? Davide Gonnella <davide.gonnella@gmail.com>
2014-07-31 15:57 ` Re: Is this a bug? desmodemone <desmodemone@gmail.com>
2014-07-31 16:19 ` Re: Is this a bug? Tom Lane <tgl@sss.pgh.pa.us>
2016-01-22 23:58 Is this a bug? Prateek Sanyal <sanyal.prateek@gmail.com>
2016-01-23 02:09 ` Re: Is this a bug? Tom Lane <tgl@sss.pgh.pa.us>
2016-01-23 02:28   ` Re: Is this a bug? Prateek Sanyal <sanyal.prateek@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox