title: Postgres return a default value when a column doesn't exist
body: <p>I have a query where I essentially want a fallback value if a certain column is missing. I was wondering if I can handle this purely in my query (rather than probing first and sending a seperate query. In essence i'm looking for an equivalent to <code>COALESCE</code> that handles the case of a missing column.</p>
  
  <p>Imagine the following 2 tables.</p>
  
  <pre><code>T1
  id | title | extra
  1    A     | value
  
  - and -
  
  T2
  id | title
  1    A
  </code></pre>
  
  <p>I'd like to be able to SELECT from either of these tables WITH THE SAME QUERY.</p>
  
  <p>eg, if t2 actually had an 'extra' column I could use</p>
  
  <pre><code> SELECT id,title, COALESCE(extra, 'default') as extra
  </code></pre>
  
  <p>But that only works if the column value is NULL, not when the column is missing entirely.</p>
  
  <p>I would prefer an SQL version but I can accept a PLPGSQL function (with a behaviour similiar to COALLESCE) too.</p>
  
  <p><em>NOTE to SQL purists: I don't really feel like debating why I want to do this in SQL and not in application logic (or why I won't just add the column permanently to the schema) so please restrict your comments/answers to the specific request and not your opinion on database 'correctness' or whatever else might offend you about this question.</em></p>