1998-08-31 03:37:51 +08:00
|
|
|
-- string_io.sql --
|
|
|
|
--
|
1997-11-06 05:38:25 +08:00
|
|
|
-- SQL code to define the new string I/O functions
|
|
|
|
--
|
1998-08-31 03:37:51 +08:00
|
|
|
-- 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.
|
1997-11-06 05:38:25 +08:00
|
|
|
|
1998-08-31 03:37:51 +08:00
|
|
|
-- Define the new output functions.
|
|
|
|
--
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION c_charout(bpchar)
|
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
1997-11-06 05:38:25 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION c_textout(text)
|
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
1997-11-06 05:38:25 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION c_varcharout(varchar)
|
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
1997-11-06 05:38:25 +08:00
|
|
|
|
1998-08-31 03:37:51 +08:00
|
|
|
-- This is not needed because escapes are handled by the parser
|
|
|
|
--
|
2002-10-19 02:41:22 +08:00
|
|
|
-- CREATE FUNCTION c_textin(cstring)
|
|
|
|
-- RETURNS text
|
|
|
|
-- AS 'MODULE_PATHNAME'
|
|
|
|
-- LANGUAGE 'c';
|
1997-11-06 05:38:25 +08:00
|
|
|
|
1998-08-31 03:37:51 +08:00
|
|
|
-- Define a function which sets the new output routines for char types.
|
1997-11-06 05:38:25 +08:00
|
|
|
--
|
2002-10-19 02:41:22 +08:00
|
|
|
-- SELECT c_mode();
|
1997-11-06 05:38:25 +08:00
|
|
|
--
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION c_mode()
|
|
|
|
RETURNS text
|
|
|
|
AS ' UPDATE pg_type SET typoutput=''c_textout'' WHERE typname=''SET'';
|
|
|
|
UPDATE pg_type SET typoutput=''c_varcharout'' WHERE typname=''bpchar'';
|
|
|
|
UPDATE pg_type SET typoutput=''c_textout'' WHERE typname=''bytea'';
|
|
|
|
UPDATE pg_type SET typoutput=''c_charout'' WHERE typname=''char'';
|
|
|
|
UPDATE pg_type SET typoutput=''c_textout'' WHERE typname=''text'';
|
|
|
|
UPDATE pg_type SET typoutput=''c_textout'' WHERE typname=''unknown'';
|
|
|
|
UPDATE pg_type SET typoutput=''c_varcharout'' WHERE typname=''varchar'';
|
1999-06-06 03:09:48 +08:00
|
|
|
select ''c_mode''::text;'
|
2002-10-19 02:41:22 +08:00
|
|
|
LANGUAGE 'SQL';
|
1997-11-06 05:38:25 +08:00
|
|
|
|
1998-08-31 03:37:51 +08:00
|
|
|
-- Define a function which restores the standard routines for char types.
|
1997-11-06 05:38:25 +08:00
|
|
|
--
|
2002-10-19 02:41:22 +08:00
|
|
|
-- SELECT pg_mode();
|
1997-11-06 05:38:25 +08:00
|
|
|
--
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION pg_mode()
|
|
|
|
RETURNS text
|
|
|
|
AS ' UPDATE pg_type SET typoutput=''textout'' WHERE typname=''SET'';
|
|
|
|
UPDATE pg_type SET typoutput=''varcharout'' WHERE typname=''bpchar'';
|
|
|
|
UPDATE pg_type SET typoutput=''textout'' WHERE typname=''bytea'';
|
|
|
|
UPDATE pg_type SET typoutput=''charout'' WHERE typname=''char'';
|
|
|
|
UPDATE pg_type SET typoutput=''textout'' WHERE typname=''text'';
|
|
|
|
UPDATE pg_type SET typoutput=''textout'' WHERE typname=''unknown'';
|
|
|
|
UPDATE pg_type SET typoutput=''varcharout'' WHERE typname=''varchar'';
|
1999-06-06 03:09:48 +08:00
|
|
|
select ''pg_mode''::text;'
|
2002-10-19 02:41:22 +08:00
|
|
|
LANGUAGE 'SQL';
|
1997-11-06 05:38:25 +08:00
|
|
|
|
1998-08-31 03:37:51 +08:00
|
|
|
-- Use these to do the changes manually.
|
1997-11-06 05:38:25 +08:00
|
|
|
--
|
2002-10-19 02:41:22 +08:00
|
|
|
-- UPDATE pg_type SET typoutput='textout' WHERE typname='SET';
|
|
|
|
-- UPDATE pg_type SET typoutput='varcharout' WHERE typname='bpchar';
|
|
|
|
-- UPDATE pg_type SET typoutput='textout' WHERE typname='bytea';
|
|
|
|
-- UPDATE pg_type SET typoutput='charout' WHERE typname='char';
|
|
|
|
-- UPDATE pg_type SET typoutput='textout' WHERE typname='text';
|
|
|
|
-- UPDATE pg_type SET typoutput='textout' WHERE typname='unknown';
|
|
|
|
-- UPDATE pg_type SET typoutput='varcharout' WHERE typname='varchar';
|
1997-11-06 05:38:25 +08:00
|
|
|
--
|
2002-10-19 02:41:22 +08:00
|
|
|
-- UPDATE pg_type SET typoutput='c_textout' WHERE typname='SET';
|
|
|
|
-- UPDATE pg_type SET typoutput='c_varcharout' WHERE typname='bpchar';
|
|
|
|
-- UPDATE pg_type SET typoutput='c_textout' WHERE typname='bytea';
|
|
|
|
-- UPDATE pg_type SET typoutput='c_charout' WHERE typname='char';
|
|
|
|
-- UPDATE pg_type SET typoutput='c_textout' WHERE typname='text';
|
|
|
|
-- UPDATE pg_type SET typoutput='c_textout' WHERE typname='unknown';
|
|
|
|
-- UPDATE pg_type SET typoutput='c_varcharout' WHERE typname='varchar';
|
1997-11-06 05:38:25 +08:00
|
|
|
|
|
|
|
-- end of file
|