Take an ACCESS SHARE LOCK on the target table, in an initial attempt to prevent concurrent DDL.

This is a first pass at Daniele's suggestion in Issue #8, although it is
definitely still buggy -- it is still possible for another transaction
to get in an AccessExclusive lock and perform DDL either before the
ACCESS SHARE lock is acquired or immediately after it is released.
This commit is contained in:
Josh Kupershmidt
2012-10-20 16:27:54 -07:00
committed by Daniele Varrazzo
parent e02811689a
commit 78bae38718
3 changed files with 69 additions and 7 deletions

View File

@ -24,6 +24,7 @@ char *password = NULL;
YesNo prompt_password = DEFAULT;
PGconn *connection = NULL;
PGconn *conn2 = NULL;
static bool parse_pair(const char buffer[], char key[], char value[]);
static char *get_username(void);
@ -51,6 +52,7 @@ reconnect(int elevel)
appendStringInfo(&buf, "password=%s ", password);
connection = pgut_connect(buf.data, prompt_password, elevel);
conn2 = pgut_connect(buf.data, prompt_password, elevel);
/* update password */
if (connection)

View File

@ -56,6 +56,7 @@ extern char *password;
extern YesNo prompt_password;
extern PGconn *connection;
extern PGconn *conn2;
extern void pgut_help(bool details);
extern void help(bool details);