Optionally, modifies queries in such a way that PostgreSQL results will
match VoltDB results; and then passes the remaining work to the base
class version.
438497
protected VoltTable runDML(String dml, boolean transformDml) {
        String modifiedDml = (transformDml ? transformDML(dml) : dml);
        printTransformedSql(dml, modifiedDml);
        return super.runDML(modifiedDml);
    }
977070
private ImmutableTriple<Integer,ResultSet,SQLWarning> update(final String sql, final int autoGeneratedKeys) throws SQLException {

        checkClosed();

        try {
            final UpdateResult res = this.handler.whenSQLUpdate(sql, NO_PARAMS);
            final SQLWarning w = res.getWarning();
            final ResultSet k = (res.generatedKeys == null 
                                 || autoGeneratedKeys == NO_GENERATED_KEYS) 
                ? EMPTY_GENERATED_KEYS.withStatement(this) 
                : res.generatedKeys.resultSet().withStatement(this);
            
            return ImmutableTriple.of(res.getUpdateCount(), k, w);
        } catch (SQLException se) {
            throw se;
        } catch (Exception e) {
            throw new SQLException(e.getMessage(), e);
        } // end of catch
    }
1340386
def _compile_update_wheres(self, query):
        
        base_where = self._compile_wheres(query)

        if not query.joins:
            return base_where

        join_where = self._compile_update_join_wheres(query)

        if not base_where.strip():
            return "WHERE %s" % self._remove_leading_boolean(join_where)

        return "%s %s" % (base_where, join_where)
544331
def handle_collection_result(result)
    results = build_classes_from_result(result)
    while partial? && @options[:eager_partial]
      results.concat handle_partial
    end
    results
  end
279657
def format_sql_workload_type_update_settings(result):
    '''
    
    '''
    from collections import OrderedDict
    # Only display parameters that have content
    order_dict = OrderedDict()
    if result.sql_workload_type is not None:
        order_dict['sqlWorkloadType'] = result.sql_workload_type

    return order_dict
1086247
function (query) {
    if (!query || !_.isObject(query)) {
      return this.viewBuilders;
    }
    query.name = query.name || '';
    query.version = query.version || 0;
    query.aggregate = query.aggregate || null;
    query.context = query.context || null;
    var found = _.filter(this.viewBuilders, function (vB) {
      return vB.name === query.name &&
            (vB.version === query.version || vB.version === -1) &&
            (vB.aggregate === query.aggregate) &&
            (vB.context === query.context);
    });
    if (found.length !== 0) {
      return found;
    }
    found = _.filter(this.viewBuilders, function (vB) {
      return vB.name === query.name &&
        (vB.version === query.version || vB.version === -1) &&
        (vB.aggregate === query.aggregate) &&
        (vB.context === query.context || !query.context);
    });
    if (found.length !== 0) {
      return found;
    }
    found = _.filter(this.viewBuilders, function (vB) {
      return vB.name === query.name &&
        (vB.version === query.version || vB.version === -1) &&
        (vB.aggregate === query.aggregate || !query.aggregate) &&
        (vB.context === query.context || !query.context);
    });
    if (found.length !== 0) {
      return found;
    }
    return _.filter(this.viewBuilders, function (vB) {
      return vB.name === '' &&
        (vB.version === query.version || vB.version === -1) &&
        (vB.aggregate === query.aggregate || !query.aggregate) &&
        (vB.context === query.context || !query.context);
    });
  }
