metabrainz/dbmirror — pull request #1 by ocharles (2013-10-17 15:04:06+00:00)
Title: Do not crash in storeData if the table lacks a primary key

When we execute the plan to INSERT INTO dbmirror_pending, we pass
NULL to SPI_execp as the third parameter, which indicates the second
parameter - planData - does not contain any NULLs. However, it is
possible for planData[1] to contain NULLs, as it is populated by
calling packageData. packageData has two paths - a successful one,
but also a path that returns NULL if the table lacks a primary key.

In this commit, check whether packageData returns NULL, and if so -
die with an error.