Columns such as nodes.kind, nodes.presence, etc. have strings that
should be one of a discrete set of values.  When we bind these columns
in C code we use something like:

    svn_sqlite__bindf("t", presence_map, svn_wc__db_status_normal);

This means we only use known values (svn_wc__db_status_normal) and the
map converts it to the correct discrete string.  This checking happens
at build time.

We also have queries where the strings are defined as literals in
wc-queries.sql like:

    DELETE FROM nodes
    WHERE wc_id = ?1
      AND IS_STRICT_DESCENDANT_OF(local_relpath, ?2)
      AND (op_depth < ?3
           OR (op_depth = ?3 AND presence = 'base-deleted'))

There is no checking of these literals to catch errors such as
'base-delete'.

I've been thinking that transform_sql.py should do some checking.
Perhaps we could move the maps into a know header, annotate them:

    { "base-deleted", svn_wc__db_status_base_deleted },  /* MAP_DELETED */

and then have transform_sql.py parse the header and convert:

      OR (op_depth = ?3 AND presence = MAP_DELETED))

into

      OR (op_depth = ?3 AND presence = 'base-deleted'))

-- 
Philip

Reply via email to