Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 62304475A9B; Tue, 3 Sep 2002 06:25:37 -0400 (EDT) Received: from internet.csl.co.uk (internet.csl.co.uk [194.130.52.3]) by postgresql.org (Postfix) with ESMTP id 69A9B475A69; Tue, 3 Sep 2002 06:25:36 -0400 (EDT) Received: from euphrates.csl.co.uk (host-194-67.csl.co.uk [194.130.52.67]) by internet.csl.co.uk (8.12.6/8.12.6) with ESMTP id g83APawl021468; Tue, 3 Sep 2002 11:25:36 +0100 Received: from kelvin.csl.co.uk by euphrates.csl.co.uk (8.9.3/ConceptI 2.4) id LAA16723; Tue, 3 Sep 2002 11:25:37 +0100 (BST) Received: by kelvin.csl.co.uk (8.11.6) id g83APaG02549; Tue, 3 Sep 2002 11:25:36 +0100 From: Lee Kindness MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15732.36384.130862.855693@kelvin.csl.co.uk> Date: Tue, 3 Sep 2002 11:25:36 +0100 To: Tom Lane Cc: pgsql-hackers@postgresql.org, pgsql-interfaces@postgresql.org, Lee Kindness Subject: 7.3 gotchas for applications and client libraries In-Reply-To: <851.1031018040@sss.pgh.pa.us> References: <851.1031018040@sss.pgh.pa.us> X-Mailer: VM 7.00 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/139 X-Sequence-Number: 28098 Tom, do you think there is millage in adding functions (at least to contrib) to PostgreSQL to avoid some of the common tasks applications look into pg_* for? For example I recently audited our code here for pg_* access, and managed to create two plpgsql functions to replace all occurrences. They were relatively simple queries to check if a table existed and to check if a column existed, functions for 7.2.x: \echo creating function: column_exists CREATE OR REPLACE FUNCTION column_exists(NAME, NAME) RETURNS BOOLEAN AS ' DECLARE tab ALIAS FOR $1; col ALIAS FOR $2; rec RECORD; BEGIN SELECT INTO rec * FROM pg_class c, pg_attribute a WHERE c.relname = tab AND c.oid = a.attrelid AND a.attnum > 0 AND a.attname = col; IF NOT FOUND THEN RETURN false; ELSE RETURN true; END IF; END; ' LANGUAGE 'plpgsql'; \echo creating function: table_exists CREATE OR REPLACE FUNCTION table_exists(NAME) RETURNS BOOLEAN AS ' DECLARE tab ALIAS FOR $1; rec RECORD; BEGIN SELECT INTO rec * FROM pg_class c WHERE c.relname = tab; IF NOT FOUND THEN RETURN false; ELSE RETURN true; END IF; END; ' LANGUAGE 'plpgsql'; Obviously these need attention when our application targets 7.3 (and thanks for the heads-up), but all changes are localised. Surely these must be fairly common tests and maybe better added to the database server so applications are less dependant on internal catalogues? Any desire for me to polish these two functions up for contrib in 7.3? Actually the Cookbook at http://www.brasileiro.net/postgres/ has similar function which will need attention for 7.3 too, is the eventual plan for this to be folded into the core release? Thanks, Lee. Tom Lane writes: > Bruce suggested that we need a porting guide to help people look for > application and client-library code that will be broken by the changes > in PG 7.3. Here is a first cut at documenting the issues. > Comments welcome --- in particular, what have I missed? > [snip ]