title: How to use column defaults with dbWriteTable(..., append=TRUE) in RPostgreSQL
body: <p>The <code>dbWriteTable</code> function in <code>RPostgreSQL</code> seems to ignore column names and tries to push data from R to PostgreSQL as-is.  This is problematic when appending to existing tables, particularly if there are columns un-specified in the R object that should be given default values.</p>
  
  <p>RMySQL handles this case very gracefully by adding the column names to <code>LOAD DATA LOCAL INFILE</code>. How do I force RPostgreSQL to assign default values to un-specified columns in <code>dbWriteTable</code> when <code>append=TRUE</code>?</p>
  
  <p>Here is an example:</p>
  
  <pre><code>CREATE TABLE test (
      column_a varchar(255) not null default 'hello',
      column_b integer not null 
      );
  insert into test values (DEFAULT, 1);
  </code></pre>
  
  <p>Which yields the following table:</p>
  
  <pre><code>select * from test;
   column_a | column_b 
  ----------+----------
   hello    |        1
  (1 row)
  </code></pre>
  
  <p>I want to insert some new data to this table from R:</p>
  
  <pre><code>require('RPostgreSQL')
  driver &lt;- PostgreSQL()
  con &lt;- dbConnect(driver, host='localhost', dbname='development')
  set.seed(42)
  x &lt;- data.frame(column_b=sample(1:100, 10))
  dbWriteTable(con, name='test', value=x, append=TRUE, row.names=FALSE)
  dbDisconnect(con)
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <pre><code>Error in postgresqlgetResult(new.con) : 
    RS-DBI driver: (could not Retrieve the result : ERROR:  missing data for 
  column "column_b"
  CONTEXT:  COPY test, line 1: "92"
  )
  </code></pre>
  
  <p>This is because I have not specified the <code>column_a</code> field, so <code>dbWriteTable</code> is trying to write the data for column_b into column_a.  I would like to force <code>dbWriteTable</code> to use the defaults for <code>column_a</code>, and properly write <code>column_b</code> to <code>column_b</code>.</p>
  
  <p>I should only get a failure if:</p>
  
  <ol>
  <li>I fail to specify a column with no default value </li>
  <li>I try to insert a column that doesn't exist in the table</li>
  <li>I insert the wrong datatype into an existing column</li>
  </ol>