From 1e9b80a2fd14b8d42fd92e43ba2145e2fc124b47 Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Sat, 12 Apr 1997 09:24:23 +0000 Subject: [PATCH] modifications to pg_dump towards supporting dumping of ACLs (doesn't work yet!) modification to c.h so that bool isn't typedef'd under __cplusplus --- src/bin/pg_dump/common.c | 9 ++++++--- src/bin/pg_dump/pg_dump.c | 41 ++++++++++++++++++++++++++--------------- src/bin/pg_dump/pg_dump.h | 18 +++++++++++++----- src/include/c.h | 4 +++- 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index ee68680a69..f12510dc3b 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.10 1997/02/13 08:31:17 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.11 1997/04/12 09:23:59 scrappy Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -192,7 +192,10 @@ strInArray(const char* pattern, char** arr, int arr_size) */ TableInfo * -dumpSchema(FILE *fout, int *numTablesPtr, const char *tablename) +dumpSchema(FILE *fout, + int *numTablesPtr, + const char *tablename, + const bool acls) { int numTypes; int numFuncs; @@ -249,7 +252,7 @@ if (fout) { if (g_verbose) fprintf(stderr,"%s dumping out tables %s\n", g_comment_start, g_comment_end); dumpTables(fout, tblinfo, numTables, inhinfo, numInherits, - tinfo, numTypes, tablename); + tinfo, numTypes, tablename, acls); } if (!tablename && fout) { diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index afc64657f1..1fb22d008e 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -13,14 +13,15 @@ * indices * aggregates * operators + * ACL - grant/revoke * - * the output script is SQL that is understood by Postgres95 + * the output script is SQL that is understood by PostgreSQL * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.26 1997/04/02 04:17:21 vadim Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.27 1997/04/12 09:24:07 scrappy Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -111,6 +112,8 @@ usage(const char* progname) fprintf(stderr, "\t -o \t\t dump object id's (oids)\n"); fprintf(stderr, + "\t -z \t\t dump ACLs (grant/revoke)\n"); + fprintf(stderr, "\nIf dbname is not supplied, then the DATABASE environment " "variable value is used.\n"); fprintf(stderr, "\n"); @@ -390,20 +393,16 @@ main(int argc, char** argv) { int c; const char* progname; - const char* filename; - const char* dbname; + const char* filename = NULL; + const char* dbname = NULL; const char *pghost = NULL; const char *pgport = NULL; - const char *tablename; - int oids; + const char *tablename = NULL; + int oids = 0, acls = 0; TableInfo *tblinfo; int numTables; - dbname = NULL; - filename = NULL; - tablename = NULL; g_verbose = false; - oids = 0; strcpy(g_comment_start,"-- "); g_comment_end[0] = '\0'; @@ -413,7 +412,7 @@ main(int argc, char** argv) progname = *argv; - while ((c = getopt(argc, argv,"f:H:p:t:vSDdDao")) != EOF) { + while ((c = getopt(argc, argv,"f:H:p:t:vSDdDaoz")) != EOF) { switch(c) { case 'f': /* output file name */ filename = optarg; @@ -446,6 +445,9 @@ main(int argc, char** argv) case 'o': /* Dump oids */ oids = 1; break; + case 'z': /* Dump oids */ + acls = 1; + break; default: usage(progname); break; @@ -488,10 +490,10 @@ main(int argc, char** argv) if (g_verbose) fprintf(stderr, "%s last builtin oid is %d %s\n", g_comment_start, g_last_builtin_oid, g_comment_end); - tblinfo = dumpSchema(g_fout, &numTables, tablename); + tblinfo = dumpSchema(g_fout, &numTables, tablename, acls); } else - tblinfo = dumpSchema(NULL, &numTables, tablename); + tblinfo = dumpSchema(NULL, &numTables, tablename, acls); if (!schemaOnly) { dumpClasses(tblinfo, numTables, g_fout, tablename, oids); @@ -924,6 +926,7 @@ getTables(int *numTables) int i_relname; int i_relarch; int i_relkind; + int i_relacl; /* find all the user-defined tables (no indices and no catalogs), ordering by oid is important so that we always process the parent @@ -940,7 +943,7 @@ getTables(int *numTables) PQclear(res); sprintf(query, - "SELECT oid, relname, relarch, relkind from pg_class " + "SELECT oid, relname, relarch, relkind, relacl from pg_class " "where (relkind = 'r' or relkind = 'S') and relname !~ '^pg_' " "and relname !~ '^Xinv' order by oid;"); @@ -961,11 +964,13 @@ getTables(int *numTables) i_relname = PQfnumber(res,"relname"); i_relarch = PQfnumber(res,"relarch"); i_relkind = PQfnumber(res,"relkind"); + i_relacl = PQfnumber(res,"relacl"); for (i=0;i