|
12 | 12 | * by PostgreSQL
|
13 | 13 | *
|
14 | 14 | * IDENTIFICATION
|
15 |
| - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.349 2003/09/23 22:48:53 tgl Exp $ |
| 15 | + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.350 2003/09/23 23:31:52 tgl Exp $ |
16 | 16 | *
|
17 | 17 | *-------------------------------------------------------------------------
|
18 | 18 | */
|
@@ -2879,42 +2879,41 @@ dumpNamespaces(Archive *fout, NamespaceInfo *nsinfo, int numNamespaces)
|
2879 | 2879 | /*
|
2880 | 2880 | * If it's the PUBLIC namespace, don't emit a CREATE SCHEMA record
|
2881 | 2881 | * for it, since we expect PUBLIC to exist already in the
|
2882 |
| - * destination database. And emit ACL info only if the ACL isn't |
2883 |
| - * the standard value for PUBLIC. |
| 2882 | + * destination database. But do emit ACL in case it's not standard, |
| 2883 | + * likewise comment. |
| 2884 | + * |
| 2885 | + * Note that ownership is shown in the AUTHORIZATION clause, |
| 2886 | + * while the archive entry is listed with empty owner (causing |
| 2887 | + * it to be emitted with SET SESSION AUTHORIZATION DEFAULT). |
| 2888 | + * This seems the best way of dealing with schemas owned by |
| 2889 | + * users without CREATE SCHEMA privilege. Further hacking has |
| 2890 | + * to be applied for --no-owner mode, though! |
2884 | 2891 | */
|
2885 |
| - if (strcmp(nspinfo->nspname, "public") == 0) |
2886 |
| - { |
2887 |
| - if (!aclsSkip && strcmp(nspinfo->nspacl, "{=UC}") != 0) |
2888 |
| - dumpACL(fout, "SCHEMA", qnspname, nspinfo->nspname, NULL, |
2889 |
| - nspinfo->usename, nspinfo->nspacl, |
2890 |
| - nspinfo->oid); |
2891 |
| - } |
2892 |
| - else |
| 2892 | + if (strcmp(nspinfo->nspname, "public") != 0) |
2893 | 2893 | {
|
2894 | 2894 | resetPQExpBuffer(q);
|
2895 | 2895 | resetPQExpBuffer(delq);
|
2896 | 2896 |
|
2897 | 2897 | appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname);
|
2898 | 2898 |
|
2899 |
| - appendPQExpBuffer(q, "CREATE SCHEMA %s;\n", qnspname); |
| 2899 | + appendPQExpBuffer(q, "CREATE SCHEMA %s AUTHORIZATION %s;\n", |
| 2900 | + qnspname, fmtId(nspinfo->usename)); |
2900 | 2901 |
|
2901 | 2902 | ArchiveEntry(fout, nspinfo->oid, nspinfo->nspname,
|
2902 |
| - NULL, |
2903 |
| - nspinfo->usename, "SCHEMA", NULL, |
| 2903 | + NULL, "", "SCHEMA", NULL, |
2904 | 2904 | q->data, delq->data, NULL, NULL, NULL);
|
| 2905 | + } |
2905 | 2906 |
|
2906 |
| - /* Dump Schema Comments */ |
2907 |
| - resetPQExpBuffer(q); |
2908 |
| - appendPQExpBuffer(q, "SCHEMA %s", qnspname); |
2909 |
| - dumpComment(fout, q->data, |
2910 |
| - NULL, nspinfo->usename, |
2911 |
| - nspinfo->oid, "pg_namespace", 0, NULL); |
| 2907 | + /* Dump Schema Comments */ |
| 2908 | + resetPQExpBuffer(q); |
| 2909 | + appendPQExpBuffer(q, "SCHEMA %s", qnspname); |
| 2910 | + dumpComment(fout, q->data, |
| 2911 | + NULL, nspinfo->usename, |
| 2912 | + nspinfo->oid, "pg_namespace", 0, NULL); |
2912 | 2913 |
|
2913 |
| - if (!aclsSkip) |
2914 |
| - dumpACL(fout, "SCHEMA", qnspname, nspinfo->nspname, NULL, |
2915 |
| - nspinfo->usename, nspinfo->nspacl, |
2916 |
| - nspinfo->oid); |
2917 |
| - } |
| 2914 | + dumpACL(fout, "SCHEMA", qnspname, nspinfo->nspname, NULL, |
| 2915 | + nspinfo->usename, nspinfo->nspacl, |
| 2916 | + nspinfo->oid); |
2918 | 2917 |
|
2919 | 2918 | free(qnspname);
|
2920 | 2919 | }
|
|
0 commit comments