You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Philip Martin <ph...@wandisco.com> on 2010/06/11 09:35:48 UTC

Re: svn commit: r953617 - in /subversion/trunk/subversion/libsvn_wc: merge.c props.c wc-queries.sql wc_db.c wc_db.h workqueue.c workqueue.h

rhuijben@apache.org writes:

> Author: rhuijben
> Date: Fri Jun 11 09:11:14 2010
> New Revision: 953617

> +svn_error_t *
> +svn_wc__db_temp_op_set_text_conflict_marker_files(svn_wc__db_t *db,
> +                                                  const char *local_abspath,
> +                                                  const char *old_basename,
> +                                                  const char *new_basename,
> +                                                  const char *wrk_basename,
> +                                                  apr_pool_t *scratch_pool)
> +{
> +  svn_wc__db_pdh_t *pdh;
> +  const char *local_relpath;
> +  svn_sqlite__stmt_t *stmt;
> +  svn_boolean_t got_row;
> +
> +  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
> +
> +  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
> +                                             local_abspath,
> +                                             svn_sqlite__mode_readwrite,
> +                                             scratch_pool, scratch_pool));
> +  VERIFY_USABLE_PDH(pdh);
> +
> +  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> +                                    STMT_SELECT_ACTUAL_NODE));
> +  SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id, local_relpath));
> +
> +  SVN_ERR(svn_sqlite__step(&got_row, stmt));
> +  SVN_ERR(svn_sqlite__reset(stmt));
> +
> +  if (got_row)
> +    {
> +      SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> +                                        STMT_UPDATE_ACTUAL_TEXT_CONFLICTS));
> +    }
> +  else
> +    {
> +      SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> +                                        STMT_INSERT_ACTUAL_TEXT_CONFLICTS));
> +    }

This SQL stuff is all a bit new to me.  Why do you choose to have
distinct insert and update queries rather than an insert or replace
query?  Should there be a transaction to combine the SELECT query with
the UPDATE/INSERT query?  Or are you relying on the working copy lock?
I realise this is a _temp_ function.

> +
> +  SVN_ERR(svn_sqlite__bindf(stmt, "issss", pdh->wcroot->wc_id,
> +                                           local_relpath,
> +                                           old_basename,
> +                                           new_basename,
> +                                           wrk_basename));
> +
> +  return svn_error_return(svn_sqlite__step_done(stmt));

-- 
Philip

Re: svn commit: r953617 - in /subversion/trunk/subversion/libsvn_wc: merge.c props.c wc-queries.sql wc_db.c wc_db.h workqueue.c workqueue.h

Posted by Greg Stein <gs...@gmail.com>.
On Fri, Jun 11, 2010 at 05:35, Philip Martin <ph...@wandisco.com> wrote:
>...
> This SQL stuff is all a bit new to me.  Why do you choose to have
> distinct insert and update queries rather than an insert or replace
> query?  Should there be a transaction to combine the SELECT query with

There could be an ACTUAL_NODE row already. You don't want to *replace*
it. You could lose (say) edited properties.

Cheers,
-g

RE: svn commit: r953617 - in /subversion/trunk/subversion/libsvn_wc: merge.c props.c wc-queries.sql wc_db.c wc_db.h workqueue.c workqueue.h

Posted by Bert Huijben <be...@vmoo.com>.

> -----Original Message-----
> From: Philip Martin [mailto:philip.martin@wandisco.com]
> Sent: vrijdag 11 juni 2010 11:36
> To: dev@subversion.apache.org
> Subject: Re: svn commit: r953617 - in
> /subversion/trunk/subversion/libsvn_wc: merge.c props.c wc-queries.sql
> wc_db.c wc_db.h workqueue.c workqueue.h
> 
> rhuijben@apache.org writes:
> 
> > Author: rhuijben
> > Date: Fri Jun 11 09:11:14 2010
> > New Revision: 953617
> 
> > +svn_error_t *
> > +svn_wc__db_temp_op_set_text_conflict_marker_files(svn_wc__db_t
> *db,
> > +                                                  const char
*local_abspath,
> > +                                                  const char
*old_basename,
> > +                                                  const char
*new_basename,
> > +                                                  const char
*wrk_basename,
> > +                                                  apr_pool_t
> > +*scratch_pool) {
> > +  svn_wc__db_pdh_t *pdh;
> > +  const char *local_relpath;
> > +  svn_sqlite__stmt_t *stmt;
> > +  svn_boolean_t got_row;
> > +
> > +  SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
> > +
> > +  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath,
> db,
> > +                                             local_abspath,
> > +
svn_sqlite__mode_readwrite,
> > +                                             scratch_pool,
> > + scratch_pool));  VERIFY_USABLE_PDH(pdh);
> > +
> > +  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> > +                                    STMT_SELECT_ACTUAL_NODE));
> > + SVN_ERR(svn_sqlite__bindf(stmt, "is", pdh->wcroot->wc_id,
> > + local_relpath));
> > +
> > +  SVN_ERR(svn_sqlite__step(&got_row, stmt));
> > + SVN_ERR(svn_sqlite__reset(stmt));
> > +
> > +  if (got_row)
> > +    {
> > +      SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> > +
STMT_UPDATE_ACTUAL_TEXT_CONFLICTS));
> > +    }
> > +  else
> > +    {
> > +      SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
> > +
STMT_INSERT_ACTUAL_TEXT_CONFLICTS));
> > +    }
> 
> This SQL stuff is all a bit new to me.  Why do you choose to have distinct
> insert and update queries rather than an insert or replace query?  Should
> there be a transaction to combine the SELECT query with the UPDATE/INSERT
> query?  Or are you relying on the working copy lock?
> I realise this is a _temp_ function.

There are more fields in ACTUAL_NODE then there are touched by this
function. If I would use an INSERT OR REPLACE, I would remove changelists,
properties and other data stored in actual node. (Sqlite documents that it
removes the old record, before it inserts the new one if it has a collision
on the insert).

(See also Greg's reply that I should have added a note on using a
transaction for this)

	Bert