question about postgres persistent connection in php

From: "Yulius Tjahjadi" <yulius(at)xfire(dot)com>
To: <postgres-php(at)postgresql(dot)org>
Subject: question about postgres persistent connection in php
Date: 2005-03-29 03:43:35
Message-ID: 08F5636B48FE8F4D856E209D0E6C0637A83E56@hq01.ultimatearena.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hi,

I have a question about the postgres interface in php. The
implementation for
a persistent connection calls _rollback_transactions. I was just
wondering
what exactly does the bottom section do by calling BEGIN; and then
ROLLBACK;.
It would seem like it's wasting cpu cycles to start up a transaction and
then rolling back the transactions doing nothing.

I'm looking at php 4.3.10 and I'm using postgres 8.0.1.

yulius

/* {{{ _rollback_transactions
*/
static int _rollback_transactions(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
PGconn *link;
PGresult *res;
int orig;

if (Z_TYPE_P(rsrc) != le_plink)
return 0;

link = (PGconn *) rsrc->ptr;

if (PQ_SETNONBLOCKING(link, 0)) {
php_error_docref("ref.pgsql" TSRMLS_CC, E_NOTICE,
"Cannot set connection to blocking mode");
return -1;
}

while ((res = PQgetResult(link))) {
PQclear(res);
}
orig = PGG(ignore_notices);
PGG(ignore_notices) = 1;
res = PQexec(link,"BEGIN;");
PQclear(res);
res = PQexec(link,"ROLLBACK;");
PQclear(res);
PGG(ignore_notices) = orig;

return 0;
}
/* }}} */

Browse pgsql-php by date

  From Date Subject
Next Message Eko Budi Setiyo 2005-03-29 05:12:08 sql command
Previous Message Christopher Kings-Lynne 2005-03-29 03:26:13 Re: New PHP/PostgreSQL functions