mirror of
https://github.com/postgres/postgres.git
synced 2025-08-06 18:42:54 +03:00
From: Massimo Dal Zotto <dz@cs.unitn.it>
Here is a tar file the new directories, which substitute the old ones in contrib. Please remove the old directories array, datetime, miscutil, string and userlock before unpacking the tar file in contrib. Note that as the modules are now installed in lib/modules I install all my sql code in lib/sql. In my opinion also the other contributors should follow these rules.
This commit is contained in:
@@ -15,36 +15,35 @@ INCLUDE_OPT = -I ./ \
|
||||
-I $(SRCDIR)/include \
|
||||
-I $(SRCDIR)/port/$(PORTNAME)
|
||||
|
||||
CFLAGS += $(INCLUDE_OPT)
|
||||
|
||||
ifeq ($(PORTNAME), linux)
|
||||
ifdef LINUX_ELF
|
||||
ifeq ($(CC), gcc)
|
||||
CFLAGS += -fPIC
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PORTNAME), i386_solaris)
|
||||
CFLAGS+= -fPIC
|
||||
endif
|
||||
CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL)
|
||||
|
||||
MODNAME = datetime_functions
|
||||
|
||||
MODULE = $(MODNAME)$(DLSUFFIX)
|
||||
|
||||
MODDIR = $(LIBDIR)/modules
|
||||
|
||||
SQLDIR = $(LIBDIR)/sql
|
||||
|
||||
all: module sql
|
||||
|
||||
module: $(MODULE)
|
||||
|
||||
sql: $(MODNAME).sql
|
||||
|
||||
install: $(MODULE)
|
||||
cp -p $(MODULE) $(LIBDIR)/modules
|
||||
cd $(LIBDIR)/modules; strip $(MODULE)
|
||||
install: $(MODULE) $(MODDIR) $(SQLDIR)
|
||||
cp -p $(MODULE) $(MODDIR)/
|
||||
strip $(MODDIR)/$(MODULE)
|
||||
cp -p $(MODNAME).sql $(SQLDIR)/
|
||||
|
||||
$(MODDIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(SQLDIR):
|
||||
mkdir -p $@
|
||||
|
||||
%.sql: %.sql.in
|
||||
sed "s|MODULE_PATHNAME|$(LIBDIR)/modules/$(MODULE)|" < $< > $@
|
||||
sed "s|MODULE_PATHNAME|$(MODDIR)/$(MODULE)|" < $< > $@
|
||||
|
||||
.SUFFIXES: $(DLSUFFIX)
|
||||
|
||||
@@ -55,7 +54,7 @@ depend dep:
|
||||
$(CC) -MM $(INCLUDE_OPT) *.c >depend
|
||||
|
||||
clean:
|
||||
rm -f $(MODULE) $(MODNAME).sql
|
||||
rm -f *~ $(MODULE) $(MODNAME).sql
|
||||
|
||||
ifeq (depend,$(wildcard depend))
|
||||
include depend
|
||||
|
@@ -3,10 +3,13 @@
|
||||
*
|
||||
* This file defines new functions for the time and date data types.
|
||||
*
|
||||
* Copyright (c) 1996, Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* for sprintf() */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#ifdef HAVE_FLOAT_H
|
||||
@@ -102,7 +105,6 @@ hhmm_out(TimeADT *time)
|
||||
sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
|
||||
result = palloc(strlen(buf) + 1);
|
||||
|
||||
strcpy(result, buf);
|
||||
|
||||
return (result);
|
||||
@@ -220,3 +222,11 @@ currentdate()
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
@@ -1,16 +1,11 @@
|
||||
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)
|
||||
I have written some new funtions for time and date data types which can
|
||||
be used to extract hour,minutes,seconds from time values, and year,
|
||||
month,day from a date. There is also a time_difference and functions
|
||||
to convert a time to minutes or seconds.
|
||||
|
||||
There are also new input/output functions for the time data type which
|
||||
allow the insertion of time attributes with value 24:00:00.
|
||||
This can be useful if your application needs to compute time difference
|
||||
from two time values representing an elapsed time of 24 hours.
|
||||
|
||||
Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
@@ -1,6 +1,13 @@
|
||||
-- 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 functions
|
||||
-- Define the new time functions.
|
||||
--
|
||||
create function hhmm_in(opaque) returns time
|
||||
as 'MODULE_PATHNAME'
|
||||
@@ -58,16 +65,14 @@ create function currentdate() returns date
|
||||
as 'MODULE_PATHNAME'
|
||||
language 'c';
|
||||
|
||||
|
||||
-- Define a new operator - for time
|
||||
-- Define new operator - for time.
|
||||
--
|
||||
create operator - (
|
||||
leftarg=time,
|
||||
rightarg=time,
|
||||
procedure=time_difference);
|
||||
|
||||
|
||||
-- Define functions to switch from time to hhmm representation
|
||||
-- Define functions to switch from time to hhmm representation.
|
||||
--
|
||||
-- select hhmm_mode();
|
||||
-- select time_mode();
|
||||
@@ -84,7 +89,6 @@ create function time_mode() returns text
|
||||
select ''time_mode''::text'
|
||||
language 'sql';
|
||||
|
||||
|
||||
-- Use these to do the updates manually
|
||||
--
|
||||
-- update pg_type set typinput ='hhmm_in' where typname='time';
|
||||
|
Reference in New Issue
Block a user