mirror of https://github.com/postgres/postgres
pg_password utility. Cleanup for psql passwords. New datetime contrib stuff for new version. Fix for strutils needing config.h.
parent
8d0e658d06
commit
f8fda03d12
@ -1,25 +1,16 @@ |
||||
From: Massimo Dal Zotto <dz@cs.unitn.it> |
||||
Date: Tue, 14 May 1996 14:31:18 +0200 (MET DST) |
||||
Subject: [PG95]: new postgres functions |
||||
|
||||
- -----BEGIN PGP SIGNED MESSAGE----- |
||||
|
||||
Some time ago I read in the mailing list requests of people looking |
||||
for more time and date functions. I have now written some of them: |
||||
|
||||
time_difference(time1, time2) ,also defined as operator '-' |
||||
hour(time) |
||||
minutes(time) |
||||
seconds(time) |
||||
asMinutes(time) |
||||
asSeconds(time) |
||||
currentTime() |
||||
currentDate() |
||||
|
||||
The file can be compiled as shared library and loaded as dynamic module |
||||
without need to recompile the backend. This can also be taken as an example |
||||
of the extensibility of postgres (user-defined functions, operators, etc). |
||||
I would be nice to see more of these user contributed modules posted to this |
||||
list and hopefully accessible from the Postgres home page. |
||||
Date & time functions for use in Postgres version 6.1 & up |
||||
|
||||
This functions replaces the original ones from the postgresql.org |
||||
because the date & time structures has changed. |
||||
|
||||
There is a Makefile that should be "ajusted" |
||||
for directories where postgres home after install. |
||||
|
||||
In this case: /usr/postgres. |
||||
|
||||
Hope this can help, |
||||
|
||||
|
||||
Sergio Lenzi (lenzi@bsi.com.br) |
||||
|
||||
|
||||
|
||||
@ -1,69 +1,75 @@ |
||||
|
||||
-- SQL code to load and define 'datetime' functions |
||||
|
||||
-- load the new functions |
||||
|
||||
load '/home/dz/lib/postgres/datetime_functions.so'; |
||||
|
||||
-- define the new functions in postgres |
||||
func=$1 |
||||
cat <<% > datetime_functions.sql |
||||
drop function time_difference(time,time); |
||||
drop function currentdate(); |
||||
drop function currenttime(); |
||||
drop function hours(time); |
||||
drop function minutes(time); |
||||
drop function seconds(time); |
||||
drop function day(date); |
||||
drop function month(date); |
||||
drop function year(date); |
||||
drop function asminutes(time); |
||||
drop function asseconds(time); |
||||
drop operator - (time,time); |
||||
|
||||
create function time_difference(time,time) |
||||
returns time |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function currentDate() |
||||
create function currentdate() |
||||
returns date |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function currentTime() |
||||
create function currenttime() |
||||
returns time |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function hours(time) |
||||
returns int4 |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function minutes(time) |
||||
returns int4 |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function seconds(time) |
||||
returns int4 |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function day(date) |
||||
returns int4 |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function month(date) |
||||
returns int4 |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function year(date) |
||||
returns int4 |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function asMinutes(time) |
||||
create function asminutes(time) |
||||
returns int4 |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create function asSeconds(time) |
||||
create function asseconds(time) |
||||
returns int4 |
||||
as '/home/dz/lib/postgres/datetime_functions.so' |
||||
as '$func' |
||||
language 'c'; |
||||
|
||||
create operator - ( |
||||
leftarg=time, |
||||
rightarg=time, |
||||
procedure=time_difference); |
||||
|
||||
% |
||||
|
||||
Loading…
Reference in new issue