Re: pg_generate_sequence and info_schema patch (Was: SELECT Question) - Mailing list pgsql-patches

From Tom Lane
Subject Re: pg_generate_sequence and info_schema patch (Was: SELECT Question)
Date
Msg-id 12141.1075611626@sss.pgh.pa.us
Whole thread Raw
In response to pg_generate_sequence and info_schema patch (Was: SELECT Question)  (Joe Conway <mail@joeconway.com>)
Responses Re: pg_generate_sequence and info_schema patch (Was: SELECT  (Joe Conway <mail@joeconway.com>)
Re: pg_generate_sequence and info_schema patch (Was: SELECT  (Joe Conway <mail@joeconway.com>)
List pgsql-patches
Joe Conway <mail@joeconway.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.

> regression=# select * from pg_generate_sequence(3,8000000000);
> ERROR:  range of start to finish is too large
> HINT:  start to finish range must be less than 4294967295

Is there a good reason for that restriction?  (I've never thought it was
good design for the SRF API to assume that the number of iterations
could be determined in advance, anyway.)

> I'm not sure if it would be a good thing, or too confusing, to document
> pg_generate_sequence() on the "Sequence Manipulation Functions" page in
> the docs. Any opinions on that?

It is *not* a sequence function in the sense used on that page.  I'm not
quite sure where to put it, but don't give people the impression that it
is related to sequence objects.

I was going to say "pg_generate_sequence" is a fine name, but after
thinking about the lack of relation to sequence objects I think we ought
not use "sequence" in the name.  How about "pg_generate_series" or
"pg_generate_set"?  Actually I think you could leave off the pg_ prefix
and just make it generate_series or generate_set.  It's not
Postgres-specific in the same way that, say. pg_get_indexdef is.

Maybe the best documentation answer is to create a new subsection in the
Functions chapter.  This may be our first standard set-returning
function but I bet it will not be the last, so the shortness of the
subsection doesn't bother me.

            regards, tom lane

pgsql-patches by date:

Previous
From: Joe Conway
Date:
Subject: pg_generate_sequence and info_schema patch (Was: SELECT Question)
Next
From: Dennis Bjorklund
Date:
Subject: reading uninitialized buffer