pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
substr
3+ messages / 3 participants
[nested] [flat]

* substr
@ 2000-10-19 13:19  Jeff MacDonald <jeff@hub.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Jeff MacDonald @ 2000-10-19 13:19 UTC (permalink / raw)
  To: pgsql-sql

i noticed that substr behaves a bit different in pgsql than perl

ie select foo from table where substr(foo,1,1) = 'X';

initially i thought it should be substr(foo,0,1) 

just wondering on the reasoning for this offset ?

Jeff MacDonald,

-----------------------------------------------------
PostgreSQL Inc		| Hub.Org Networking Services
jeff@pgsql.com		| jeff@hub.org
www.pgsql.com		| www.hub.org
1-902-542-0713		| 1-902-542-3657
-----------------------------------------------------
Facsimile : 1 902 542 5386
IRC Nick  : bignose




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

* Re: substr
@ 2000-10-19 14:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jeff MacDonald <jeff@hub.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2000-10-19 14:50 UTC (permalink / raw)
  To: Jeff MacDonald <jeff@hub.org>; +Cc: pgsql-sql

Jeff MacDonald <jeff@hub.org> writes:
> i noticed that substr behaves a bit different in pgsql than perl
> ie select foo from table where substr(foo,1,1) = 'X';

> just wondering on the reasoning for this offset ?

Larry Wall and the SQL92 authors didn't talk to each other...

We are implementing SQL around here, not Perl, so we have to follow
the SQL spec's definition of substr().

			regards, tom lane



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

* Re: substr
@ 2000-10-19 16:05  Jeff MacDonald <jeff@pgsql.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Jeff MacDonald @ 2000-10-19 16:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jeff MacDonald <jeff@hub.org>; pgsql-sql


> Jeff MacDonald <jeff@hub.org> writes:
> > i noticed that substr behaves a bit different in pgsql than perl
> > ie select foo from table where substr(foo,1,1) = 'X';
> 
> > just wondering on the reasoning for this offset ?
> 
> Larry Wall and the SQL92 authors didn't talk to each other...

bastards :) now we gotta decide who to kill, larry or the sql folk.
i'd say the sql folk, 0 is just more inututive for computer counting.

but that's just me.. :) anyway thanks.

> 
> We are implementing SQL around here, not Perl, so we have to follow
> the SQL spec's definition of substr().
> 
> 			regards, tom lane
> 

Jeff MacDonald,

-----------------------------------------------------
PostgreSQL Inc		| Hub.Org Networking Services
jeff@pgsql.com		| jeff@hub.org
www.pgsql.com		| www.hub.org
1-902-542-0713		| 1-902-542-3657
-----------------------------------------------------
Facsimile : 1 902 542 5386
IRC Nick  : bignose




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


end of thread, other threads:[~2000-10-19 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-19 13:19 substr Jeff MacDonald <jeff@hub.org>
2000-10-19 14:50 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-10-19 16:05   ` Jeff MacDonald <jeff@pgsql.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