postgresql/contrib/datetime/datetime_functions.sql.in
Bruce Momjian 27b8143944 Hi,
I have updated my contrib code for version 6.5. In the attachment you will
find the directories array, datetime, miscutil, string, tools and userlocks
which replace the corresponding directories under contrib.

In contrib/tools you will find some developement scripts which I use while
hacking the sources. I hope they will be useful for some other people.

I have also added a contrib/Makefile which tries to compile and install all
the contribs. Unfortunately many of them don't have a Makefile or don't
compile cleanly.

--
Massimo Dal Zotto
1999-06-05 19:09:48 +00:00

101 lines
2.5 KiB
MySQL

-- datetime_functions.sql --
--
-- SQL code to define the new date and time functions and operators
--
-- Copyright (c) 1998, Massimo Dal Zotto <dz@cs.unitn.it>
--
-- This file is distributed under the GNU General Public License
-- either version 2, or (at your option) any later version.
-- Define the new time functions.
--
create function hhmm_in(opaque) returns time
as 'MODULE_PATHNAME'
language 'c';
create function hhmm_out(opaque) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function hhmm(time) returns time
as 'MODULE_PATHNAME'
language 'c';
create function time_difference(time,time) returns time
as 'MODULE_PATHNAME'
language 'c';
create function time_hours(time) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function time_minutes(time) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function time_seconds(time) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function as_minutes(time) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function as_seconds(time) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function date_day(date) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function date_month(date) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function date_year(date) returns int4
as 'MODULE_PATHNAME'
language 'c';
create function currenttime() returns time
as 'MODULE_PATHNAME'
language 'c';
create function currentdate() returns date
as 'MODULE_PATHNAME'
language 'c';
-- Define new operator - for time.
--
create operator - (
leftarg=time,
rightarg=time,
procedure=time_difference);
-- Define functions to switch from time to hhmm representation.
--
-- select hhmm_mode();
-- select time_mode();
--
create function hhmm_mode() returns text
as 'update pg_type set typinput =''hhmm_in'' where typname=''time'';
update pg_type set typoutput=''hhmm_out'' where typname=''time'';
select ''hhmm_mode''::text;'
language 'sql';
create function time_mode() returns text
as 'update pg_type set typinput =''time_in'' where typname=''time'';
update pg_type set typoutput=''time_out'' where typname=''time'';
select ''time_mode''::text;'
language 'sql';
-- Use these to do the updates manually
--
-- update pg_type set typinput ='hhmm_in' where typname='time';
-- update pg_type set typoutput='hhmm_out' where typname='time';
--
-- update pg_type set typinput ='time_in' where typname='time';
-- update pg_type set typoutput='time_out' where typname='time';
-- end of file