pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Louise Grandjonc <louve.grandjonc@gmail.com>
To: Peter Geoghegan <pg@bowt.ie>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Segmentation fault in volatile c function
Date: Wed, 27 Oct 2021 15:44:04 -0700
Message-ID: <0760A561-0728-472D-8C7B-6BA839E4AD46@gmail.com> (raw)
In-Reply-To: <CAH2-Wznhw+iiW8BEjFFDRoPKF+M9C=DS9pqbYo2w+LeEvQW4iQ@mail.gmail.com>
References: <5FEFE970-6A6B-454E-A3C7-FFD0FAAFDABD@gmail.com>
	<CAH2-Wznhw+iiW8BEjFFDRoPKF+M9C=DS9pqbYo2w+LeEvQW4iQ@mail.gmail.com>

Thank you! I used that. The segmentation fault came from a later code in my hook. But that helped.

> On Oct 27, 2021, at 12:47 PM, Peter Geoghegan <pg@bowt.ie> wrote:
> 
> On Wed, Oct 27, 2021 at 12:39 PM Louise Grandjonc
> <louve.grandjonc@gmail.com> wrote:
>> I'm creating my first ever extension. The function that I'm trying to write takes the schema and name of a table, and adds it in a table with all the tables the extension follows.
>> In that table I want the schema, name and oid of the table.
>> 
>> I created a C function for that. Here is the code
> 
> I don't think that using cstring as an argument is appropriate here.
> That's only used for "internal" functions that are called through C,
> rather than being called through SQL.
> 
> It would probably be better to use a regclass argument instead. Take a
> look at the example of (say) amcheck's bt_index_check() or
> verify_heapam() functions to see how that's done. Not all C functions
> use this built-in way of specifying a particular relation from SQL (a
> few older ones really do just pass a string some other way), but it's
> definitely considered the way to go.
> 
> Note that you can do stuff like this from SQL:
> 
> pg@regression:5432 [2999218]=# select 'pg_class'::regclass::oid;
>  oid
> ───────
> 1,259
> (1 row)
> 
> -- 
> Peter Geoghegan






view thread (3+ messages)

Message-ID: <0760A561-0728-472D-8C7B-6BA839E4AD46@gmail.com>
Permalink:  ../0760A561-0728-472D-8C7B-6BA839E4AD46@gmail.com/
Also on:    postgresql.org/message-id/0760A561-0728-472D-8C7B-6BA839E4AD46@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: louve.grandjonc@gmail.com, pg@bowt.ie
  Subject: Re: Segmentation fault in volatile c function
  In-Reply-To: <0760A561-0728-472D-8C7B-6BA839E4AD46@gmail.com>
  References: <5FEFE970-6A6B-454E-A3C7-FFD0FAAFDABD@gmail.com> <CAH2-Wznhw+iiW8BEjFFDRoPKF+M9C=DS9pqbYo2w+LeEvQW4iQ@mail.gmail.com> <0760A561-0728-472D-8C7B-6BA839E4AD46@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox