pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Empty String Comparison Standard compliant?
3+ messages / 3 participants
[nested] [flat]

* Empty String Comparison Standard compliant?
@ 2004-01-30 13:12 Christoph Haller <ch@rodos.fzk.de>
  2004-01-30 15:18 ` Re: Empty String Comparison Standard compliant? Tom Lane <tgl@sss.pgh.pa.us>
  2004-01-30 15:29 ` Re: Empty String Comparison Standard compliant? Stephan Szabo <sszabo@megazone.bigpanda.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Christoph Haller @ 2004-01-30 13:12 UTC (permalink / raw)
  To: pgsql-sql

Just a short question (PostgreSQL 7.3.4 on hppa-hp-hpux10.20, compiled by GCC 2.8.1) 

SELECT ('' > 'GDMF') ; SELECT ('GDMF' > '');
 ?column? 
----------
 f
(1 row)

 ?column? 
----------
 t
(1 row)

Are these results standard compliant? 
Looks at least pretty reasonable to me. 
It's just because I have a DBMS here, where the results are vice versa. 

TIA. 

Regards, Christoph 




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

* Re: Empty String Comparison Standard compliant?
  2004-01-30 13:12 Empty String Comparison Standard compliant? Christoph Haller <ch@rodos.fzk.de>
@ 2004-01-30 15:18 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2004-01-30 15:18 UTC (permalink / raw)
  To: Christoph Haller <ch@rodos.fzk.de>; +Cc: pgsql-sql

Christoph Haller <ch@rodos.fzk.de> writes:
> [ '' is less than 'GDMF' ]

> Are these results standard compliant? 

I doubt that the SQL standard really says anything on the subject, but
ISTM any rational string-sorting algorithm would put '' before anything
else.

> It's just because I have a DBMS here, where the results are vice versa. 

Let me guess ... it's Oracle?  Last I heard Oracle had a problem
distinguishing empty strings from NULLs.  If it sorts NULLs at the
end then it wouldn't be surprising for empty strings to come out at
the end in an ORDER BY sort.  However, I'm not sure that explains
the exact example you cite of boolean comparison results.  If it
were taking the '' as a NULL then both comparisons ought to return
NULL.

			regards, tom lane



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

* Re: Empty String Comparison Standard compliant?
  2004-01-30 13:12 Empty String Comparison Standard compliant? Christoph Haller <ch@rodos.fzk.de>
@ 2004-01-30 15:29 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2004-01-30 15:29 UTC (permalink / raw)
  To: Christoph Haller <ch@rodos.fzk.de>; +Cc: pgsql-sql


On Fri, 30 Jan 2004, Christoph Haller wrote:

> Just a short question (PostgreSQL 7.3.4 on hppa-hp-hpux10.20, compiled by GCC 2.8.1)
>
> SELECT ('' > 'GDMF') ; SELECT ('GDMF' > '');
>  ?column?
> ----------
>  f
> (1 row)
>
>  ?column?
> ----------
>  t
> (1 row)
>
> Are these results standard compliant?

I think so in general.  If the two lengths are not equal, then
"effectively" the shorter string is replaced by an extended version.  If
it's NO PAD (varchar/text for us) the character used is a character that
sorts less than any string.  Otherwise (char) it's a space.  Then you use
the collating sequence to determine the value of >.  Most will put space
before any of GDMF, so the above seems reasonable.





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


end of thread, other threads:[~2004-01-30 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-30 13:12 Empty String Comparison Standard compliant? Christoph Haller <ch@rodos.fzk.de>
2004-01-30 15:18 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-01-30 15:29 ` Stephan Szabo <sszabo@megazone.bigpanda.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