mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Move contrib/odbc/odbc.sql together with odbc driver, remove old files;
revise ODBC "installation instructions"; update some other outdated documentation; update contrib documentation
This commit is contained in:
@ -1,82 +0,0 @@
|
||||
|
||||
The PostgreSQL contrib:
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
tips/apache_logging -
|
||||
Getting Apache to log to PostgreSQL
|
||||
by Terry Mackintosh <terry@terrym.com>
|
||||
|
||||
array -
|
||||
Array iterator functions
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
earthdistance -
|
||||
Operator for computing earth distance for two points
|
||||
by Hal Snyder <hal@vailsys.com>
|
||||
|
||||
findoidjoins -
|
||||
Finds the joins used by oid columns by examining the actual
|
||||
values in the oid columns and row oids.
|
||||
by Bruce Momjian <root@candle.pha.pa.us>
|
||||
|
||||
fulltextindex -
|
||||
Full text indexing using triggers
|
||||
by Maarten Boekhold <maartenb@dutepp0.et.tudelft.nl>
|
||||
|
||||
isbn_issn -
|
||||
PostgreSQL type extensions for ISBN (books) and ISSN (serials)
|
||||
by Garrett A. Wollman <wollman@khavrinen.lcs.mit.edu>
|
||||
|
||||
linux -
|
||||
Start postgres back end system
|
||||
by Thomas Lockhart <lockhart@alumni.caltech.edu>
|
||||
|
||||
lo -
|
||||
Large Object maintenance
|
||||
by Peter Mount <peter@retep.org.uk>
|
||||
|
||||
miscutil -
|
||||
Postgres assert checking and various utility functions
|
||||
by Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
mSQL-interface -
|
||||
mSQL API translation library
|
||||
by Aldrin Leal <aldrin@americasnet.com>
|
||||
|
||||
noupdate -
|
||||
trigger to prevent updates on single columns
|
||||
|
||||
|
||||
pg_dumplo -
|
||||
Dump large objects
|
||||
by Karel Zak <zakkr@zf.jcu.cz>
|
||||
|
||||
soundex -
|
||||
Prototype for soundex function
|
||||
|
||||
spi -
|
||||
A general trigger function autoinc() and so on.
|
||||
|
||||
string -
|
||||
C-like input/output conversion routines for strings
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
tools -
|
||||
Assorted developer tools
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
unixdate -
|
||||
Conversions from integer to datetime
|
||||
by Thomas Lockhart <lockhart@alumni.caltech.edu>
|
||||
|
||||
userlock -
|
||||
User locks
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
vacuumlo -
|
||||
Remove orphaned large objects
|
||||
by Peter T Mount <peter@retep.org.uk>
|
||||
|
||||
pgbench -
|
||||
TPC-B like benchmarking tool
|
||||
by Tatsuo Ishii <t-ishii@sra.co.jp>
|
@ -1,12 +1,8 @@
|
||||
#
|
||||
# The PostgreSQL contrib tree Makefile
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/contrib/Makefile,v 1.7 2000/07/16 14:50:29 petere Exp $
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/contrib/Makefile,v 1.8 2000/09/18 20:11:34 petere Exp $
|
||||
|
||||
subdir = contrib
|
||||
top_builddir = ..
|
||||
include ../src/Makefile.global
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
WANTED_DIRS = array \
|
||||
earthdistance \
|
||||
@ -16,6 +12,7 @@ WANTED_DIRS = array \
|
||||
linux \
|
||||
lo \
|
||||
mSQL-interface \
|
||||
mac \
|
||||
miscutil \
|
||||
noupdate \
|
||||
pg_dumplo \
|
||||
@ -27,19 +24,10 @@ WANTED_DIRS = array \
|
||||
unixdate \
|
||||
userlock \
|
||||
vacuumlo
|
||||
# odbc
|
||||
|
||||
all install installdirs uninstall clean distclean maintainer-clean:
|
||||
for dir in $(WANTED_DIRS); do \
|
||||
if [ -e $$dir/Makefile ]; then \
|
||||
$(MAKE) -C $$dir $@ ; \
|
||||
$(MAKE) -C $$dir $@; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
install:
|
||||
for dir in $(WANTED_DIRS); do \
|
||||
if [ -e $$dir/Makefile ]; then \
|
||||
$(MAKE) -C $$dir $@ ; \
|
||||
fi; \
|
||||
done
|
||||
$(INSTALL_DATA) Contrib.index $(docdir)/contrib
|
||||
|
162
contrib/README
162
contrib/README
@ -1,81 +1,109 @@
|
||||
The PostgreSQL contrib tree
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The PostgreSQL contrib tree
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
This subtree contains tools, modules, and examples that are not
|
||||
maintained as part of the core PostgreSQL system, mainly because
|
||||
they only address a limited audience or are too inelegant to be
|
||||
sold as an official feature. That, however, does not preclude
|
||||
their usefulness.
|
||||
|
||||
FIXME:
|
||||
odbc
|
||||
spi/preprocessor
|
||||
tools
|
||||
Each subdirectory contains a README file with information about the
|
||||
module. Most items can be built with `gmake all' and installed
|
||||
with `gmake install' in the usual fashion, after you have run the
|
||||
`configure' script in the top-level directory. Some directories
|
||||
supply new user-defined functions, operators, or types. After you
|
||||
have installed the files you need to register the new entities in
|
||||
the database system by running the commands in the supplied .sql
|
||||
file. For example,
|
||||
|
||||
- the contrib contain is in the "Contrib.index"
|
||||
$ psql -d dbname -f module.sql
|
||||
|
||||
- in each directory must be Makefile, possible Makefile template
|
||||
is below this text,
|
||||
|
||||
--------
|
||||
#
|
||||
# $Header: /cvsroot/pgsql/contrib/README,v 1.19 2000/06/19 13:52:59 momjian Exp $
|
||||
#
|
||||
|
||||
TOPDIR=../..
|
||||
|
||||
include ../Makefile.global
|
||||
|
||||
NAME = some_name
|
||||
|
||||
PROGRAM =
|
||||
OBJS = $(NAME).o
|
||||
DOCS = $(NAME).doc
|
||||
SQLS = $(NAME).sql
|
||||
BINS =
|
||||
EXAMPLES=
|
||||
MODS = $(NAME)$(DLSUFFIX)
|
||||
|
||||
CFLAGS += -I. $(CFLAGS_SL)
|
||||
|
||||
OTHER_CLEAN = $(SQLS)
|
||||
|
||||
all: $(MODS) $(SQLS)
|
||||
|
||||
%.sql: %.sql.in
|
||||
$(SED) "s|MODULE_PATHNAME|$(CONTRIB_MODDIR)/$@|" < $< > $@
|
||||
See the PostgreSQL documentation for more information about this
|
||||
procedure.
|
||||
|
||||
|
||||
install: install_doc install_sql install_mod install_bin install_example
|
||||
Index:
|
||||
------
|
||||
|
||||
install_doc:
|
||||
for inst_file in $(DOCS); do \
|
||||
$(INSTALL) $(INSTL_LIB_OPTS) $$inst_file $(CONTRIB_DOCDIR); \
|
||||
done
|
||||
array -
|
||||
Array iterator functions
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
install_sql:
|
||||
for inst_file in $(SQLS); do \
|
||||
$(INSTALL) $(INSTL_LIB_OPTS) $$inst_file $(CONTRIB_SQLDIR); \
|
||||
done
|
||||
earthdistance -
|
||||
Operator for computing earth distance for two points
|
||||
by Hal Snyder <hal@vailsys.com>
|
||||
|
||||
install_mod:
|
||||
for inst_file in $(MODS); do \
|
||||
$(INSTALL) $(INSTL_SHLIB_OPTS) $$inst_file $(CONTRIB_MODDIR); \
|
||||
done
|
||||
findoidjoins -
|
||||
Finds the joins used by oid columns by examining the actual
|
||||
values in the oid columns and row oids.
|
||||
by Bruce Momjian <pgman@candle.pha.pa.us>
|
||||
|
||||
install_bin:
|
||||
for inst_file in $(BINS); do \
|
||||
$(INSTALL) $(INSTL_EXE_OPTS) $$inst_file $(CONTRIB_BINDIR); \
|
||||
done
|
||||
fulltextindex -
|
||||
Full text indexing using triggers
|
||||
by Maarten Boekhold <maartenb@dutepp0.et.tudelft.nl>
|
||||
|
||||
install_example:
|
||||
for inst_file in $(EXAMPLES); do \
|
||||
$(INSTALL) $(INSTL_LIB_OPTS) $$inst_file $(CONTRIB_EXAMPLESDIR); \
|
||||
done
|
||||
isbn_issn -
|
||||
PostgreSQL type extensions for ISBN (books) and ISSN (serials)
|
||||
by Garrett A. Wollman <wollman@khavrinen.lcs.mit.edu>
|
||||
|
||||
depend dep:
|
||||
$(CC) -MM -MG $(CFLAGS) *.c > depend
|
||||
linux -
|
||||
Scripts for starting and stopping the PostgreSQL server on
|
||||
a Linux system
|
||||
by Thomas Lockhart <lockhart@alumni.caltech.edu>
|
||||
|
||||
clean:
|
||||
$(RM) *~ $(OBJS) $(MODS) $(PROGRAM) depend $(OTHER_CLEAN) core log
|
||||
lo -
|
||||
Large Object maintenance
|
||||
by Peter Mount <peter@retep.org.uk>
|
||||
|
||||
ifeq (depend,$(wildcard depend))
|
||||
include depend
|
||||
endif
|
||||
-----------
|
||||
|
||||
mSQL-interface -
|
||||
mSQL API translation library
|
||||
by Aldrin Leal <aldrin@americasnet.com>
|
||||
|
||||
mac -
|
||||
Support functions for MAC address types
|
||||
by Lawrence E. Rosenman <ler@lerctr.org>
|
||||
|
||||
miscutil -
|
||||
PostgreSQL assert checking and various utility functions
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
noupdate -
|
||||
trigger to prevent updates on single columns
|
||||
|
||||
pgbench -
|
||||
TPC-B like benchmarking tool
|
||||
by Tatsuo Ishii <t-ishii@sra.co.jp>
|
||||
|
||||
pg_dumplo -
|
||||
Dump large objects
|
||||
by Karel Zak <zakkr@zf.jcu.cz>
|
||||
|
||||
soundex -
|
||||
Soundex function
|
||||
|
||||
spi -
|
||||
Various trigger functions, examples for using SPI.
|
||||
|
||||
string -
|
||||
C-like input/output conversion routines for strings
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
tips/apache_logging -
|
||||
Getting Apache to log to PostgreSQL
|
||||
by Terry Mackintosh <terry@terrym.com>
|
||||
|
||||
tools -
|
||||
Assorted developer tools
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
unixdate -
|
||||
Conversions from integer to datetime
|
||||
by Thomas Lockhart <lockhart@alumni.caltech.edu>
|
||||
|
||||
userlock -
|
||||
User locks
|
||||
by Massimo Dal Zotto <dz@cs.unitn.it>
|
||||
|
||||
vacuumlo -
|
||||
Remove orphaned large objects
|
||||
by Peter T Mount <peter@retep.org.uk>
|
||||
|
8
contrib/mac/README.mac
Normal file
8
contrib/mac/README.mac
Normal file
@ -0,0 +1,8 @@
|
||||
This directory contains tools to create a mapping table from MAC
|
||||
addresses (e.g., Ethernet hardware addresses) to human-readable
|
||||
manufacturer strings. The `createoui' script builds the table
|
||||
structure, `updateoui' obtains the current official mapping table
|
||||
from the web site of the IEEE, converts it, and stores it in the
|
||||
database, `dropoui' removes everything. Use the --help option to
|
||||
get more usage information from the respective script. All three
|
||||
use the psql program; any extra arguments will be passed to psql.
|
@ -1,48 +0,0 @@
|
||||
# ODBC extensions
|
||||
# Thomas Lockhart 2000-04-03
|
||||
|
||||
subdir = contrib/odbc
|
||||
top_builddir = ../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
ifndef PGLIB
|
||||
PGLIB= .
|
||||
endif
|
||||
|
||||
CFLAGS+= $(CFLAGS_SL)
|
||||
|
||||
TARGETS_7= odbc.sql
|
||||
TARGETS_PRE7= odbc$(DLSUFFIX) odbc-pre7.sql
|
||||
|
||||
TARGETS= $(TARGETS_7)
|
||||
|
||||
CLEANFILES+= $(TARGETS) $(TARGETS_PRE7)
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
install: all
|
||||
ifneq ($(filter odbc$(DLSUFFIX), $(TARGETS)),)
|
||||
-test -d $(PGLIB) || $(INSTALL) -d $(PGLIB)
|
||||
$(INSTALL) odbc$(DLSUFFIX) $(PGLIB)
|
||||
endif
|
||||
|
||||
pre7:
|
||||
$(MAKE) TARGETS="$(TARGETS) $(TARGETS_PRE7)"
|
||||
|
||||
install-pre7:
|
||||
$(MAKE) TARGETS="$(TARGETS) $(TARGETS_PRE7)" install
|
||||
|
||||
odbc-pre7.sql: odbc-pre7.source odbc.sql
|
||||
rm -f $@; \
|
||||
cat $^ \
|
||||
| sed -e "s:_OBJWD_:$(PGLIB):g" \
|
||||
-e "s:_DLSUFFIX_:$(DLSUFFIX):g" \
|
||||
-e "s:float(15):float8:g" > $@
|
||||
|
||||
%.sql: %.source
|
||||
rm -f $@; \
|
||||
sed -e "s:_OBJWD_:$(PGLIB):g" \
|
||||
-e "s:_DLSUFFIX_:$(DLSUFFIX):g" < $< > $@
|
||||
|
||||
clean:
|
||||
rm -f $(TARGETS) *.o
|
@ -1,38 +0,0 @@
|
||||
This directory contains support functions for the ODBC driver
|
||||
supplied with PostgreSQL-7.0.
|
||||
|
||||
To enable additional ODBC functions with PostgreSQL-7.0, simply
|
||||
execute the commands in odbc.sql:
|
||||
|
||||
psql
|
||||
Welcome to psql, the PostgreSQL interactive terminal.
|
||||
|
||||
Type: \copyright for distribution terms
|
||||
\h for help with SQL commands
|
||||
\? for help on internal slash commands
|
||||
\g or terminate with semicolon to execute query
|
||||
\q to quit
|
||||
|
||||
postgres=# \i odbc.sql
|
||||
CREATE
|
||||
...
|
||||
|
||||
|
||||
To enable additional ODBC functions with versions of PostgreSQL
|
||||
prior to PostgreSQL-7.0 (e.g. PostgreSQL-6.5.3), build the shared
|
||||
library and SQL commands as follows:
|
||||
|
||||
make pre7
|
||||
psql
|
||||
Welcome to psql, the PostgreSQL interactive terminal.
|
||||
|
||||
Type: \copyright for distribution terms
|
||||
\h for help with SQL commands
|
||||
\? for help on internal slash commands
|
||||
\g or terminate with semicolon to execute query
|
||||
\q to quit
|
||||
|
||||
postgres=# \i odbc-pre7.sql
|
||||
CREATE
|
||||
...
|
||||
|
@ -1,162 +0,0 @@
|
||||
-- ODBC-pre7.sql
|
||||
--
|
||||
-- Use float8 rather than float(15) since pre-7.0 does not accept
|
||||
-- SQL92 type names of this form in the CREATE FUNCTION command.
|
||||
--
|
||||
|
||||
--
|
||||
-- Character string manipulation
|
||||
--
|
||||
|
||||
--
|
||||
-- Compatibility functions for pre-v7.0.
|
||||
-- These should be applied to pre-v7.0 databases
|
||||
-- when using the v7.0 ODBC driver.
|
||||
--
|
||||
|
||||
CREATE FUNCTION char_length(text)
|
||||
RETURNS integer
|
||||
AS 'SELECT length(CAST($1 AS text))'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION pow(float8)
|
||||
RETURNS float8
|
||||
AS 'SELECT dpow($1)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
--
|
||||
-- Extensions for ODBC compliance in v7.0.
|
||||
-- In the current driver, ODBC functions must map directly into a
|
||||
-- Postgres function. So in some cases we must create a compatible
|
||||
-- function.
|
||||
--
|
||||
|
||||
CREATE FUNCTION ascii(text)
|
||||
RETURNS integer
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'ascii'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION ichar(integer)
|
||||
RETURNS char(1)
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'ichar'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION insert(text, integer, integer, text)
|
||||
RETURNS text
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'insert'
|
||||
LANGUAGE 'C';
|
||||
|
||||
-- replace all occurences of $2 with $3
|
||||
CREATE FUNCTION replace(text, text, text)
|
||||
RETURNS text
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'replace'
|
||||
LANGUAGE 'C';
|
||||
|
||||
-- return the string repeated n times
|
||||
CREATE FUNCTION repeat(text, integer)
|
||||
RETURNS text
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'repeat'
|
||||
LANGUAGE 'C';
|
||||
|
||||
--
|
||||
-- Mathematical functions for pre-v7.0
|
||||
--
|
||||
|
||||
CREATE FUNCTION dround(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'dround'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION round(float8)
|
||||
RETURNS float8
|
||||
AS 'SELECT dround($1)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
--
|
||||
-- Math functions present in backend, but not in catalog for v7.0
|
||||
--
|
||||
|
||||
CREATE FUNCTION acos(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'dacos'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION asin(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'dasin'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION atan(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'datan'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION atan2(float8,float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'datan2'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION cos(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'dcos'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION cot(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'dcot'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION sin(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'dsin'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION dtan(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'dtan'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION degrees(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'degrees'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION pi()
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'dpi'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION radians(float8)
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'radians'
|
||||
LANGUAGE 'C';
|
||||
|
||||
-- random number generator currently requires RAND_MAX be available
|
||||
CREATE FUNCTION random()
|
||||
RETURNS float8
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_', 'drandom'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE FUNCTION truncate(numeric,integer)
|
||||
RETURNS numeric
|
||||
AS 'SELECT trunc($1, $2)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
--
|
||||
-- Date/time functions for v7.0
|
||||
--
|
||||
|
||||
CREATE FUNCTION interval_mul(interval,float8)
|
||||
RETURNS interval
|
||||
AS '_OBJWD_/odbc_DLSUFFIX_'
|
||||
LANGUAGE 'C';
|
||||
|
||||
CREATE OPERATOR * (
|
||||
LEFTARG = interval,
|
||||
RIGHTARG = float8,
|
||||
PROCEDURE = interval_mul
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
@ -1,403 +0,0 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <float.h> /* faked on sunos4 */
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "utils/timestamp.h"
|
||||
#include "utils/builtins.h"
|
||||
|
||||
|
||||
int4 ascii(text *string);
|
||||
text *ichar(int4 cvalue);
|
||||
text *repeat(text *string, int4 count);
|
||||
Interval *interval_mul(Interval *span1, float8 *arg2);
|
||||
float64 dasin(float64 arg1);
|
||||
float64 datan(float64 arg1);
|
||||
float64 datan2(float64 arg1, float64 arg2);
|
||||
float64 dcos(float64 arg1);
|
||||
float64 dcot(float64 arg1);
|
||||
float64 dsin(float64 arg1);
|
||||
float64 dtan(float64 arg1);
|
||||
float64 degrees(float64 arg1);
|
||||
float64 dpi(void);
|
||||
float64 radians(float64 arg1);
|
||||
float64 drandom(void);
|
||||
void setseed(int32 seed);
|
||||
|
||||
|
||||
int4
|
||||
ascii(text *string)
|
||||
{
|
||||
if (!PointerIsValid(string))
|
||||
return 0;
|
||||
|
||||
if (VARSIZE(string) <= VARHDRSZ)
|
||||
return 0;
|
||||
|
||||
return ((int) *(VARDATA(string)));
|
||||
} /* ascii() */
|
||||
|
||||
|
||||
text *
|
||||
ichar(int4 cvalue)
|
||||
{
|
||||
text *result;
|
||||
|
||||
result = (text *) palloc(VARHDRSZ + 1);
|
||||
VARSIZE(result) = VARHDRSZ + 1;
|
||||
*VARDATA(result) = (char) cvalue;
|
||||
|
||||
return result;
|
||||
} /* ichar() */
|
||||
|
||||
|
||||
text *
|
||||
repeat(text *string, int4 count)
|
||||
{
|
||||
text *result;
|
||||
int slen, tlen;
|
||||
int i;
|
||||
char *cp;
|
||||
|
||||
if (count < 0)
|
||||
count = 0;
|
||||
|
||||
slen = (VARSIZE(string)-VARHDRSZ);
|
||||
tlen = (VARHDRSZ + (count * slen));
|
||||
|
||||
result = (text *) palloc(tlen);
|
||||
|
||||
VARSIZE(result) = tlen;
|
||||
cp = VARDATA(result);
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
memcpy(cp, VARDATA(string), slen);
|
||||
cp += slen;
|
||||
}
|
||||
|
||||
return result;
|
||||
} /* ichar() */
|
||||
|
||||
Interval *
|
||||
interval_mul(Interval *span1, float8 *arg2)
|
||||
{
|
||||
Interval *result;
|
||||
double months;
|
||||
|
||||
if ((!PointerIsValid(span1)) || (!PointerIsValid(arg2)))
|
||||
return NULL;
|
||||
|
||||
if (!PointerIsValid(result = palloc(sizeof(Interval))))
|
||||
elog(ERROR, "Memory allocation failed, can't divide intervals");
|
||||
|
||||
months = (span1->month * *arg2);
|
||||
result->month = rint(months);
|
||||
result->time = JROUND(span1->time * *arg2);
|
||||
result->time += JROUND((months - result->month) * 30);
|
||||
|
||||
return result;
|
||||
} /* interval_mul() */
|
||||
|
||||
/*
|
||||
* dasin - returns a pointer to the arcsin of arg1 (radians)
|
||||
*/
|
||||
float64
|
||||
dasin(float64 arg1)
|
||||
{
|
||||
float64 result;
|
||||
double tmp;
|
||||
|
||||
if (!PointerIsValid(arg1))
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
tmp = *arg1;
|
||||
errno = 0;
|
||||
*result = (float64data) asin(tmp);
|
||||
if (errno != 0
|
||||
#ifdef HAVE_FINITE
|
||||
|| !finite(*result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "dasin(%f) input is out of range", *arg1);
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* dasin() */
|
||||
|
||||
|
||||
/*
|
||||
* datan - returns a pointer to the arctan of arg1 (radians)
|
||||
*/
|
||||
float64
|
||||
datan(float64 arg1)
|
||||
{
|
||||
float64 result;
|
||||
double tmp;
|
||||
|
||||
if (!PointerIsValid(arg1))
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
tmp = *arg1;
|
||||
errno = 0;
|
||||
*result = (float64data) atan(tmp);
|
||||
if (errno != 0
|
||||
#ifdef HAVE_FINITE
|
||||
|| !finite(*result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "atan(%f) input is out of range", *arg1);
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* datan() */
|
||||
|
||||
|
||||
/*
|
||||
* atan2 - returns a pointer to the arctan2 of arg1 (radians)
|
||||
*/
|
||||
float64
|
||||
datan2(float64 arg1, float64 arg2)
|
||||
{
|
||||
float64 result;
|
||||
|
||||
if (!PointerIsValid(arg1) || !PointerIsValid(arg1))
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
errno = 0;
|
||||
*result = (float64data) atan2(*arg1, *arg2);
|
||||
if (errno != 0
|
||||
#ifdef HAVE_FINITE
|
||||
|| !finite(*result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "atan2(%f,%f) input is out of range", *arg1, *arg2);
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* datan2() */
|
||||
|
||||
|
||||
/*
|
||||
* dcos - returns a pointer to the cosine of arg1 (radians)
|
||||
*/
|
||||
float64
|
||||
dcos(float64 arg1)
|
||||
{
|
||||
float64 result;
|
||||
double tmp;
|
||||
|
||||
if (!PointerIsValid(arg1))
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
tmp = *arg1;
|
||||
errno = 0;
|
||||
*result = (float64data) cos(tmp);
|
||||
if (errno != 0
|
||||
#ifdef HAVE_FINITE
|
||||
|| !finite(*result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "dcos(%f) input is out of range", *arg1);
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* dcos() */
|
||||
|
||||
|
||||
/*
|
||||
* dcot - returns a pointer to the cotangent of arg1 (radians)
|
||||
*/
|
||||
float64
|
||||
dcot(float64 arg1)
|
||||
{
|
||||
float64 result;
|
||||
double tmp;
|
||||
|
||||
if (!PointerIsValid(arg1))
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
tmp = *arg1;
|
||||
errno = 0;
|
||||
*result = (float64data) tan(tmp);
|
||||
if ((errno != 0) || (*result == 0.0)
|
||||
#ifdef HAVE_FINITE
|
||||
|| !finite(*result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "dcot(%f) input is out of range", *arg1);
|
||||
|
||||
*result = 1.0/(*result);
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* dcot() */
|
||||
|
||||
|
||||
/*
|
||||
* dsin - returns a pointer to the sine of arg1 (radians)
|
||||
*/
|
||||
float64
|
||||
dsin(float64 arg1)
|
||||
{
|
||||
float64 result;
|
||||
double tmp;
|
||||
|
||||
if (!PointerIsValid(arg1))
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
tmp = *arg1;
|
||||
errno = 0;
|
||||
*result = (float64data) sin(tmp);
|
||||
if (errno != 0
|
||||
#ifdef HAVE_FINITE
|
||||
|| !finite(*result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "dsin(%f) input is out of range", *arg1);
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* dsin() */
|
||||
|
||||
|
||||
/*
|
||||
* dtan - returns a pointer to the tangent of arg1 (radians)
|
||||
*/
|
||||
float64
|
||||
dtan(float64 arg1)
|
||||
{
|
||||
float64 result;
|
||||
double tmp;
|
||||
|
||||
if (!PointerIsValid(arg1))
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
tmp = *arg1;
|
||||
errno = 0;
|
||||
*result = (float64data) tan(tmp);
|
||||
if (errno != 0
|
||||
#ifdef HAVE_FINITE
|
||||
|| !finite(*result)
|
||||
#endif
|
||||
)
|
||||
elog(ERROR, "dtan(%f) input is out of range", *arg1);
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* dtan() */
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
/* from my RH5.2 gcc math.h file - thomas 2000-04-03 */
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* degrees - returns a pointer to degrees converted from radians
|
||||
*/
|
||||
float64
|
||||
degrees(float64 arg1)
|
||||
{
|
||||
float64 result;
|
||||
|
||||
if (!arg1)
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
*result = ((*arg1) * (180.0 / M_PI));
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* degrees() */
|
||||
|
||||
|
||||
/*
|
||||
* dpi - returns a pointer to degrees converted to radians
|
||||
*/
|
||||
float64
|
||||
dpi(void)
|
||||
{
|
||||
float64 result;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
*result = (M_PI);
|
||||
|
||||
return result;
|
||||
} /* dpi() */
|
||||
|
||||
|
||||
/*
|
||||
* radians - returns a pointer to radians converted from degrees
|
||||
*/
|
||||
float64
|
||||
radians(float64 arg1)
|
||||
{
|
||||
float64 result;
|
||||
|
||||
if (!arg1)
|
||||
return (float64) NULL;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
*result = ((*arg1) * (M_PI / 180.0));
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* radians() */
|
||||
|
||||
|
||||
#ifdef RAND_MAX
|
||||
|
||||
/*
|
||||
* drandom - returns a random number
|
||||
*/
|
||||
float64
|
||||
drandom(void)
|
||||
{
|
||||
float64 result;
|
||||
|
||||
result = (float64) palloc(sizeof(float64data));
|
||||
|
||||
/* result 0.0-1.0 */
|
||||
*result = (((double)rand()) / RAND_MAX);
|
||||
|
||||
CheckFloat8Val(*result);
|
||||
return result;
|
||||
} /* drandom() */
|
||||
|
||||
|
||||
/*
|
||||
* setseed - set seed for the random number generator
|
||||
*/
|
||||
void
|
||||
setseed(int32 seed)
|
||||
{
|
||||
srand(seed);
|
||||
|
||||
return;
|
||||
} /* setseed() */
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,145 +0,0 @@
|
||||
-- ODBC.sql
|
||||
--
|
||||
|
||||
--
|
||||
-- Character string manipulation
|
||||
--
|
||||
|
||||
--
|
||||
-- Extensions for ODBC compliance in v7.0.
|
||||
-- In the current driver, ODBC functions must map directly into a
|
||||
-- Postgres function. So in some cases we must create a compatible
|
||||
-- function.
|
||||
--
|
||||
|
||||
-- truncate on the left
|
||||
CREATE FUNCTION ltrunc(text, integer)
|
||||
RETURNS text
|
||||
AS 'SELECT substring($1 FROM 1 FOR $2)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
-- truncate on the right
|
||||
CREATE FUNCTION rtrunc(text, integer)
|
||||
RETURNS text
|
||||
AS 'SELECT substring($1 FROM (char_length($1)-($2)+1) FOR $2)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION space(integer)
|
||||
RETURNS text
|
||||
AS 'SELECT lpad('''', $1, '' '')'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
--
|
||||
-- Mathematical functions
|
||||
--
|
||||
|
||||
CREATE FUNCTION truncate(numeric,integer)
|
||||
RETURNS numeric
|
||||
AS 'SELECT trunc($1, $2)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
--
|
||||
-- Date/time functions for v7.0
|
||||
--
|
||||
|
||||
CREATE FUNCTION curdate()
|
||||
RETURNS date
|
||||
AS 'SELECT CAST(''now'' AS date)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION curtime()
|
||||
RETURNS time
|
||||
AS 'SELECT CAST(''now'' AS time)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION dayname(timestamp)
|
||||
RETURNS text
|
||||
AS 'SELECT to_char($1,''Day'')'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION dayofmonth(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''day'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION dayofweek(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT ( CAST(date_part(''dow'', $1) AS integer) + 1)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION dayofyear(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''doy'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION hour(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''hour'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION minute(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''minute'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION odbc_month(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''month'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION monthname(timestamp)
|
||||
RETURNS text
|
||||
AS 'SELECT to_char($1, ''Month'')'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION quarter(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''quarter'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION second(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''second'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
/*
|
||||
-- The first argument is an integer constant denoting the units
|
||||
-- of the second argument. Until we know the actual values, we
|
||||
-- cannot implement these. - thomas 2000-04-11
|
||||
CREATE FUNCTION timestampadd(integer,integer,timestamp)
|
||||
RETURNS timestamp
|
||||
AS 'SELECT CAST(($3 + ($2 * $1)) AS timestamp)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION timestampdiff(integer,integer,timestamp)
|
||||
RETURNS timestamp
|
||||
AS 'SELECT CAST(($3 + ($2 * $1)) AS timestamp)'
|
||||
LANGUAGE 'SQL';
|
||||
*/
|
||||
|
||||
CREATE FUNCTION week(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''week'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
CREATE FUNCTION year(timestamp)
|
||||
RETURNS integer
|
||||
AS 'SELECT CAST(date_part(''year'', $1) AS integer)'
|
||||
LANGUAGE 'SQL';
|
||||
|
||||
--
|
||||
-- System functions.
|
||||
--
|
||||
|
||||
/*
|
||||
CREATE FUNCTION database()
|
||||
RETURNS text
|
||||
AS 'SELECT ...'
|
||||
LANGUAGE 'SQL';
|
||||
*/
|
||||
|
||||
CREATE FUNCTION odbc_user()
|
||||
RETURNS text
|
||||
AS 'SELECT CAST(USER AS text)'
|
||||
LANGUAGE 'SQL';
|
||||
|
Reference in New Issue
Block a user