From 4ddc50dffa279b2c0147474f7b323de99a6b7aa7 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 23 Mar 2000 21:38:58 +0000 Subject: [PATCH] Hmm, absolute pathnames for the copy makes sense. I'll whip up that patch in a second. Should be sufficent to just make sure the first character is a '/', right? Ross J. Reedstrom --- doc/src/sgml/ref/lock.sgml | 91 ++++++++++++++++++++++++++++++++----- src/backend/commands/copy.c | 7 ++- 2 files changed, 85 insertions(+), 13 deletions(-) diff --git a/doc/src/sgml/ref/lock.sgml b/doc/src/sgml/ref/lock.sgml index da753b9bb38..06dc405b31c 100644 --- a/doc/src/sgml/ref/lock.sgml +++ b/doc/src/sgml/ref/lock.sgml @@ -1,5 +1,5 @@ @@ -32,6 +32,70 @@ LOCK [ TABLE ] name IN SHARE ROW EX 1999-06-09 + + + Terms + + + + + EXCLUSIVE + + + Exclusive lock that prevents other locks from being granted. + + + + + + + + SHARE + + + Allows others to share lock. Prevents EXCLUSIVE locks. + + + + + + + + ACCESS + + + Locks table schema. + + + + + + + + ROW + + + Locks individual rows. + + + + + + + + Notes + + + If EXCLUSIVE or SHARE are not speicified, EXCLUSIVE is assumed. + If ROW or ACCESS is not specified, the entire table is locked + for the duration of the transaction. + + + + + + + Inputs @@ -53,17 +117,17 @@ LOCK [ TABLE ] name IN SHARE ROW EX This lock mode is acquired automatically over tables being queried. - Postgres releases automatically acquired - ACCESS SHARE locks after the statement is done. + This lock is released automatically after the statement completes. + It does not remain for the duration of the transaction. This is the least restrictive lock mode which conflicts only with ACCESS EXCLUSIVE mode. It is intended to protect a table being - queried from concurrent ALTER TABLE, + modified by concurrent ALTER TABLE, DROP TABLE and VACUUM - statements over the same table. + commands. @@ -74,6 +138,8 @@ LOCK [ TABLE ] name IN SHARE ROW EX Automatically acquired by any SELECT FOR UPDATE statement. + While it is a SHARE lock, there is the intention to later upgrade + this to an EXCLUSIVE lock. @@ -90,7 +156,7 @@ LOCK [ TABLE ] name IN SHARE ROW EX Automatically acquired by any UPDATE, DELETE, INSERT statement. - + @@ -107,6 +173,7 @@ LOCK [ TABLE ] name IN SHARE ROW EX Automatically acquired by any CREATE INDEX statement. + Share-locks entire table. @@ -123,10 +190,10 @@ LOCK [ TABLE ] name IN SHARE ROW EX - Conflicts with ROW EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE, - EXCLUSIVE and ACCESS EXCLUSIVE modes. This mode is more - restrictive than SHARE mode because of only one transaction - at time can hold this lock. + This is like an EXCLUSIVE lock, but allows SHARE ROW locks + by others. + Conflicts with ROW EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE, + EXCLUSIVE and ACCESS EXCLUSIVE modes. @@ -139,7 +206,7 @@ LOCK [ TABLE ] name IN SHARE ROW EX Conflicts with ROW SHARE, ROW EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE, EXCLUSIVE and ACCESS EXCLUSIVE modes. This mode is yet more restrictive than that of SHARE ROW EXCLUSIVE; it blocks all concurrent - SELECT FOR UPDATE queries. + SHARE ROW/SELECT FOR UPDATE queries. @@ -149,7 +216,7 @@ LOCK [ TABLE ] name IN SHARE ROW EX - Automatically acquired by ALTER TABLE, + Automatically acquired by ALTER TABLE, DROP TABLE, VACUUM statements. diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index a91072522a5..8634ab11dd5 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.102 2000/03/09 05:00:23 inoue Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.103 2000/03/23 21:38:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -348,6 +348,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, mode_t oumask; /* Pre-existing umask value */ oumask = umask((mode_t) 022); + + if (*filename != '/') + elog(ERROR, "Relative path not allowed for server side" + " COPY command."); + #ifndef __CYGWIN32__ fp = AllocateFile(filename, "w"); #else