6. David Fetter
Husband and father of four
Long-time PostgreSQL contributor
Expander of SQL
Tuesday, March 7, 17
7. David Fetter
Husband and father of four
Long-time PostgreSQL contributor
Expander of SQL
Happy contractor for OpenSCG at GE
Digital
Tuesday, March 7, 17
41. Preamble
#include "postgres.h"
/* Headers you need start here: */
/* Headers you need end here: */
PG_MODULE_MAGIC;
/* Hooking: All hooks start with this. */
void _PG_init(void);
/* Unhooking: All hooks end with this. */
void _PG_fini(void);
Tuesday, March 7, 17
42. Snag/Bag
/*
* There is a type for each hook.
* This is not one of them.
* You will need it for hooking and unhooking.
*/
static System_hook_type prev_system_hook = NULL;
void _PG_init(void)
{
prev_system_hook = System_hook;
System_hook = blackhole_hook;
}
Tuesday, March 7, 17
47. You could:
Updated or deleted from a whole table
without meaning to?
Lock out everyone who could make a
mistake...
Make a simple hook for simple errors
Tuesday, March 7, 17
56. You could
Wanted to slow people down when they
auth too fast
Tuesday, March 7, 17
57. You could
Wanted to slow people down when they
auth too fast
Hope the network layer handles it
Tuesday, March 7, 17
58. You could
Wanted to slow people down when they
auth too fast
Hope the network layer handles it
and isn’t Mallory
Tuesday, March 7, 17
59. You could
Wanted to slow people down when they
auth too fast
Hope the network layer handles it
and isn’t Mallory
auth_delay (contrib)
Tuesday, March 7, 17
60. You could
Wanted to replace our TSP-based
planner with one based on simulated
annealing
Um....er....
2313 LoC later: Wow!
Tuesday, March 7, 17