Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D07606326EE for ; Fri, 18 Dec 2009 11:56:56 -0400 (AST) 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 22483-08 for ; Fri, 18 Dec 2009 15:56:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.159]) by mail.postgresql.org (Postfix) with ESMTP id 4B45E6323A9 for ; Fri, 18 Dec 2009 11:56:49 -0400 (AST) Received: by fg-out-1718.google.com with SMTP id 22so1220953fge.1 for ; Fri, 18 Dec 2009 07:56:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:x-mailer:mime-version:content-type; bh=jTihGXi8Y9jl2x0V/ndz4ccnOdD9kIv8nvDYh1jDoQU=; b=PsuGLGtW4vduXcNIdhl7+rOkxOyq85Ztf+3YVr9/TcegGWs3c6KAttkk3bONCTroQ3 gJYfr2TgKTx9yKe6yUnetbLy84kJV3JmTPMwlNdpB4WcrNSMoWuaAwFlBhtc6GvhlBmt OzKxSQga8tvo3Axg/beVqqZJbUBC+BxGIVy+w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:x-mailer:mime-version:content-type; b=nI2nbTBPWPXRJSoCocElwcEt6Sd9TdQgyux0iVH85osEERlkUNT/MwQOTL4T7hMqo6 SpvWguNKMFdEkEudrdvp1QEvoMuxumqVu6Y3F/5oi2HwcKf78ID+ex/bRCcpxGVvzH5S ojM7vzj9stf7qTshlOPG4zcWKNnkV52qGagrI= Received: by 10.87.69.28 with SMTP id w28mr5035821fgk.46.1261151806620; Fri, 18 Dec 2009 07:56:46 -0800 (PST) Received: from DEAN ([162.105.36.202]) by mx.google.com with ESMTPS id d6sm16052908fga.24.2009.12.18.07.56.42 (version=SSLv3 cipher=RC4-MD5); Fri, 18 Dec 2009 07:56:45 -0800 (PST) Date: Fri, 18 Dec 2009 23:57:53 +0800 From: "suzhiyang" To: "pgsql-hackers" Subject: Distinguish view and table problem Message-ID: <200912182357482650255@gmail.com> X-mailer: Foxmail 6, 15, 201, 22 [cn] Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=====003_Dragon137262887273_=====" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.598 tagged_above=-10 required=5 tests=BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200912/1646 X-Sequence-Number: 152349 This is a multi-part message in MIME format. --=====003_Dragon137262887273_===== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi! I just want to distinguish a view and a table while postgres execute exec_simple_query(). In the systable of pg_class, a view and a table has different relkind ('r' 'v'). But when I print the parsetree and the rewrite parsetree, I found that a view and a table has no character to distinguish because the structure Relation has no attribute called relkind. Maybe I should read systable to confirm that we are select from a view or table? But there's still has problem. How could I get the relkind of a table(view) by its name from pg_class? Another question is that does postgres save the user's original query_string at anywhere(systable etc.)? If I want to save the sourceText in the systable, I could add a column to pg_class called query_string. How could I insert a line to pg_class or read a line from it? Thank you very much! 2009-12-18 suzhiyang --=====003_Dragon137262887273_===== Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit
Hi!
I just want to distinguish a view and a table while postgres execute exec_simple_query(). In the systable of pg_class, a view and a table has different relkind ('r' 'v'). But when I print the parsetree and the rewrite parsetree, I found that a view and a table has no character to distinguish because the structure Relation has no attribute called relkind. Maybe I should read systable to confirm that we are select from a view or table? But there's still has problem. How could I get the relkind of a table(view) by its name from pg_class?
Another question is that does postgres save the user's original query_string at anywhere(systable etc.)? If I want to save the sourceText in the systable, I could add a column to pg_class called query_string. How could I insert a line to pg_class or read a line from it?
 
Thank you very much!
 
2009-12-18

suzhiyang
--=====003_Dragon137262887273_=====--