From: | Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz> |
---|---|
To: | Philip Graham <philip(at)lightbox(dot)org> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #5244: Attempting to rollback to a savepoint after receiving an error with state 55000 the process hangs |
Date: | 2009-12-16 22:59:23 |
Message-ID: | 4B29664B.6010505@catalyst.net.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Philip Graham wrote:
> The following bug has been logged online:
>
> Bug reference: 5244
> Logged by: Philip Graham
> Email address: philip(at)lightbox(dot)org
> PostgreSQL version: 8.3.8
> Operating system: Linux
> Description: Attempting to rollback to a savepoint after receiving an
> error with state 55000 the process hangs
> Details:
>
> This may be a PHP so please excure me if it is.
>
> <?php
> $pdo = new PDO('pgsql:host=localhost;dbname=a_db', 'a_user', 'my_pass');
> $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
>
> echo 'Creating test objects'."\n";
> $pdo->query('CREATE SEQUENCE test_seq');
>
> echo 'Setup complete'."\n";
> $pdo->beginTransaction();
>
> try {
> echo 'Setting savepoint'."\n";
> $pdo->query('SAVEPOINT pre_id_fetch');
> echo 'Fetching value'."\n";
> $stmt = $pdo->query('SELECT currval(\'test_seq\');');
> $curId = $stmt->fetchColumn();
> echo 'Releasing savepoint'."\n";
> $pdo->query('RELEASE SAVEPOINT pre_id_fetch');
> } catch (PDOException $e) {
> echo 'Rolling back'."\n";
> $pdo->query('ROLLBACK TO pre_id_fetch');
> $curId = 0;
> }
>
> echo 'Cur Id: ',$curId,"\n";
>
>
> Running this code it hangs after echoing 'Rolling back', but only hangs
> every other execution (assuming the sequence was deleted first).
>
>
I think you need to be using $pdo->exec instead of $pdo->query for
everything *except* the SELECT operation. The query method is really
only intended for statements returning rows. Making the indicated
changes stops the hang for me (Php 5.3.2)
regards
Mark
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Travers | 2009-12-17 01:14:59 | Re: BUG #5246: Misleading/inconsistent SQLSTATE behavior |
Previous Message | Chris Travers | 2009-12-16 22:36:21 | Re: BUG #5246: Misleading/inconsistent SQLSTATE behavior |