private OptionalTable getOptionalTable(String tableName, int keyType, int valueType,
			boolean testExistence) throws SQLException {
		if (optionaltables != null) {		// Search for existing table
			for (OptionalTable table : optionaltables) {
				if (table.getName().equals(tableName)) {
					if (keyType != table.getKeyType() || valueType != table.getValueType()) {
						throw new SQLException("Optional table: column type mismatch");
					}
					return table;
				}
			}
		}
		// If we reach here, table object doesn't exist, so we create it
		OptionalTable table = new OptionalTable(tableName, keyType, valueType, db);
		if (testExistence) {			// If the user requested
			if (!table.exists()) {		//    test for the existence of the table
				table.close();
				return null;			// If it doesn't exist, don't save new table object, return null
			}
		}
		// Insert the new table object at the end of the list
		OptionalTable[] newArray;
		if (optionaltables != null) {
			newArray = Arrays.copyOf(optionaltables, optionaltables.length + 1);
			newArray[optionaltables.length] = table;
		}
		else {
			newArray = new OptionalTable[1];
			newArray[0] = table;
		}
		optionaltables = newArray;
		return table;
	}
Establish an optional key/value table with this connection.
The OptionalTable object is created and added to the list for this connection.
If the caller desires, the table is tested for existence. If it doesn't
exist, the object is not added to the list and null is returned.
@param tableName is the name of the SQL table
@param keyType is the type-code of the key column
@param valueType is the type-code of the value column
@param testExistence if true, we test the existence of the table
@return the OptionalTable or null
@throws SQLException for problems with the connection, or if
    the table exists with different column types
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java