aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1997-04-12 09:24:23 +0000
committerMarc G. Fournier <scrappy@hub.org>1997-04-12 09:24:23 +0000
commit1e9b80a2fd14b8d42fd92e43ba2145e2fc124b47 (patch)
treeb978e4cbdf6dd7777696b26338fced9ca45ec4f1 /src
parentbb0a17412d133885c6eb98e1741ee65b89c528f1 (diff)
downloadpostgresql-1e9b80a2fd14b8d42fd92e43ba2145e2fc124b47.tar.gz
postgresql-1e9b80a2fd14b8d42fd92e43ba2145e2fc124b47.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/common.c9
-rw-r--r--src/bin/pg_dump/pg_dump.c41
-rw-r--r--src/bin/pg_dump/pg_dump.h18
-rw-r--r--src/include/c.h4
4 files changed, 48 insertions, 24 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index ee68680a69a..f12510dc3b1 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 afc64657f17..1fb22d008e9 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<ntups;i++) {
tblinfo[i].oid = strdup(PQgetvalue(res,i,i_oid));
tblinfo[i].relname = strdup(PQgetvalue(res,i,i_relname));
tblinfo[i].relarch = strdup(PQgetvalue(res,i,i_relarch));
+ tblinfo[i].relacl = strdup(PQgetvalue(res,i,i_relacl));
tblinfo[i].sequence = (strcmp (PQgetvalue(res,i,i_relkind), "S") == 0);
}
@@ -1504,7 +1509,8 @@ dumpAggs(FILE* fout, AggInfo* agginfo, int numAggs,
void dumpTables(FILE* fout, TableInfo *tblinfo, int numTables,
InhInfo *inhinfo, int numInherits,
- TypeInfo *tinfo, int numTypes, const char *tablename)
+ TypeInfo *tinfo, int numTypes, const char *tablename,
+ const bool acls)
{
int i,j,k;
char q[MAXQUERYLEN];
@@ -1611,6 +1617,11 @@ void dumpTables(FILE* fout, TableInfo *tblinfo, int numTables,
q,
archiveMode);
fputs(q,fout);
+
+ if(acls)
+ fprintf(fout,
+ "UPDATE pg_class SET relacl='%s' where relname='%s';\n",
+ tblinfo[i].relacl, tblinfo[i].relname);
}
}
}
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 775c05612dd..988dbd0e196 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_dump.h,v 1.11 1997/04/02 04:17:27 vadim Exp $
+ * $Id: pg_dump.h,v 1.12 1997/04/12 09:24:14 scrappy Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
@@ -55,6 +55,7 @@ typedef struct _tableInfo {
char *oid;
char *relname;
char *relarch;
+ char *relacl;
bool sequence;
int numatts; /* number of attributes */
int *inhAttrs; /* an array of flags, one for each attribute
@@ -143,9 +144,15 @@ extern char g_opaque_type[10]; /* name for the opaque type */
* common utility functions
*/
-extern TableInfo* dumpSchema(FILE* fout, int *numTablesPtr, const char *tablename);
-extern void dumpSchemaIdx(FILE* fout, int *numTablesPtr, const char *tablename,
- TableInfo* tblinfo, int numTables);
+extern TableInfo* dumpSchema(FILE* fout,
+ int *numTablesPtr,
+ const char *tablename,
+ const bool acls);
+extern void dumpSchemaIdx(FILE* fout,
+ int *numTablesPtr,
+ const char *tablename,
+ TableInfo* tblinfo,
+ int numTables);
extern char* findTypeByOid(TypeInfo* tinfo, int numTypes, const char* oid);
extern char* findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid);
@@ -188,7 +195,8 @@ extern void dumpOneFunc(FILE* fout, FuncInfo* finfo, int i,
TypeInfo *tinfo, int numTypes);
extern void dumpTables(FILE* fout, TableInfo* tbinfo, int numTables,
InhInfo *inhinfo, int numInherits,
- TypeInfo *tinfo, int numTypes, const char *tablename);
+ TypeInfo *tinfo, int numTypes, const char *tablename,
+ const bool acls);
extern void dumpIndices(FILE* fout, IndInfo* indinfo, int numIndices,
TableInfo* tbinfo, int numTables, const char *tablename);
diff --git a/src/include/c.h b/src/include/c.h
index 877603f00d4..42767288790 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: c.h,v 1.9 1997/02/14 04:18:27 momjian Exp $
+ * $Id: c.h,v 1.10 1997/04/12 09:24:23 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -60,7 +60,9 @@
*/
#define false ((char) 0)
#define true ((char) 1)
+#ifndef __cplusplus
typedef char bool;
+#endif /* not C++ */
typedef bool *BoolPtr;
#ifndef TRUE