Projects ⇒ Bugs ⇒ #506: Inserting '' fails on DBs that respect NOT NULL constraint ⇒ CPG Dragonfly™ CMS
Bug #506 Inserting '' fails on DBs that respect NOT NULL constraint
Project: Dragonfly 9.0.3 -> 9.3 Category: SQL
Submitted: Saturday, May 14, 2005 (04:07:17) Modified: Saturday, November 26, 2005 (23:12:10)
Status: Closed Assigned to:
PHP Version: 4.3.10 HTTPD Server: Apache 2.0

View/Vote Add Comment

by: Brennor
Postgres Integration:

This bug is similar in nature to Bug 441.

PostgreSQL doesn't like inserting a '' (a NULL) into a field that is defined as NOT NULL. A value NULL is currently inserted most times a serial/auto_increment field needs to be incremented.

html/includes/coppermine/ (rev 9.7), change line 84 to:
$result = $db->sql_query("INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip) VALUES (DEFAULT, '$aid', '" . $filepath . "', '" . $filename . "', '$image_filesize', '$total_filesize', '".$imginfo[0]."', '".$imginfo[1]."', '" . time() . "', '" . USER_ID . "', '$title', '$caption', '$keywords', '$approved', '$user1', '$user2', '$user3', '$user4', '$raw_ip', '$hdr_ip')",false,__FILE__, __LINE__);

html/modules/coppermine/groupmgr.php (rev 9.3), change lines 34-37 to:
$db->sql_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} VALUES (DEFAULT, 'Administrators', 0, 1, 1, 1, 1, 1, 1)",false,__FILE__, __LINE__);
$db->sql_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} VALUES (DEFAULT, 'Registered', 1024, 0, 1, 1, 1, 1, 1)",false,__FILE__, __LINE__);
$db->sql_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} VALUES (DEFAULT, 'Anonymous', 0, 0, 0, 0, 1, 0, 0)",false,__FILE__, __LINE__);
$db->sql_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} VALUES (DEFAULT, 'Banned', 0, 0, 0, 0, 0, 0, 0);",false,__FILE__, __LINE__);

html/modules/coppermine/install.php (rev 9.0), change line 220 to:
$sql[] = "INSERT INTO `".$prefix."_cpg_installs` VALUES(DEFAULT, '" . $dirname . "', '" . $_POST['table_prefix'] . "', '$CPG_VERSION');";
by: DJMaze
Strange because '' is actualy NOT NULL, a real NOT NULL field is queried as NULL.


If PostgreSQL complaints about this behavior then we will change the database fields to allow NULL and add a remark to the documentation or something.
by: Brennor
Actually, when inserting into an integer field '' is taken as a NULL... there IS no number.

That's the real problem. All of those IDs are defined as integers and then something that is NOT an integer is inserted into the DB.
by: DJMaze
This bug has been fixed in the CVS.

Snapshots of the sources are packaged every 6 hours; this change
will be in the next snapshot. You can grab the snapshot at the
Downloads section.

Thank you for the report, and for helping us to make CPG-Nuke 9.0.3 -> 9.1 better.
User Info

Welcome Anonymous


Support for DragonflyCMS in a other languages: