pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Compiling "C" Functions
3+ messages / 3 participants
[nested] [flat]

* Compiling "C" Functions
@ 2000-12-14 18:05 Tulio Oliveira <mestredosmagos@marilia.com>
  2000-12-28 14:36 ` Re: Compiling "C" Functions Ron Peterson <ron.peterson@yellowbank.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tulio Oliveira @ 2000-12-14 18:05 UTC (permalink / raw)
  To: pgsql-sql

Hi, ALL

This is my first time in this list... Sorry by any inconvenience....

I need a TRIGGER thats runs whith POSTGRES permissions. I´ll give an
ODBC 
connection for programmers that don´t need to know the "rules" of my
Data 
Base.

So, I´ll creata an "fake" table, and with a BEFORE INSERT TRIGGER I´ll
make 
all consistences, and update the REAL tables.

The ODBC users have only INSERT permission on the fake table, and NO
RIGHTS 
on the real table.

I´ll make VIEWS whith SELECT, UPDATE and DELETE permissions for the ODBC 
users.

By the same way, I´ll make TRIGGERS that manager the VIEWS.

-----------

ALMOST ALL THIS WORK FINE when the function of the trigger is in
PLPGSQL, but 
in this language, the Trigger run with the same ODBD user´s rights ....

I read that only a "C" function runs with POSTGRES permissions, but all
the 
samples I get don´t work... I can´t even compile them...

Please, anyone could help an "poor brazilian guy" to make this work :-)
?

I appreciate any "C" Function complete samples, including de command
line for 
the compiler.

I using a RedHat Linux 6.2 and  Postgresql 7.0.2-2 


Best Regards,

Tulio Oliveira.





-- 
======================================================
AKACIA TECNOLOGIA
Desenvolvimento de sistemas para Internet
www.akacia.com.br



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Compiling "C" Functions
  2000-12-14 18:05 Compiling "C" Functions Tulio Oliveira <mestredosmagos@marilia.com>
@ 2000-12-28 14:36 ` Ron Peterson <ron.peterson@yellowbank.com>
  2001-02-27 20:40   ` Re: Compiling "C" Functions Louis-David Mitterrand <cunctator@apartia.ch>
  0 siblings, 1 reply; 3+ messages in thread

From: Ron Peterson @ 2000-12-28 14:36 UTC (permalink / raw)
  To: pgsql-sql

Tulio Oliveira wrote:
> 
> I appreciate any "C" Function complete samples, including de command
> line for
> the compiler.

I've attached a generic GNU make snippet for compiling .so files. 
Adjust to suite your tastes.  Like my math textbooks used to say
"writing the C code is trivial, and is left as an excercise for the
reader."  ;)

CC = /usr/bin/gcc
TARGET = debug
#TARGET = final
DFLAGS = -Wall -g
FFLAGS = -Wall -O2
SFLAGS = -fpic -shared
MYINCLUDES = -I/usr/local/include
-I/usr/local/src/postgresql/src/include -I/usr/local/postgresql/include
MYLIBS = -L/usr/local/lib -L/usr/local/postgresql/lib -lpq

ifeq ($(TARGET),final)
        MYCFLAGS = $(FFLAGS)
else
        MYCFLAGS = $(DFLAGS)
endif 

%.so:
        $(CC) $(MYCFLAGS) $(MYINCLUDES) $(MYLIBS) $(*F).c -c -o $(*F).o
        $(CC) $(SFLAGS) $(*F).o -o $(*F).so
	[ -d $(TARGET) ] || mkdir $(TARGET)
	mv $(*F).so $(TARGET)
        rm *.o



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Compiling "C" Functions
  2000-12-14 18:05 Compiling "C" Functions Tulio Oliveira <mestredosmagos@marilia.com>
  2000-12-28 14:36 ` Re: Compiling "C" Functions Ron Peterson <ron.peterson@yellowbank.com>
@ 2001-02-27 20:40   ` Louis-David Mitterrand <cunctator@apartia.ch>
  0 siblings, 0 replies; 3+ messages in thread

From: Louis-David Mitterrand @ 2001-02-27 20:40 UTC (permalink / raw)
  To: pgsql-sql

On Thu, Dec 28, 2000 at 09:36:57AM -0500, Ron Peterson wrote:
> Tulio Oliveira wrote:
> > 
> > I appreciate any "C" Function complete samples, including de command
> > line for
> > the compiler.
> 
> I've attached a generic GNU make snippet for compiling .so files. 
> Adjust to suite your tastes.  Like my math textbooks used to say
> "writing the C code is trivial, and is left as an excercise for the
> reader."  ;)
> 
> CC = /usr/bin/gcc
> TARGET = debug
> #TARGET = final
> DFLAGS = -Wall -g
> FFLAGS = -Wall -O2
> SFLAGS = -fpic -shared
> MYINCLUDES = -I/usr/local/include
> -I/usr/local/src/postgresql/src/include -I/usr/local/postgresql/include
> MYLIBS = -L/usr/local/lib -L/usr/local/postgresql/lib -lpq
> 
> ifeq ($(TARGET),final)
>         MYCFLAGS = $(FFLAGS)
> else
>         MYCFLAGS = $(DFLAGS)
> endif 
> 
> %.so:
>         $(CC) $(MYCFLAGS) $(MYINCLUDES) $(MYLIBS) $(*F).c -c -o $(*F).o
>         $(CC) $(SFLAGS) $(*F).o -o $(*F).so
> 	[ -d $(TARGET) ] || mkdir $(TARGET)
> 	mv $(*F).so $(TARGET)
>         rm *.o

Or using implicit rules, only type "make my_file.so":

INCLUDES = -I /usr/include/postgresql
CFLAGS = -g -Wall $(INCLUDES) -fPIC 

%.so: %.o 
	ld -shared -soname $@ -o $@ $< $(LIBS)


-- 
 THERAMENE: Elle veut quelque temps douter de son malheur,
            Et ne connaissant plus ce héros qu'elle adore,
            Elle voit Hippolyte et le demande encore.
                                          (Phèdre, J-B Racine, acte 5, scène 6)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-02-27 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-12-14 18:05 Compiling "C" Functions Tulio Oliveira <mestredosmagos@marilia.com>
2000-12-28 14:36 ` Ron Peterson <ron.peterson@yellowbank.com>
2001-02-27 20:40   ` Louis-David Mitterrand <cunctator@apartia.ch>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox