Plan and execute a batch of DML/DQL sql. Any DDL has been filtered out at this point.
964809
protected CompletableFuture<ClientResponse> runNonDDLAdHoc(CatalogContext context,
                                                               List<String> sqlStatements,
                                                               boolean inferPartitioning,
                                                               Object userPartitionKey,
                                                               ExplainMode explainMode,
                                                               boolean isLargeQuery,
                                                               boolean isSwapTables,
                                                               Object[] userParamSet)
    {
        // record the catalog version the query is planned against to
        // catch races vs. updateApplicationCatalog.
        if (context == null) {
            context = VoltDB.instance().getCatalogContext();
        }

        List<String> errorMsgs = new ArrayList<>();
        List<AdHocPlannedStatement> stmts = new ArrayList<>();
        int partitionParamIndex = -1;
        VoltType partitionParamType = null;
        Object partitionParamValue = null;
        assert(sqlStatements != null);

        boolean inferSP = (sqlStatements.size() == 1) && inferPartitioning;

        if (userParamSet != null && userParamSet.length > 0) {
            if (sqlStatements.size() != 1) {
                return makeQuickResponse(ClientResponse.GRACEFUL_FAILURE,
                                         AdHocErrorResponseMessage);
            }
        }

        for (final String sqlStatement : sqlStatements) {
            try {
                AdHocPlannedStatement result = compileAdHocSQL(context.m_ptool,
                                                               sqlStatement,
                                                               inferSP,
                                                               userPartitionKey,
                                                               explainMode,
                                                               isLargeQuery,
                                                               isSwapTables,
                                                               userParamSet);
                // The planning tool may have optimized for the single partition case
                // and generated a partition parameter.
                if (inferSP) {
                    partitionParamIndex = result.getPartitioningParameterIndex();
                    partitionParamType = result.getPartitioningParameterType();
                    partitionParamValue = result.getPartitioningParameterValue();
                }
                stmts.add(result);
            }
            catch (AdHocPlanningException e) {
                errorMsgs.add(e.getMessage());
            }
        }

        if (!errorMsgs.isEmpty()) {
            String errorSummary = StringUtils.join(errorMsgs, "\n");
            return makeQuickResponse(ClientResponse.GRACEFUL_FAILURE, errorSummary);
        }

        AdHocPlannedStmtBatch plannedStmtBatch =
                new AdHocPlannedStmtBatch(userParamSet,
                                          stmts,
                                          partitionParamIndex,
                                          partitionParamType,
                                          partitionParamValue,
                                          userPartitionKey == null ? null : new Object[] { userPartitionKey });

        if (adhocLog.isDebugEnabled()) {
            logBatch(context, plannedStmtBatch, userParamSet);
        }

        final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.CI);
        if (traceLog != null) {
            traceLog.add(() -> VoltTrace.endAsync("planadhoc", getClientHandle()));
        }

        if (explainMode == ExplainMode.EXPLAIN_ADHOC) {
            return processExplainPlannedStmtBatch(plannedStmtBatch);
        }
        else if (explainMode == ExplainMode.EXPLAIN_DEFAULT_PROC) {
            return processExplainDefaultProc(plannedStmtBatch);
        }
        else if (explainMode == ExplainMode.EXPLAIN_JSON) {
            return processExplainPlannedStmtBatchInJSON(plannedStmtBatch);
        }
        else {
            try {
                return createAdHocTransaction(plannedStmtBatch, isSwapTables);
            }
            catch (VoltTypeException vte) {
                String msg = "Unable to execute adhoc sql statement(s): " + vte.getMessage();
                return makeQuickResponse(ClientResponse.GRACEFUL_FAILURE, msg);
            }
        }
    }
360654
protected void runQuery() {

        String pool = m_pool.getValue();
        String stmt = m_script.getValue();
        if (stmt.trim().isEmpty()) {
            return;
        }
        CmsStringBufferReport report = new CmsStringBufferReport(Locale.ENGLISH);
        List<Throwable> errors = new ArrayList<>();
        CmsSqlConsoleResults result = m_console.execute(stmt, pool, report, errors);
        if (errors.size() > 0) {
            CmsErrorDialog.showErrorDialog(report.toString() +  errors.get(0).getMessage(), errors.get(0));
        } else {
            Window window = CmsBasicDialog.prepareWindow(DialogWidth.max);
            window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_SQLCONSOLE_QUERY_RESULTS_0));
            window.setContent(new CmsSqlConsoleResultsForm(result, report.toString()));
            A_CmsUI.get().addWindow(window);
            window.center();
        }

    }
