Thread: gethostbyaddr() or equivalent?
I have a table which contains IP addresses (written as a log by applications which may or may not be local to the box hosting the database): log_time | timestamp ip_addr | text I would like to display the ip_addr column as a symbolic hostname (all the IP addresses are local and well-known). My initial attempt was to write a simple PLPerl function: CREATE FUNCTION fn_ip2name(text) returns text as ' use Socket; return scalar gethostbyaddr(inet_aton($_[0]),AF_INET) ' language 'plperl'; However, this fails: ERROR: creation of function failed: require trapped by operation mask at (eval 2) line 2. Any suggestions? -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer fax 269.349.9076 Nexcerpt, Inc. http://www.nexcerpt.com ...Nexcerpt... Extend your Expertise
On Tue, 10 Sep 2002, Jeff Boes wrote: > CREATE FUNCTION fn_ip2name(text) returns text as ' > use Socket; > return scalar gethostbyaddr(inet_aton($_[0]),AF_INET) > ' language 'plperl'; > > However, this fails: > > ERROR: creation of function failed: > require trapped by operation mask at (eval 2) line 2. I think you need to use the unstrusted version of the language (plperlu, not plperl). -- Alvaro Herrera (<alvherre[@]dcc.uchile.cl>) "El sudor es la mejor cura para un pensamiento enfermo" (Bardia)