~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to contrib/string/string_io.sql.in

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- string_io.sql --
 
2
--
 
3
-- SQL code to define the new string I/O functions
 
4
--
 
5
-- Copyright (c) 1998, Massimo Dal Zotto <dz@cs.unitn.it>
 
6
--
 
7
-- This file is distributed under the GNU General Public License
 
8
-- either version 2, or (at your option) any later version.
 
9
 
 
10
-- Define the new output functions.
 
11
--
 
12
CREATE FUNCTION c_charout(bpchar)
 
13
RETURNS cstring
 
14
AS 'MODULE_PATHNAME' 
 
15
LANGUAGE 'C';
 
16
 
 
17
CREATE FUNCTION c_textout(text)
 
18
RETURNS cstring
 
19
AS 'MODULE_PATHNAME' 
 
20
LANGUAGE 'C';
 
21
 
 
22
CREATE FUNCTION c_varcharout(varchar)
 
23
RETURNS cstring
 
24
AS 'MODULE_PATHNAME' 
 
25
LANGUAGE 'C';
 
26
 
 
27
-- This is not needed because escapes are handled by the parser
 
28
--
 
29
-- CREATE FUNCTION c_textin(cstring)
 
30
-- RETURNS text
 
31
-- AS 'MODULE_PATHNAME' 
 
32
-- LANGUAGE 'c';
 
33
 
 
34
-- Define a function which sets the new output routines for char types.
 
35
--
 
36
--   SELECT c_mode();
 
37
--
 
38
CREATE FUNCTION c_mode()
 
39
RETURNS text
 
40
AS '  UPDATE pg_type SET typoutput=''c_textout''    WHERE typname=''SET'';
 
41
      UPDATE pg_type SET typoutput=''c_varcharout'' WHERE typname=''bpchar'';
 
42
      UPDATE pg_type SET typoutput=''c_textout''    WHERE typname=''bytea'';
 
43
      UPDATE pg_type SET typoutput=''c_charout''    WHERE typname=''char'';
 
44
      UPDATE pg_type SET typoutput=''c_textout''    WHERE typname=''text'';
 
45
      UPDATE pg_type SET typoutput=''c_textout''    WHERE typname=''unknown'';
 
46
      UPDATE pg_type SET typoutput=''c_varcharout'' WHERE typname=''varchar'';
 
47
      select ''c_mode''::text;'
 
48
LANGUAGE 'SQL';
 
49
 
 
50
-- Define a function which restores the standard routines for char types.
 
51
--
 
52
--   SELECT pg_mode();
 
53
--
 
54
CREATE FUNCTION pg_mode()
 
55
RETURNS text
 
56
AS '  UPDATE pg_type SET typoutput=''textout''    WHERE typname=''SET'';
 
57
      UPDATE pg_type SET typoutput=''varcharout'' WHERE typname=''bpchar'';
 
58
      UPDATE pg_type SET typoutput=''textout''    WHERE typname=''bytea'';
 
59
      UPDATE pg_type SET typoutput=''charout''    WHERE typname=''char'';
 
60
      UPDATE pg_type SET typoutput=''textout''    WHERE typname=''text'';
 
61
      UPDATE pg_type SET typoutput=''textout''    WHERE typname=''unknown'';
 
62
      UPDATE pg_type SET typoutput=''varcharout'' WHERE typname=''varchar'';
 
63
      select ''pg_mode''::text;'
 
64
LANGUAGE 'SQL';
 
65
 
 
66
-- Use these to do the changes manually.
 
67
--
 
68
-- UPDATE pg_type SET typoutput='textout'    WHERE typname='SET';
 
69
-- UPDATE pg_type SET typoutput='varcharout' WHERE typname='bpchar';
 
70
-- UPDATE pg_type SET typoutput='textout'    WHERE typname='bytea';
 
71
-- UPDATE pg_type SET typoutput='charout'    WHERE typname='char';
 
72
-- UPDATE pg_type SET typoutput='textout'    WHERE typname='text';
 
73
-- UPDATE pg_type SET typoutput='textout'    WHERE typname='unknown';
 
74
-- UPDATE pg_type SET typoutput='varcharout' WHERE typname='varchar';
 
75
--
 
76
-- UPDATE pg_type SET typoutput='c_textout'    WHERE typname='SET';
 
77
-- UPDATE pg_type SET typoutput='c_varcharout' WHERE typname='bpchar';
 
78
-- UPDATE pg_type SET typoutput='c_textout'    WHERE typname='bytea';
 
79
-- UPDATE pg_type SET typoutput='c_charout'    WHERE typname='char';
 
80
-- UPDATE pg_type SET typoutput='c_textout'    WHERE typname='text';
 
81
-- UPDATE pg_type SET typoutput='c_textout'    WHERE typname='unknown';
 
82
-- UPDATE pg_type SET typoutput='c_varcharout' WHERE typname='varchar';
 
83
 
 
84
-- end of file