Problem/Motivation

NodeCreationTest fails currently with PostgreSQL as database backend.

Proposed resolution

Identify and fix the failing tests.

Remaining tasks

Write patch.

User interface changes

None.

API changes

None.

Comments

grom358’s picture

So this test fails due to the PHP PDO pgsql driver with doing a LIKE query on a bytea field. There is an attempt at workaround already there but it does not work.

  public function prepareQuery($query) {
    // mapConditionOperator converts LIKE operations to ILIKE for consistency
    // with MySQL. However, Postgres does not support ILIKE on bytea (blobs)
    // fields.
    // To make the ILIKE operator work, we type-cast bytea fields into text.
    // @todo This workaround only affects bytea fields, but the involved field
    //   types involved in the query are unknown, so there is no way to
    //   conditionally execute this for affected queries only.
    return parent::prepareQuery(preg_replace('/ ([^ ]+) +(I*LIKE|NOT +I*LIKE) /i', ' ${1}::text ${2} ', $query));
  }
grom358’s picture

Status: Active » Needs review
StatusFileSize
new689 bytes

I tried doing the CONVERT_FROM inside the Connection class but to no success. So patched the query for this single test. Really we shouldn't be using serialized PHP. See #839444: Make serializer customizable for Cache\DatabaseBackend

Status: Needs review » Needs work

The last submitted patch, 2: 244366-pgsql-node-creation-test.5ad41ab.patch, failed testing.

bzrudi71’s picture

@grom358: Thanks a lot! There is already a (broken) patch available #2238253: Add bindValue to a PDO::PARAM_* type in database query arguments that might fix bytea selects. If we can't get that one working I think we should just change the test to unserialize first.

grom358’s picture

Status: Needs work » Needs review
StatusFileSize
new906 bytes

Use PHP to filter the log messages.

So in Postgres 9 they added the Hex format for bytea. ::text with PDO driver will use the hex format and hence using a LIKE on ::text for bytea fields doesn't work for postgres 9

What other places is the preg_replace hack used on LIKE conditions?

grom358’s picture

Issue tags: -PostgreSQL +PostgreSQL DrupalSouth
daffie’s picture

Status: Needs review » Reviewed & tested by the community

It all looks good to me.
I can confirm that the test fails for postgreSQL and with the patch the test passes for postgreSQL.
So for me it is RTBC.

bzrudi71’s picture

Status: Reviewed & tested by the community » Needs review

Setting back to needs review because we should check if this is fixed by #2238253: Add bindValue to a PDO::PARAM_* type in database query arguments first, @grom358 did a patch reroll. If it doesn't pass, the patch in this issue is the way to go and this can be set to RTBC again :-)

bzrudi71’s picture

Status: Needs review » Reviewed & tested by the community

Sadly no pass with #2238253: Add bindValue to a PDO::PARAM_* type in database query arguments applied. We do nowhere a bytea select in core but within this test, so the patch here is the way to go and we should leave bytea select open as a feature request. Back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Let's add a comment as to why this method is as complex as it is.

bzrudi71’s picture

StatusFileSize
new1.02 KB

Added comment.

bzrudi71’s picture

Status: Needs work » Needs review
daffie’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

  • catch committed 1483ef1 on 8.0.x
    Issue #2443665 by grom358, bzrudi71: PostgreSQL: Fix node\Tests\...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Comment looks good. I don't see a nice way to fix this without a lot more changes. Committed/pushed to 8.0.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

quietone’s picture

Issue tags: -PostgreSQL DrupalSouth +PostgreSQL, +DrupalSouth