Re: How to refer to resource files from UDFs written in C

From: Supun Nakandala <supun(dot)nakandala(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to refer to resource files from UDFs written in C
Date: 2017-06-09 17:04:58
Message-ID: CAFwzmVBkFYrgTOseUTvFb6mAP5U4zsgA5F-SP17YMKBqCc44ig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 9, 2017 at 3:05 AM, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:

> On 06/09/2017 08:56 AM, Supun Nakandala wrote:
>
>> Hi hackers,
>>
>> I am trying to extend PostgreSQL by adding UDT and UDF for a custom use
>> case and I am using C language extensions to do that.
>>
>> However, I have a requirement of reading a text file from one of the C
>> functions. The compiled *.so files are placed in the "pg_config
>> --pkglibdir" directory and tried copying my text files there but it didn't
>> work. I found that, when these shared libs are loaded they are run from a
>> different working directory. In this case, what is the best way to refer
>> to
>> my text files from the C code other than giving the absolute path which
>> can
>> change from system to system.
>>
>
> All backend processes run with the data directory as the current
> directory. So you can put the files into the data directory, probably best
> to have a subdirectory there to avoid confusing them with PostgreSQL's own
> files. Or you could have a config option, to set an absolute path.
>
> - Heikki
>
>
Thank you everyone for your quick replies. I ended up copying the files to
the data directory and referring using relative path.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-06-09 17:14:30 Re: partial aggregation with internal state type
Previous Message Jeff Janes 2017-06-09 16:47:29 Re: partial aggregation with internal state type