820079
def execute(cur, sql):
    
    command, verbose, arg = parse_special_command(sql)

    if (command not in COMMANDS) and (command.lower() not in COMMANDS):
        raise CommandNotFound

    try:
        special_cmd = COMMANDS[command]
    except KeyError:
        special_cmd = COMMANDS[command.lower()]
        if special_cmd.case_sensitive:
            raise CommandNotFound('Command not found: %s' % command)

    # "help <SQL KEYWORD> is a special case.
    if command == 'help' and arg:
        return show_keyword_help(cur=cur, arg=arg)

    if special_cmd.arg_type == NO_QUERY:
        return special_cmd.handler()
    elif special_cmd.arg_type == PARSED_QUERY:
        return special_cmd.handler(cur=cur, arg=arg, verbose=verbose)
    elif special_cmd.arg_type == RAW_QUERY:
        return special_cmd.handler(cur=cur, query=sql)
882928
private void executeQuery(
      long index,
      long sequence,
      long timestamp,
      RaftSession session,
      PrimitiveOperation operation,
      CompletableFuture<OperationResult> future) {
    // If the service has been deleted then throw an unknown service exception.
    if (deleted) {
      log.warn("Service {} has been deleted by another process", serviceName);
      future.completeExceptionally(new RaftException.UnknownService("Service " + serviceName + " has been deleted"));
      return;
    }

    // If the session is not open, fail the request.
    if (!session.getState().active()) {
      log.warn("Inactive session: " + session.sessionId());
      future.completeExceptionally(new RaftException.UnknownSession("Unknown session: " + session.sessionId()));
      return;
    }

    // Otherwise, sequence the query.
    sequenceQuery(index, sequence, timestamp, session, operation, future);
  }
987762
def script(self, sql_script, split_algo='sql_split', prep_statements=True, dump_fails=True):
        """"""
        return Execute(sql_script, split_algo, prep_statements, dump_fails, self)
1097605
@Override
    public void runDDL(String ddl) {
        String modifiedDdl = transformDDL(ddl);
        printTransformedSql(ddl, modifiedDdl);
        super.runDDL(modifiedDdl, false);
    }
1276607
def run(self, statement):
        '''
        '''
        # Remove spaces and EOL
        statement = statement.strip()
        if not statement:  # Empty string
            yield (None, None, None, None)

        # Split the sql into separate queries and run each one.
        components = sqlparse.split(statement)

        for sql in components:
            # Remove spaces, eol and semi-colons.
            sql = sql.rstrip(';')

            # \G is treated specially since we have to set the expanded output.
            if sql.endswith('\\G'):
                special.set_expanded_output(True)
                sql = sql[:-2].strip()

            cur = self.conn.cursor()

            try:
                for result in special.execute(cur, sql):
                    yield result
            except special.CommandNotFound:  # Regular SQL
                cur.execute(sql)
                yield self.get_result(cur)
932012
def execute(self, conn, migration_url="", migration_input="", create_by="", migration_request_id="", transaction=False):
        
        binds = {}
	result = self.dbi.processData(self.sql, binds, conn, transaction)
        result = self.formatDict(result)
	if len(result) == 0 :
	    return []
	if result[0]["migration_request_id"] in ('', None) :
	    return []
        return result
254272
private function execute()
    {
        // Let the generator do his work now,
        if ($this->queryType !== self::QUERY_INSERT && $this->queryType !== self::QUERY_UPDATE && $this->queryType !== self::QUERY_DELETE) {
            throw new QueryException("Can only do apply() on INSERT and UPDATE mode!", 0, $this->exception); // @codeCoverageIgnore
        }

        // Validate all variables
        if ($this->queryType === self::QUERY_INSERT) {
            // We should have the table, all required data.
            if (count($this->changeData) === 0 || empty($this->table)) {
                throw new QueryException("When inserting you should at least give a table and the inserting data!", 0, $this->exception); // @codeCoverageIgnore
            }
        }
        if ($this->queryType === self::QUERY_UPDATE) {
            // We should have a where with at least one condition, data, and a table
            if (count($this->whereConditions) === 0 || count($this->changeData) === 0 || empty($this->table)) {
                throw new QueryException("When updating you should at least give a table, at least one where condition and the updating data!", 0, $this->exception); // @codeCoverageIgnore
            }
        }
        if ($this->queryType === self::QUERY_DELETE) {
            // We should have a where and table
            if (count($this->whereConditions) === 0 || empty($this->table)) {
                throw new QueryException("When deleting you should at least give a table and at least one where condition!", 0, $this->exception); // @codeCoverageIgnore
            }
        }

        $this->bindValues = array();
        $this->bindTypes = array();

        // Generate parts
        if ($this->queryType === self::QUERY_INSERT) {
            $this->generator->generateInsert($this->columnOrder, $this->changeData, $this->start, $this->data, $this->bindValues, $this->bindTypes);
        }

        if ($this->queryType === self::QUERY_UPDATE) {
            $this->generator->generateJoin($this->joinTables, $this->join);
            $this->generator->generateUpdate($this->changeData, $this->data, $this->bindValues, $this->bindTypes);
            $this->generator->generateWhere($this->whereConditions, $this->where, $this->bindValues, $this->bindTypes);
        }

        if ($this->queryType === self::QUERY_DELETE) {
            $this->generator->generateJoin($this->joinTables, $this->join);
            $this->generator->generateWhere($this->whereConditions, $this->where, $this->bindValues, $this->bindTypes);
        }

        $this->query = "";
        $this->combineQuery();

        // Verify if bind has same number as the number of question marks in the query
        // TODO: Implement this when stable
        //$this->verifyQuery();

        $connection = ConnectionManager::getConnection();
        $query = $connection->prepare($this->query);

        // Bind all values
        $idx = 1;
        foreach ($this->bindValues as $key => $value) {
            $query->bindValue($idx, $value, $this->bindTypes[$key]);
            $idx++;
        }

        // Execute
        $status = $query->execute();

        if ($status && $this->queryType === self::QUERY_INSERT) {
            return $connection->lastInsertId();
        }
        return $status;
    }
