Re: question

Поиск
Список
Период
Сортировка
От Robert B. Easter
Тема Re: question
Дата
Msg-id 00121620301503.22968@comptechnews
обсуждение исходный текст
Ответ на Re: question  (Sandeep Joshi <sjoshi@Zambeel.com>)
Список pgsql-general
I have no idea what my problems were with getting the autoinc example to work
before.  I took a break today and came back later and tried it with no
problems. (this was with PostgreSQL 7.0.3)

mkdir autoinc
cd autoinc
cp /usr/src/postgresql-7.0.3/contrib/spi/autoinc.* .

Created a simple Makefile:

autoinc.so: autoinc.c
    gcc -shared -I/usr/local/pgsql/include
-I/usr/src/postgresql-7.0.3/src/include autoinc.c -o autoinc.so

clean:
    rm -f *.so


Edited autoinc.source and changed path to the so file as:
/home/reaster/prog/triggers/autoinc/autoinc.so (where it compiled to).

createdb tt
psql tt
\i autoinc.source
\i autoinc.example

It ran fine:

tt=# \i autoinc.example
DROP
DROP
CREATE
CREATE
CREATE
INSERT 2834802 1
INSERT 2834803 1
INSERT 2834804 1
 id |     idesc
----+---------------
 -2 | first (-2 ?)
 -1 | second (-1 ?)
  1 | third (1 ?!)
(3 rows)

UPDATE 1
UPDATE 1
UPDATE 1
 id |      idesc
----+------------------
  2 | first: -2 --> 2
  3 | second: -1 --> 3
  4 | third: 1 --> 4
(3 rows)

    nextval    | value
---------------+-------
 Wasn't it 4 ? |     4
(1 row)

INSERT 0 3
 id |          idesc
----+-------------------------
  2 | first: -2 --> 2
  3 | second: -1 --> 3
  4 | third: 1 --> 4
  5 | first: -2 --> 2. Copy.
  6 | second: -1 --> 3. Copy.
  7 | third: 1 --> 4. Copy.
(6 rows)


Sorry for any confusion.


On Saturday 16 December 2000 16:43, Sandeep Joshi wrote:
> Sure, I will mail the example to you and anyone else IFF I get it
> working ! I have already received couple of mails of this sort.
>
> Also, example in doc needs to make "PQconnectdb()" call rather than
> "PQsetdb()" if the earlier call is better call.
>
> thanks and regards,
>
> Sandeep
>
> > If you or anyone reading this can put together a working C trigger
> > example with a test table and compile and trigger load procedure, I'd
> > like to have it to play with!  I've been trying to use the examples in
> > the docs and the ones in contrib/spi, but with no luck.  I'm using 7.0.3.
> >  I notice that the delev docs have a different C trigger example than the
> > 7.0 docs.  I don't know what the differences are, one returns a HeapTuple
> > and the other a Datum (a unsigned long)?
> >
> > Anyhow, some more detailed, up-to-date, docs on some of this would be
> > nice. If I can learn these structs etc for C triggers, I'll try to write
> > some HTML page about it how it all works in detail.
> >
> > On Friday 15 December 2000 18:12, Sandeep Joshi wrote:
> > > It results in following error: (just "shared")
> > >
> > > ERROR:  Load of file /var/lib/pgsql/trigger/db1trig.so failed:
> > > libpq.so.2.1: cannot open shared object file: No such file or directory
> > >
> > > I tried following link line (which specifies "run-time" linking path).
> > > ld -shared -o db1trig.so db1trig.o -R/work/posgresql/lib -lpq
> > >
> > > This results in following error when  "PQsetdb" is called:
> > >
> > > pqReadData() -- backend closed the channel unexpectedly.
> > >         This probably means the backend terminated abnormally
> > >         before or while processing the request.
> > > The connection to the server was lost. Attempting reset: Failed.
> > >
> > >
> > > Sandeep
> > >
> > > > * Sandeep Joshi <sjoshi@Zambeel.com> [001215 14:54] wrote:
> > > > > ld -shared -o db1trig.so db1trig.o -L/work/posgresql/lib -static
> > > > > -lpq
> > > > >
> > > > > Using above link line I was able to link and load the library but I
> > > > > get following error
> > > > > ERROR:  conneciton bad.
> > > >
> > > > I think using both -shared and -static is an error, you might try
> > > > linking to /work/posgresql/lib/libpq.a or try without as well.
> >
> > --
> > -------- Robert B. Easter  reaster@comptechnews.com ---------
> > - CompTechNews Message Board   http://www.comptechnews.com/ -
> > - CompTechServ Tech Services   http://www.comptechserv.com/ -
> > ---------- http://www.comptechnews.com/~reaster/ ------------

--
-------- Robert B. Easter  reaster@comptechnews.com ---------
- CompTechNews Message Board   http://www.comptechnews.com/ -
- CompTechServ Tech Services   http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------

В списке pgsql-general по дате отправления:

Предыдущее
От: Toshio Kuratomi
Дата:
Сообщение: Foreign Keys and OIDs
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Foreign Keys and OIDs