Re: Oracle date type compat. functions: next_day, last_day,

From: Neil Conway <neilc(at)samurai(dot)com>
To: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
Cc: pgsql-patches(at)postgresql(dot)org, david(at)fetter(dot)org, kzak(at)redhat(dot)com, hsn(at)netmag(dot)cz
Subject: Re: Oracle date type compat. functions: next_day, last_day,
Date: 2005-06-02 14:43:28
Message-ID: 429F1B10.2010007@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Pavel Stehule wrote:
> http://www.techonthenet.com/oracle/functions/add_months.htm
> http://www.techonthenet.com/oracle/functions/last_day.htm
> http://www.techonthenet.com/oracle/functions/next_day.htm
> http://www.techonthenet.com/oracle/functions/months_between.htm

Are these functions useful enough to be provided as builtins?
add_months(), for example, seems to be a less general version of 'date'
+ 'interval'.

> diff -c -r --new-file pgsql.old/src/include/catalog/pg_proc.h pgsql.new/src/include/catalog/pg_proc.h
> *** pgsql.old/src/include/catalog/pg_proc.h 2005-05-20 03:29:55.000000000 +0200
> --- pgsql.new/src/include/catalog/pg_proc.h 2005-05-24 13:55:16.000000000 +0200
> ***************
> *** 2195,2200 ****
> --- 2195,2208 ----
> DESCR("trim selected characters from both ends of string");
> DATA(insert OID = 885 ( btrim PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ btrim1 - _null_ ));
> DESCR("trim spaces from both ends of string");
> + DATA(insert OID = 901 ( next_day PGNSP PGUID 12 f f t f i 2 1082 "1082 25" _null_ _null_ _null_ next_day - _null_ ));
> + DESCR("return the first weekday that is greater than a date value");
> + DATA(insert OID = 902 ( last_day PGNSP PGUID 12 f f t f i 1 1082 "1082" _null_ _null_ _null_ last_day - _null_ ));
> + DESCR("last day of the month");
> + DATA(insert OID = 903 ( months_between PGNSP PGUID 12 f f t f i 2 701 "1082 1082" _null_ _null_ _null_ months_between - _null_ ));
> + DESCR("returns the number of months between date1 and date2");
> + DATA(insert OID = 904 ( add_months PGNSP PGUID 12 f f t f i 2 1082 "1082 23" _null_ _null_ _null_ add_months - _null_ ));
> + DESCR("returns a date plus n months");
>
> DATA(insert OID = 936 ( substring PGNSP PGUID 12 f f t f i 3 25 "25 23 23" _null_ _null_ _null_ text_substr - _null_ ));
> DESCR("return portion of string");

These OIDs duplicate some OIDs used in pg_operator -- it is standard
practice to assign OIDs to builtin system catalog rows that are unique
across the _entire_ system catalogs, not just the particular catalog
where the row exists. You can use the include/catalog/unused_oids script
to find some candidate OIDs.

-Neil

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Qingqing Zhou 2005-06-02 14:48:04 Re: Simplify Win32 Signaling code
Previous Message Pavel Stehule 2005-06-02 14:28:33 Re: pgsql: Add PL/pgSQL SQLSTATE and SQLERRM support