Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0J3n-0001oF-GU for pgsql-sql@arkaria.postgresql.org; Fri, 06 Oct 2017 03:12:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e0J3n-0007Q9-3J for pgsql-sql@arkaria.postgresql.org; Fri, 06 Oct 2017 03:12:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e0J2k-0002xE-PE for pgsql-sql@postgresql.org; Fri, 06 Oct 2017 03:11:18 +0000 Received: from mail-qk0-x229.google.com ([2607:f8b0:400d:c09::229]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e0J2f-0001W7-2P for pgsql-sql@postgresql.org; Fri, 06 Oct 2017 03:11:17 +0000 Received: by mail-qk0-x229.google.com with SMTP id f199so3512067qke.2 for ; Thu, 05 Oct 2017 20:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5Mqpq6ZJvf/xQTObhvq8Lf7ip6yg3/G3jSWG6+zC9F0=; b=bCMCAZgN95bSEFqSB5QWGVcLr9lHst9CxlRT6L5SYsgi3WgUzGsPRq5W6kyiEZ1CHl rhcckQgHld5N0sRFwf/68/1lu4RMBHtTRRkuLs2EekHwRUL3UhDm0w9lhQhq1A6VY91m HcBg7e2kk8u3KGL2WY446z0bOI+CGoGbXVDFr8LKoptc943r9PL2O2fLRaoJfKVSZ2TF z15FMTNXWGJEZJVuNo/jSwnUGdgC5ayZosupqiCljL01KFfHAOuNxDvOxoUu63/6fJ4T TbAy3QP9lb3+33a+HRnIagDXZJBLohi2k8v26dn8hBLb24gB60hvLctMpTMRbTPLRnZG 5/fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5Mqpq6ZJvf/xQTObhvq8Lf7ip6yg3/G3jSWG6+zC9F0=; b=k3c6fLXos4GhrLMZZ95aoYMiEJ4UigDfzR4vH4xNMacYzT3enGYqBQi6LQ5SB4IpeV RkaqWV3xQ0Sh1IXHF0yS1c843kkCTUPHJXlqA0jXaUyDqq2MNK1y7vTUUhUU9ahxqoFp af1XdTfcN0DeT4L+vCYPWoxGhFaB9CtQ7aoq/il2Yl5Vqda9ae5UNbQRhEklaeFrimx7 NSO2zD9P9QyZl+WYcM9KUnNhVm1CuYmjKT7/P8Tis8aq8/8xPm6Fl9yM5f+9eVExnLA8 hfRhI4od2X6rM+1yuBiPDTwmbdfk53+zGqGjHl0qqHIkuwr/IBkBIAsm6O1gyR3taaUL 5m+w== X-Gm-Message-State: AMCzsaXPsrYq/X/dLMR3W1IUlSTSjhwafaj2smDIKGgYpbaSRCK16dxN eahbH2Puf8ibIbJLDVbl7J5sTcXkGZkS9gljeUE= X-Google-Smtp-Source: AOwi7QB/ZMv1/h4TVcV54+bF+GVh/0CCA4uxVUUKBoTMCLzvwjniPEQklNO+SJs6pR7JwtpFlc57Zddqo/GIvw+Nktc= X-Received: by 10.55.142.5 with SMTP id q5mr31031522qkd.83.1507259470918; Thu, 05 Oct 2017 20:11:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.33.187 with HTTP; Thu, 5 Oct 2017 20:10:50 -0700 (PDT) In-Reply-To: References: From: Rene Romero Benavides Date: Thu, 5 Oct 2017 22:10:50 -0500 Message-ID: Subject: Re: Get relation name form relids in postgresql To: Gourav Kumar Cc: pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary="94eb2c081fd6593a77055ad83153" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org --94eb2c081fd6593a77055ad83153 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Mmm, what do you mean by postgres code ? Are we talking here about the postgres source code or SQL ? If it's the source code, that's beyond my knowledge, sorry. The pgsql-hackers list may be a better fit for what you're looking for, or perhaps pgsql-general Best. . 2017-10-05 22:04 GMT-05:00 Gourav Kumar : > But I can't fire a query when I am inside postgres code, while executing > another query. > On 06-Oct-2017 8:31 AM, "Rene Romero Benavides" > wrote: > >> Sure, if you cast a field that contains a relid to the reglass type, you >> get the name of the relation. >> >> Example: >> select relid, relid::regclass from pg_stat_user_tables where relname =3D >> 'theNameOfYourTable'; >> >> >> 2017-10-05 21:55 GMT-05:00 Gourav Kumar : >> >>> I did not get this part. Can you elaborate please. >>> On 06-Oct-2017 8:24 AM, "Rene Romero Benavides" >>> wrote: >>> >>>> Sure, you can cast the relid to regclass, or join the mentioned table. >>>> >>>> >>>> 2017-10-05 21:48 GMT-05:00 Gourav Kumar : >>>> >>>>> Hi, >>>>> >>>>> Thanks for the reply. >>>>> >>>>> I want to be able to do that from inside the postgres code, while I a= m >>>>> in middle of executing a Query. >>>>> On 06-Oct-2017 7:12 AM, "Rene Romero Benavides" < >>>>> rene.romero.b@gmail.com> wrote: >>>>> >>>>>> Hi. Try pg_catalog.pg_stat_user_tables, there you have the relid >>>>>> (oid) identifier >>>>>> >>>>>> 2017-10-05 13:17 GMT-05:00 Gourav Kumar : >>>>>> >>>>>>> Hi all, >>>>>>> >>>>>>> I am looking for a way to get the relation name from the relid or >>>>>>> RelOptInfo data structure. Can anyone help me with this ? How can I= use >>>>>>> these to get to relation name ? >>>>>>> >>>>>>> -- >>>>>>> Thanks, >>>>>>> Gourav Kumar >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> El genio es 1% inspiraci=C3=B3n y 99% transpiraci=C3=B3n. >>>>>> Thomas Alva Edison >>>>>> http://pglearn.blogspot.mx/ >>>>>> >>>>>> >>>> >>>> >>>> -- >>>> El genio es 1% inspiraci=C3=B3n y 99% transpiraci=C3=B3n. >>>> Thomas Alva Edison >>>> http://pglearn.blogspot.mx/ >>>> >>>> >> >> >> -- >> El genio es 1% inspiraci=C3=B3n y 99% transpiraci=C3=B3n. >> Thomas Alva Edison >> http://pglearn.blogspot.mx/ >> >> --=20 El genio es 1% inspiraci=C3=B3n y 99% transpiraci=C3=B3n. Thomas Alva Edison http://pglearn.blogspot.mx/ --94eb2c081fd6593a77055ad83153 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Mmm, what do you mean by postgres code ? Are we talki= ng here about the postgres source code or SQL ? If it's the source code= , that's beyond my knowledge, sorry. The pgsql-hackers list may be a be= tter fit for what you're looking for, or perhaps pgsql-general

<= /div>Best.
.

2017-10-05 22:04 GMT-05:00 Gourav Kumar = <gourav1905@gm= ail.com>:

Bu= t I can't fire a query when I am inside postgres code, while executing = another query.

On 06-Oct-2017 8:31 AM, "Rene Romero Benavi= des" <= rene.romero.b@gmail.com> wrote:
Sure, if you cast a fiel= d that contains a relid to the reglass type, you get the name of the relati= on.

Example:
select relid, relid::regclass from pg_stat_user_tabl= es where relname =3D 'theNameOfYourTable';


2017-10-05= 21:55 GMT-05:00 Gourav Kumar <gourav1905@gmail.com>:
=

I did not get this part. Can = you elaborate please.

On 06-Oct-2017 8:24 AM, "Rene Romero Benavi= des" <= rene.romero.b@gmail.com> wrote:
Sure, you can cast the relid to regclas= s, or join the mentioned table.

2017-10-05 21:48 GMT-05:00 Gourav Kumar <go= urav1905@gmail.com>:

Hi,

Thanks for the reply.

I want to be able to do that from inside the postgres code, = while I am in middle of executing a Query.

On 06-Oct-2017 7:12 AM, "Rene Romero Benavi= des" <= rene.romero.b@gmail.com> wrote:
Hi. Try pg_catalog.pg_stat_user_tables<= wbr>, there you have the relid (oid) identifier

2017-10-05 13:17 GMT-05:00 Gourav K= umar <gourav1905@gmail.com>:
Hi all,

I am looking for a way = to get the relation name from the relid or RelOptInfo data structure. Can a= nyone help me with this ? How can I use these to get to relation name ?

--
Thanks,
Gourav Kumar




--
El genio es 1% inspiraci=C3=B3n y 99% transpiraci=C3= =B3n.
Thomas Alva Edison
http://pglearn.blogspot.mx/

=



--
El genio= es 1% inspiraci=C3=B3n y 99% transpiraci=C3=B3n.
Thomas Alva Edison
= http://pglearn.bl= ogspot.mx/




--
El genio es 1% inspiraci=C3=B3n y 99% transpiraci= =C3=B3n.
Thomas Alva Edison
http://pglearn.blogspot.mx/




--
El genio es 1% insp= iraci=C3=B3n y 99% transpiraci=C3=B3n.
Thomas Alva Edison
http://pglearn.blogspot.mx/<= /a>

--94eb2c081fd6593a77055ad83153--