title: Test for null in function with varying parameters
body: <p>I have a Postgres function: </p>
  
  <pre><code>create function myfunction(integer, text, text, text, text, text, text) RETURNS 
  table(id int, match text, score int, nr int, nr_extra character varying, info character varying, postcode character varying,
  street character varying, place character varying, country character varying, the_geom geometry)
  AS $$
  BEGIN
  
  return query (select a.id, 'address' as match, 1 as score, a.ad_nr, a.ad_nr_extra,a.ad_info,a.ad_postcode, s.name as street, p.name place , c.name country, a.wkb_geometry as wkb_geometry from "Addresses" a 
      left join "Streets" s on a.street_id = s.id 
          left join "Places" p on s.place_id = p.id 
              left join "Countries" c on p.country_id = c.id 
              where c.name = $7 
                  and p.name = $6
                      and s.name = $5
                      and a.ad_nr = $1 
                      and a.ad_nr_extra = $2
                      and a.ad_info = $3
                      and ad_postcode = $4);
  END;
  $$
  LANGUAGE plpgsql;
  </code></pre>
  
  <p>This function fails to give the right result when one or more of the variables entered are NULL because <code>ad_postcode = NULL</code> will fail.</p>
  
  <p>What can I do to test for NULL inside the query?</p>