Re: pg_generate_sequence and info_schema patch (Was: SELECT Question)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Kris Jurka <books(at)ejurka(dot)com>, Alex <alex(at)meerkatsoft(dot)com>, "Lada 'Ray' Lostak" <ray(at)unreal64(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: pg_generate_sequence and info_schema patch (Was: SELECT Question)
Date: 2004-02-01 21:12:41
Message-ID: 2094.1075669961@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

Joe Conway <mail(at)joeconway(dot)com> writes:
> Tom Lane wrote:
>> Joe Conway <mail(at)joeconway(dot)com> writes:
>>> regression=# select * from pg_generate_sequence(8, 4);
>>> ERROR: finish is less than start
>>
>> Hm, would it be better just to return an empty set? Certainly I'd
>> expect pg_generate_sequence(1,0) to return an empty set with no error.

> OK -- for this and other concerns below, I bit the bullet and decided to
> support descending series and step sizes other than one. Now it does this:

> regression=# select * from generate_series(8, 4);
> generate_series
> -----------------
> 8
> 7
> 6
> 5
> 4
> (5 rows)

And how do I get a zero-size set out of it? I think it's a really bad
idea to silently assume descending is meant if start > finish --- that
will create boundary-case bugs in many scenarios. A looping construct
that cannot iterate zero times is broken and dangerous (see Fortran DO
loops for context ... folklore has it that Mariner II was lost to
exactly such a bug).

If you want to allow the 3-parameter form to specify a negative step
size, that's fine. But don't use a heuristic to guess the intended
step direction.

> p.s. I did a `make distclean` prior to creating the attached diff. Do
> the lines at the top, e.g.:
> ? src/bin/pg_id/.deps
> ? src/bin/pg_id/pg_id
> ...
> indicate stuff not being cleaned up when it ought to be?

Something odd there. The src/bin/pg_id subdirectory should be entirely
gone in recent checkouts, and I'm not sure why you're seeing .so files
still laying about but they shouldn't be there either ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rajesh Kumar Mallah 2004-02-01 21:13:46 Functions in CHECK constraint not getting dumped before tables.
Previous Message Joe Conway 2004-02-01 20:54:18 Re: pg_generate_sequence and info_schema patch (Was: SELECT

Browse pgsql-patches by date

  From Date Subject
Next Message Claudio Natoli 2004-02-01 23:04:17 Re: pg_generate_sequence and info_schema patch (Was: SE
Previous Message Tom Lane 2004-02-01 20:57:00 Re: Patch for psql startup clarity