Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mfreV-0006lJ-NM for pgsql-general@arkaria.postgresql.org; Wed, 27 Oct 2021 22:44:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mfreU-0001iu-DY for pgsql-general@arkaria.postgresql.org; Wed, 27 Oct 2021 22:44:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mfreU-0001il-1h for pgsql-general@lists.postgresql.org; Wed, 27 Oct 2021 22:44:10 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mfreR-0007qt-M6 for pgsql-general@lists.postgresql.org; Wed, 27 Oct 2021 22:44:09 +0000 Received: by mail-pl1-x630.google.com with SMTP id w16so3058229plg.3 for ; Wed, 27 Oct 2021 15:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=MGOKC8wVeeLbw3fI8rECx3KqSi1YoqnHOFOmRirZ0GM=; b=BOHhQwCZysVxf6KPsFWvi7i7HDoaoeLMV0ny3adPC6SP1DGnE/rwPEVoYVsUxP0eA8 eez8UgYOQ/CGF7KInBZLAdw+76jek0MaWkAmwrPcyF9P6vzyi8DXw5CxRM2JAy6ccERH z3RJOx3cfwZoDfzo8yRI7HPosBVLVGpu+FMvNHVNZEzwwKRo+MhzQ3tRbUvDverSN9Cp qERCqtSpoLPKJCgVcCrArv8vPW6CmTqzUBwXheSQ8rM/7FGACJYzBq3c7c/yn8mGKXRX G6fKJuRAVXPbSdmDUHRr5b5z6g+flJQaTArQ6Wc+fP2RtFcoC82vuT6pXlC/uBSQo/mq g3gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=MGOKC8wVeeLbw3fI8rECx3KqSi1YoqnHOFOmRirZ0GM=; b=3W89YIjeybqMwSC/CjrD+3XTKk5fQ95kwpogxh2eI+LGiIyaHNUXaolrG3P0RfITs3 VxQv0Yw5w7kVPSxqmOTQqWha/TrgdR0e5k4t/nLdvkbUwMcyhouM1l0Jg6hqyZxNvitx jzeo6TtIf0WDJz8VoqMeLN33KEigPMowLdfBPfXD0MXm9EvhHqMu3Dm+kzBNY37twvl3 moRJAg8Ff/i+OhmeizH8gR0kUr6zLPdrz6wIXkS2yoy6lLwofK5lOxSrhQtpPBeRClwx ZxnaLpPW2Bqru1LbM0muhYx6I3OYmTD4+a7JUEeZ4RQqMQ8WIi84LymrQ2oXYNXPAwJ0 KD9g== X-Gm-Message-State: AOAM531lctElb5pHn7yKai1yFvttxka0KkXySa1xMrjNChPzHRuDLc7j cT3YEEzZ9wyhu+CmIF+bT2sNc2qGVWM= X-Google-Smtp-Source: ABdhPJw+P5gvV1ddPEB0Qqtqg/m+WCMZ1wunqWVEP8qauFczSnSZectQkXyg0wlWVffBrzVeescevQ== X-Received: by 2002:a17:902:6544:b0:13e:dd16:bd5b with SMTP id d4-20020a170902654400b0013edd16bd5bmr336658pln.61.1635374645491; Wed, 27 Oct 2021 15:44:05 -0700 (PDT) Received: from smtpclient.apple (node-1w7jr9pis2gio3aejyv2ivtii.ipv6.telus.net. [2001:569:5119:b800:1974:efff:47eb:b12a]) by smtp.gmail.com with ESMTPSA id il17sm687199pjb.52.2021.10.27.15.44.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Oct 2021 15:44:05 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Segmentation fault in volatile c function From: Louise Grandjonc In-Reply-To: Date: Wed, 27 Oct 2021 15:44:04 -0700 Cc: "pgsql-generallists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <0760A561-0728-472D-8C7B-6BA839E4AD46@gmail.com> References: <5FEFE970-6A6B-454E-A3C7-FFD0FAAFDABD@gmail.com> To: Peter Geoghegan X-Mailer: Apple Mail (2.3654.120.0.1.13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 wrote: >=20 > On Wed, Oct 27, 2021 at 12:39 PM Louise Grandjonc > 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. >>=20 >> I created a C function for that. Here is the code >=20 > 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. >=20 > 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. >=20 > Note that you can do stuff like this from SQL: >=20 > pg@regression:5432 [2999218]=3D# select 'pg_class'::regclass::oid; > oid > =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > 1,259 > (1 row) >=20 > --=20 > Peter Geoghegan