* CacheRegisterSyscacheCallback * Register the specified function to be called for all future * invalidation events in the specified cache. The cache ID and the * hash value of the tuple being invalidated will be passed to the * function. * * NOTE: Hash value zero will be passed if a cache reset request is received. * In this case the called routines should flush all cached state. * Y
| 1528 | * flush all cached state anyway. |
| 1529 | */ |
| 1530 | void |
| 1531 | CacheRegisterSyscacheCallback(int cacheid, |
| 1532 | SyscacheCallbackFunction func, |
| 1533 | Datum arg) |
| 1534 | { |
| 1535 | if (cacheid < 0 || cacheid >= SysCacheSize) |
| 1536 | elog(FATAL, "invalid cache ID: %d", cacheid); |
| 1537 | if (syscache_callback_count >= MAX_SYSCACHE_CALLBACKS) |
| 1538 | elog(FATAL, "out of syscache_callback_list slots"); |
| 1539 | |
| 1540 | if (syscache_callback_links[cacheid] == 0) |
| 1541 | { |
| 1542 | /* first callback for this cache */ |
| 1543 | syscache_callback_links[cacheid] = syscache_callback_count + 1; |
| 1544 | } |
| 1545 | else |
| 1546 | { |
| 1547 | /* add to end of chain, so that older callbacks are called first */ |
| 1548 | int i = syscache_callback_links[cacheid] - 1; |
| 1549 | |
| 1550 | while (syscache_callback_list[i].link > 0) |
| 1551 | i = syscache_callback_list[i].link - 1; |
| 1552 | syscache_callback_list[i].link = syscache_callback_count + 1; |
| 1553 | } |
| 1554 | |
| 1555 | syscache_callback_list[syscache_callback_count].id = cacheid; |
| 1556 | syscache_callback_list[syscache_callback_count].link = 0; |
| 1557 | syscache_callback_list[syscache_callback_count].function = func; |
| 1558 | syscache_callback_list[syscache_callback_count].arg = arg; |
| 1559 | |
| 1560 | ++syscache_callback_count; |
| 1561 | } |
| 1562 | |
| 1563 | /* |
| 1564 | * CacheRegisterRelcacheCallback |
no outgoing calls