Fix incorrect SQL syntax emitted when -E is given without -P.
authorTom Lane <[email protected]>
Fri, 9 Jan 2004 00:15:19 +0000 (00:15 +0000)
committerTom Lane <[email protected]>
Fri, 9 Jan 2004 00:15:19 +0000 (00:15 +0000)
Report and fix from Martin Pitt.

src/bin/scripts/createuser.c

index c9dd2ac9aff2cc7230e7dc84254812df1d710577..e466f7cc93846b654f65fb83907452a3ab5e2935 100644 (file)
@@ -189,12 +189,12 @@ main(int argc, char *argv[])
        printfPQExpBuffer(&sql, "CREATE USER %s", fmtId(newuser));
        if (sysid)
                appendPQExpBuffer(&sql, " SYSID %s", sysid);
-       if (encrypted == +1)
-               appendPQExpBuffer(&sql, " ENCRYPTED");
-       if (encrypted == -1)
-               appendPQExpBuffer(&sql, " UNENCRYPTED");
        if (newpassword)
        {
+               if (encrypted == +1)
+                       appendPQExpBuffer(&sql, " ENCRYPTED");
+               if (encrypted == -1)
+                       appendPQExpBuffer(&sql, " UNENCRYPTED");
                appendPQExpBuffer(&sql, " PASSWORD ");
                appendStringLiteral(&sql, newpassword, false);
        }