pg_generate_sequence and info_schema patch (Was: SELECT Question)

From: Joe Conway <mail(at)joeconway(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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: pg_generate_sequence and info_schema patch (Was: SELECT Question)
Date: 2004-02-01 04:31:00
Message-ID: 401C8104.80903@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

Joe Conway wrote:
> Tom Lane wrote:
>> I was thinking of proposing that we provide something just about like
>> that as a standard function (written in C, not in plpgsql, so that it
>> would be available whether or not you'd installed plpgsql). There are
>> some places in the information_schema that desperately need it ---
>> right now, the value of FUNC_MAX_ARGS is effectively hard-wired into
>> some of the information_schema views, which means they are broken if
>> one changes that #define. We could fix this if we had a function like
>> the above and exported FUNC_MAX_ARGS as a read-only GUC variable.
>
> The attached patch introduces a C function as discussed above. Looks
> like this:

The attached incorporates the feedback received. Specifically there is
now an int8 version of the function, and I left it as a simple
start-to-finish sequence generator. Result looks like this:

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

regression=# select * from pg_generate_sequence(8, 4);
ERROR: finish is less than start

regression=# select * from pg_generate_sequence(8000000000, 8000000004);
pg_generate_sequence
----------------------
8000000000
8000000001
8000000002
8000000003
8000000004
(5 rows)

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

I'm still not sure the name is the best -- other ideas welcome. Also,
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?

If there are no objections I'll commit in 24 hours or so. Barring better
ideas, I'll probably add pg_generate_sequence() to "Sequence
Manipulation Functions".

Thanks,

Joe

Attachment Content-Type Size
current.75.diff text/plain 8.7 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2004-02-01 04:41:54 Re: Are there commands to enquire about table structure?
Previous Message Tom Lane 2004-02-01 03:52:57 Re: Incorrect Results From Select When Using Non-English Characters

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-02-01 05:00:26 Re: pg_generate_sequence and info_schema patch (Was: SELECT Question)
Previous Message Joe Conway 2004-02-01 04:07:38 Re: [HACKERS] v7.4.1 text_position() patch