提交 9bd64be0 authored 作者: Thomas Mueller's avatar Thomas Mueller

When creating a database from a recovery script, the same user can now be used…

When creating a database from a recovery script, the same user can now be used (CREATE USER now always includes IF EXISTS).
上级 383bad13
......@@ -80,7 +80,7 @@ public class User extends RightOwner {
}
public String getCreateSQL() {
return getCreateSQL(true, false);
return getCreateSQL(true);
}
public String getDropSQL() {
......@@ -149,14 +149,10 @@ public class User extends RightOwner {
*
* @param password true if the password (actually the salt and hash) should
* be returned
* @param ifNotExists true if IF NOT EXISTS should be used
* @return the SQL statement
*/
public String getCreateSQL(boolean password, boolean ifNotExists) {
StringBuilder buff = new StringBuilder("CREATE USER ");
if (ifNotExists) {
buff.append("IF NOT EXISTS ");
}
public String getCreateSQL(boolean password) {
StringBuilder buff = new StringBuilder("CREATE USER IF NOT EXISTS ");
buff.append(getSQL());
if (comment != null) {
buff.append(" COMMENT ").append(StringUtils.quoteStringSQL(comment));
......
......@@ -1021,6 +1021,9 @@ public class Recover extends Tool implements DataHandler {
int saltIndex = Utils.indexOf(s.getBytes(), "SALT ".getBytes(), off);
if (saltIndex >= 0) {
String userName = sql.substring("CREATE USER ".length(), sql.indexOf("SALT ") - 1);
if (userName.startsWith("IF NOT EXISTS ")) {
userName = userName.substring("IF NOT EXISTS ".length());
}
if (userName.startsWith("\"")) {
// TODO doesn't work for all cases ("" inside user name)
userName = userName.substring(1, userName.length() - 1);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论