Query failed: ERROR: duplicate key violates unique constrain

Found a bug? Tell us!!
Post Reply
ndv
Posts: 3
Joined: Tue Jun 01, 2004 12:18 pm
Contact:

Query failed: ERROR: duplicate key violates unique constrain

Post by ndv »

Hi!

I'm not sure if this is a bug (maybe I did sth wrong during installation?), but FYI: I sometimes got this warning on my blog:
Warning: pg_query(): Query failed: ERROR: duplicate key violates unique constraint "url" . in /home/neodave/public_html/serendipity/serendipity_db_postgres.inc.php on line 63
This on Postgres 7.4
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Query failed: ERROR: duplicate key violates unique const

Post by garvinhicking »

Hi!

Could you please set the $serendipity['procution'] value to '0' inside your serendipity_config.inc.php file? If that is set, the error message should be more verbose and I can have a look at it.

Sadly most of the users (including myself) use MySQL-DB and therefore I don't have that much experience with PgSQL...

Regards,
Garvin.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ndv
Posts: 3
Joined: Tue Jun 01, 2004 12:18 pm
Contact:

Post by ndv »

sure, I just set production to 0.

Just in case this error won't be triggered up when you will be on my blog, I will copy here what I got:

Code: Select all

Notice: Undefined index: port in /home/neodave/public_html/serendipity/serendipity_functions.inc.php on line 2275
 
Notice: Undefined index: port in /home/neodave/public_html/serendipity/serendipity_functions.inc.php on line 2285
 
Notice: Undefined index: port in /home/neodave/public_html/serendipity/serendipity_functions.inc.php on line 2290
 
Warning: pg_query(): Query failed: ERROR: duplicate key violates unique constraint "url" . in /home/neodave/public_html/serendipity/serendipity_db_postgres.inc.php on line 63
 Error in INSERT INTO serendipity_suppress (ip, last, scheme, host, port, path, query) VALUES ('62.87.244.34', now(), 'http', 'php-blog.sourceforge.net', '', '/forums/viewtopic.php', 'p=840')
 ERROR: duplicate key violates unique constraint "url" array (
  0 => 
  array (
    'file' => '/home/neodave/public_html/serendipity/serendipity_functions.inc.php',
    'line' => 2295,
    'function' => 'serendipity_db_query',
    'args' => 
    array (
      0 => 'INSERT INTO serendipity_suppress
                      (ip, last, scheme, host, port, path, query)
                      VALUES (\'62.87.244.34\', now(), \'http\', \'php-blog.sourceforge.net\', \'\', \'/forums/viewtopic.php\', \'p=840\')',
    ),
  ),
  1 => 
  array (
    'file' => '/home/neodave/public_html/serendipity/index.php',
    'line' => 184,
    'function' => 'serendipity_track_referrer',
    'args' => 
    array (
    ),
  ),
) 
INSERT INTO serendipity_suppress (ip, last, scheme, host, port, path, query) VALUES ('62.87.244.34', now(), 'http', 'php-blog.sourceforge.net', '', '/forums/viewtopic.php', 'p=840')
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Thanks, your input was valuable. Could you now please edit your serendipity_config.inc.php and search for the serendipity_track_referrer function. You will then see something like:

Code: Select all

        $suppressu = "INSERT INTO $serendipity[dbPrefix]suppress
                      (ip, last, scheme, host, port, path, query)
                      VALUES ('$_SERVER[REMOTE_ADDR]', now(), '$url_parts[scheme]', '$url_parts[host]', '$url_parts[port]', '$url_parts[path]', '$url_parts[query]')";
change that into:

Code: Select all

        $suppressu = "REPLACE INTO $serendipity[dbPrefix]suppress
                      (ip, last, scheme, host, port, path, query)
                      VALUES ('$_SERVER[REMOTE_ADDR]', now(), '$url_parts[scheme]', '$url_parts[host]', '$url_parts[port]', '$url_parts[path]', '$url_parts[query]')";
That should do the trick for you - and please tell if it works, so we can include it into our codebase.

Thanks,
Garvin.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ndv
Posts: 3
Joined: Tue Jun 01, 2004 12:18 pm
Contact:

Post by ndv »

I have found (and changed how you suggested) serendipity_track_referrer() function in serendipity_functions.inc.php file, not in serendipity_config.inc.php, but I understand this was small mistake. ;)

However, fix seems to not work. :-(

Now I get:

Code: Select all

Warning: pg_query(): Query failed: ERROR: syntax error at or near "REPLACE" at character 1 . in /home/neodave/public_html/serendipity/serendipity_db_postgres.inc.php on line 63
 Error in REPLACE INTO serendipity_suppress (ip, last, scheme, host, port, path, query) VALUES ('62.87.244.34', now(), 'http', 'www.neodave.civ.pl', '', '/', '')
 ERROR: syntax error at or near "REPLACE" at character 1 array (
  0 => 
  array (
    'file' => '/home/neodave/public_html/serendipity/serendipity_functions.inc.php',
    'line' => 2304,
    'function' => 'serendipity_db_query',
    'args' => 
    array (
      0 => 'REPLACE INTO serendipity_suppress
                      (ip, last, scheme, host, port, path, query)
                      VALUES (\'62.87.244.34\', now(), \'http\', \'www.neodave.civ.pl\', \'\', \'/\', \'\')',
    ),
  ),
  1 => 
  array (
    'file' => '/home/neodave/public_html/serendipity/index.php',
    'line' => 184,
    'function' => 'serendipity_track_referrer',
    'args' => 
    array (
    ),
  ),
) 
REPLACE INTO serendipity_suppress (ip, last, scheme, host, port, path, query) VALUES ('62.87.244.34', now(), 'http', 'www.neodave.civ.pl', '', '/', '')
Post Reply