Skip to content

Commit c4bc9a8

Browse files
author
Hiroshi Inoue
committed
keep relations open until they are no longer needed.
1 parent 93fcbd1 commit c4bc9a8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/backend/utils/adt/ri_triggers.c

Lines changed: 9 additions & 5 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.18 2000/11/16 22:30:31 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.19 2000/11/21 04:01:09 inoue Exp $
1010
*
1111
* ----------
1212
*/
@@ -247,7 +247,6 @@ RI_FKey_check(PG_FUNCTION_ARGS)
247247
qplan = SPI_saveplan(qplan);
248248
ri_HashPreparedPlan(&qkey, qplan);
249249
}
250-
heap_close(pk_rel, NoLock);
251250

252251
/* ----------
253252
* Execute the plan
@@ -257,6 +256,8 @@ RI_FKey_check(PG_FUNCTION_ARGS)
257256
elog(NOTICE, "SPI_connect() failed in RI_FKey_check()");
258257

259258
SetUserId(RelationGetForm(pk_rel)->relowner);
259+
/* pk_rel is no longer neede OK ? */
260+
heap_close(pk_rel, NoLock);
260261

261262
if (SPI_execp(qplan, check_values, check_nulls, 1) != SPI_OK_SELECT)
262263
elog(ERROR, "SPI_execp() failed in RI_FKey_check()");
@@ -353,7 +354,6 @@ RI_FKey_check(PG_FUNCTION_ARGS)
353354
*/
354355
break;
355356
}
356-
heap_close(pk_rel, NoLock);
357357

358358
/* ----------
359359
* Note:
@@ -445,6 +445,8 @@ RI_FKey_check(PG_FUNCTION_ARGS)
445445
*/
446446

447447
SetUserId(RelationGetForm(pk_rel)->relowner);
448+
/* pk_rel is no longer needed OK ? */
449+
heap_close(pk_rel, NoLock);
448450

449451
if (SPI_execp(qplan, check_values, check_nulls, 1) != SPI_OK_SELECT)
450452
elog(ERROR, "SPI_execp() failed in RI_FKey_check()");
@@ -2357,7 +2359,6 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
23572359
*/
23582360
break;
23592361
}
2360-
heap_close(fk_rel, NoLock);
23612362

23622363
if (SPI_connect() != SPI_OK_CONNECT)
23632364
elog(NOTICE, "SPI_connect() failed in RI_FKey_setdefault_del()");
@@ -2461,6 +2462,8 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
24612462
}
24622463
}
24632464
}
2465+
/* fk_rel is no longer needed OK ? */
2466+
heap_close(fk_rel, NoLock);
24642467

24652468
/* ----------
24662469
* We have a plan now. Build up the arguments for SPI_execp()
@@ -2614,7 +2617,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
26142617
*/
26152618
break;
26162619
}
2617-
heap_close(fk_rel, NoLock);
26182620

26192621
/* ----------
26202622
* No need to do anything if old and new keys are equal
@@ -2743,6 +2745,8 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
27432745
}
27442746
}
27452747
}
2748+
/* fk_rel is no longer needed OK ? */
2749+
heap_close(fk_rel, NoLock);
27462750

27472751
/* ----------
27482752
* We have a plan now. Build up the arguments for SPI_execp()

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