895491
def _setop(self, query):
        
        if isinstance(query.select, list):
            # RETURN BORING RESULT SET
            selects = FlatList()
            for s in listwrap(query.select):
                if isinstance(s.value, Mapping):
                    for k, v in s.value.items:
                        selects.append(sql_alias(v, quote_column(s.name + "." + k)))
                if isinstance(s.value, list):
                    for i, ss in enumerate(s.value):
                        selects.append(sql_alias(s.value, quote_column(s.name + "," + str(i))))
                else:
                    selects.append(sql_alias(s.value, quote_column(s.name)))

            sql = expand_template("""
                SELECT
                    {{selects}}
                FROM
                    {{table}}
                {{where}}
                {{sort}}
                {{limit}}
            """, {
                "selects": SQL(",\n".join(selects)),
                "table": self._subquery(query["from"])[0],
                "where": self._where2sql(query.where),
                "limit": self._limit2sql(query.limit),
                "sort": self._sort2sql(query.sort)
            })

            def post_process(sql):
                result = self.db.query(sql)
                for s in listwrap(query.select):
                    if isinstance(s.value, Mapping):
                        for r in result:
                            r[s.name] = {}
                            for k, v in s.value:
                                r[s.name][k] = r[s.name + "." + k]
                                r[s.name + "." + k] = None

                    if isinstance(s.value, list):
                        # REWRITE AS TUPLE
                        for r in result:
                            r[s.name] = tuple(r[s.name + "," + str(i)] for i, ss in enumerate(s.value))
                            for i, ss in enumerate(s.value):
                                r[s.name + "," + str(i)] = None

                expand_json(result)
                return result

            return sql, post_process  # RETURN BORING RESULT SET
        else:
            # RETURN LIST OF VALUES
            if query.select.value == ".":
                select = "*"
            else:
                name = query.select.name
                select = sql_alias(query.select.value, quote_column(name))

            sql = expand_template("""
                SELECT
                    {{selects}}
                FROM
                    {{table}}
                {{where}}
                {{sort}}
                {{limit}}
            """, {
                "selects": SQL(select),
                "table": self._subquery(query["from"])[0],
                "where": self._where2sql(query.where),
                "limit": self._limit2sql(query.limit),
                "sort": self._sort2sql(query.sort)
            })

            if query.select.value == ".":
                def post(sql):
                    result = self.db.query(sql)
                    expand_json(result)
                    return result

                return sql, post
            else:
                return sql, lambda sql: [r[name] for r in self.db.query(sql)]
630174
private void compileFallbackQueriesAndUpdateCatalog(Database db,
                                                        String query,
                                                        List<VoltXMLElement> fallbackQueryXMLs,
                                                        MaterializedViewInfo matviewinfo) throws VoltCompilerException {
        DatabaseEstimates estimates = new DatabaseEstimates();
        for (int i=0; i<fallbackQueryXMLs.size(); ++i) {
            String key = String.valueOf(i);
            Statement fallbackQueryStmt = matviewinfo.getFallbackquerystmts().add(key);
            VoltXMLElement fallbackQueryXML = fallbackQueryXMLs.get(i);
            fallbackQueryStmt.setSqltext(query);
            StatementCompiler.compileStatementAndUpdateCatalog(m_compiler,
                              m_hsql,
                              db,
                              estimates,
                              fallbackQueryStmt,
                              fallbackQueryXML,
                              fallbackQueryStmt.getSqltext(),
                              null, // no user-supplied join order
                              DeterminismMode.FASTER,
                              StatementPartitioning.forceSP());
        }
    }
214742
private void prepareMVBasedQueryFix() {

        // ENG-5386: Edge cases query returning correct answers with
        // aggregation push down does not need reAggregation work.
        if (m_hasComplexGroupby) {
            m_mvFixInfo.setEdgeCaseQueryNoFixNeeded(false);
        }

        // Handle joined query case case.
        // MV partitioned table without partition column can only join with
        // replicated tables. For all tables in this query, the # of tables
        // that need to be fixed should not exceed one.
        for (StmtTableScan mvTableScan: allScans()) {
            Set<SchemaColumn> mvNewScanColumns = new HashSet<>();

            Collection<SchemaColumn> columns = mvTableScan.getScanColumns();
            // For a COUNT(*)-only scan, a table may have no scan columns.
            // For a joined query without processed columns from table TB,
            // TB has no scan columns
            if (columns != null) {
                mvNewScanColumns.addAll(columns);
            }
            // ENG-5669: HAVING aggregation and order by aggregation
            // also need to be checked.
            if (m_mvFixInfo.processMVBasedQueryFix(mvTableScan,
                    mvNewScanColumns, m_joinTree,
                    m_aggResultColumns, groupByColumns())) {
                break;
            }
        }
    }
