Re: Oracle date type compat. functions: next_day, last_day, - Mailing list pgsql-patches

From Neil Conway
Subject Re: Oracle date type compat. functions: next_day, last_day,
Date
Msg-id 429F1B10.2010007@samurai.com
Whole thread Raw
In response to Oracle date type compat. functions: next_day, last_day, ..  (Pavel Stehule <stehule@kix.fsv.cvut.cz>)
Responses Re: Oracle date type compat. functions: next_day, last_day,
List 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

pgsql-patches by date:

Previous
From: "Luke Lonergan"
Date:
Subject: Re: COPY fast parse patch
Next
From: "Qingqing Zhou"
Date:
Subject: Re: Simplify Win32 Signaling code