php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58772 PDO::fetchAll() issue with INSERT on view
Submitted: 2009-07-23 11:19 UTC Modified: 2013-10-15 11:54 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: michael dot leuthold at googlemail dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.2.6 OS: Linux / Debian
Private report: No CVE-ID: None
 [2009-07-23 11:19 UTC] michael dot leuthold at googlemail dot com
Description:
------------
"ON INSERT" rule on view returns rows which cannot be retrieved by PDO::fetchAll():

We have a view that has a ON INSERT DO INSTEAD rule. In this rule the insert on the view is basically split to do the actual inserts into the individual tables. In the end it SELECTs the new row (which has just been created) from that view. Doing this in psql for example behaves like expected: after the INSERT  the new row is returned.

We haven't managed to retrieve that row into an array via "PDO::fetchAll(PDO::FETCH_ASSOC)" - for some reason PDO seems to ignore that returned data - though PDO::rowCount returns 1 (actually it does always return 1 no matter how many rows are expected to be returned by that INSERT).

This scenario works as expected when connected via PHP's pg_connect using pg_fetch_all.


Information from phpinfo():

pdo_pgsql
PDO Driver for PostgreSQL	enabled
PostgreSQL(libpq) Version 	8.3.7
Module version 	1.0.2
Revision 	$Id: pdo_pgsql.c,v 1.7.2.11.2.2 2007/12/31 07:20:10 sebastian Exp $ 


Reproduce code:
---------------
For a small schema setup run this file through psql:
http://www.byoc.de/pdo-pgsql.sql.txt

This script inserts to the created example view and tries to retrieve the values:
http://www.byoc.de/pdo-pgsql.php.txt

Expected result:
----------------
the associative array should contain all rows returned by the INSERT statement.

Actual result:
--------------
an empty array is returned by PDO::fetchAll though there are rows returned.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-01 10:27 UTC] mike@php.net
-Status: Open +Status: Feedback -Package: PDO_PGSQL +Package: *General Issues
 [2013-10-01 10:27 UTC] mike@php.net
Your reproduce scripts are not available anymore and PQresultStatus for an INSERT that that resolves to a RULE with an SELECT as last statement returns PGRES_COMMAND_OK, so the result is freed regardless.
 [2013-10-15 11:54 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Mar 13 21:01:32 2025 UTC