VoltDB added method to get a non-catalog-dependent
representation of this HSQLDB object.
@param session The current Session object may be needed to resolve
some names.
@return XML, correctly indented, representing this object.
@throws HSQLParseException
341930
VoltXMLElement voltGetRangeVariableXML(Session session)
    throws org.hsqldb_voltpatches.HSQLInterface.HSQLParseException
    {
        Index        index;
        Index        primaryIndex;

        index        = rangeIndex;
        primaryIndex = rangeTable.getPrimaryIndex();

        // get the index for this scan (/filter)
        // note: ignored if scan if full table scan
        if (index == null)
            index = primaryIndex;

        // output open tag
        VoltXMLElement scan = new VoltXMLElement("tablescan");

        if (rangeTable.tableType == TableBase.SYSTEM_SUBQUERY) {
            if (rangeTable instanceof TableDerived) {
                if (tableAlias == null || tableAlias.name == null) {
                    // VoltDB require derived sub select table with user specified alias
                    throw new org.hsqldb_voltpatches.HSQLInterface.HSQLParseException(
                            "SQL Syntax error: Every derived table must have its own alias.");
                }
                scan.attributes.put("table", tableAlias.name.toUpperCase());

                VoltXMLElement subQuery = ((TableDerived) rangeTable).dataExpression.voltGetXML(session);
                scan.children.add(subQuery);
            }
        } else {
            scan.attributes.put("table", rangeTable.getName().name.toUpperCase());
        }

        if (tableAlias != null && !rangeTable.getName().name.equals(tableAlias)) {
            scan.attributes.put("tablealias", tableAlias.name.toUpperCase());
        }

        // note if this is an outer join
        if (isLeftJoin && isRightJoin) {
            scan.attributes.put("jointype", "full");
        } else if (isLeftJoin) {
            scan.attributes.put("jointype", "left");
        } else if (isRightJoin) {
            scan.attributes.put("jointype", "right");
        } else {
            scan.attributes.put("jointype", "inner");
        }

        Expression joinCond = null;
        Expression whereCond = null;
        // if isJoinIndex and indexCondition are set then indexCondition is join condition
        // else if indexCondition is set then it is where condition
        if (isJoinIndex == true) {
            joinCond = indexCondition;
            if (indexEndCondition != null) {
            	joinCond = makeConjunction(joinCond, indexEndCondition);
            }
            // then go to the nonIndexJoinCondition
            if (nonIndexJoinCondition != null) {
            	joinCond = makeConjunction(joinCond, nonIndexJoinCondition);
            }
            // then go to the nonIndexWhereCondition
            whereCond = nonIndexWhereCondition;
        } else {
            joinCond = nonIndexJoinCondition;

            whereCond = indexCondition;
            if (indexEndCondition != null) {
            	whereCond = makeConjunction(whereCond, indexEndCondition);
            }
            // then go to the nonIndexWhereCondition
            if (nonIndexWhereCondition != null) {
            	whereCond = makeConjunction(whereCond, nonIndexWhereCondition);
            }

        }
        if (joinCond != null) {
            joinCond = joinCond.eliminateDuplicates(session);
            VoltXMLElement joinCondEl = new VoltXMLElement("joincond");
            joinCondEl.children.add(joinCond.voltGetXML(session));
            scan.children.add(joinCondEl);
        }

        if (whereCond != null) {
            whereCond = whereCond.eliminateDuplicates(session);
            VoltXMLElement whereCondEl = new VoltXMLElement("wherecond");
            whereCondEl.children.add(whereCond.voltGetXML(session));
            scan.children.add(whereCondEl);
        }

        return scan;
    }
195334
protected Session createSession(Connection connection) throws JMSException {
        if (connection instanceof QueueConnection) {
            return ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        }
        return connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    }
