* dumpDatabase: * dump the database definition */
| 3292 | * dump the database definition |
| 3293 | */ |
| 3294 | static void |
| 3295 | dumpDatabase(Archive *fout) |
| 3296 | { |
| 3297 | DumpOptions *dopt = fout->dopt; |
| 3298 | PQExpBuffer dbQry = createPQExpBuffer(); |
| 3299 | PQExpBuffer delQry = createPQExpBuffer(); |
| 3300 | PQExpBuffer creaQry = createPQExpBuffer(); |
| 3301 | PQExpBuffer labelq = createPQExpBuffer(); |
| 3302 | PGconn *conn = GetConnection(fout); |
| 3303 | PGresult *res; |
| 3304 | int i_tableoid, |
| 3305 | i_oid, |
| 3306 | i_datname, |
| 3307 | i_dba, |
| 3308 | i_encoding, |
| 3309 | i_collate, |
| 3310 | i_ctype, |
| 3311 | i_frozenxid, |
| 3312 | i_minmxid, |
| 3313 | i_datacl, |
| 3314 | i_rdatacl, |
| 3315 | i_datistemplate, |
| 3316 | i_datconnlimit, |
| 3317 | i_tablespace; |
| 3318 | CatalogId dbCatId; |
| 3319 | DumpId dbDumpId; |
| 3320 | const char *datname, |
| 3321 | *dba, |
| 3322 | *encoding, |
| 3323 | *collate, |
| 3324 | *ctype, |
| 3325 | *datacl, |
| 3326 | *rdatacl, |
| 3327 | *datistemplate, |
| 3328 | *datconnlimit, |
| 3329 | *tablespace; |
| 3330 | uint32 frozenxid, |
| 3331 | minmxid; |
| 3332 | char *qdatname; |
| 3333 | |
| 3334 | pg_log_info("saving database definition"); |
| 3335 | |
| 3336 | /* |
| 3337 | * Fetch the database-level properties for this database. |
| 3338 | * |
| 3339 | * The order in which privileges are in the ACL string (the order they |
| 3340 | * have been GRANT'd in, which the backend maintains) must be preserved to |
| 3341 | * ensure that GRANTs WITH GRANT OPTION and subsequent GRANTs based on |
| 3342 | * those are dumped in the correct order. Note that initial privileges |
| 3343 | * (pg_init_privs) are not supported on databases, so this logic cannot |
| 3344 | * make use of buildACLQueries(). |
| 3345 | */ |
| 3346 | if (fout->remoteVersion >= 90600) |
| 3347 | { |
| 3348 | appendPQExpBuffer(dbQry, "SELECT tableoid, oid, datname, " |
| 3349 | "(%s datdba) AS dba, " |
| 3350 | "pg_encoding_to_char(encoding) AS encoding, " |
| 3351 | "datcollate, datctype, datfrozenxid, datminmxid, " |
no test coverage detected