~ubuntu-branches/ubuntu/utopic/postgresql-9.1/utopic

« back to all changes in this revision

Viewing changes to contrib/pg_trgm/trgm_op.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-09-25 05:40:23 UTC
  • mfrom: (1.2.1)
  • Revision ID: package-import@ubuntu.com-20120925054023-lv75ptpdzvjdhkbw
Tags: 9.1.6-1
* Urgency medium because of data loss bug fix.
* New upstream bug fix release:
  - Fix persistence marking of shared buffers during WAL replay.
    This mistake can result in buffers not being written out during
    checkpoints, resulting in data corruption if the server later
    crashes without ever having written those buffers. Corruption can
    occur on any server following crash recovery, but it is
    significantly more likely to occur on standby slave servers since
    those perform much more WAL replay. There is a low probability of
    corruption of btree and GIN indexes. There is a much higher
    probability of corruption of table "visibility maps". Fortunately,
    visibility maps are non-critical data in 9.1, so the worst
    consequence of such corruption in 9.1 installations is transient
    inefficiency of vacuuming. Table data proper cannot be corrupted by
    this bug.
    While no index corruption due to this bug is known to have occurred
    in the field, as a precautionary measure it is recommended that
    production installations "REINDEX" all btree and GIN indexes at a
    convenient time after upgrading to 9.1.6.
    Also, if you intend to do an in-place upgrade to 9.2.X, before
    doing so it is recommended to perform a "VACUUM" of all tables
    while having vacuum_freeze_table_age set to zero. This will ensure
    that any lingering wrong data in the visibility maps is corrected
    before 9.2.X can depend on it. vacuum_cost_delay can be adjusted to
    reduce the performance impact of vacuuming, while causing it to
    take longer to finish.
  - See HISTORY/changelog.gz for the other bug fixes.
* debian/rules: Compress all binaries with xz. Thanks Cyril Brulebois!
  (Closes: #688678)

Show diffs side-by-side

added added

removed removed

Lines of Context:
273
273
        const char *beginword = str;
274
274
        const char *endword;
275
275
        char       *s = buf;
276
 
        bool            in_wildcard_meta = false;
 
276
        bool            in_leading_wildcard_meta = false;
 
277
        bool            in_trailing_wildcard_meta = false;
277
278
        bool            in_escape = false;
278
279
        int                     clen;
279
280
 
280
281
        /*
281
 
         * Find the first word character remembering whether last character was
282
 
         * wildcard meta-character.
 
282
         * Find the first word character, remembering whether preceding character
 
283
         * was wildcard meta-character.  Note that the in_escape state persists
 
284
         * from this loop to the next one, since we may exit at a word character
 
285
         * that is in_escape.
283
286
         */
284
287
        while (beginword - str < lenstr)
285
288
        {
286
289
                if (in_escape)
287
290
                {
288
 
                        in_escape = false;
289
 
                        in_wildcard_meta = false;
290
291
                        if (iswordchr(beginword))
291
292
                                break;
 
293
                        in_escape = false;
 
294
                        in_leading_wildcard_meta = false;
292
295
                }
293
296
                else
294
297
                {
295
298
                        if (ISESCAPECHAR(beginword))
296
299
                                in_escape = true;
297
300
                        else if (ISWILDCARDCHAR(beginword))
298
 
                                in_wildcard_meta = true;
 
301
                                in_leading_wildcard_meta = true;
299
302
                        else if (iswordchr(beginword))
300
303
                                break;
301
304
                        else
302
 
                                in_wildcard_meta = false;
 
305
                                in_leading_wildcard_meta = false;
303
306
                }
304
307
                beginword += pg_mblen(beginword);
305
308
        }
311
314
                return NULL;
312
315
 
313
316
        /*
314
 
         * Add left padding spaces if last character wasn't wildcard
 
317
         * Add left padding spaces if preceding character wasn't wildcard
315
318
         * meta-character.
316
319
         */
317
320
        *charlen = 0;
318
 
        if (!in_wildcard_meta)
 
321
        if (!in_leading_wildcard_meta)
319
322
        {
320
323
                if (LPADDING > 0)
321
324
                {
334
337
         * string boundary.  Strip escapes during copy.
335
338
         */
336
339
        endword = beginword;
337
 
        in_wildcard_meta = false;
338
 
        in_escape = false;
339
340
        while (endword - str < lenstr)
340
341
        {
341
342
                clen = pg_mblen(endword);
342
343
                if (in_escape)
343
344
                {
344
 
                        in_escape = false;
345
 
                        in_wildcard_meta = false;
346
345
                        if (iswordchr(endword))
347
346
                        {
348
347
                                memcpy(s, endword, clen);
350
349
                                s += clen;
351
350
                        }
352
351
                        else
 
352
                        {
 
353
                                /*
 
354
                                 * Back up endword to the escape character when stopping at
 
355
                                 * an escaped char, so that subsequent get_wildcard_part will
 
356
                                 * restart from the escape character.  We assume here that
 
357
                                 * escape chars are single-byte.
 
358
                                 */
 
359
                                endword--;
353
360
                                break;
 
361
                        }
 
362
                        in_escape = false;
354
363
                }
355
364
                else
356
365
                {
358
367
                                in_escape = true;
359
368
                        else if (ISWILDCARDCHAR(endword))
360
369
                        {
361
 
                                in_wildcard_meta = true;
 
370
                                in_trailing_wildcard_meta = true;
362
371
                                break;
363
372
                        }
364
373
                        else if (iswordchr(endword))
368
377
                                s += clen;
369
378
                        }
370
379
                        else
371
 
                        {
372
 
                                in_wildcard_meta = false;
373
380
                                break;
374
 
                        }
375
381
                }
376
382
                endword += clen;
377
383
        }
378
384
 
379
385
        /*
380
 
         * Add right padding spaces if last character wasn't wildcard
 
386
         * Add right padding spaces if next character isn't wildcard
381
387
         * meta-character.
382
388
         */
383
 
        if (!in_wildcard_meta)
 
389
        if (!in_trailing_wildcard_meta)
384
390
        {
385
391
                if (RPADDING > 0)
386
392
                {