6.0.0-beta1
7/8/25

[#10602] Broken Postgresql value encoding
Summary Broken Postgresql value encoding
Queue Horde Framework Packages
Queue Version Git master
Type Bug
State Resolved
Priority 3. High
Owners slusarz (at) horde (dot) org
Requester slusarz (at) horde (dot) org
Created 10/03/2011 (5027 days ago)
Due
Updated 10/07/2011 (5023 days ago)
Assigned 10/03/2011 (5027 days ago)
Resolved 10/07/2011 (5023 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
10/07/2011 06:58:56 PM Michael Slusarz State ⇒ Resolved
 
10/07/2011 02:23:58 PM Jan Schneider Comment #11 Reply to this comment
All unit test run fine now with 8.1.11 and 8.4.8.
10/04/2011 06:51:35 PM Michael Slusarz Comment #10 Reply to this comment
This fixes on 9.1, and *should* fix on 8.1 also.

However, it doesn't use quotedStringPrefix() anymore.  That is because 
this was failing to add the 'E' prefix, since 
Horde_Db_Adapter_Postgresql_Schema is extending 
Horde_Db_Adapter_Base_Schema which will always return the empty 
string.  The dynamic determination of whether to add 'E' is instead in 
Horde_Db_Adapter_Pdo_Pgsql.

So #1 - quoteBinary() doesn't have any access to this adapter object.   
And #2, why do we even need this anyway?  Once we escape the string by 
converting characters to octets, we necessarily need to report this to 
the postgres as an escaped string, which means we must ALWAYS use the 
'E' prefix.

So I'm going to go ahead and remove the quotedStringPrefix() code.  It 
sort of looks like an artifact given the new Horde_Db_Value_Binary 
code, and it isn't used anymore after this fix.
10/04/2011 06:51:30 PM Git Commit Comment #9 Reply to this comment
Changes have been made in Git for this ticket:

Bug #10602: changelog

  1 files changed, 1 insertions(+), 1 deletions(-)
http://git.horde.org/horde-git/-/commit/2baf7b69bd3ae2c671b999e86e8cb3e84c0577cd
10/04/2011 06:51:26 PM Git Commit Comment #8 Reply to this comment
Changes have been made in Git for this ticket:

Bug #10602: Remove quotedStringPrefix() code

  2 files changed, 0 insertions(+), 30 deletions(-)
http://git.horde.org/horde-git/-/commit/ef2ae176105eb03feabc06181447a13e77e19ae5
10/04/2011 06:41:18 PM Git Commit Comment #7 Reply to this comment
Changes have been made in Git for this ticket:

Bug #10602: Forgot to add this - this should fix escaping on older versions

  1 files changed, 1 insertions(+), 1 deletions(-)
http://git.horde.org/horde-git/-/commit/184546702d610850adcf31e2295a1773894b6153
10/04/2011 06:39:38 PM Git Commit Comment #6 Reply to this comment
Changes have been made in Git for this ticket:

Bug #10602: Fix binary encoding on Postgres - take 2

  1 files changed, 2 insertions(+), 2 deletions(-)
http://git.horde.org/horde-git/-/commit/c5bbd54c9155ece725176f4f13fff04386b99861
10/04/2011 12:17:03 PM Jan Schneider Comment #5 Reply to this comment
On 8.1:

1) Horde_Db_Adapter_Pdo_PgsqlTest::testQuoteBinary
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-foobar\baz'boo\'bee
+foo

/home/jan/horde-git/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php:328

10/04/2011 08:10:39 AM Jan Schneider Comment #4
Assigned to Michael Slusarz
Reply to this comment
But I have no idea if this breaks 9.0.
It breaks on 8.4.

Horde_Db_Exception: SQLSTATE[22021]: Character not in repertoire: 7 
ERROR:  invalid byte sequence for encoding "UTF8": 0x00
HINT:  This error can also happen if the byte sequence does not match 
the encoding expected by the server, which is controlled by 
"client_encoding".
10/03/2011 10:59:37 PM Michael Slusarz Comment #3
State ⇒ Feedback
Reply to this comment
Without this fix, Postgresql unit tests were failing.  I was receiving 
this issue:

1) Horde_Db_Adapter_Pdo_PgsqlTest::testQuoteBinary
Horde_Db_Exception: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax 
error at or near "boo"
LINE 1: ..._testings (data) VALUES ('foo\\000bar\\\\ba\\172\'boo\\\\\'b...

This now works on this server:

slusarz@bigworm % psql --version
psql (PostgreSQL) 9.1.1

But I have no idea if this breaks 9.0.
10/03/2011 10:57:43 PM Git Commit Comment #2 Reply to this comment
Changes have been made in Git for this ticket:

Bug #10602: Fix broken postgresql binary encoding

  1 files changed, 1 insertions(+), 7 deletions(-)
http://git.horde.org/horde-git/-/commit/fd87138ebb5cf13718bb923e861c35521e7ce619
10/03/2011 10:57:18 PM Michael Slusarz Comment #1
Patch ⇒ No
State ⇒ Unconfirmed
Milestone ⇒
Queue ⇒ Horde Framework Packages
Summary ⇒ Broken Postgresql value encoding
Type ⇒ Bug
Priority ⇒ 3. High
Reply to this comment
As of Postgresql 9.1, binary quoting no longer works.

Saved Queries