347037
public boolean performBooleanQuery(String queryString, SPARQLQueryBindingSet bindings, Transaction tx, boolean includeInferred, String baseURI) {
        SPARQLQueryDefinition qdef = sparqlManager.newQueryDefinition(queryString);
        if(notNull(baseURI) && !baseURI.isEmpty()){ qdef.setBaseUri(baseURI);}
        qdef.setIncludeDefaultRulesets(includeInferred);
        if (notNull(ruleset)) {qdef.setRulesets(ruleset);}
        if (notNull(getConstrainingQueryDefinition())){
        	qdef.setConstrainingQueryDefinition(getConstrainingQueryDefinition());
            qdef.setDirectory(getConstrainingQueryDefinition().getDirectory());
            qdef.setCollections(getConstrainingQueryDefinition().getCollections());
            qdef.setResponseTransform(getConstrainingQueryDefinition().getResponseTransform());
            qdef.setOptionsName(getConstrainingQueryDefinition().getOptionsName());
        	}
        if(notNull(graphPerms)){ qdef.setUpdatePermissions(graphPerms);}
        return sparqlManager.executeAsk(qdef,tx);
    }
1180072
function _update(query, op, criteria, doc, options, force, callback) {
  query.op = op;

  if (Query.canMerge(criteria)) {
    query.merge(criteria);
  }

  if (doc) {
    query._mergeUpdate(doc);
  }

  if (utils.isObject(options)) {
    // { overwrite: true }
    query.setOptions(options);
  }

  // we are done if we don't have callback and they are
  // not forcing an unsafe write.
  if (!(force || callback)) {
    return query;
  }

  if (!query._update ||
      !query.options.overwrite && 0 === utils.keys(query._update).length) {
    callback && utils.soon(callback.bind(null, null, 0));
    return query;
  }

  options = query._optionsForExec();
  if (!callback) options.safe = false;

  criteria = query._conditions;
  doc = query._updateForExec();

  debug('update', query._collection.collectionName, criteria, doc, options);
  callback = query._wrapCallback(op, callback, {
    conditions: criteria,
    doc: doc,
    options: options
  });

  query._collection[op](criteria, doc, options, utils.tick(callback));

  return query;
}
43148
public static ModifyType detectModifyType(SQLiteModelMethod method, JQLType jqlType) {
		// Elements elementUtils = BaseProcessor.elementUtils;
		SQLiteDaoDefinition daoDefinition = method.getParent();
		SQLiteEntity entity = method.getEntity();

		ModifyType updateResultType = null;

		// check type of arguments
		int count = 0;
		for (Pair<String, TypeName> param : method.getParameters()) {
			if (method.isThisDynamicWhereConditionsName(param.value0)) {
				// if current parameter is dynamic where, skip it
				continue;
			}

			if (TypeUtility.isEquals(param.value1, typeName(entity.getElement()))) {
				count++;
			}
		}

		if (count == 0) {
			// method to update raw data: no bean is used
			updateResultType = jqlType == JQLType.UPDATE ? ModifyType.UPDATE_RAW : ModifyType.DELETE_RAW;

			ModelAnnotation annotation;

			if (jqlType == JQLType.UPDATE) {
				annotation = method.getAnnotation(BindSqlUpdate.class);

				AssertKripton.assertTrueOrInvalidMethodSignException(
						AnnotationUtility.extractAsStringArray(method, annotation, AnnotationAttributeType.FIELDS)
								.size() == 0,
						method, " can not use attribute %s in this kind of query definition",
						AnnotationAttributeType.FIELDS.getValue());
				AssertKripton
						.assertTrueOrInvalidMethodSignException(
								AnnotationUtility.extractAsStringArray(method, annotation,
										AnnotationAttributeType.EXCLUDED_FIELDS).size() == 0,
								method, " can not use attribute %s in this kind of query definition",
								AnnotationAttributeType.EXCLUDED_FIELDS.getValue());

			} else {
				annotation = method.getAnnotation(BindSqlDelete.class);
			}

			// check if there is only one parameter
			AssertKripton.failWithInvalidMethodSignException(method.getParameters().size() > 1
					&& TypeUtility.isEquals(method.getParameters().get(0).value1, daoDefinition.getEntityClassName()),
					method);

		} else if (count == 1) {
			updateResultType = jqlType == JQLType.UPDATE ? ModifyType.UPDATE_BEAN : ModifyType.DELETE_BEAN;

			// with dynamic where conditions, we have to add 1 to parameter
			// check size (one parameter is a bean and one is the where
			// conditions)
			AssertKripton.assertTrueOrInvalidMethodSignException(
					method.getParameters().size() == 1 + (method.hasDynamicWhereConditions() ? 1 : 0)
							+ (method.hasDynamicWhereArgs() ? 1 : 0),
					method, " expected only one parameter of %s type", daoDefinition.getEntityClassName());
		} else {
			throw (new InvalidMethodSignException(method,
					"only one parameter of type " + typeName(entity.getElement()) + " can be used"));
		}
		return updateResultType;
	}
