Fix WC upgrades from old formats that didn't yet have a NODES table to
format 31 and beyond.

Format 31 introduced a new column in NODES, called inherited_props. When an
svn client which uses format 31 or greater is used to upgrade a pre-NODES WC,
this new column will be created as part of the CREATE TABLE statement which
creates the NODES table.

The format 31 upgrade code would unconditionally attempt to add a new
inherited_props column, which raises an error if the column already exists.

To fix this, check whether the inherited_props column exists before
attempting to create the column. Unfortunately this has to be done
from C as there doesn't seem to be a way of executing an ALTER TABLE
statement based on the result of a PRAGMA table_info() statement.
(If somebody knows a better way of doing this, I welcome any suggestions.)

* subversion/libsvn_wc/wc-metadata.sql
  (STMT_UPGRADE_TO_31): Split this query into two parts, ...
  (STMT_UPGRADE_TO_31_ALTER_TABLE): ... this one, which creates the new
   column and can be skipped if needed, and ...
  (STMT_UPGRADE_TO_31_FINALIZE): ... this one, which runs other upgrade
   statements which are idempotent.

* subversion/libsvn_wc/wc-queries.sql
  (STMT_PRAGMA_TABLE_INFO_NODES): New statement which returns info about
   the NODES table, such as the names of existing columns.

* subversion/libsvn_wc/upgrade.c
  (bump_to_31): Check if the inherited_props column exists before running
   the SQL statement which attempts to create it.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1463601 13f79535-47bb-0310-9956-ffa450edef68