/** * Drops Serde-s. Should be called with the list short enough to not trip up Oracle/etc. * @param serdeIdList The serde identifiers to drop * @throws MetaException If there is an SQL exception during the execution it converted to * MetaException */ private void dropSerdes(List<Object> serdeIdList) throws MetaException { String queryText; if (serdeIdList.isEmpty()) { return; } String serdeIds = getIdListForIn(serdeIdList); try { // Drop the serde params queryText = "delete from " + SERDE_PARAMS + " where \"SERDE_ID\" in (" + serdeIds + ")"; executeNoResult(queryText); Deadline.checkTimeout(); // Drop the serdes queryText = "delete from " + SERDES + " where \"SERDE_ID\" in (" + serdeIds + ")"; executeNoResult(queryText); } catch (SQLException sqlException) { LOG.warn("SQL error executing query while dropping serde.", sqlException); throw new MetaException("Encountered error while dropping serde."); } }
/** * This run the necessary logic to prepare for queries. It should be called once, after the * txn on DataNucleus connection is opened, and before any queries are issued. What it does * currently is run db-specific logic, e.g. setting ansi quotes mode for MySQL. The reason it * must be used inside of the txn is connection pooling; there's no way to guarantee that the * effect will apply to the connection that is executing the queries otherwise. */ public void prepareTxn() throws MetaException { if (dbType != DatabaseProduct.MYSQL) return; try { assert pm.currentTransaction().isActive(); // must be inside tx together with queries executeNoResult("SET @@session.sql_mode=ANSI_QUOTES"); } catch (SQLException sqlEx) { throw new MetaException("Error setting ansi quotes: " + sqlEx.getMessage()); } }
executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); } catch (SQLException sqlException) { LOG.warn("SQL error executing query while dropping storage descriptor.", sqlException);
executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); } catch (SQLException sqlException) { LOG.warn("SQL error executing query while dropping dangling col descriptions", sqlException);
executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); executeNoResult(queryText); Deadline.checkTimeout(); } catch (SQLException sqlException) {
/** * This function is intended to be called by functions before they put together a query * Thus, any query-specific instantiation to be done from within the transaction is done * here - for eg., for MySQL, we signal that we want to use ANSI SQL quoting behaviour */ private void doDbSpecificInitializationsBeforeQuery() throws MetaException { if (dbType != DB.MYSQL) return; try { assert pm.currentTransaction().isActive(); // must be inside tx together with queries executeNoResult("SET @@session.sql_mode=ANSI_QUOTES"); } catch (SQLException sqlEx) { throw new MetaException("Error setting ansi quotes: " + sqlEx.getMessage()); } }
/** * This function is intended to be called by functions before they put together a query * Thus, any query-specific instantiation to be done from within the transaction is done * here - for eg., for MySQL, we signal that we want to use ANSI SQL quoting behaviour */ private void doDbSpecificInitializationsBeforeQuery() throws MetaException { if (dbType != DB.MYSQL) return; try { assert pm.currentTransaction().isActive(); // must be inside tx together with queries executeNoResult("SET @@session.sql_mode=ANSI_QUOTES"); } catch (SQLException sqlEx) { throw new MetaException("Error setting ansi quotes: " + sqlEx.getMessage()); } }
private boolean runDbCheck(String queryText, String name) { Transaction tx = pm.currentTransaction(); if (!tx.isActive()) { tx.begin(); } try { executeNoResult(queryText); return true; } catch (Throwable t) { LOG.debug(name + " check failed, assuming we are not on " + name + ": " + t.getMessage()); tx.rollback(); tx = pm.currentTransaction(); tx.begin(); return false; } }
private boolean runDbCheck(String queryText, String name) { Transaction tx = pm.currentTransaction(); if (!tx.isActive()) { tx.begin(); } try { executeNoResult(queryText); return true; } catch (Throwable t) { LOG.debug(name + " check failed, assuming we are not on " + name + ": " + t.getMessage()); tx.rollback(); tx = pm.currentTransaction(); tx.begin(); return false; } }