Changing pg_type records

From: "Rob Richardson" <Rob(dot)Richardson(at)rad-con(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Changing pg_type records
Date: 2009-03-19 14:43:45
Message-ID: 04A6DB42D2BA534FAC77B90562A6A03DD6204E@server.rad-con.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings!

I just discovered the existence of a couple of functions I don't
understand in one customer's PostgreSQL database:

-- Function: c_mode()

-- DROP FUNCTION c_mode();

CREATE OR REPLACE FUNCTION c_mode()
RETURNS text AS
$BODY$ 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;$BODY$
LANGUAGE 'sql' VOLATILE;
ALTER FUNCTION c_mode() OWNER TO postgres;

-- Function: pg_mode()

-- DROP FUNCTION pg_mode();

CREATE OR REPLACE FUNCTION pg_mode()
RETURNS text AS
$BODY$ 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;$BODY$
LANGUAGE 'sql' VOLATILE;
ALTER FUNCTION pg_mode() OWNER TO postgres;

This customer has demanded extensive modifications to their database and
our application. I think these functions are used in encryption, since
there are several other non-standard functions in this database that are
related to encryption.

Our lead developer is in another state, and is naturally very
uncommunicative. When I asked him about the c_mode() function and
expressed concern that changing pg_type records might not be a good
idea, his reply was:

"Ignore it, it is a database contrib routine for string I/O. It
doesn't change the database properties."

Are these functions really as innocuous as he claims? It seems to me
that between the time c_mode() is called and the time that pg_mode() is
called, any other database access is likely to be confused.

Thank you very much.

RobR

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2009-03-19 14:57:33 Re: Long-running query blocks all other queries
Previous Message Anton V. Belyaev 2009-03-19 14:42:30 Long-running query blocks all other queries