Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7ff7711

Browse files
committed
For create/dropdb, only connect once to the server since we now have a
shared description table for pg_database comments.Also update comments about database name selection.
1 parent87631ac commit7ff7711

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

‎src/bin/scripts/createdb.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ main(int argc, char *argv[])
192192

193193
appendPQExpBuffer(&sql,";\n");
194194

195+
/*
196+
* Connect to the 'postgres' database by default, except have
197+
* the 'postgres' user use 'template1' so he can create the
198+
* 'postgres' database.
199+
*/
195200
conn=connectDatabase(strcmp(dbname,"postgres")==0 ?"template1" :"postgres",
196201
host,port,username,prompt_password,progname);
197202

@@ -208,12 +213,9 @@ main(int argc, char *argv[])
208213
}
209214

210215
PQclear(result);
211-
PQfinish(conn);
212216

213217
if (comment)
214218
{
215-
conn=connectDatabase(dbname,host,port,username,prompt_password,progname);
216-
217219
printfPQExpBuffer(&sql,"COMMENT ON DATABASE %s IS ",fmtId(dbname));
218220
appendStringLiteralConn(&sql,comment,conn);
219221
appendPQExpBuffer(&sql,";\n");
@@ -231,9 +233,10 @@ main(int argc, char *argv[])
231233
}
232234

233235
PQclear(result);
234-
PQfinish(conn);
235236
}
236237

238+
PQfinish(conn);
239+
237240
exit(0);
238241
}
239242

‎src/bin/scripts/dropdb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ main(int argc, char *argv[])
113113
appendPQExpBuffer(&sql,"DROP DATABASE %s;\n",
114114
fmtId(dbname));
115115

116+
/*
117+
* Connect to the 'postgres' database by default, except have
118+
* the 'postgres' user use 'template1' so he can drop the
119+
* 'postgres' database.
120+
*/
116121
conn=connectDatabase(strcmp(dbname,"postgres")==0 ?"template1" :"postgres",
117122
host,port,username,prompt_password,progname);
118123

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp