I logged in on my Drupal 5 beta 1 installation as admin. I have tried almost all functions (heavy testing :)) without problems and errors but when i logged out i give many DB warnings.

I had same problem with previous Drupal 5 cvs few days ago but if i tried complete new installation from scratch (i have erase database and create new) this problem go on. Now is again here.

I have installed DEVEL module and i discover this weird thing.

0.93 0 db_lock_table BEGIN; LOCK TABLE drupal_cache_page IN EXCLUSIVE MODE

2.04 0 cache_set UPDATE drupal_cache_page SET data = '�', created = 1162451974, expire = -1, headers = 'Content-Type: text/html; charset=utf-8' WHERE cid = 'http://www.fem.uniag.sk/drupal5/'

0.84 0 cache_set INSERT INTO drupal_cache_page (cid, data, created, expire, headers) VALUES ('http://www.fem.uniag.sk/drupal5/', '�', 1162451974, -1, 'Content-Type: text/html; charset=utf-8')

0.39 0 db_unlock_tables COMMIT

I don't understand where DRUPAL get this character which is generate errors:

Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid byte sequence for encoding "UNICODE": 0x8b in /data/www/htdocs.cms/drupal/includes/database.pgsql.inc on line 125

Warning: ERROR: invalid byte sequence for encoding "UNICODE": 0x8b query: cache_set UPDATE drupal_cache_page SET data = '�', created = 1162451974, expire = -1, headers = 'Content-Type: text/html; charset=utf-8' WHERE cid = 'http://www.fem.uniag.sk/drupal5/' in /data/www/htdocs.cms/drupal/includes/database.pgsql.inc on line 144

Warning: pg_affected_rows(): supplied argument is not a valid PostgreSQL result resource in /data/www/htdocs.cms/drupal/includes/database.pgsql.inc on line 241

I have enable locale module with selected SK language (but for now without any translations). This error i get only if i not logged in. I have tried disable localization but errors still presents. Nov i have enable devel module for anonymous users too.

Here is site: http://www.fem.uniag.sk/drupal5/

Comments

havran’s picture

Title: Weird character in cache... » Problem with page caching (binary data)
Version: x.y.z » 5.0-beta1
Component: base system » postgresql database
Priority: Normal » Critical

I have examine this problem and i discover problem in cache_set() function from file includes/cache.inc (look for 3 exclamation mark :))

function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
  db_lock_table($table);
  // !!! binary $data is inserted as string !!!
  db_query("UPDATE {%s} SET data = '%s', created = %d, expire = %d, headers = '%s' 
    WHERE cid = '%s'", $table, $data, time(), $expire, $headers, $cid);
  if (!db_affected_rows()) {
    @db_query("INSERT INTO {%s} (cid, data, created, expire, headers) 
      VALUES ('%s', '%s', %d, %d, '%s')", $table, $cid, $data, time(), $expire, $headers);
  }
  db_unlock_tables();
}

should be

function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
  db_lock_table($table);
  // !!! binary $data need %b !!!
  db_query("UPDATE {%s} SET data = %b, created = %d, expire = %d, headers = '%s' 
    WHERE cid = '%s'", $table, $data, time(), $expire, $headers, $cid);
  if (!db_affected_rows()) {
    @db_query("INSERT INTO {%s} (cid, data, created, expire, headers) 
      VALUES ('%s', '%s', %d, %d, '%s')", $table, $cid, $data, time(), $expire, $headers);
  }
  db_unlock_tables();
}

Same problem is too in CVS version.

havran’s picture

I miss same error in INSERT query, here is corrected version of function cache_set:

function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
  db_lock_table($table);
  db_query("UPDATE {%s} SET data = %b, created = %d, expire = %d, headers = '%s' 
    WHERE cid = '%s'", $table, $data, time(), $expire, $headers, $cid);
  if (!db_affected_rows()) {
    @db_query("INSERT INTO {%s} (cid, data, created, expire, headers) 
      VALUES ('%s', %b, %d, %d, '%s')", $table, $cid, $data, time(), $expire, $headers);
  }
  db_unlock_tables();
}
havran’s picture

Hmm sorry this problem need some more examination from caching system guru - now i have much more problems then before.

Warning: pg_query() [function.pg-query]: Query failed: ERROR: value for domain int_unsigned violates check constraint "$1" in /data/www/htdocs.cms/drupal/includes/database.pgsql.inc on line 125

Warning: ERROR: value for domain int_unsigned violates check constraint "$1" query: statistics_init INSERT INTO drupal_accesslog (title, path, url, hostname, uid, sid, timer, timestamp) values('', 'node', '', '194.160.91.90', 0, '78f390986cade389ebabf6d2b4ae9044', -1388829454, 1162547307) in /data/www/htdocs.cms/drupal/includes/database.pgsql.inc on line 144

Warning: Cannot modify header information - headers already sent by (output started at /data/www/htdocs.cms/drupal/includes/database.pgsql.inc:125) in /data/www/htdocs.cms/drupal/includes/bootstrap.inc on line 430

Warning: Cannot modify header information - headers already sent by (output started at /data/www/htdocs.cms/drupal/includes/database.pgsql.inc:125) in /data/www/htdocs.cms/drupal/includes/bootstrap.inc on line 431

Warning: Cannot modify header information - headers already sent by (output started at /data/www/htdocs.cms/drupal/includes/database.pgsql.inc:125) in /data/www/htdocs.cms/drupal/includes/bootstrap.inc on line 434

Warning: Cannot modify header information - headers already sent by (output started at /data/www/htdocs.cms/drupal/includes/database.pgsql.inc:125) in /data/www/htdocs.cms/drupal/includes/bootstrap.inc on line 435

Warning: Cannot modify header information - headers already sent by (output started at /data/www/htdocs.cms/drupal/includes/database.pgsql.inc:125) in /data/www/htdocs.cms/drupal/includes/bootstrap.inc on line 443

Warning: Cannot modify header information - headers already sent by (output started at /data/www/htdocs.cms/drupal/includes/database.pgsql.inc:125) in /data/www/htdocs.cms/drupal/includes/bootstrap.inc on line 451
�[binary data]
havran’s picture

PS: this problem is present only when is caching enabled and when i not logged in. Devel module help me for examination this...

doq’s picture

Looks like devel module breaks smth - there is timer < 0. Please, submit new issue for this.

And then close this issue marking this as duplicate for http://drupal.org/node/92430 .

doq’s picture

Smth strange has happed with my prev/ post.

Looks like the problem is with devel module or with somewhere in Drupal - timer value is < 0. Please create new issue for this. And then mark current issue as duplicate of http://drupal.org/node/92430 .

doq’s picture

Smth strange has happed with my prev/ post.

Looks like the problem is with devel module or with somewhere in Drupal - timer value is < 0. Please create new issue for this. And then mark current issue as duplicate of http://drupal.org/node/92430 .

doq’s picture

hmmmmm. IE maybe:)

doq’s picture

Smth strange has happed with my prev/ post.

Looks like the problem is with devel module or with somewhere in Drupal - timer value is < 0.

Please create new issue for this.

And then mark current issue as duplicate of http://drupal.org/node/92430 .

doq’s picture

Smth strange has happed with my prev/ post.

Looks like the problem is with devel module or with somewhere in Drupal - timer value is less 0.

Please create new issue for this.

And then mark current issue as duplicate of http://drupal.org/node/92430 .

doq’s picture

Smth strange has happed with my prev/ post.

Looks like the problem is with devel module or with somewhere in Drupal - timer value is less 0.

Please create new issue for this.

And then mark current issue as duplicate of http://drupal.org/node/92430 .

havran’s picture

I have tried patch from http://drupal.org/node/92430 second time and i agre - patch is god and working. Now here is new problem - with negative value which is return from function timer_read('page') in function statistics_init() (in statistics.module).

Warning: pg_query() [function.pg-query]: Query failed: ERROR: value for domain int_unsigned violates check constraint "$1" in /data/www/htdocs.cms/drupal/includes/database.pgsql.inc on line 125

Warning: ERROR: value for domain int_unsigned violates check constraint "$1" query: statistics_init INSERT INTO drupal_accesslog (title, path, url, hostname, uid, sid, timer, timestamp) values('', 'node', 'http://www.fem.uniag.sk/drupal5/?q=admin/build/modules', '217.144.19.169', 0, '5a66e03780ed81070702f6a741b4de58', -1007718779, 1162928418) in /data/www/htdocs.cms/drupal/includes/database.pgsql.inc on line 144
havran’s picture

Status: Active » Closed (duplicate)

Ok, this is duplicate with http://drupal.org/node/92430 - now we have only one thread :)