1135984
public static Map<String, String> getNamespaces(final Session session) {
        final NamespaceRegistry registry = getNamespaceRegistry(session);
        final Map<String, String> namespaces = new HashMap<>();

        try {
            stream(registry.getPrefixes()).filter(internalPrefix.negate()).forEach(x -> {
                try {
                    namespaces.put(x, registry.getURI(x));
                } catch (final RepositoryException e) {
                    throw new RepositoryRuntimeException(e);
                }
            });
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
        return namespaces;
    }
928847
public Reference getReference() throws NamingException {

        String    cname = "org.hsqldb_voltpatches.jdbc.JDBCDataSourceFactory";
        Reference ref   = new Reference(getClass().getName(), cname, null);

        ref.add(new StringRefAddr("database", getDatabase()));
        ref.add(new StringRefAddr("user", getUser()));
        ref.add(new StringRefAddr("password", password));

        return ref;
    }
12873
@Override
    public VoltTable runDML(String dml) {
        String modifiedDml = transformDML(dml);
        printTransformedSql(dml, modifiedDml);
        return super.runDML(modifiedDml, false);
    }
1058315
public static SQLXML createSQLXML(final Connection conn) {
		try {
			return conn.createSQLXML();
		} catch (SQLException e) {
			throw new UroborosqlRuntimeException(e);
		}
	}
1262434
public Table getTable(Session session, String name, String schema) {

        Table t = null;

        if (schema == null) {
            t = findSessionTable(session, name, schema);
        }

        if (t == null) {
            schema = session.getSchemaName(schema);
            t      = findUserTable(session, name, schema);
        }

        if (t == null) {
            if (SqlInvariants.INFORMATION_SCHEMA.equals(schema)
                    && database.dbInfo != null) {
                t = database.dbInfo.getSystemTable(session, name);
            }
        }

        if (t == null) {
            throw Error.error(ErrorCode.X_42501, name);
        }

        return t;
    }
127552
public static Session create(SessionStore sessionStore, HttpRequest<?> request) {
        Session session = sessionStore.newSession();
        request.getAttributes().put(HttpSessionFilter.SESSION_ATTRIBUTE, session);
        return session;
    }
490224
public VoltXMLElement getXMLForTable(String tableName) throws HSQLParseException {
        VoltXMLElement xml = emptySchema.duplicate();

        // search all the tables XXX probably could do this non-linearly,
        //  but i don't know about case-insensitivity yet
        HashMappedList hsqlTables = getHSQLTables();
        for (int i = 0; i < hsqlTables.size(); i++) {
            Table table = (Table) hsqlTables.get(i);
            String candidateTableName = table.getName().name;

            // found the table of interest
            if (candidateTableName.equalsIgnoreCase(tableName)) {
                VoltXMLElement vxmle = table.voltGetTableXML(sessionProxy);
                assert(vxmle != null);
                xml.children.add(vxmle);
                return xml;
            }
        }
        return null;
    }
150247
public static <T> AttributeKey<T> sessionScoped() {
        return new AttributeKey<T>() {
            public T get(HttpServletRequest req) {
                HttpSession s = req.getSession(false);
                if (s==null)    return null;
                return (T)s.getAttribute(name);
            }

            public void set(HttpServletRequest req, T value) {
                req.getSession().setAttribute(name, value);
            }

            public void remove(HttpServletRequest req) {
                HttpSession s = req.getSession(false);
                if (s!=null)
                    s.removeAttribute(name);
            }
        };
    }
1208272
@Override
    public ResultSet getSchemas() throws SQLException
    {
        checkClosed();
        VoltTable vtable = new VoltTable(
                new ColumnInfo("TABLE_SCHEM", VoltType.STRING),
                new ColumnInfo("TABLE_CATALOG", VoltType.STRING));
        JDBC4ResultSet res = new JDBC4ResultSet(this.sysCatalog, vtable);
        return res;
    }
849043
private static org.hibernate.engine.spi.EntityKey getOptionalObjectKey(QueryParameters queryParameters, SharedSessionContractImplementor session) {
		final Object optionalObject = queryParameters.getOptionalObject();
		final Serializable optionalId = queryParameters.getOptionalId();
		final String optionalEntityName = queryParameters.getOptionalEntityName();

		if ( optionalObject != null && optionalEntityName != null ) {
			return session.generateEntityKey( optionalId, session.getEntityPersister( optionalEntityName, optionalObject ) );
		}
		else {
			return null;
		}
	}
973282
public <T> List<T>  sql(Class<T> beanType,  String entity) throws ElasticSearchException {
		SQLRestResponse result = this.client.executeRequest("/_xpack/sql",entity,   new SQLRestResponseHandler());
		return ResultUtil.buildSQLResult(result,beanType);
	}
942064
private Map<String, ComponentDto> indexExistingDtosByUuids(DbSession session) {
    return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getDbKey())
      .stream()
      .collect(Collectors.toMap(ComponentDto::uuid, Function.identity()));
  }
759458
public StringBuffer addXML(StringBuffer sbXML)
    {
        if (sbXML == null)
            sbXML = new StringBuffer();
        Util.addStartTag(sbXML, BaseMessage.HEADER_TAG).append(DBConstants.RETURN);
        Map<String,Object> map = this.getProperties();
        Util.addXMLMap(sbXML, map);
        Util.addEndTag(sbXML, BaseMessage.HEADER_TAG).append(DBConstants.RETURN);
        return sbXML;
    }
161517
public static Map<String, Object> createSessionMap(HttpServletRequest request) {
        Map<String, Object> sessionMap = new HashMap<>();
        HttpSession session = request.getSession(false);

        if (session != null) {
            for (Enumeration attributeNameEnum = session.getAttributeNames(); attributeNameEnum.hasMoreElements(); ) {
                String attributeName = (String)attributeNameEnum.nextElement();
                sessionMap.put(attributeName, session.getAttribute(attributeName));
            }
        }

        return sessionMap;
    }
672763
public void addSession(String id, Session session) {
    PoolInfo poolInfo = getPoolInfo(session);
    LOG.info("Session " + id + " added to pool info " +
        poolInfo + " (originally " + session.getInfo().getPoolInfoStrings() +") for " + type);
    getPoolSchedulable(poolInfo).addSession(id, session);
  }