Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 6EADD2E2E6C for ; Sat, 29 Dec 2007 17:23:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 73432-01 for ; Sat, 29 Dec 2007 17:23:49 -0400 (AST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.189]) by postgresql.org (Postfix) with ESMTP id DC1DA2E2E64 for ; Sat, 29 Dec 2007 17:23:53 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id b27so5164732fka.3 for ; Sat, 29 Dec 2007 13:23:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=FRXz+J9CnIlcAFTZFavENxj+LddX5eA8ERqDOo0We28=; b=usyBzAGANlH5MIn1Dm41u4oYAqrpWH3V9RM9Ew0ozi//CC+IXPRC/6os8tHxkeFTZXggUpyfMCnyzD0yYO2dJd2EIst16f4jer+KXaAa+VuCeiUnBS7D0LCO/6LXvCilHTKGrGczWk/RpFtpqZ4N6a673bkbZ6IuS4tThO1FtB8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=EraTY8ZGvAT763P5OVP1qy5S29DREf8vj6Y5JlrJJO95dcEqyadcFfsBMin6sZ0EUUrUyyz5GoosrSowgfyucSPDHlXvZQXG7T921GO7JfwE/8BTC9Aq3mMClkNbzdEWpcDvHa9cnHkc5WELPKV++k3Lvv3kcIVEHAiOHrQSvhM= Received: by 10.78.168.1 with SMTP id q1mr13395749hue.71.1198963431801; Sat, 29 Dec 2007 13:23:51 -0800 (PST) Received: by 10.78.35.10 with HTTP; Sat, 29 Dec 2007 13:23:51 -0800 (PST) Message-ID: <162867790712291323m2d7212e9i6e85d7b128e9dc1c@mail.gmail.com> Date: Sat, 29 Dec 2007 22:23:51 +0100 From: "Pavel Stehule" To: "Marcin Krawczyk" Subject: Re: temp table existence Cc: pgsql-sql@postgresql.org In-Reply-To: <95f6bf9b0712291316x31ae9c8er80fb60a7db4aaca6@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <95f6bf9b0712291116lc3c1df0o978922176e98f8d7@mail.gmail.com> <162867790712291133n1bb6a6fcqeb1234df1576dd8c@mail.gmail.com> <95f6bf9b0712291316x31ae9c8er80fb60a7db4aaca6@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/156 X-Sequence-Number: 29848 Hello my solution isn't 100% perfect too. Better is test visibility: SELECT n.nspname as "Schema", c.relname as "Name", CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as "Type", r.rolname as "Owner" FROM pg_catalog.pg_class c JOIN pg_catalog.pg_roles r ON r.oid = c.relowner LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r','') AND n.nspname <> 'pg_catalog' -- replace LIKE 'pg_temp%'; AND n.nspname !~ '^pg_toast' AND pg_catalog.pg_table_is_visible(c.oid) ORDER BY 1,2; for existence test this query can be simplified Regards Pavel Stehule On 29/12/2007, Marcin Krawczyk wrote: > I just realized something... my bad. It will work since TRUNCATE removes > only table from current session. > > Thank you again. > Regards > >