postgresql/contrib/string/string_io.sql.in

85 lines
3.1 KiB
MySQL
Raw Normal View History

-- string_io.sql --
--
1997-11-06 05:38:25 +08:00
-- SQL code to define the new string I/O functions
--
-- 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
-- Define the new output functions.
--
CREATE FUNCTION c_charout(bpchar)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
1997-11-06 05:38:25 +08:00
CREATE FUNCTION c_textout(text)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
1997-11-06 05:38:25 +08:00
CREATE FUNCTION c_varcharout(varchar)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
1997-11-06 05:38:25 +08:00
-- This is not needed because escapes are handled by the parser
--
-- CREATE FUNCTION c_textin(cstring)
-- RETURNS text
-- AS 'MODULE_PATHNAME'
-- LANGUAGE 'c';
1997-11-06 05:38:25 +08:00
-- Define a function which sets the new output routines for char types.
1997-11-06 05:38:25 +08:00
--
-- SELECT c_mode();
1997-11-06 05:38:25 +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'';
select ''c_mode''::text;'
LANGUAGE 'SQL';
1997-11-06 05:38:25 +08:00
-- Define a function which restores the standard routines for char types.
1997-11-06 05:38:25 +08:00
--
-- SELECT pg_mode();
1997-11-06 05:38:25 +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'';
select ''pg_mode''::text;'
LANGUAGE 'SQL';
1997-11-06 05:38:25 +08:00
-- Use these to do the changes manually.
1997-11-06 05:38:25 +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
--
-- 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