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 & time functions for use in Postgres version 6.1 & up |
||||||
Date: Tue, 14 May 1996 14:31:18 +0200 (MET DST) |
|
||||||
Subject: [PG95]: new postgres functions |
This functions replaces the original ones from the postgresql.org |
||||||
|
because the date & time structures has changed. |
||||||
- -----BEGIN PGP SIGNED MESSAGE----- |
|
||||||
|
There is a Makefile that should be "ajusted" |
||||||
Some time ago I read in the mailing list requests of people looking |
for directories where postgres home after install. |
||||||
for more time and date functions. I have now written some of them: |
|
||||||
|
In this case: /usr/postgres. |
||||||
time_difference(time1, time2) ,also defined as operator '-' |
|
||||||
hour(time) |
Hope this can help, |
||||||
minutes(time) |
|
||||||
seconds(time) |
|
||||||
asMinutes(time) |
Sergio Lenzi (lenzi@bsi.com.br) |
||||||
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. |
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,69 +1,75 @@ |
|||||||
|
func=$1 |
||||||
-- SQL code to load and define 'datetime' functions |
cat <<% > datetime_functions.sql |
||||||
|
drop function time_difference(time,time); |
||||||
-- load the new functions |
drop function currentdate(); |
||||||
|
drop function currenttime(); |
||||||
load '/home/dz/lib/postgres/datetime_functions.so'; |
drop function hours(time); |
||||||
|
drop function minutes(time); |
||||||
-- define the new functions in postgres |
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) |
create function time_difference(time,time) |
||||||
returns time |
returns time |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function currentDate() |
create function currentdate() |
||||||
returns date |
returns date |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function currentTime() |
create function currenttime() |
||||||
returns time |
returns time |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function hours(time) |
create function hours(time) |
||||||
returns int4 |
returns int4 |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function minutes(time) |
create function minutes(time) |
||||||
returns int4 |
returns int4 |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function seconds(time) |
create function seconds(time) |
||||||
returns int4 |
returns int4 |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function day(date) |
create function day(date) |
||||||
returns int4 |
returns int4 |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function month(date) |
create function month(date) |
||||||
returns int4 |
returns int4 |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function year(date) |
create function year(date) |
||||||
returns int4 |
returns int4 |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function asMinutes(time) |
create function asminutes(time) |
||||||
returns int4 |
returns int4 |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create function asSeconds(time) |
create function asseconds(time) |
||||||
returns int4 |
returns int4 |
||||||
as '/home/dz/lib/postgres/datetime_functions.so' |
as '$func' |
||||||
language 'c'; |
language 'c'; |
||||||
|
|
||||||
create operator - ( |
create operator - ( |
||||||
leftarg=time, |
leftarg=time, |
||||||
rightarg=time, |
rightarg=time, |
||||||
procedure=time_difference); |
procedure=time_difference); |
||||||
|
% |
||||||
|
|||||||
Loading…
Reference in new issue