binary operators / C func getting "invalid ELF header"

From: Michael Olivier <molivier(at)yahoo(dot)com>
To: "pgsql-sql postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: binary operators / C func getting "invalid ELF header"
Date: 1999-01-19 00:51:30
Message-ID: 19990119005130.1209.rocketmail@send105.yahoomail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi folks,

I need to do a complex bitwise operation on integers during a select
query such as:

select acctname from users U where func(U.flags, 27) = 0;

The function in C is:

result = (~A) & (A ^ B)

I didn't see any bitwise operations like AND and XOR in the postgres
doc -- if they're there, I apologize and would love a pointer to the
doc.

Otherwise, I've gone down the path of trying to write a C function to
do this... and am getting this error:

db=> select not_a_and__a_xor_b(1,1);
ERROR: Load of file /home/michael/sql/funcs.so failed:
t(at)t@chael/sql/funcs.so: invalid ELF header

I'm compiling with the -fpic option for Linux (under gcc)

cc -c -O2 -fpic -g -I. -I./include -I. -I./include -c funcs.c -o
funcs.o
/bin/rm -f funcs.so
/usr/bin/ar cr funcs.so funcs.o

Can someone tell me the step(s) I'm missing or what to try next? I've
tested the C code - works fine (included below).

thanks,
--Michael

------------------------------------------------
//
// functions used within postgres
//

#include "postgres.h" /* for char16, etc. */

int
not_a_and__a_xor_b(int A, int B)
{
return (~A) & (A ^ B);
}

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

Browse pgsql-sql by date

  From Date Subject
Next Message Gene Selkov Jr. 1999-01-19 01:47:25 Re: [SQL] binary operators / C func getting "invalid ELF header"
Previous Message Michael Olivier 1999-01-18 21:23:01 need help with error: cannot find attribute 1 of relation...