Unix Technical Forum

MAGIC_MODULE and libc

This is a discussion on MAGIC_MODULE and libc within the Pgsql General forums, part of the PostgreSQL category; --> I just upgraded to v8.2 and have an issue with one of my stored proc/functions that worked under 8.1: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 01:59 PM
Jeff Amiel
 
Posts: n/a
Default MAGIC_MODULE and libc

I just upgraded to v8.2 and have an issue with one of my stored
proc/functions that worked under 8.1:

CREATE OR REPLACE FUNCTION getpid()
RETURNS integer AS
'/lib/libc.so.6', 'getpid'
LANGUAGE 'c' VOLATILE;

ERROR: incompatible library "/lib/libc.so.6": missing magic block
SQL state: XX000
Hint: Extension libraries are required to use the PG_MODULE_MAGIC macro.

I've added the appropriate macro to all my actual C code...but in this
case surely I am not expected to recompile libc...am I? Is there an
easier way to get the pid of the current process?

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 01:59 PM
Alvaro Herrera
 
Posts: n/a
Default Re: MAGIC_MODULE and libc

Jeff Amiel wrote:
> I just upgraded to v8.2 and have an issue with one of my stored
> proc/functions that worked under 8.1:
>
> CREATE OR REPLACE FUNCTION getpid()
> RETURNS integer AS
> '/lib/libc.so.6', 'getpid'
> LANGUAGE 'c' VOLATILE;
>
> ERROR: incompatible library "/lib/libc.so.6": missing magic block
> SQL state: XX000
> Hint: Extension libraries are required to use the PG_MODULE_MAGIC macro.
>
> I've added the appropriate macro to all my actual C code...but in this
> case surely I am not expected to recompile libc...am I? Is there an
> easier way to get the pid of the current process?


I'd use MyProcPid from #include "miscadmin.h"

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 01:59 PM
Martijn van Oosterhout
 
Posts: n/a
Default Re: MAGIC_MODULE and libc

On Tue, Dec 19, 2006 at 08:20:23AM -0600, Jeff Amiel wrote:
> ERROR: incompatible library "/lib/libc.so.6": missing magic block
> SQL state: XX000
> Hint: Extension libraries are required to use the PG_MODULE_MAGIC macro.
>
> I've added the appropriate macro to all my actual C code...but in this
> case surely I am not expected to recompile libc...am I? Is there an
> easier way to get the pid of the current process?


In general you should use a wrapper library, but in your case
pg_backend_pid() will do it.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFh/bFIB7bNG8LQkwRAv/YAJ9GCIC7MN5v20Y4E8oqSR80u3N5cwCeL5Vw
KGA0DJkBY48KE1MGZlU/oXg=
=O3Z9
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 01:59 PM
Jeff Amiel
 
Posts: n/a
Default Re: MAGIC_MODULE and libc

yup...
I did this
CREATE OR REPLACE FUNCTION getpid()
RETURNS integer AS
$BODY$
DECLARE
thepid integer;
BEGIN
select into thepid pg_backend_pid from pg_backend_pid();
return thepid;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;

thanks!!!


Martijn van Oosterhout wrote:
> On Tue, Dec 19, 2006 at 08:20:23AM -0600, Jeff Amiel wrote:
>
>> ERROR: incompatible library "/lib/libc.so.6": missing magic block
>> SQL state: XX000
>> Hint: Extension libraries are required to use the PG_MODULE_MAGIC macro.
>>
>> I've added the appropriate macro to all my actual C code...but in this
>> case surely I am not expected to recompile libc...am I? Is there an
>> easier way to get the pid of the current process?
>>

>
> In general you should use a wrapper library, but in your case
> pg_backend_pid() will do it.
>
> Have a nice day,
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:09 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com