PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2_Driver_oci8 » Bug #7109

Oracle Driver, Autoincremement Constraint problem

Details

Submitted2006-03-13 14:43 UTC
Fromnolife at gmail dot com
Assignedlsmith
StatusClosed
PackageMDB2_Driver_oci8
PHP Version5.1.2
OSLinux
Roadmaps(Not assigned)

Comments

[2006-03-13 14:43 UTC] nolife at gmail dot com

Description:
------------
When creating an autoincrement field mdb2 creates a constraint .
The name is based on the tablename and the constant "AUTOINCREMENT_PK"
This is used for various things.
My Oracle 9R2 defaults to a varchar2(30) for the constraint identifier, this limits the table size and the reportet pear error does not really help debugging the problem.

Test script:
---------------
hotfix that solves the problem for me, suggested is a validation that tests the table string length
--------------------------------------------------------
--- oci8_orig.php 2006-03-10 14:26:19.000000000 +0100
+++ oci8.php 2006-03-13 14:36:18.000000000 +0100
@@ -140,7 +140,7 @@
}

$table = strtoupper($table);
- $index_name = $table . '_AUTOINCREMENT_PK';
+ $index_name = $table . '_AUTOINC_PK';
$definition = array(
'primary' => true,
'fields' => array($name => true),
@@ -169,7 +169,7 @@
'_makeAutoincrement: sequence for autoincrement PK could not be created');
}
$sequence_name = $db->getSequenceName($table);
- $trigger_name = $db->quoteIdentifier($table . '_AUTOINCREMENT_PK', true);
+ $trigger_name = $db->quoteIdentifier($table . '_AUTOINC_PK', true);
$table = $db->quoteIdentifier($table, true);
$name = $db->quoteIdentifier($name, true);
$trigger_sql = "CREATE TRIGGER $trigger_name BEFORE INSERT ON $table";
@@ -196,7 +196,7 @@
}

$table = strtoupper($table);
- $trigger_name = $table . '_AUTOINCREMENT_PK';
+ $trigger_name = $table . '_AUTOINC_PK';
$trigger_name = $db->quoteIdentifier($trigger_name, true);
$trigger = $db->queryOne("SELECT trigger_name FROM user_triggers WHERE trigger_name = '$trigger_name'");
if (PEAR::isError($trigger)) {
@@ -217,7 +217,7 @@
'_dropAutoincrement: sequence for autoincrement PK could not be dropped');
}

- $index_name = $table . '_AUTOINCREMENT_PK';
+ $index_name = $table . '_AUTOINC_PK';
$result = $db->manager->dropConstraint($table, $index_name);
if (PEAR::isError($result)) {
return $db->raiseError(MDB2_ERROR, null, null,
@@ -795,4 +795,4 @@
return $result;
}
}
-?>
\ Kein Zeilenumbruch am Dateiende.
+?>
--------------------------------------------------------