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

« back to all changes in this revision

Viewing changes to src/backend/access/spgist/spgdoinsert.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:
25
25
/*
26
26
 * SPPageDesc tracks all info about a page we are inserting into.  In some
27
27
 * situations it actually identifies a tuple, or even a specific node within
28
 
 * an inner tuple.      But any of the fields can be invalid.  If the buffer
 
28
 * an inner tuple.  But any of the fields can be invalid.  If the buffer
29
29
 * field is valid, it implies we hold pin and exclusive lock on that buffer.
30
30
 * page pointer should be valid exactly when buffer is.
31
31
 */
122
122
 *
123
123
 * NB: this is used during WAL replay, so beware of trying to make it too
124
124
 * smart.  In particular, it shouldn't use "state" except for calling
125
 
 * spgFormDeadTuple().
 
125
 * spgFormDeadTuple().  This is also used in a critical section, so no
 
126
 * pallocs either!
126
127
 */
127
128
void
128
129
spgPageIndexMultiDelete(SpGistState *state, Page page,
131
132
                                                BlockNumber blkno, OffsetNumber offnum)
132
133
{
133
134
        OffsetNumber firstItem;
134
 
        OffsetNumber *sortednos;
 
135
        OffsetNumber sortednos[MaxIndexTuplesPerPage];
135
136
        SpGistDeadTuple tuple = NULL;
136
137
        int                     i;
137
138
 
145
146
         * replacement tuples.)  However, we must not scribble on the caller's
146
147
         * array, so we have to make a copy.
147
148
         */
148
 
        sortednos = (OffsetNumber *) palloc(sizeof(OffsetNumber) * nitems);
149
149
        memcpy(sortednos, itemnos, sizeof(OffsetNumber) * nitems);
150
150
        if (nitems > 1)
151
151
                qsort(sortednos, nitems, sizeof(OffsetNumber), cmpOffsetNumbers);
173
173
                else if (tupstate == SPGIST_PLACEHOLDER)
174
174
                        SpGistPageGetOpaque(page)->nPlaceholder++;
175
175
        }
176
 
 
177
 
        pfree(sortednos);
178
176
}
179
177
 
180
178
/*
251
249
        else
252
250
        {
253
251
                /*
254
 
                 * Tuple must be inserted into existing chain.  We mustn't change the
 
252
                 * Tuple must be inserted into existing chain.  We mustn't change the
255
253
                 * chain's head address, but we don't need to chase the entire chain
256
254
                 * to put the tuple at the end; we can insert it second.
257
255
                 *
816
814
         * We may not actually insert new tuple because another picksplit may be
817
815
         * necessary due to too large value, but we will try to allocate enough
818
816
         * space to include it; and in any case it has to be included in the input
819
 
         * for the picksplit function.  So don't increment nToInsert yet.
 
817
         * for the picksplit function.  So don't increment nToInsert yet.
820
818
         */
821
819
        in.datums[in.nTuples] = SGLTDATUM(newLeafTuple, state);
822
820
        heapPtrs[in.nTuples] = newLeafTuple->heapPtr;
874
872
        /*
875
873
         * Check to see if the picksplit function failed to separate the values,
876
874
         * ie, it put them all into the same child node.  If so, select allTheSame
877
 
         * mode and create a random split instead.      See comments for
 
875
         * mode and create a random split instead.  See comments for
878
876
         * checkAllTheSame as to why we need to know if the new leaf tuples could
879
877
         * fit on one page.
880
878
         */
1039
1037
                                                                                &xlrec.initDest);
1040
1038
 
1041
1039
                /*
1042
 
                 * Attempt to assign node groups to the two pages.      We might fail to
 
1040
                 * Attempt to assign node groups to the two pages.  We might fail to
1043
1041
                 * do so, even if totalLeafSizes is less than the available space,
1044
1042
                 * because we can't split a group across pages.
1045
1043
                 */
1919
1917
                if (current.blkno == InvalidBlockNumber)
1920
1918
                {
1921
1919
                        /*
1922
 
                         * Create a leaf page.  If leafSize is too large to fit on a page,
 
1920
                         * Create a leaf page.  If leafSize is too large to fit on a page,
1923
1921
                         * we won't actually use the page yet, but it simplifies the API
1924
1922
                         * for doPickSplit to always have a leaf page at hand; so just
1925
1923
                         * quietly limit our request to a page size.
2122
2120
                                                                         out.result.addNode.nodeLabel);
2123
2121
 
2124
2122
                                        /*
2125
 
                                         * Retry insertion into the enlarged node.      We assume that
 
2123
                                         * Retry insertion into the enlarged node.  We assume that
2126
2124
                                         * we'll get a MatchNode result this time.
2127
2125
                                         */
2128
2126
                                        goto process_inner_tuple;