Thanks to Richard Huxton to point the right documentation.
Using it, it is possible to condition the prepared statement code lines with this test :
$rs = pg_query($link, "select * from pg_prepared_statements");
if ($rs && pg_num_rows($rs) == 0) {
// prepared statements here
}
The test is not verifying that the known prepared statement are the ones in the if.
In my case, I prepare all of them them just after the pg_pconnect
so no need to check. But it can be more aligned to your case using WHERE name IN ('name1', 'name2')
and testing the number of lines is not equals to number of provided names.