diff options
| author | Robert Haas | 2014-02-01 03:25:01 +0000 |
|---|---|---|
| committer | Robert Haas | 2014-02-01 03:25:01 +0000 |
| commit | c7de3295ba9db6649c32568bb46b91f1160da8d3 (patch) | |
| tree | 52bda214aaf8fa4bcc80eb8593c06807f2dc776d /src | |
| parent | e01fc2377bfdb6a519aea7007a57c901c8a95da6 (diff) | |
| parent | d1981719adbcc05fa15f540e8fc4327907991fc6 (diff) | |
Merge branch 'master' into slot2slot2
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend/libpq/be-secure.c | 13 | ||||
| -rw-r--r-- | src/backend/storage/ipc/procsignal.c | 9 | ||||
| -rw-r--r-- | src/backend/storage/lmgr/proc.c | 42 | ||||
| -rw-r--r-- | src/bin/psql/tab-complete.c | 30 | ||||
| -rw-r--r-- | src/include/catalog/pg_amproc.h | 52 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-secure.c | 6 | ||||
| -rw-r--r-- | src/tools/entab/entab.c | 36 | ||||
| -rwxr-xr-x | src/tools/pgindent/pgindent | 12 |
8 files changed, 144 insertions, 56 deletions
diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index a04701e555..71f9747300 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -822,6 +822,13 @@ initialize_SSL(void) #endif SSL_library_init(); SSL_load_error_strings(); + + /* + * We use SSLv23_method() because it can negotiate use of the highest + * mutually supported protocol version, while alternatives like + * TLSv1_2_method() permit only one specific version. Note that we + * don't actually allow SSL v2 or v3, only TLS protocols (see below). + */ SSL_context = SSL_CTX_new(SSLv23_method()); if (!SSL_context) ereport(FATAL, @@ -880,9 +887,11 @@ initialize_SSL(void) SSLerrmessage()))); } - /* set up ephemeral DH keys, and disallow SSL v2 while at it */ + /* set up ephemeral DH keys, and disallow SSL v2/v3 while at it */ SSL_CTX_set_tmp_dh_callback(SSL_context, tmp_dh_cb); - SSL_CTX_set_options(SSL_context, SSL_OP_SINGLE_DH_USE | SSL_OP_NO_SSLv2); + SSL_CTX_set_options(SSL_context, + SSL_OP_SINGLE_DH_USE | + SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); /* set up ephemeral ECDH keys */ initialize_ecdh(); diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c index 6ebabce72f..6526b2688a 100644 --- a/src/backend/storage/ipc/procsignal.c +++ b/src/backend/storage/ipc/procsignal.c @@ -149,6 +149,13 @@ CleanupProcSignalState(int status, Datum arg) slot = &ProcSignalSlots[pss_idx - 1]; Assert(slot == MyProcSignalSlot); + /* + * Clear MyProcSignalSlot, so that a SIGUSR1 received after this point + * won't try to access it after it's no longer ours (and perhaps even + * after we've unmapped the shared memory segment). + */ + MyProcSignalSlot = NULL; + /* sanity check */ if (slot->pss_pid != MyProcPid) { @@ -285,7 +292,7 @@ procsignal_sigusr1_handler(SIGNAL_ARGS) if (CheckProcSignal(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN)) RecoveryConflictInterrupt(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN); - if (set_latch_on_sigusr1) + if (set_latch_on_sigusr1 && MyProc != NULL) SetLatch(&MyProc->procLatch); latch_sigusr1_handler(); diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 45a48229a5..fb449a8820 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -774,6 +774,7 @@ ProcKill(int code, Datum arg) { /* use volatile pointer to prevent code rearrangement */ volatile PROC_HDR *procglobal = ProcGlobal; + PGPROC *proc; Assert(MyProc != NULL); @@ -802,31 +803,34 @@ ProcKill(int code, Datum arg) */ LWLockReleaseAll(); - /* Release ownership of the process's latch, too */ - DisownLatch(&MyProc->procLatch); + /* + * Clear MyProc first; then disown the process latch. This is so that + * signal handlers won't try to clear the process latch after it's no + * longer ours. + */ + proc = MyProc; + MyProc = NULL; + DisownLatch(&proc->procLatch); SpinLockAcquire(ProcStructLock); /* Return PGPROC structure (and semaphore) to appropriate freelist */ if (IsAnyAutoVacuumProcess()) { - MyProc->links.next = (SHM_QUEUE *) procglobal->autovacFreeProcs; - procglobal->autovacFreeProcs = MyProc; + proc->links.next = (SHM_QUEUE *) procglobal->autovacFreeProcs; + procglobal->autovacFreeProcs = proc; } else if (IsBackgroundWorker) { - MyProc->links.next = (SHM_QUEUE *) procglobal->bgworkerFreeProcs; - procglobal->bgworkerFreeProcs = MyProc; + proc->links.next = (SHM_QUEUE *) procglobal->bgworkerFreeProcs; + procglobal->bgworkerFreeProcs = proc; } else { - MyProc->links.next = (SHM_QUEUE *) procglobal->freeProcs; - procglobal->freeProcs = MyProc; + proc->links.next = (SHM_QUEUE *) procglobal->freeProcs; + procglobal->freeProcs = proc; } - /* PGPROC struct isn't mine anymore */ - MyProc = NULL; - /* Update shared estimate of spins_per_delay */ procglobal->spins_per_delay = update_spins_per_delay(procglobal->spins_per_delay); @@ -855,6 +859,7 @@ AuxiliaryProcKill(int code, Datum arg) { int proctype = DatumGetInt32(arg); PGPROC *auxproc PG_USED_FOR_ASSERTS_ONLY; + PGPROC *proc; Assert(proctype >= 0 && proctype < NUM_AUXILIARY_PROCS); @@ -865,16 +870,19 @@ AuxiliaryProcKill(int code, Datum arg) /* Release any LW locks I am holding (see notes above) */ LWLockReleaseAll(); - /* Release ownership of the process's latch, too */ - DisownLatch(&MyProc->procLatch); + /* + * Clear MyProc first; then disown the process latch. This is so that + * signal handlers won't try to clear the process latch after it's no + * longer ours. + */ + proc = MyProc; + MyProc = NULL; + DisownLatch(&proc->procLatch); SpinLockAcquire(ProcStructLock); /* Mark auxiliary proc no longer in use */ - MyProc->pid = 0; - - /* PGPROC struct isn't mine anymore */ - MyProc = NULL; + proc->pid = 0; /* Update shared estimate of spins_per_delay */ ProcGlobal->spins_per_delay = update_spins_per_delay(ProcGlobal->spins_per_delay); diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 5a6fe7d2d7..1d69b95387 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1622,12 +1622,12 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_CONST("IDENTITY"); } - /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET */ + /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET, MOVE */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && pg_strcasecmp(prev2_wd, "TABLESPACE") == 0) { static const char *const list_ALTERTSPC[] = - {"RENAME TO", "OWNER TO", "SET", "RESET", NULL}; + {"RENAME TO", "OWNER TO", "SET", "RESET", "MOVE", NULL}; COMPLETE_WITH_LIST(list_ALTERTSPC); } @@ -1649,6 +1649,27 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_LIST(list_TABLESPACEOPTIONS); } + /* ALTER TABLESPACE <foo> MOVE ALL|TABLES|INDEXES|MATERIALIZED VIEWS */ + else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && + pg_strcasecmp(prev3_wd, "TABLESPACE") == 0 && + pg_strcasecmp(prev_wd, "MOVE") == 0) + { + static const char *const list_TABLESPACEMOVETARGETS[] = + {"ALL", "TABLES", "INDEXES", "MATERIALIZED VIEWS", NULL}; + + COMPLETE_WITH_LIST(list_TABLESPACEMOVETARGETS); + } + else if ((pg_strcasecmp(prev4_wd, "TABLESPACE") == 0 && + pg_strcasecmp(prev2_wd, "MOVE") == 0) || + (pg_strcasecmp(prev5_wd, "TABLESPACE") == 0 && + pg_strcasecmp(prev3_wd, "MOVE") == 0 && + pg_strcasecmp(prev2_wd, "MATERIALIZED") == 0)) + { + static const char *const list_TABLESPACEMOVEOPTIONS[] = + {"OWNED BY", "TO", NULL}; + + COMPLETE_WITH_LIST(list_TABLESPACEMOVEOPTIONS); + } /* ALTER TEXT SEARCH */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && @@ -2559,8 +2580,9 @@ psql_completion(char *text, int start, int end) * but we may as well tab-complete both: perhaps some users prefer one * variant or the other. */ - else if (pg_strcasecmp(prev3_wd, "FETCH") == 0 || - pg_strcasecmp(prev3_wd, "MOVE") == 0) + else if ((pg_strcasecmp(prev3_wd, "FETCH") == 0 || + pg_strcasecmp(prev3_wd, "MOVE") == 0) && + pg_strcasecmp(prev_wd, "TO") != 0) { static const char *const list_FROMIN[] = {"FROM", "IN", NULL}; diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h index c090be4ee8..66bd76505a 100644 --- a/src/include/catalog/pg_amproc.h +++ b/src/include/catalog/pg_amproc.h @@ -121,8 +121,6 @@ DATA(insert ( 1988 1700 1700 1 1769 )); DATA(insert ( 1989 26 26 1 356 )); DATA(insert ( 1989 26 26 2 3134 )); DATA(insert ( 1991 30 30 1 404 )); -DATA(insert ( 2994 2249 2249 1 2987 )); -DATA(insert ( 3194 2249 2249 1 3187 )); DATA(insert ( 1994 25 25 1 360 )); DATA(insert ( 1996 1083 1083 1 1107 )); DATA(insert ( 2000 1266 1266 1 1358 )); @@ -134,7 +132,12 @@ DATA(insert ( 2233 703 703 1 380 )); DATA(insert ( 2234 704 704 1 381 )); DATA(insert ( 2789 27 27 1 2794 )); DATA(insert ( 2968 2950 2950 1 2960 )); +DATA(insert ( 2994 2249 2249 1 2987 )); +DATA(insert ( 3194 2249 2249 1 3187 )); DATA(insert ( 3522 3500 3500 1 3514 )); +DATA(insert ( 3626 3614 3614 1 3622 )); +DATA(insert ( 3683 3615 3615 1 3668 )); +DATA(insert ( 3901 3831 3831 1 3870 )); /* hash */ @@ -171,9 +174,18 @@ DATA(insert ( 2231 1042 1042 1 1080 )); DATA(insert ( 2235 1033 1033 1 329 )); DATA(insert ( 2969 2950 2950 1 2963 )); DATA(insert ( 3523 3500 3500 1 3515 )); +DATA(insert ( 3903 3831 3831 1 3902 )); /* gist */ +DATA(insert ( 1029 600 600 1 2179 )); +DATA(insert ( 1029 600 600 2 2583 )); +DATA(insert ( 1029 600 600 3 1030 )); +DATA(insert ( 1029 600 600 4 2580 )); +DATA(insert ( 1029 600 600 5 2581 )); +DATA(insert ( 1029 600 600 6 2582 )); +DATA(insert ( 1029 600 600 7 2584 )); +DATA(insert ( 1029 600 600 8 3064 )); DATA(insert ( 2593 603 603 1 2578 )); DATA(insert ( 2593 603 603 2 2583 )); DATA(insert ( 2593 603 603 3 2579 )); @@ -209,14 +221,13 @@ DATA(insert ( 3702 3615 3615 4 3696 )); DATA(insert ( 3702 3615 3615 5 3700 )); DATA(insert ( 3702 3615 3615 6 3697 )); DATA(insert ( 3702 3615 3615 7 3699 )); -DATA(insert ( 1029 600 600 1 2179 )); -DATA(insert ( 1029 600 600 2 2583 )); -DATA(insert ( 1029 600 600 3 1030 )); -DATA(insert ( 1029 600 600 4 2580 )); -DATA(insert ( 1029 600 600 5 2581 )); -DATA(insert ( 1029 600 600 6 2582 )); -DATA(insert ( 1029 600 600 7 2584 )); -DATA(insert ( 1029 600 600 8 3064 )); +DATA(insert ( 3919 3831 3831 1 3875 )); +DATA(insert ( 3919 3831 3831 2 3876 )); +DATA(insert ( 3919 3831 3831 3 3877 )); +DATA(insert ( 3919 3831 3831 4 3878 )); +DATA(insert ( 3919 3831 3831 5 3879 )); +DATA(insert ( 3919 3831 3831 6 3880 )); +DATA(insert ( 3919 3831 3831 7 3881 )); /* gin */ @@ -345,20 +356,14 @@ DATA(insert ( 3659 3614 3614 2 3656 )); DATA(insert ( 3659 3614 3614 3 3657 )); DATA(insert ( 3659 3614 3614 4 3658 )); DATA(insert ( 3659 3614 3614 5 2700 )); -DATA(insert ( 3626 3614 3614 1 3622 )); -DATA(insert ( 3683 3615 3615 1 3668 )); -DATA(insert ( 3901 3831 3831 1 3870 )); -DATA(insert ( 3903 3831 3831 1 3902 )); -DATA(insert ( 3919 3831 3831 1 3875 )); -DATA(insert ( 3919 3831 3831 2 3876 )); -DATA(insert ( 3919 3831 3831 3 3877 )); -DATA(insert ( 3919 3831 3831 4 3878 )); -DATA(insert ( 3919 3831 3831 5 3879 )); -DATA(insert ( 3919 3831 3831 6 3880 )); -DATA(insert ( 3919 3831 3831 7 3881 )); /* sp-gist */ +DATA(insert ( 3474 3831 3831 1 3469 )); +DATA(insert ( 3474 3831 3831 2 3470 )); +DATA(insert ( 3474 3831 3831 3 3471 )); +DATA(insert ( 3474 3831 3831 4 3472 )); +DATA(insert ( 3474 3831 3831 5 3473 )); DATA(insert ( 4015 600 600 1 4018 )); DATA(insert ( 4015 600 600 2 4019 )); DATA(insert ( 4015 600 600 3 4020 )); @@ -374,10 +379,5 @@ DATA(insert ( 4017 25 25 2 4028 )); DATA(insert ( 4017 25 25 3 4029 )); DATA(insert ( 4017 25 25 4 4030 )); DATA(insert ( 4017 25 25 5 4031 )); -DATA(insert ( 3474 3831 3831 1 3469 )); -DATA(insert ( 3474 3831 3831 2 3470 )); -DATA(insert ( 3474 3831 3831 3 3471 )); -DATA(insert ( 3474 3831 3831 4 3472 )); -DATA(insert ( 3474 3831 3831 5 3473 )); #endif /* PG_AMPROC_H */ diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index 7e7a4f9ff1..d8ac40c784 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -967,8 +967,10 @@ init_ssl_system(PGconn *conn) } /* - * Only SSLv23_method() negotiates higher protocol versions; - * alternatives like TLSv1_2_method() permit one specific version. + * We use SSLv23_method() because it can negotiate use of the highest + * mutually supported protocol version, while alternatives like + * TLSv1_2_method() permit only one specific version. Note that we + * don't actually allow SSL v2 or v3, only TLS protocols (see below). */ SSL_context = SSL_CTX_new(SSLv23_method()); if (!SSL_context) diff --git a/src/tools/entab/entab.c b/src/tools/entab/entab.c index 3b849f2a72..19b1740c9b 100644 --- a/src/tools/entab/entab.c +++ b/src/tools/entab/entab.c @@ -51,13 +51,18 @@ main(int argc, char **argv) { int tab_size = 8, min_spaces = 2, + only_comment_periods = FALSE, protect_quotes = FALSE, + protect_leading_whitespace = FALSE, del_tabs = FALSE, clip_lines = FALSE, + in_comment = FALSE, + was_period = FALSE, prv_spaces, col_in_tab, escaped, - nxt_spaces; + nxt_spaces, + in_leading_whitespace; char in_line[BUFSIZ], out_line[BUFSIZ], *src, @@ -74,7 +79,7 @@ main(int argc, char **argv) if (strcmp(cp, "detab") == 0) del_tabs = 1; - while ((ch = getopt(argc, argv, "cdhqs:t:")) != -1) + while ((ch = getopt(argc, argv, "cdhlmqs:t:")) != -1) switch (ch) { case 'c': @@ -83,6 +88,13 @@ main(int argc, char **argv) case 'd': del_tabs = TRUE; break; + case 'l': + protect_leading_whitespace = TRUE; + break; + case 'm': + /* only process text followed by periods in C comments */ + only_comment_periods = TRUE; + break; case 'q': protect_quotes = TRUE; break; @@ -97,6 +109,8 @@ main(int argc, char **argv) fprintf(stderr, "USAGE: %s [ -cdqst ] [file ...]\n\ -c (clip trailing whitespace)\n\ -d (delete tabs)\n\ + -l (protect leading whitespace)\n\ + -m (only C comment periods)\n\ -q (protect quotes)\n\ -s minimum_spaces\n\ -t tab_width\n", @@ -134,13 +148,24 @@ main(int argc, char **argv) if (escaped == FALSE) quote_char = ' '; escaped = FALSE; + in_leading_whitespace = TRUE; /* process line */ while (*src != NUL) { col_in_tab++; + + /* look backward so we handle slash-star-slash properly */ + if (!in_comment && src > in_line && + *(src - 1) == '/' && *src == '*') + in_comment = TRUE; + else if (in_comment && *src == '*' && *(src + 1) == '/') + in_comment = FALSE; + /* Is this a potential space/tab replacement? */ - if (quote_char == ' ' && (*src == ' ' || *src == '\t')) + if ((!only_comment_periods || (in_comment && was_period)) && + (!protect_leading_whitespace || !in_leading_whitespace) && + quote_char == ' ' && (*src == ' ' || *src == '\t')) { if (*src == '\t') { @@ -192,6 +217,11 @@ main(int argc, char **argv) /* Not a potential space/tab replacement */ else { + /* allow leading stars in comments */ + if (in_leading_whitespace && *src != ' ' && *src != '\t' && + (!in_comment || *src != '*')) + in_leading_whitespace = FALSE; + was_period = (*src == '.'); /* output accumulated spaces */ output_accumulated_spaces(&prv_spaces, &dst); /* This can only happen in a quote. */ diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 8e45b18a9a..8633c62c5a 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -22,10 +22,11 @@ my $indent_opts = # indent-dependant settings my $extra_opts = ""; -my ($typedefs_file, $code_base, $excludes, $indent, $build); +my ($typedefs_file, $typedef_str, $code_base, $excludes, $indent, $build); my %options = ( "typedefs=s" => \$typedefs_file, + "list-of-typedefs=s" => \$typedef_str, "code-base=s" => \$code_base, "excludes=s" => \$excludes, "indent=s" => \$indent, @@ -126,6 +127,15 @@ sub load_typedefs my @typedefs = <$typedefs_fh>; close($typedefs_fh); + # add command-line-supplied typedefs? + if (defined($typedef_str)) + { + foreach my $typedef (split(m/[, \t\n]+/, $typedef_str)) + { + push(@typedefs, $typedef . "\n"); + } + } + # remove certain entries @typedefs = grep { !m/^(FD_SET|date|interval|timestamp|ANY)\n?$/ } @typedefs; |
