private ScriptCommand parseScript() { ScriptCommand command = new ScriptCommand(session); boolean data = true, passwords = true, settings = true; boolean dropTables = false, simple = false; command.setLobBlockSize(blockSize); command.setData(data); command.setPasswords(passwords); command.setSettings(settings); command.setDrop(dropTables); command.setSimple(simple); if (readIf("TO")) { command.setFileNameExpr(readExpression()); if (readIf("COMPRESSION")) { command.setCompressionAlgorithm(readUniqueIdentifier()); command.setCipher(readUniqueIdentifier()); if (readIf("PASSWORD")) { command.setPassword(readExpression()); command.setCharset(Charset.forName(readString())); schemaNames.add(readUniqueIdentifier()); } while (readIf(",")); command.setSchemaNames(schemaNames); } else if (readIf("TABLE")) { ArrayList<Table> tables = New.arrayList(); tables.add(readTableOrView());
@Override public ResultInterface query(int maxrows) { session.getUser().checkAdmin(); reset(); Database db = session.getDatabase(); if (schemaNames != null) { result = createResult(); deleteStore(); openOutput(); if (out != null) { buffer = new byte[Constants.IO_BUFFER_SIZE]; add(setting.getCreateSQL(), false); add("", true); add(user.getCreateSQL(passwords), false); add(role.getCreateSQL(true), false); if (excludeSchema(schema)) { continue; add(schema.getCreateSQL(), false); add(datatype.getDropSQL(), false); add(datatype.getCreateSQL(), false);
return null; final ResultSet rs = getLobStream(conn, "BDATA", id); return new InputStream() { private InputStream current;
private ScriptCommand parseScript() throws SQLException { ScriptCommand command = new ScriptCommand(session); boolean data = true, passwords = true, settings = true, dropTables = false, simple = false; if (readIf("SIMPLE")) { command.setLobBlockSize(blockSize); command.setData(data); command.setPasswords(passwords); command.setSettings(settings); command.setDrop(dropTables); command.setSimple(simple); if (readIf("TO")) { command.setFile(readExpression()); if (readIf("COMPRESSION")) { command.setCompressionAlgorithm(readUniqueIdentifier()); command.setCipher(readUniqueIdentifier()); if (readIf("PASSWORD")) { command.setPassword(readString().toCharArray());
public LocalResult query(int maxrows) throws SQLException { session.getUser().checkAdmin(); reset(); try { result = createResult(); deleteStore(); openOutput(); if (out != null) { buffer = new byte[Constants.IO_BUFFER_SIZE]; add(setting.getCreateSQL(), false); add("", true); add(user.getCreateSQL(passwords, true), false); add(role.getCreateSQL(), false); add(schema.getCreateSQL(), false); UserDataType datatype = (UserDataType) datatypes.get(i); if (drop) { add(datatype.getDropSQL(), false); add(datatype.getCreateSQL(), false); add(constant.getCreateSQL(), false); FunctionAlias alias = (FunctionAlias) functionAliases.get(i); if (drop) {
int id; if (v.getType() == Value.CLOB) { id = writeLobStream(v); buff.append("SYSTEM_COMBINE_CLOB(").append(id).append(')'); } else if (v.getType() == Value.BLOB) { id = writeLobStream(v); buff.append("SYSTEM_COMBINE_BLOB(").append(id).append(')'); } else { count++; if ((count & 127) == 0) { checkCanceled(); add(buff.toString(), true); buff = null; add(buff.toString(), true);
/** * Combine a CLOB. * This method is called from the script. * * @param conn a connection * @param id the lob id * @return a reader for the combined data */ public static Reader combineClob(Connection conn, int id) throws SQLException, IOException { ResultSet rs = getLobStream(conn, "CDATA", id); Writer out = FileUtils.openFileWriter(TEMP_LOB_FILENAME, false); while (rs.next()) { Reader in = new BufferedReader(rs.getCharacterStream(1)); IOUtils.copyAndCloseInput(in, out); } out.close(); deleteLobStream(conn, id); return IOUtils.getReader(openAutoCloseInput()); }
@Override public ResultInterface queryMeta() { LocalResult r = createResult(); r.done(); return r; }
private int writeLobStream(Value v) throws IOException { if (!tempLobTableCreated) { add("CREATE TABLE IF NOT EXISTS SYSTEM_LOB_STREAM" + "(ID INT NOT NULL, PART INT NOT NULL, " + "CDATA VARCHAR, BDATA BINARY)", true); add("CREATE PRIMARY KEY SYSTEM_LOB_STREAM_PRIMARY_KEY " + "ON SYSTEM_LOB_STREAM(ID, PART)", true); add("CREATE ALIAS IF NOT EXISTS " + "SYSTEM_COMBINE_CLOB FOR \"" + this.getClass().getName() + ".combineClob\"", true); add("CREATE ALIAS IF NOT EXISTS " + "SYSTEM_COMBINE_BLOB FOR \"" + this.getClass().getName() + ".combineBlob\"", true); tempLobTableCreated = true; add(sql, true); append(", NULL)"); String sql = buff.toString(); add(sql, true);
int id; if (v.getType() == Value.CLOB) { id = writeLobStream(v); buff.append("SYSTEM_COMBINE_CLOB(" + id + ")"); } else if (v.getType() == Value.BLOB) { id = writeLobStream(v); buff.append("SYSTEM_COMBINE_BLOB(" + id + ")"); } else { count++; if ((count & 127) == 0) { checkCanceled(); add(buff.toString(), true); buff = null; add(buff.toString(), true);
/** * Combine a BLOB. * This method is called from the script. * When calling with id -1, the file is deleted. * * @param conn a connection * @param id the lob id * @return a stream for the combined data */ public static InputStream combineBlob(Connection conn, int id) throws SQLException, IOException { if (id < 0) { FileUtils.delete(TEMP_LOB_FILENAME); return null; } ResultSet rs = getLobStream(conn, "BDATA", id); OutputStream out = FileUtils.openFileOutputStream(TEMP_LOB_FILENAME, false); while (rs.next()) { InputStream in = rs.getBinaryStream(1); IOUtils.copyAndCloseInput(in, out); } out.close(); deleteLobStream(conn, id); return openAutoCloseInput(); }
@Override public ResultInterface queryMeta() { LocalResult r = createResult(); r.done(); return r; }
private int writeLobStream(Value v) throws IOException { if (!tempLobTableCreated) { add("CREATE TABLE IF NOT EXISTS SYSTEM_LOB_STREAM" + "(ID INT NOT NULL, PART INT NOT NULL, " + "CDATA VARCHAR, BDATA BINARY)", true); add("CREATE PRIMARY KEY SYSTEM_LOB_STREAM_PRIMARY_KEY " + "ON SYSTEM_LOB_STREAM(ID, PART)", true); add("CREATE ALIAS IF NOT EXISTS " + "SYSTEM_COMBINE_CLOB FOR \"" + this.getClass().getName() + ".combineClob\"", true); add("CREATE ALIAS IF NOT EXISTS " + "SYSTEM_COMBINE_BLOB FOR \"" + this.getClass().getName() + ".combineBlob\"", true); tempLobTableCreated = true; add(sql, true); append(", NULL)"); String sql = buff.toString(); add(sql, true);
private ScriptCommand parseScript() { ScriptCommand command = new ScriptCommand(session); boolean data = true, passwords = true, settings = true; boolean dropTables = false, simple = false; command.setLobBlockSize(blockSize); command.setData(data); command.setPasswords(passwords); command.setSettings(settings); command.setDrop(dropTables); command.setSimple(simple); if (readIf("TO")) { command.setFileNameExpr(readExpression()); if (readIf("COMPRESSION")) { command.setCompressionAlgorithm(readUniqueIdentifier()); command.setCipher(readUniqueIdentifier()); if (readIf("PASSWORD")) { command.setPassword(readExpression()); command.setCharset(Charset.forName(readString())); schemaNames.add(readUniqueIdentifier()); } while (readIf(",")); command.setSchemaNames(schemaNames); } else if (readIf("TABLE")) { ArrayList<Table> tables = New.arrayList(); tables.add(readTableOrView());
@Override public ResultInterface query(int maxrows) { session.getUser().checkAdmin(); reset(); Database db = session.getDatabase(); if (schemaNames != null) { result = createResult(); deleteStore(); openOutput(); if (out != null) { buffer = new byte[Constants.IO_BUFFER_SIZE]; add(setting.getCreateSQL(), false); add("", true); add(user.getCreateSQL(passwords), false); add(role.getCreateSQL(true), false); if (excludeSchema(schema)) { continue; add(schema.getCreateSQL(), false); add(datatype.getDropSQL(), false); add(datatype.getCreateSQL(), false);
int id; if (v.getType() == Value.CLOB) { id = writeLobStream(v); buff.append("SYSTEM_COMBINE_CLOB(" + id + ")"); } else if (v.getType() == Value.BLOB) { id = writeLobStream(v); buff.append("SYSTEM_COMBINE_BLOB(" + id + ")"); } else { count++; if ((count & 127) == 0) { checkCanceled(); add(buff.toString(), true); buff = null; add(buff.toString(), true);
return null; final ResultSet rs = getLobStream(conn, "CDATA", id); return new Reader() { private Reader current;
public LocalResult queryMeta() throws SQLException { LocalResult result = createResult(); result.done(); return result; }
private int writeLobStream(Value v) throws IOException { if (!tempLobTableCreated) { add("CREATE TABLE IF NOT EXISTS SYSTEM_LOB_STREAM" + "(ID INT NOT NULL, PART INT NOT NULL, " + "CDATA VARCHAR, BDATA BINARY)", true); add("CREATE PRIMARY KEY SYSTEM_LOB_STREAM_PRIMARY_KEY " + "ON SYSTEM_LOB_STREAM(ID, PART)", true); add("CREATE ALIAS IF NOT EXISTS " + "SYSTEM_COMBINE_CLOB FOR \"" + this.getClass().getName() + ".combineClob\"", true); add("CREATE ALIAS IF NOT EXISTS " + "SYSTEM_COMBINE_BLOB FOR \"" + this.getClass().getName() + ".combineBlob\"", true); tempLobTableCreated = true; add(sql, true); append(", NULL)"); String sql = buff.toString(); add(sql, true);
private ScriptCommand parseScript() { ScriptCommand command = new ScriptCommand(session); boolean data = true, passwords = true, settings = true; boolean dropTables = false, simple = false; command.setLobBlockSize(blockSize); command.setData(data); command.setPasswords(passwords); command.setSettings(settings); command.setDrop(dropTables); command.setSimple(simple); if (readIf("TO")) { command.setFileNameExpr(readExpression()); if (readIf("COMPRESSION")) { command.setCompressionAlgorithm(readUniqueIdentifier()); command.setCipher(readUniqueIdentifier()); if (readIf("PASSWORD")) { command.setPassword(readExpression()); command.setCharset(Charset.forName(readString())); schemaNames.add(readUniqueIdentifier()); } while (readIf(",")); command.setSchemaNames(schemaNames); } else if (readIf("TABLE")) { ArrayList<Table> tables = New.arrayList(); tables.add(readTableOrView());