Re: [HACKERS] User defined types -- Social Security number...

2004-03-09 Thread Tom Hebbron
isbn_sum:= CASE WHEN substring($1 from i for 1) IN (''X'',''x'') AND i=10 THEN isbn_sum + (11-i * 10) ELSE isbn_sum + (11-i * substring($1 from i for 1)::int) END; END LOOP;

Re: [HACKERS] How to get Relation name from Oid ??

2004-03-09 Thread Tom Hebbron
e utilities schema) you can use 3245342::oid::regclass::text to find the path of a table given it's oid.This does take into account the current schema_path settings, so use of this cast may or may not schema-qualify the table name depending on the schema_path setting. -- Tom Hebbron www.hebbron.

Re: [HACKERS] How to retrieve functional index column names

2004-01-11 Thread Tom Hebbron
og.pg_attribute.attname - linked to the oid in pg_class of the index. select c.oid::regclass, i.*, ia.attname from pg_catalog.pg_class c inner join pg_catalog.pg_index i ON (i.indrelid = c.oid) inner join pg_catalog.pg_attribute ia ON (i.indexrelid = ia.attrelid); should

Re: [HACKERS] Handy user/group hack

2003-11-28 Thread Tom Hebbron
Here's a slightly condensed version - do SQL functions have an advantage in that they can be inlined? Or have I misunderstood? CREATE OR REPLACE FUNCTION user_in_group(name,name) RETURNS boolean STRICT AS ' SELECT EXISTS(SELECT u.* FROM pg_catalog.pg_user u INNER JOIN pg_catalog.pg_group g ON (u.

[HACKERS] Comment on pg_catalog and information_schema objects

2003-11-18 Thread Tom Hebbron
s. I imagine that someone who has worked with SGML before would be able to knock up this transformation pretty quick(?) so I'll try appealing here before getting my hands dirty attempting to try it myself. Is there any reason not to have the system objects commented in this way in the