![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||||
| |||||
|
|
tgconstrname | tgconstrrelid |
|
| 0 |
|
| 0 |
|
| 0 |
|
| 0 |
#2
| |||
| |||
|
|
It seems that every foreign key constraint in the database is, actually, a trigger? The code is defined like this: scott=> select prosrc from pg_proc where proname='RI_FKey_check_ins'; prosrc ------------------- RI_FKey_check_in I can't go check the source code right now, but I suspect this is implemented as a C function? |
#3
| |||
| |||
|
|
Mladen Gogala wrote: It seems that every foreign key constraint in the database is, actually, a trigger? The code is defined like this: scott=> select prosrc from pg_proc where proname='RI_FKey_check_ins'; prosrc ------------------- RI_FKey_check_in I can't go check the source code right now, but I suspect this is implemented as a C function? Yes: test=> CREATE TABLE test( id integer CONSTRAINT test_pkey PRIMARY KEY, fk integer CONSTRAINT test_fkey REFERENCES test(id) ); test=> INSERT INTO test VALUES (1, NULL); test=> SELECT tableoid FROM test; tableoid ---------- 19701 (1 row) test=> SELECT tgname, tgfoid, tgtype, tgconstrname FROM pg_trigger WHERE tgrelid=19701; tgname | tgfoid | tgtype | tgconstrname ----------------------------+--------+--------+-------------- RI_ConstraintTrigger_19707 | 1644 | 5 | test_fkey RI_ConstraintTrigger_19708 | 1645 | 17 | test_fkey RI_ConstraintTrigger_19709 | 1654 | 9 | test_fkey RI_ConstraintTrigger_19710 | 1655 | 17 | test_fkey (4 rows) test=> SELECT p.proname, l.lanname FROM pg_proc AS p JOIN pg_language AS l ON (p.prolang = l.oid) WHERE p.oid IN (1644, 1645, 1654, 1655); proname | lanname ----------------------+---------- RI_FKey_check_ins | internal RI_FKey_check_upd | internal RI_FKey_noaction_del | internal RI_FKey_noaction_upd | internal (4 rows) Language "internal" means it is a builtin C function. They are defined in /src/backend/utils/adt/ri_triggers.c Documentation pointers: http://www.postgresql.org/docs/8.4/s...onstraint.html http://www.postgresql.org/docs/8.4/s...g-trigger.html Yours, Laurenz Albe |
#4
| |||
| |||
|
|
Do you see Oracle people starting to use Postgres? Oracle's predatory pricing did not make them many new friends, that's for sure. You are a person from both worlds. When would you recommend replacing Oracle with Postgres? |
![]() |
| Thread Tools | |
| Display Modes | |
| |