Index: src/bin/pg_dump/common.c =================================================================== RCS file: /var/cvsup/pgsql/src/bin/pg_dump/common.c,v retrieving revision 1.60 diff -c -r1.60 common.c *** src/bin/pg_dump/common.c 25 Oct 2001 05:49:52 -0000 1.60 --- src/bin/pg_dump/common.c 11 Jan 2002 00:31:39 -0000 *************** *** 309,315 **** if (g_verbose) write_msg(NULL, "reading user-defined tables\n"); ! tblinfo = getTables(&numTables, finfo, numFuncs); if (g_verbose) write_msg(NULL, "reading index information\n"); --- 309,315 ---- if (g_verbose) write_msg(NULL, "reading user-defined tables\n"); ! tblinfo = getTables(&numTables, finfo, numFuncs, tablename); if (g_verbose) write_msg(NULL, "reading index information\n"); Index: src/bin/pg_dump/pg_dump.c =================================================================== RCS file: /var/cvsup/pgsql/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.236 diff -c -r1.236 pg_dump.c *** src/bin/pg_dump/pg_dump.c 28 Oct 2001 06:25:58 -0000 1.236 --- src/bin/pg_dump/pg_dump.c 11 Jan 2002 02:46:11 -0000 *************** *** 2035,2047 **** * numTables is set to the number of tables read in */ TableInfo * ! getTables(int *numTables, FuncInfo *finfo, int numFuncs) { PGresult *res; int ntups; int i; PQExpBuffer query = createPQExpBuffer(); PQExpBuffer delqry = createPQExpBuffer(); TableInfo *tblinfo; int i_reloid; --- 2035,2048 ---- * numTables is set to the number of tables read in */ TableInfo * ! getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename) { PGresult *res; int ntups; int i; PQExpBuffer query = createPQExpBuffer(); PQExpBuffer delqry = createPQExpBuffer(); + PQExpBuffer lockquery = createPQExpBuffer(); TableInfo *tblinfo; int i_reloid; *************** *** 2150,2156 **** tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename)); tblinfo[i].ncheck = atoi(PQgetvalue(res, i, i_relchecks)); tblinfo[i].ntrig = atoi(PQgetvalue(res, i, i_reltriggers)); ! if (strlen(tblinfo[i].usename) == 0) write_msg(NULL, "WARNING: owner of table \"%s\" appears to be invalid\n", tblinfo[i].relname); --- 2151,2181 ---- tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename)); tblinfo[i].ncheck = atoi(PQgetvalue(res, i, i_relchecks)); tblinfo[i].ntrig = atoi(PQgetvalue(res, i, i_reltriggers)); ! ! /* lock this table to make sure it isn't DROPPED while we're ! * running. If no tablename is specified, lock all tables ! * we see, otherwise, only lock the specified table(s). ! */ ! if( ( strcmp(PQgetvalue(res, i, i_relkind), "r") == 0 ) ! && ! ( tablename == NULL || strcmp(tblinfo[i].relname, tablename) == 0 ) ) ! { ! PGresult *lres; ! resetPQExpBuffer(lockquery); ! appendPQExpBuffer(lockquery,"LOCK TABLE \""); ! appendPQExpBuffer(lockquery,tblinfo[i].relname); ! appendPQExpBuffer(lockquery,"\" IN ACCESS SHARE MODE"); ! lres = PQexec(g_conn,lockquery->data); ! if (!lres ! || PQresultStatus(lres) != PGRES_COMMAND_OK) ! { ! write_msg(NULL, "Attempt to lock table \"%s\" failed. %s", ! tblinfo[i].relname, PQerrorMessage(g_conn)); ! exit_nicely(); ! } ! PQclear(lres); ! } ! if (strlen(tblinfo[i].usename) == 0) write_msg(NULL, "WARNING: owner of table \"%s\" appears to be invalid\n", tblinfo[i].relname); *************** *** 2208,2213 **** --- 2233,2239 ---- tblinfo[i].relname); exit_nicely(); } + PQclear(res2); } else tblinfo[i].viewdef = NULL; *************** *** 2647,2652 **** --- 2673,2679 ---- destroyPQExpBuffer(query); destroyPQExpBuffer(delqry); + destroyPQExpBuffer(lockquery); return tblinfo; } Index: src/bin/pg_dump/pg_dump.h =================================================================== RCS file: /var/cvsup/pgsql/src/bin/pg_dump/pg_dump.h,v retrieving revision 1.76 diff -c -r1.76 pg_dump.h *** src/bin/pg_dump/pg_dump.h 5 Nov 2001 17:46:30 -0000 1.76 --- src/bin/pg_dump/pg_dump.h 11 Jan 2002 00:31:10 -0000 *************** *** 254,260 **** extern void clearTypeInfo(TypeInfo *, int); extern OprInfo *getOperators(int *numOperators); ! extern TableInfo *getTables(int *numTables, FuncInfo *finfo, int numFuncs); extern InhInfo *getInherits(int *numInherits); extern void getTableAttrs(TableInfo *tbinfo, int numTables); extern IndInfo *getIndexes(int *numIndexes); --- 254,260 ---- extern void clearTypeInfo(TypeInfo *, int); extern OprInfo *getOperators(int *numOperators); ! extern TableInfo *getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename); extern InhInfo *getInherits(int *numInherits); extern void getTableAttrs(TableInfo *tbinfo, int numTables); extern IndInfo *getIndexes(int *numIndexes);