Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5402590f authored by Vasu Nori's avatar Vasu Nori
Browse files

change return type from void to int on execSQL() methods

1. let execSQL() methods return the number of rows affected by the SQL
staement executed.
2. remove synchronized on 2 public methods. since public API is not
supposed to have synchronized, this was a mistake in previously submitted
CL

Change-Id: Ic610a0c38e7bd7c77006a08c7b82fa01957739e5
parent b729dcc8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -65351,7 +65351,7 @@
>
</method>
<method name="execSQL"
 return="void"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
@@ -65366,7 +65366,7 @@
</exception>
</method>
<method name="execSQL"
 return="void"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
@@ -65918,7 +65918,7 @@
 return="void"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
@@ -65957,7 +65957,7 @@
 return="void"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
+34 −23
Original line number Diff line number Diff line
@@ -1825,16 +1825,18 @@ public class SQLiteDatabase extends SQLiteClosable {
     *
     * @param sql the SQL statement to be executed. Multiple statements separated by semicolons are
     * not supported.
     * @return the number of rows affected by this SQL statement execution, if this SQL statement
     * caused data updates/deletes/inserts.
     * @throws SQLException If the SQL string is invalid for some reason
     */
    public void execSQL(String sql) throws SQLException {
    public int execSQL(String sql) throws SQLException {
        int stmtType = DatabaseUtils.getSqlStatementType(sql);
        if (stmtType == DatabaseUtils.STATEMENT_ATTACH) {
            disableWriteAheadLogging();
        }
        long timeStart = SystemClock.uptimeMillis();
        logTimeStat(mLastSqlStatement, timeStart, GET_LOCK_LOG_PREFIX);
        executeSql(sql, null);
        int n = executeSql(sql, null);

        // Log commit statements along with the most recently executed
        // SQL statement for disambiguation.
@@ -1843,6 +1845,7 @@ public class SQLiteDatabase extends SQLiteClosable {
        } else {
            logTimeStat(sql, timeStart, null);
        }
        return n;
    }

    /**
@@ -1886,20 +1889,23 @@ public class SQLiteDatabase extends SQLiteClosable {
     * @param sql the SQL statement to be executed. Multiple statements separated by semicolons are
     * not supported.
     * @param bindArgs only byte[], String, Long and Double are supported in bindArgs.
     * @return the number of rows affected by this SQL statement execution, if this SQL statement
     * caused data updates/deletes/inserts.
     * @throws SQLException If the SQL string is invalid for some reason
     */
    public void execSQL(String sql, Object[] bindArgs) throws SQLException {
    public int execSQL(String sql, Object[] bindArgs) throws SQLException {
        if (bindArgs == null) {
            throw new IllegalArgumentException("Empty bindArgs");
        }
        executeSql(sql, bindArgs);
        return executeSql(sql, bindArgs);
    }

    private void executeSql(String sql, Object[] bindArgs) throws SQLException {
    private int executeSql(String sql, Object[] bindArgs) throws SQLException {
        long timeStart = SystemClock.uptimeMillis();
        int n;
        SQLiteStatement statement = new SQLiteStatement(this, sql, bindArgs);
        try {
            statement.executeUpdateDelete();
            n = statement.executeUpdateDelete();
        } catch (SQLiteDatabaseCorruptException e) {
            onCorruption();
            throw e;
@@ -1907,6 +1913,7 @@ public class SQLiteDatabase extends SQLiteClosable {
            statement.close();
        }
        logTimeStat(sql, timeStart);
        return n;
    }

    @Override
@@ -2183,7 +2190,8 @@ public class SQLiteDatabase extends SQLiteClosable {
     * @throws IllegalStateException if input cacheSize > {@link #MAX_SQL_CACHE_SIZE} or
     * the value set with previous setMaxSqlCacheSize() call.
     */
    public synchronized void setMaxSqlCacheSize(int cacheSize) {
    public void setMaxSqlCacheSize(int cacheSize) {
        synchronized(this) {
            if (cacheSize > MAX_SQL_CACHE_SIZE || cacheSize < 0) {
                throw new IllegalStateException("expected value between 0 and " + MAX_SQL_CACHE_SIZE);
            } else if (cacheSize < mMaxSqlCacheSize) {
@@ -2192,6 +2200,7 @@ public class SQLiteDatabase extends SQLiteClosable {
            }
            mMaxSqlCacheSize = cacheSize;
        }
    }

    /* package */ boolean isSqlInStatementCache(String sql) {
        synchronized (mCompiledQueries) {
@@ -2352,7 +2361,8 @@ public class SQLiteDatabase extends SQLiteClosable {
     *
     * @param size the value the connection handle pool size should be set to.
     */
    public synchronized void setConnectionPoolSize(int size) {
    public void setConnectionPoolSize(int size) {
        synchronized(this) {
            if (mConnectionPool == null) {
                throw new IllegalStateException("connection pool not enabled");
            }
@@ -2364,6 +2374,7 @@ public class SQLiteDatabase extends SQLiteClosable {
            }
            mConnectionPool.setMaxPoolSize(size);
        }
    }

    /* package */ SQLiteDatabase createPoolConnection(short connectionNum) {
        SQLiteDatabase db = openDatabase(mPath, mFactory, mFlags, mErrorHandler, connectionNum);