~ubuntu-branches/ubuntu/trusty/postgresql-9.3/trusty-proposed

« back to all changes in this revision

Viewing changes to src/backend/tcop/postgres.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-07-24 16:13:59 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140724161359-uk325qfv03euxuuh
Tags: 9.3.5-0ubuntu0.14.04.1
* New upstream bug fix release: (LP: #1348176)
  - pg_upgrade: Users who upgraded to version 9.3 using pg_upgrade may have
    an issue with transaction information which causes VACUUM to eventually
    fail. These users should run the script provided in the release notes to
    determine if their installation is affected, and then take the remedy
    steps outlined there.
  - Various data integrity and other bug fixes.
  - Secure Unix-domain sockets of temporary postmasters started during make
    check.
    Any local user able to access the socket file could connect as the
    server's bootstrap superuser, then proceed to execute arbitrary code as
    the operating-system user running the test, as we previously noted in
    CVE-2014-0067. This change defends against that risk by placing the
    server's socket in a temporary, mode 0700 subdirectory of /tmp.
  - See release notes for details:
    http://www.postgresql.org/about/news/1534/
* Remove pg_regress patches to support --host=/path, obsolete with above
  upstream changes and not applicable any more.
* Drop tcl8.6 patch, applied upstream.
* Add missing logrotate test dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
452
452
                default:
453
453
 
454
454
                        /*
455
 
                         * Otherwise we got garbage from the frontend.  We treat this as
 
455
                         * Otherwise we got garbage from the frontend.  We treat this as
456
456
                         * fatal because we have probably lost message boundary sync, and
457
457
                         * there's no good way to recover.
458
458
                         */
854
854
                ResetUsage();
855
855
 
856
856
        /*
857
 
         * Start up a transaction command.      All queries generated by the
 
857
         * Start up a transaction command.  All queries generated by the
858
858
         * query_string will be in this same command block, *unless* we find a
859
859
         * BEGIN/COMMIT/ABORT statement; we have to force a new xact command after
860
860
         * one of those, else bad things will happen in xact.c. (Note that this
863
863
        start_xact_command();
864
864
 
865
865
        /*
866
 
         * Zap any pre-existing unnamed statement.      (While not strictly necessary,
 
866
         * Zap any pre-existing unnamed statement.  (While not strictly necessary,
867
867
         * it seems best to define simple-Query mode as if it used the unnamed
868
868
         * statement and portal; this ensures we recover any storage used by prior
869
869
         * unnamed operations.)
922
922
 
923
923
                /*
924
924
                 * Get the command name for use in status display (it also becomes the
925
 
                 * default completion tag, down inside PortalRun).      Set ps_status and
 
925
                 * default completion tag, down inside PortalRun).  Set ps_status and
926
926
                 * do any special start-of-SQL-command processing needed by the
927
927
                 * destination.
928
928
                 */
1010
1010
 
1011
1011
                /*
1012
1012
                 * Select the appropriate output format: text unless we are doing a
1013
 
                 * FETCH from a binary cursor.  (Pretty grotty to have to do this here
 
1013
                 * FETCH from a binary cursor.  (Pretty grotty to have to do this here
1014
1014
                 * --- but it avoids grottiness in other places.  Ah, the joys of
1015
1015
                 * backward compatibility...)
1016
1016
                 */
1311
1311
        }
1312
1312
        else
