0

I'm trying to import a C-Language function to my postgresql database.

I have my shared object inside my home directory but I can't use it on my database.

CREATE OR REPLACE FUNCTION add_one(integer) RETURNS integer AS '/home/pedro/.../.../example.so', 'add_one' LANGUAGE C STRICT;

And this is my error message:

ERROR:  could not access file "/home/pedro/.../.../example.so": Permission denied

I think is probably my OS blocking access to this file but I don't want to give permission to all users.

tl;dr: I'm looking for a elegant solution to import my C-Language Function, as a Shared Object file, inside my postgresql database.

Thanks in advance!

1
2

Permissions on the path and file should be postgres:postgres.

ls -l /home/pedro/.../.../example.so
chown -R postgres: /home/pedro/.../.../

You will probably need sudo for changing the file ownership.

2
  • So I've tried: sudo chown postgres: /home/pedro/.../.../example.so and sudo chmod u+rX /home/pedro/.../.../example.so and it didn't work. Running: ls -l /home/pedro/.../.../example.so I get: -rwxrwxrwx 1 postgres postgres 12952 Aug 17 17:42 /home/pedro/.../.../example.so Tried with my user (pedro) and (postgres) user. – Pedro Caldeira Aug 19 '16 at 0:32
  • The chown command above has -R option, which changes the directory and recursively the ownership. The dir must be accessible to the user postgres too. @PedroCaldeira – 3manuek Aug 19 '16 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.