471048
def _processDML(self, dataset_name, cols, reader):
        """"""
        sql_template = self._generateInsertStatement(dataset_name, cols)

        # Now insert in batch, reader is a list of rows to insert at this point
        c = self.conn.cursor()
        c.executemany(sql_template, reader)
        self.conn.commit()
946613
def _execute_sql_query(
            self):
        
        self.log.info('starting the ``_execute_sql_query`` method')

        # generate the api call url
        params = urllib.urlencode({'cmd': self.sqlQuery, 'format': "json"})
        # grab the results
        results = urllib.urlopen(self.sdssUrl + '?%s' % params)

        # report any errors
        ofp = sys.stdout
        results = results.read()
        if results.startswith("ERROR"):  # SQL Statement Error -> stderr
            ofp = sys.stderr
            ofp.write(string.rstrip(line) + os.linesep)

        # clean up the json response so it can be parsed
        results = results.replace(
            ": ,", ': "NULL",')
        regex = re.compile(r'"photoz_err"\:\s*(\n\s*})')
        newString = regex.sub('"photoz_err": "NULL"\g<1>', results)
        results = newString

        # parse the json results
        results = json.loads(results)[0]
        self.results = results["Rows"]

        self.log.info('completed the ``_execute_sql_query`` method')
        return
264704
public final void execute()
  {
    _log.debug( _sqlString );

    PreparedStatement lPreparedStatement = null;

    try
    {
      lPreparedStatement = _callableStatementProvider.createPreparedStatement( _sqlString );

      usePreparedStatement( lPreparedStatement );
    }
    catch( SQLException e )
    {
      if( !handleSQLException( e ) )
      {
        throw ExceptionManager.createException( e, _sqlString );
      }
    }
    finally
    {
      if( lPreparedStatement != null )
      {
        try
        {
          lPreparedStatement.close();
        }
        catch( SQLException eSQLException )
        {
          throw ExceptionManager.createException( eSQLException, _sqlString );
        }
      }
    }
  }
1043651
async def executemany(self, sql: str, parameters: Iterable[Iterable[Any]]) -> None:
        """"""
        await self._execute(self._cursor.executemany, sql, parameters)
455052
function executeBatches(bulkOperation, options, callback) {
  let numberOfCommandsToExecute = bulkOperation.s.batches.length;
  // Execute over all the batches
  for (let i = 0; i < bulkOperation.s.batches.length; i++) {
    executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
      // Count down the number of commands left to execute
      numberOfCommandsToExecute = numberOfCommandsToExecute - 1;

      // Execute
      if (numberOfCommandsToExecute === 0) {
        // Driver level error
        if (err) return handleCallback(callback, err);

        const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
        if (bulkOperation.handleWriteError(callback, writeResult)) return;

        return handleCallback(callback, null, writeResult);
      }
    });
  }
}
692270
def execute(self, sql):
        """"""
        cursor = self.connection.cursor()
        try:
            cursor.execute(sql)
        finally:
            cursor.close()
1049963
private void executeQuery(Subscriber<? super T> subscriber, State state) throws SQLException {
        if (!subscriber.isUnsubscribed()) {
            try {
                log.debug("executing sql={}, parameters {}", query.sql(), parameters);
                state.rs = query.resultSetTransform()
                        .call(query.context().resultSetTransform().call(state.ps.executeQuery()));
                log.debug("executed ps={}", state.ps);
            } catch (SQLException e) {
                throw new SQLException("failed to run sql=" + query.sql(), e);
            }
        }
    }
1269659
function Batch(db, options) {
  this.options = options || {};
  this.ops = [];
  this.db = db;
  this.written = false;
}