Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e506ca4

Browse files
committed
Tables without oids wouldn't be able to be
used inside fk constraints, since some of the checks in the trigger did a SELECT oid. Since the oid wasn't actually used, I changed this to SELECT 1. My test case with non-oid tables now works and fk regression appears to run fine on my machine. Stephan Szabo
1 parent 9371325 commit e506ca4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/backend/utils/adt/ri_triggers.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Portions Copyright (c) 2000-2001, PostgreSQL Global Development Group
1919
* Copyright 1999 Jan Wieck
2020
*
21-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.30 2001/11/12 00:46:36 tgl Exp $
21+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.31 2001/11/12 06:09:09 momjian Exp $
2222
*
2323
* ----------
2424
*/
@@ -232,10 +232,10 @@ RI_FKey_check(PG_FUNCTION_ARGS)
232232

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

@@ -376,14 +376,14 @@ RI_FKey_check(PG_FUNCTION_ARGS)
376376

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

610610
/* ----------
611611
* The query string built is
612-
* SELECT oid FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
612+
* SELECT 1 FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
613613
* The type id's for the $ parameters are those of the
614614
* corresponding PK attributes. Thus, SPI_prepare could
615615
* eventually fail if the parser cannot identify some way
616616
* how to compare these two types by '='.
617617
* ----------
618618
*/
619-
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
619+
sprintf(querystr, "SELECT 1 FROM ONLY \"%s\"",
620620
tgargs[RI_FK_RELNAME_ARGNO]);
621621
querysep = "WHERE";
622622
for (i = 0; i < qkey.nkeypairs; i++)
@@ -823,14 +823,14 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
823823

824824
/* ----------
825825
* The query string built is
826-
* SELECT oid FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
826+
* SELECT 1 FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
827827
* The type id's for the $ parameters are those of the
828828
* corresponding PK attributes. Thus, SPI_prepare could
829829
* eventually fail if the parser cannot identify some way
830830
* how to compare these two types by '='.
831831
* ----------
832832
*/
833-
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
833+
sprintf(querystr, "SELECT 1 FROM ONLY \"%s\"",
834834
tgargs[RI_FK_RELNAME_ARGNO]);
835835
querysep = "WHERE";
836836
for (i = 0; i < qkey.nkeypairs; i++)
@@ -1450,14 +1450,14 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
14501450

14511451
/* ----------
14521452
* The query string built is
1453-
* SELECT oid FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
1453+
* SELECT 1 FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
14541454
* The type id's for the $ parameters are those of the
14551455
* corresponding PK attributes. Thus, SPI_prepare could
14561456
* eventually fail if the parser cannot identify some way
14571457
* how to compare these two types by '='.
14581458
* ----------
14591459
*/
1460-
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
1460+
sprintf(querystr, "SELECT 1 FROM ONLY \"%s\"",
14611461
tgargs[RI_FK_RELNAME_ARGNO]);
14621462
querysep = "WHERE";
14631463
for (i = 0; i < qkey.nkeypairs; i++)
@@ -1670,14 +1670,14 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
16701670

16711671
/* ----------
16721672
* The query string built is
1673-
* SELECT oid FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
1673+
* SELECT 1 FROM ONLY <fktable> WHERE fkatt1 = $1 [AND ...]
16741674
* The type id's for the $ parameters are those of the
16751675
* corresponding PK attributes. Thus, SPI_prepare could
16761676
* eventually fail if the parser cannot identify some way
16771677
* how to compare these two types by '='.
16781678
* ----------
16791679
*/
1680-
sprintf(querystr, "SELECT oid FROM ONLY \"%s\"",
1680+
sprintf(querystr, "SELECT 1 FROM ONLY \"%s\"",
16811681
tgargs[RI_FK_RELNAME_ARGNO]);
16821682
querysep = "WHERE";
16831683
for (i = 0; i < qkey.nkeypairs; i++)

0 commit comments

Comments
 (0)