Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f2a07d

Browse files
author
Thomas G. Lockhart
committed
Internal functions to support newest ODBC driver {fn ...} conventions.
Includes compiled code to support pre-7.0 backends, but for 7.0 onlyrequires executing odbc.sql.
1 parentf947bbb commit9f2a07d

File tree

5 files changed

+806
-0
lines changed

5 files changed

+806
-0
lines changed

‎contrib/odbc/Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# ODBC extensions
2+
# Thomas Lockhart 2000-04-03
3+
4+
SRCDIR= ../../src
5+
6+
include$(SRCDIR)/Makefile.global
7+
8+
ifndefPGLIB
9+
PGLIB= .
10+
endif
11+
12+
CFLAGS+=$(CFLAGS_SL) -I$(SRCDIR)/include
13+
14+
TARGETS_7= odbc.sql
15+
TARGETS_PRE7= odbc$(DLSUFFIX) odbc-pre7.sql
16+
17+
TARGETS=$(TARGETS_7)
18+
19+
CLEANFILES+=$(TARGETS)$(TARGETS_PRE7)
20+
21+
all::$(TARGETS)
22+
23+
install: all
24+
ifneq ($(filter odbc$(DLSUFFIX),$(TARGETS)),)
25+
-test -d $(PGLIB) || $(INSTALL) -d $(PGLIB)
26+
$(INSTALL) odbc$(DLSUFFIX) $(PGLIB)
27+
endif
28+
29+
pre7:
30+
$(MAKE) TARGETS="$(TARGETS)$(TARGETS_PRE7)"
31+
32+
install-pre7:
33+
$(MAKE) TARGETS="$(TARGETS)$(TARGETS_PRE7)" install
34+
35+
odbc-pre7.sql: odbc-pre7.source odbc.sql
36+
rm -f$@;\
37+
cat$^\
38+
| sed -e"s:_OBJWD_:$(PGLIB):g"\
39+
-e"s:_DLSUFFIX_:$(DLSUFFIX):g"\
40+
-e"s:float(15):float8:g">$@
41+
42+
%.sql:%.source
43+
rm -f$@;\
44+
sed -e"s:_OBJWD_:$(PGLIB):g"\
45+
-e"s:_DLSUFFIX_:$(DLSUFFIX):g"<$<>$@
46+
47+
clean:
48+
rm -f$(TARGETS)*.o

‎contrib/odbc/README

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
This directory contains support functions for the ODBC driver
2+
supplied with PostgreSQL-7.0.
3+
4+
To enable additional ODBC functions with PostgreSQL-7.0, simply
5+
execute the commands in odbc.sql:
6+
7+
psql
8+
Welcome to psql, the PostgreSQL interactive terminal.
9+
10+
Type: \copyright for distribution terms
11+
\h for help with SQL commands
12+
\? for help on internal slash commands
13+
\g or terminate with semicolon to execute query
14+
\q to quit
15+
16+
postgres=# \i odbc.sql
17+
CREATE
18+
...
19+
20+
21+
To enable additional ODBC functions with versions of PostgreSQL
22+
prior to PostgreSQL-7.0 (e.g. PostgreSQL-6.5.3), build the shared
23+
library and SQL commands as follows:
24+
25+
make pre7
26+
psql
27+
Welcome to psql, the PostgreSQL interactive terminal.
28+
29+
Type: \copyright for distribution terms
30+
\h for help with SQL commands
31+
\? for help on internal slash commands
32+
\g or terminate with semicolon to execute query
33+
\q to quit
34+
35+
postgres=# \i odbc-pre7.sql
36+
CREATE
37+
...
38+

‎contrib/odbc/odbc-pre7.source

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
-- ODBC-pre7.sql
2+
--
3+
-- Use float8 rather than float(15) since pre-7.0 does not accept
4+
-- SQL92 type names of this form in the CREATE FUNCTION command.
5+
--
6+
7+
--
8+
-- Character string manipulation
9+
--
10+
11+
--
12+
-- Compatibility functions for pre-v7.0.
13+
-- These should be applied to pre-v7.0 databases
14+
-- when using the v7.0 ODBC driver.
15+
--
16+
17+
CREATE FUNCTION char_length(text)
18+
RETURNS integer
19+
AS 'SELECT length(CAST($1 AS text))'
20+
LANGUAGE 'SQL';
21+
22+
CREATE FUNCTION pow(float8)
23+
RETURNS float8
24+
AS 'SELECT dpow($1)'
25+
LANGUAGE 'SQL';
26+
27+
--
28+
-- Extensions for ODBC compliance in v7.0.
29+
-- In the current driver, ODBC functions must map directly into a
30+
-- Postgres function. So in some cases we must create a compatible
31+
-- function.
32+
--
33+
34+
CREATE FUNCTION ascii(text)
35+
RETURNS integer
36+
AS '_OBJWD_/odbc_DLSUFFIX_', 'ascii'
37+
LANGUAGE 'C';
38+
39+
CREATE FUNCTION ichar(integer)
40+
RETURNS char(1)
41+
AS '_OBJWD_/odbc_DLSUFFIX_', 'ichar'
42+
LANGUAGE 'C';
43+
44+
CREATE FUNCTION insert(text, integer, integer, text)
45+
RETURNS text
46+
AS '_OBJWD_/odbc_DLSUFFIX_', 'insert'
47+
LANGUAGE 'C';
48+
49+
-- replace all occurences of $2 with $3
50+
CREATE FUNCTION replace(text, text, text)
51+
RETURNS text
52+
AS '_OBJWD_/odbc_DLSUFFIX_', 'replace'
53+
LANGUAGE 'C';
54+
55+
-- return the string repeated n times
56+
CREATE FUNCTION repeat(text, integer)
57+
RETURNS text
58+
AS '_OBJWD_/odbc_DLSUFFIX_', 'repeat'
59+
LANGUAGE 'C';
60+
61+
--
62+
-- Mathematical functions for pre-v7.0
63+
--
64+
65+
CREATE FUNCTION dround(float8)
66+
RETURNS float8
67+
AS '_OBJWD_/odbc_DLSUFFIX_', 'dround'
68+
LANGUAGE 'C';
69+
70+
CREATE FUNCTION round(float8)
71+
RETURNS float8
72+
AS 'SELECT dround($1)'
73+
LANGUAGE 'SQL';
74+
75+
--
76+
-- Math functions present in backend, but not in catalog for v7.0
77+
--
78+
79+
CREATE FUNCTION acos(float8)
80+
RETURNS float8
81+
AS '_OBJWD_/odbc_DLSUFFIX_', 'dacos'
82+
LANGUAGE 'C';
83+
84+
CREATE FUNCTION asin(float8)
85+
RETURNS float8
86+
AS '_OBJWD_/odbc_DLSUFFIX_', 'dasin'
87+
LANGUAGE 'C';
88+
89+
CREATE FUNCTION atan(float8)
90+
RETURNS float8
91+
AS '_OBJWD_/odbc_DLSUFFIX_', 'datan'
92+
LANGUAGE 'C';
93+
94+
CREATE FUNCTION atan2(float8,float8)
95+
RETURNS float8
96+
AS '_OBJWD_/odbc_DLSUFFIX_', 'datan2'
97+
LANGUAGE 'C';
98+
99+
CREATE FUNCTION cos(float8)
100+
RETURNS float8
101+
AS '_OBJWD_/odbc_DLSUFFIX_', 'dcos'
102+
LANGUAGE 'C';
103+
104+
CREATE FUNCTION cot(float8)
105+
RETURNS float8
106+
AS '_OBJWD_/odbc_DLSUFFIX_', 'dcot'
107+
LANGUAGE 'C';
108+
109+
CREATE FUNCTION sin(float8)
110+
RETURNS float8
111+
AS '_OBJWD_/odbc_DLSUFFIX_', 'dsin'
112+
LANGUAGE 'C';
113+
114+
CREATE FUNCTION dtan(float8)
115+
RETURNS float8
116+
AS '_OBJWD_/odbc_DLSUFFIX_', 'dtan'
117+
LANGUAGE 'C';
118+
119+
CREATE FUNCTION degrees(float8)
120+
RETURNS float8
121+
AS '_OBJWD_/odbc_DLSUFFIX_', 'degrees'
122+
LANGUAGE 'C';
123+
124+
CREATE FUNCTION pi()
125+
RETURNS float8
126+
AS '_OBJWD_/odbc_DLSUFFIX_', 'dpi'
127+
LANGUAGE 'C';
128+
129+
CREATE FUNCTION radians(float8)
130+
RETURNS float8
131+
AS '_OBJWD_/odbc_DLSUFFIX_', 'radians'
132+
LANGUAGE 'C';
133+
134+
-- random number generator currently requires RAND_MAX be available
135+
CREATE FUNCTION random()
136+
RETURNS float8
137+
AS '_OBJWD_/odbc_DLSUFFIX_', 'drandom'
138+
LANGUAGE 'C';
139+
140+
CREATE FUNCTION truncate(numeric,integer)
141+
RETURNS numeric
142+
AS 'SELECT trunc($1, $2)'
143+
LANGUAGE 'SQL';
144+
145+
--
146+
-- Date/time functions for v7.0
147+
--
148+
149+
CREATE FUNCTION interval_mul(interval,float8)
150+
RETURNS interval
151+
AS '_OBJWD_/odbc_DLSUFFIX_'
152+
LANGUAGE 'C';
153+
154+
CREATE OPERATOR * (
155+
LEFTARG = interval,
156+
RIGHTARG = float8,
157+
PROCEDURE = interval_mul
158+
);
159+
160+
161+
162+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp