*
*
* 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
*
*/
TableInfo *
-dumpSchema(FILE *fout, int *numTablesPtr, const char *tablename)
+dumpSchema(FILE *fout,
+ int *numTablesPtr,
+ const char *tablename,
+ const bool acls)
{
int numTypes;
int numFuncs;
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) {
* 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
*
"\t -t table \t\t dump for this table only\n");
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");
{
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';
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;
case 'o': /* Dump oids */
oids = 1;
break;
+ case 'z': /* Dump oids */
+ acls = 1;
+ break;
default:
usage(progname);
break;
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);
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
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;");
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);
}
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];
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);
}
}
}
*
* 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
*
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
* 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);
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);