583226
function executeRelatedResult (result) {
    // load related records or resolve/with in parallel
    return Promise.all([
        this.executeRelatedResultResolve(result),
        this.executeRelatedResultWith(result),
    ])
    // resolve with result with related data merged in
    .then(() => result)
}
405995
function (values, schema, options) {
    var virtualList = find(schema, 'virtual');

    //Set default value for virtual if not exists in values
    if (options && options.query === true) {
    }
    else {
        for (var virtual in virtualList) {

            if (_.isArray(virtualList[virtual])) {

                for (var thisVirtual in virtualList[virtual]) {

                    if (_.isArray(values[virtual])) {
                        for (var thisValue in values[virtual]) {
                            setVirtuals(values[virtual][thisValue], virtualList[virtual][thisVirtual], options);
                        }
                    }
                }
            }
            else {
                if (values[virtual] === undefined && virtualList[virtual] && virtualList[virtual].hasOwnProperty('default') && options && options.partial !== true) {
                    values[virtual] = (virtualList[virtual]).default;
                }
            }
        }
    }

    for (var value in values) {

        if (virtualList[value] && virtualList[value].virtual) {

            var setFunction = virtualList[value].virtual;

            //Check for setter and getter
            if (virtualList[value].virtual.set) {
                setFunction = virtualList[value].virtual.set;
            }

            //Check conditions and apply virtual
            rulesMatch(value, values[value], setFunction, null, function (err, data) {
                if (!err) {
                    if (_.isFunction(setFunction)) {
                        var virtualResult = setFunction(values[value]);
                        if (_.isObject(virtualResult) && !_.isEmpty(virtualResult)) {
                            //Check if virtual values does not exists in given values list. Do not overwrite given
                            for (var vValue in virtualResult) {
                                {
                                    if (vValue == 'this') {
                                        virtualResult[value] = virtualResult[vValue];
                                        delete(virtualResult[vValue]);
                                    }
                                    else {
                                        // Prevent overwrite of given values
                                        if (values[vValue] !== undefined) {
                                            delete(virtualResult[vValue]);
                                        }
                                    }
                                }
                            }
                            values = _.assign(values, virtualResult);
                        }
                    }
                }
            });
        }
    }
    return values;
}
251954
private function fixWrongDepthGap()
    {
        // FIXME: convert this native query to DQL (once its possible to join within UPDATE statement)
        // fix categories where difference to parents depth > 1
        $sql = 'UPDATE ca_categories c2
                JOIN ca_categories c1 ON c2.idCategoriesParent = c1.id
                SET c2.depth = (c1.depth + 1)
                WHERE ( c2.depth - 1 ) <> c1.depth';

        $statement = $this->entityManager->getConnection()->prepare($sql);
        if ($statement->execute()) {
            return $statement->rowCount();
        }

        return false;
    }
712293
def mutate_query_from_config(self, sql):
        """"""
        SQL_QUERY_MUTATOR = config.get('SQL_QUERY_MUTATOR')
        if SQL_QUERY_MUTATOR:
            username = utils.get_username()
            sql = SQL_QUERY_MUTATOR(sql, username, security_manager, self.database)
        return sql
1278866
def compile_update(self, query, values):
        
        table = self.wrap_table(query.from__)

        columns = self._compile_update_columns(values)

        from_ = self._compile_update_from(query)

        where = self._compile_update_wheres(query)

        return ("UPDATE %s SET %s%s %s" % (table, columns, from_, where)).strip()