Req #69457 [NEW]: pg_copy_from: order of table fields

From: Date: Wed, 15 Apr 2015 08:14:22 +0000
Subject: Req #69457 [NEW]: pg_copy_from: order of table fields
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192078@lists.php.net to get a copy of this message
From: okoanton at yandex dot ru Operating system: any PHP version: 5.6.7 Package: PostgreSQL related Bug Type: Feature/Change Request Bug description:pg_copy_from: order of table fields Description: ------------ pg_copy_from is a wrapper of postgresql syntax COPY test FROM stdin But in postgresql people usually do this: COPY test (field1, field2, field3) FROM stdin; So I can describe fields and its order. pg_copy_from without fields order is dangerous to use, because table can be changed by somebody. Test script: --------------- -- sql: CREATE TABLE test ( field1 int, field2 int ); // php: $rows = [1, 2]; pg_copy_from($db, $table_name, $rows); -- sql -- change order of fields DROP TABLE test; CREATE TABLE test ( field2 int, field1 int ); // php script without changes $rows = [1, 2]; pg_copy_from($db, $table_name, $rows); //it inserts data into wrong fields Expected result: ---------------- a new parameter should be added to pg_copy_from to describe fields order Actual result: -------------- result depends of table -- Edit bug report at https://bugs.php.net/bug.php?id=69457&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69457&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69457&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69457&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69457&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69457&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69457&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69457&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69457&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69457&r=support Expected behavior: https://bugs.php.net/fix.php?id=69457&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69457&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69457&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69457&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69457&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69457&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69457&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69457&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69457&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69457&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69457&r=mysqlcfg

« previous php.bugs (#192078) next »