Skip to content

Commit 04b3160

Browse files
committed
Add 'ONLY' to queries generated by RI triggers, so as to preserve pre-7.1
semantics of RI operations. Eventually we ought to look at making RI work properly across inheritance trees, but not for 7.1 ...
1 parent f4eef66 commit 04b3160

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/backend/utils/adt/ri_triggers.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* 1999 Jan Wieck
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.19 2000/11/21 04:01:09 inoue Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.20 2000/12/22 18:35:09 tgl Exp $
1010
*
1111
* ----------
1212
*/
@@ -232,10 +232,10 @@ RI_FKey_check(PG_FUNCTION_ARGS)
232232

233233
/* ----------
234234
* The query string built is
235-
* SELECT oid FROM <pktable>
235+
* SELECT oid FROM ONLY <pktable>
236236
* ----------
237237
*/
238-
sprintf(querystr, "SELECT oid FROM \"%s\" FOR UPDATE OF \"%s\"",
238+
sprintf(querystr, "SELECT oid FROM ONLY \"%s\" FOR UPDATE OF \"%s\"",
239239
tgargs[RI_PK_RELNAME_ARGNO],
240240
tgargs[RI_PK_RELNAME_ARGNO]);
241241

@@ -381,14 +381,14 @@ RI_FKey_check(PG_FUNCTION_ARGS)
381381

382382
/* ----------
383383
* The query string built is
384-
* SELECT oid FROM <pktable> WHERE pkatt1 = $1 [AND ...]
384+
* SELECT oid FROM ONLY <pktable> WHERE pkatt1 = $1 [AND ...]
385385
* The type id's for the $ parameters are those of the
386386
* corresponding FK attributes. Thus, SPI_prepare could
387387
* eventually fail if the parser cannot identify some way
388388
* how to compare these two types by '='.
389389
* ----------
390390
*/
391-
sprintf(querystr, "SELECT oid FROM \"%s\"",
391+
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
392392
tgargs[RI_PK_RELNAME_ARGNO]);
393393
querysep = "WHERE";
394394
for (i = 0; i < qkey.nkeypairs; i++)
@@ -623,14 +623,14 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
623623

624624
/* ----------
625625
* The query string built is
626-
* SELECT oid FROM <fktable> WHERE fkatt1 = $1 [AND ...]
626+
* SELECT oid FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
627627
* The type id's for the $ parameters are those of the
628628
* corresponding PK attributes. Thus, SPI_prepare could
629629
* eventually fail if the parser cannot identify some way
630630
* how to compare these two types by '='.
631631
* ----------
632632
*/
633-
sprintf(querystr, "SELECT oid FROM \"%s\"",
633+
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
634634
tgargs[RI_FK_RELNAME_ARGNO]);
635635
querysep = "WHERE";
636636
for (i = 0; i < qkey.nkeypairs; i++)
@@ -847,14 +847,14 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
847847

848848
/* ----------
849849
* The query string built is
850-
* SELECT oid FROM <fktable> WHERE fkatt1 = $1 [AND ...]
850+
* SELECT oid FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
851851
* The type id's for the $ parameters are those of the
852852
* corresponding PK attributes. Thus, SPI_prepare could
853853
* eventually fail if the parser cannot identify some way
854854
* how to compare these two types by '='.
855855
* ----------
856856
*/
857-
sprintf(querystr, "SELECT oid FROM \"%s\"",
857+
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
858858
tgargs[RI_FK_RELNAME_ARGNO]);
859859
querysep = "WHERE";
860860
for (i = 0; i < qkey.nkeypairs; i++)
@@ -1055,14 +1055,14 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
10551055

10561056
/* ----------
10571057
* The query string built is
1058-
* DELETE FROM <fktable> WHERE fkatt1 = $1 [AND ...]
1058+
* DELETE FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
10591059
* The type id's for the $ parameters are those of the
10601060
* corresponding PK attributes. Thus, SPI_prepare could
10611061
* eventually fail if the parser cannot identify some way
10621062
* how to compare these two types by '='.
10631063
* ----------
10641064
*/
1065-
sprintf(querystr, "DELETE FROM \"%s\"",
1065+
sprintf(querystr, "DELETE FROM ONLY \"%s\"",
10661066
tgargs[RI_FK_RELNAME_ARGNO]);
10671067
querysep = "WHERE";
10681068
for (i = 0; i < qkey.nkeypairs; i++)
@@ -1263,15 +1263,15 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
12631263

12641264
/* ----------
12651265
* The query string built is
1266-
* UPDATE <fktable> SET fkatt1 = $1 [, ...]
1266+
* UPDATE ONLY <fktable> SET fkatt1 = $1 [, ...]
12671267
* WHERE fkatt1 = $n [AND ...]
12681268
* The type id's for the $ parameters are those of the
12691269
* corresponding PK attributes. Thus, SPI_prepare could
12701270
* eventually fail if the parser cannot identify some way
12711271
* how to compare these two types by '='.
12721272
* ----------
12731273
*/
1274-
sprintf(querystr, "UPDATE \"%s\" SET",
1274+
sprintf(querystr, "UPDATE ONLY \"%s\" SET",
12751275
tgargs[RI_FK_RELNAME_ARGNO]);
12761276
qualstr[0] = '\0';
12771277
querysep = "";
@@ -1483,14 +1483,14 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
14831483

14841484
/* ----------
14851485
* The query string built is
1486-
* SELECT oid FROM <fktable> WHERE fkatt1 = $1 [AND ...]
1486+
* SELECT oid FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
14871487
* The type id's for the $ parameters are those of the
14881488
* corresponding PK attributes. Thus, SPI_prepare could
14891489
* eventually fail if the parser cannot identify some way
14901490
* how to compare these two types by '='.
14911491
* ----------
14921492
*/
1493-
sprintf(querystr, "SELECT oid FROM \"%s\"",
1493+
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
14941494
tgargs[RI_FK_RELNAME_ARGNO]);
14951495
querysep = "WHERE";
14961496
for (i = 0; i < qkey.nkeypairs; i++)
@@ -1708,14 +1708,14 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
17081708

17091709
/* ----------
17101710
* The query string built is
1711-
* SELECT oid FROM <fktable> WHERE fkatt1 = $1 [AND ...]
1711+
* SELECT oid FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
17121712
* The type id's for the $ parameters are those of the
17131713
* corresponding PK attributes. Thus, SPI_prepare could
17141714
* eventually fail if the parser cannot identify some way
17151715
* how to compare these two types by '='.
17161716
* ----------
17171717
*/
1718-
sprintf(querystr, "SELECT oid FROM \"%s\"",
1718+
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
17191719
tgargs[RI_FK_RELNAME_ARGNO]);
17201720
querysep = "WHERE";
17211721
for (i = 0; i < qkey.nkeypairs; i++)
@@ -1919,15 +1919,15 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
19191919

19201920
/* ----------
19211921
* The query string built is
1922-
* UPDATE <fktable> SET fkatt1 = NULL [, ...]
1922+
* UPDATE ONLY <fktable> SET fkatt1 = NULL [, ...]
19231923
* WHERE fkatt1 = $1 [AND ...]
19241924
* The type id's for the $ parameters are those of the
19251925
* corresponding PK attributes. Thus, SPI_prepare could
19261926
* eventually fail if the parser cannot identify some way
19271927
* how to compare these two types by '='.
19281928
* ----------
19291929
*/
1930-
sprintf(querystr, "UPDATE \"%s\" SET",
1930+
sprintf(querystr, "UPDATE ONLY \"%s\" SET",
19311931
tgargs[RI_FK_RELNAME_ARGNO]);
19321932
qualstr[0] = '\0';
19331933
querysep = "";
@@ -2157,15 +2157,15 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
21572157

21582158
/* ----------
21592159
* The query string built is
2160-
* UPDATE <fktable> SET fkatt1 = NULL [, ...]
2160+
* UPDATE ONLY <fktable> SET fkatt1 = NULL [, ...]
21612161
* WHERE fkatt1 = $1 [AND ...]
21622162
* The type id's for the $ parameters are those of the
21632163
* corresponding PK attributes. Thus, SPI_prepare could
21642164
* eventually fail if the parser cannot identify some way
21652165
* how to compare these two types by '='.
21662166
* ----------
21672167
*/
2168-
sprintf(querystr, "UPDATE \"%s\" SET",
2168+
sprintf(querystr, "UPDATE ONLY \"%s\" SET",
21692169
tgargs[RI_FK_RELNAME_ARGNO]);
21702170
qualstr[0] = '\0';
21712171
querysep = "";
@@ -2385,15 +2385,15 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
23852385

23862386
/* ----------
23872387
* The query string built is
2388-
* UPDATE <fktable> SET fkatt1 = NULL [, ...]
2388+
* UPDATE ONLY <fktable> SET fkatt1 = NULL [, ...]
23892389
* WHERE fkatt1 = $1 [AND ...]
23902390
* The type id's for the $ parameters are those of the
23912391
* corresponding PK attributes. Thus, SPI_prepare could
23922392
* eventually fail if the parser cannot identify some way
23932393
* how to compare these two types by '='.
23942394
* ----------
23952395
*/
2396-
sprintf(querystr, "UPDATE \"%s\" SET",
2396+
sprintf(querystr, "UPDATE ONLY \"%s\" SET",
23972397
tgargs[RI_FK_RELNAME_ARGNO]);
23982398
qualstr[0] = '\0';
23992399
querysep = "";
@@ -2651,15 +2651,15 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
26512651

26522652
/* ----------
26532653
* The query string built is
2654-
* UPDATE <fktable> SET fkatt1 = NULL [, ...]
2654+
* UPDATE ONLY <fktable> SET fkatt1 = NULL [, ...]
26552655
* WHERE fkatt1 = $1 [AND ...]
26562656
* The type id's for the $ parameters are those of the
26572657
* corresponding PK attributes. Thus, SPI_prepare could
26582658
* eventually fail if the parser cannot identify some way
26592659
* how to compare these two types by '='.
26602660
* ----------
26612661
*/
2662-
sprintf(querystr, "UPDATE \"%s\" SET",
2662+
sprintf(querystr, "UPDATE ONLY \"%s\" SET",
26632663
tgargs[RI_FK_RELNAME_ARGNO]);
26642664
qualstr[0] = '\0';
26652665
querysep = "";

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy