Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5E372632CB8 for ; Mon, 26 Oct 2009 23:03:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 31052-06 for ; Tue, 27 Oct 2009 02:03:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.cal.net (smtp.cal.net [206.170.184.5]) by mail.postgresql.org (Postfix) with ESMTP id AFE6362F1B2 for ; Mon, 26 Oct 2009 23:03:02 -0300 (ADT) X-ASG-Debug-ID: 1256608976-22a600050000-hAWazd X-Barracuda-URL: http://206.170.184.5:8000/cgi-bin/mark.cgi Received: from [192.168.1.219] (statics-76-14-161-10.wsac.wavecable.com [76.14.161.10]) by smtp.cal.net (Spam & Virus Firewall) with ESMTP id 63865A37A6A for ; Mon, 26 Oct 2009 19:02:56 -0700 (PDT) Received: from [192.168.1.219] (statics-76-14-161-10.wsac.wavecable.com [76.14.161.10]) by smtp.cal.net with ESMTP id WrQu1EBqq4ilkNXT for ; Mon, 26 Oct 2009 19:02:56 -0700 (PDT) From: John To: pgsql-sql@postgresql.org X-ASG-Orig-Subj: Re: [SQL] trouble with getting the field names Subject: Re: trouble with getting the field names Date: Mon, 26 Oct 2009 19:02:55 -0700 User-Agent: KMail/1.9.9 References: <200910261641.49211.jfabiani@yolo.com> In-Reply-To: <200910261641.49211.jfabiani@yolo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200910261902.55913.jfabiani@yolo.com> X-Barracuda-Connect: statics-76-14-161-10.wsac.wavecable.com[76.14.161.10] X-Barracuda-Start-Time: 1256608976 X-Barracuda-Virus-Scanned: by Cal.net at cal.net X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=9.0 KILL_LEVEL=7.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.12942 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=-10 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200910/129 X-Sequence-Number: 33328 On Monday 26 October 2009 04:41:49 pm John wrote: > Below is a SQL statement that was created to retreive the primary key , a= nd > column names and data types for a table name and a schema. The problem is > that is works very well if I only use the 'public' schema. But it does n= ot > work if I use a 'system' schema I created (owned my me). The offending > line is "AND pg_table_is_visible(c.oid)" which makes me believe I done > something wrong with the roles? IOW if I drop the "pg_table_is_visible" = it > works with my 'system' schema. So I need a better guru than myself to > help/tell me what I did wrong. Thanks in advance! > > SELECT a.attname, t.typname, > EXISTS(SELECT * FROM generate_series(0, 31) idx(n) > WHERE a.attnum =3D i.indkey[idx.n]) AS isprimary > FROM pg_class c > JOIN pg_namespace n ON n.oid =3D c.relnamespace > JOIN pg_attribute a ON a.attrelid =3D c.oid > JOIN pg_type t ON t.oid =3D a.atttypid LEFT > JOIN pg_index i ON i.indrelid =3D c.oid AND i.indisprimary > WHERE c.relname =3D 'sys_company' AND n.nspname =3D 'system' > AND a.attname NOT IN ('ctid', 'cmin', 'cmax', 'tableoid', 'xmax', 'xmin') > AND has_schema_privilege(n.oid, 'usage') > AND has_table_privilege(c.oid, 'select') > AND pg_table_is_visible(c.oid) ORDER BY c.relname, a.attname > > Johnf OK I discovered the problem I needed to add=20 =E2=80=A6 ALTER USER test SET search_path TO schema1,schema2 thanks Johnf