<commit_before>package org.basex.core.cmd;

import static org.basex.core.Text.*;

import java.util.Locale;

import org.basex.core.*;
import org.basex.util.Util;

/**
 * Evaluates the 'set' command and modifies database properties.
 *
 * @author BaseX Team 2005-12, BSD License
 * @author <NAME>
 */
public final class Set extends AGet {
  /**
   * Default constructor.
   * @param key property
   * @param value value to set (optional, depending on the property)
   */
  public Set(final Object key, final Object value) {
    super(User.READ, (key instanceof Object[] ?
        ((Object[]) key)[0] : key).toString(),
        value == null ? "" : value.toString());
  }

  @Override
  protected boolean run() {
    final String key = args[0].toUpperCase(Locale.ENGLISH);
    final String val = args[1];
    try {
      String v = prop.set(key, val);
      if(v == null && !context.client()) {
        // disallow modification of database path if any database is opened
        if(key.equals(MainProp.DBPATH[0]) && context.datas.size() > 0) {
          return error(INVALID_VALUE_X_X, key, val);
        }
        v = mprop.set(key, val);
      }
      return v == null ? error(prop.unknown(key)) : info(key + COLS + v);
    } catch(final Exception ex) {
      Util.debug(ex);
      return error(INVALID_VALUE_X_X, key, val);
    }
  }

  @Override
  public boolean updating(final Context ctx) {
    // command may set options that influence other commands
    return true;
  }
}<commit_msg>[MOD] Commands, GH-458: mark SET command as non-updating<commit_after>package org.basex.core.cmd;

import static org.basex.core.Text.*;

import java.util.Locale;

import org.basex.core.*;
import org.basex.util.Util;

/**
 * Evaluates the 'set' command and modifies database properties.
 *
 * @author BaseX Team 2005-12, BSD License
 * @author <NAME>
 */
public final class Set extends AGet {
  /**
   * Default constructor.
   * @param key property
   * @param value value to set (optional, depending on the property)
   */
  public Set(final Object key, final Object value) {
    super(User.READ, (key instanceof Object[] ?
        ((Object[]) key)[0] : key).toString(),
        value == null ? "" : value.toString());
  }

  @Override
  protected boolean run() {
    final String key = args[0].toUpperCase(Locale.ENGLISH);
    final String val = args[1];
    try {
      String v = prop.set(key, val);
      if(v == null && !context.client()) {
        // disallow modification of database path if any database is opened
        if(key.equals(MainProp.DBPATH[0]) && context.datas.size() > 0) {
          return error(INVALID_VALUE_X_X, key, val);
        }
        v = mprop.set(key, val);
      }
      return v == null ? error(prop.unknown(key)) : info(key + COLS + v);
    } catch(final Exception ex) {
      Util.debug(ex);
      return error(INVALID_VALUE_X_X, key, val);
    }
  }
}
{'fraction_non_alphanumeric': 0.13685307398402222, 'fraction_numerical': 0.00868357068426537, 'mean_word_length': 2.819628647214854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1874641', 'n_tokens_mistral': 918, 'n_tokens_neox': 895, 'n_words': 263}