[PHP-BUG] Bug #71176 [NEW]: Updating records within a limit/offset loop misses records

[email protected] ("espadav8 at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             espadav8 at gmail dot com
Operating system: OS X and Linux
PHP version:      7.0.1
Package:          PDO PgSQL
Bug Type:         Bug
Bug description:Updating records within a limit/offset loop misses records

Description:
------------
When looping over all records in the database using 'limit X offset Y'
to update a column, the postgres PDO driver will start to return the
same records again for different offset values. It gets worse the
smaller the limit size compared to the dataset size.

Test script:
---------------
https://github.com/EspadaV8/laravel-chunking-non-persistance/blob/develop/public/pg-pdo-test.php

Script assumes that there is a database with a table called `example`
with columns `id` (serial), `name` (text) and `name-new` (text).

Expected result:
----------------
ID: 72 - Name: 5677360fde707 - Name new: 5677360fde707-qwe
ID: 69 - Name: 5677360fdde80 - Name new: 5677360fdde80-qwe
ID: 70 - Name: 5677360fde241 - Name new: 5677360fde241-qwe
ID: 71 - Name: 5677360fde4c3 - Name new: 5677360fde4c3-qwe

Actual result:
--------------
Depending on the limit to dataset size (limit 1, 4 records)

ID: 62 - Name: 567735dbccacd - Name new: 567735dbccacd
ID: 64 - Name: 567735dbccffc - Name new: 567735dbccffc
ID: 63 - Name: 567735dbccd4c - Name new: 567735dbccd4c-qwe
ID: 61 - Name: 567735dbcc64b - Name new: 567735dbcc64b-qwe-qwe-qwe

or (limit 3, 4 records)

ID: 72 - Name: 5677360fde707 - Name new: 5677360fde707
ID: 69 - Name: 5677360fdde80 - Name new: 5677360fdde80-qwe
ID: 70 - Name: 5677360fde241 - Name new: 5677360fde241-qwe
ID: 71 - Name: 5677360fde4c3 - Name new: 5677360fde4c3-qwe-qwe

-- 
Edit bug report at https://bugs.php.net/bug.php?id=71176&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71176&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71176&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71176&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71176&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71176&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71176&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71176&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71176&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71176&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71176&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71176&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71176&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71176&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71176&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71176&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71176&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71176&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71176&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71176&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71176&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.