1313
1313
        {
1314
 
                /* Empty input string.  This is legal. */
 
1314
                /* Empty input string.  This is legal. */
1315
1315
                raw_parse_tree = NULL;
1316
1316
                commandTag = NULL;
1317
1317
                psrc = CreateCachedPlan(raw_parse_tree, query_string, commandTag);
1361
1361
 
1362
1362
        /*
1363
1363
         * We do NOT close the open transaction command here; that only happens
1364
 
         * when the client sends Sync.  Instead, do CommandCounterIncrement just
 
1364
         * when the client sends Sync.  Instead, do CommandCounterIncrement just
1365
1365
         * in case something happened during parse/plan.
1366
1366
         */
1367
1367
        CommandCounterIncrement();
1503
1503
         * If we are in aborted transaction state, the only portals we can
1504
1504
         * actually run are those containing COMMIT or ROLLBACK commands. We
1505
1505
         * disallow binding anything else to avoid problems with infrastructure
1506
 
         * that expects to run inside a valid transaction.      We also disallow
 
1506
         * that expects to run inside a valid transaction.  We also disallow
1507
1507
         * binding any parameters, since we can't risk calling user-defined I/O
1508
1508
         * functions.
1509
1509
         */
1592
1592
                                /*
1593
1593
                                 * Rather than copying data around, we just set up a phony
1594
1594
                                 * StringInfo pointing to the correct portion of the message
1595
 
                                 * buffer.      We assume we can scribble on the message buffer so
 
1595
                                 * buffer.  We assume we can scribble on the message buffer so
1596
1596
                                 * as to maintain the convention that StringInfos have a
1597
1597
                                 * trailing null.  This is grotty but is a big win when
1598
1598
                                 * dealing with very large parameter strings.
1942
1942
                if (is_xact_command)
1943
1943
                {
1944
1944
                        /*
1945
 
                         * If this was a transaction control statement, commit it.      We
 
1945
                         * If this was a transaction control statement, commit it.  We
1946
1946
                         * will start a new xact command for the next command (if any).
1947
1947
                         */
1948
1948
                        finish_xact_command();
2348
2348
        /*
2349
2349
         * If we are in aborted transaction state, we can't run
2350
2350
         * SendRowDescriptionMessage(), because that needs catalog accesses.
2351
 
         * Hence, refuse to Describe portals that return data.  (We shouldn't just
 
2351
         * Hence, refuse to Describe portals that return data.  (We shouldn't just
2352
2352
         * refuse all Describes, since that might break the ability of some
2353
2353
         * clients to issue COMMIT or ROLLBACK commands, if they use code that
2354
2354
         * blindly Describes whatever it does.)
2565
2565
        on_exit_reset();
2566
2566
 
2567
2567
        /*
2568
 
         * Note we do exit(2) not exit(0).      This is to force the postmaster into a
 
2568
         * Note we do exit(2) not exit(0).  This is to force the postmaster into a
2569
2569
         * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random
2570
2570
         * backend.  This is necessary precisely because we don't clean up our
2571
2571
         * shared memory state.  (The "dead man switch" mechanism in pmsignal.c
2809
2809
                }
2810
2810
        }
2811
2811
 
 
2812
        /*
 
2813
         * Set the process latch. This function essentially emulates signal
 
2814
         * handlers like die() and StatementCancelHandler() and it seems prudent
 
2815
         * to behave similarly as they do. Alternatively all plain backend code
 
2816
         * waiting on that latch, expecting to get interrupted by query cancels et
 
2817
         * al., would also need to set set_latch_on_sigusr1.
 
2818
         */
 
2819
        if (MyProc)
 
2820
                SetLatch(&MyProc->procLatch);
 
2821
 
2812
2822
        errno = save_errno;
2813
2823
}
2814
2824
 
3294
3304
#endif
3295
3305
 
3296
3306
        /*
3297
 
         * Parse command-line options.  CAUTION: keep this in sync with
 
3307
         * Parse command-line options.  CAUTION: keep this in sync with
3298
3308
         * postmaster/postmaster.c (the option sets should not conflict) and with
3299
3309
         * the common help() function in main/main.c.
3300
3310
         */
3597
3607
         * we have set up the handler.
3598
3608
         *
3599
3609
         * Also note: it's best not to use any signals that are SIG_IGNored in the
3600
 
         * postmaster.  If such a signal arrives before we are able to change the
 
3610
         * postmaster.  If such a signal arrives before we are able to change the
3601
3611
         * handler to non-SIG_IGN, it'll get dropped.  Instead, make a dummy
3602
3612
         * handler in the postmaster to reserve the signal. (Of course, this isn't
3603
3613
         * an issue for signals that are locally generated, such as SIGALRM and
3803
3813
                /*
3804
3814
                 * NOTE: if you are tempted to add more code in this if-block,
3805
3815
                 * consider the high probability that it should be in
3806
 
                 * AbortTransaction() instead.  The only stuff done directly here
 
3816
                 * AbortTransaction() instead.  The only stuff done directly here
3807
3817
                 * should be stuff that is guaranteed to apply *only* for outer-level
3808
3818
                 * error recovery, such as adjusting the FE/BE protocol status.
3809
3819
                 */
3916
3926
                 * collector, and to update the PS stats display.  We avoid doing
3917
3927
                 * those every time through the message loop because it'd slow down
3918
3928
                 * processing of batched messages, and because we don't want to report
3919
 
                 * uncommitted updates (that confuses autovacuum).      The notification
 
3929
                 * uncommitted updates (that confuses autovacuum).  The notification
3920
3930
                 * processor wants a call too, if we are not in a transaction block.
3921
3931
                 */
3922
3932
                if (send_ready_for_query)