Re: Segmentation fault in volatile c function

From: Louise Grandjonc <louve(dot)grandjonc(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Segmentation fault in volatile c function
Date: 2021-10-27 22:44:04
Message-ID: 0760A561-0728-472D-8C7B-6BA839E4AD46@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)bowt(dot)ie> wrote:
>
> On Wed, Oct 27, 2021 at 12:39 PM Louise Grandjonc
> <louve(dot)grandjonc(at)gmail(dot)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(at)regression:5432 [2999218]=# select 'pg_class'::regclass::oid;
> oid
> ───────
> 1,259
> (1 row)
>
> --
> Peter Geoghegan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2021-10-27 23:18:20 Re: jsonb: unwrapping text
Previous Message Adrian Klaver 2021-10-27 22:17:15 Re: psql could not connect to server after complete reinstallation [Ubuntu 21.10 / PostgreSQL 13]