<commit_before>Index: skeleton/rdbms/sybase/SybaseConnection.class.php
===================================================================
--- skeleton/rdbms/sybase/SybaseConnection.class.php	(revision 12005)
+++ skeleton/rdbms/sybase/SybaseConnection.class.php	(working copy)
@@ -22,7 +22,6 @@
    * @purpose  Database connection
    */
   class SybaseConnection extends DBConnection {
-  
     private
       $formatter= NULL;
 
@@ -62,7 +61,7 @@
       }
 
       if (!is_resource($this->handle)) {
-        throw(new SQLConnectException(trim(sybase_get_last_message()), $this->dsn));
+        throw new SQLConnectException(trim(sybase_get_last_message()), $this->dsn);
       }
       
       $this->_obs && $this->notifyObservers(new DBEvent(__FUNCTION__, $reconnect));
@@ -91,11 +90,11 @@
      */
     public function selectdb($db) {
       if (!sybase_select_db($db, $this->handle)) {
-        throw(new SQLStatementFailedException(
+        throw new SQLStatementFailedException(
           'Cannot select database: '.trim(sybase_get_last_message()),
           'use '.$db,
           current(sybase_fetch_row(sybase_query('select @@error', $this->handle)))
-        ));
+        );
       }
       return TRUE;
     }
@@ -209,11 +208,11 @@
       $sql= call_user_func_array(array($this, 'prepare'), $args);
 
       if (!is_resource($this->handle)) {
-        if (!($this->flags & DB_AUTOCONNECT)) throw(new SQLStateException('Not connected'));
+        if (!($this->flags & DB_AUTOCONNECT)) throw new SQLStateException('Not connected');
         $c= $this->connect();
         
         // Check for subsequent connection errors
-        if (FALSE === $c) throw(new SQLStateException('Previously failed to connect'));
+        if (FALSE === $c) throw new SQLStateException('Previously failed to connect');
       }
       
       $this->_obs && $this->notifyObservers(new DBEvent(__FUNCTION__, $sql));
@@ -233,17 +232,19 @@
           // Sybase:  Client message:  Read from SQL server failed. (severity 78)
           //
           // but that seems a bit errorprone. 
-          throw(new SQLConnectionClosedException(
+          throw new SQLConnectionClosedException(
             'Statement failed: '.trim(sybase_get_last_message()), 
             $sql
-          ));
+          );
         }
-
-        throw(new SQLStatementFailedException(
-          'Statement failed: '.trim(sybase_get_last_message()), 
-          $sql,
-          current(sybase_fetch_row($error))
-        ));
+        
+        $code= current(sybase_fetch_row($error));
+        $message= trim(sybase_get_last_message());
+        if (1205 == $code) {
+          throw new SQLDeadlockException($message, $sql);
+        } else {
+          throw new SQLStatementFailedException('Statement failed: '.$message, $sql, $code);
+        }
       }
       
       if (TRUE === $result) {
Index: skeleton/rdbms/sybase/SybaseResultSet.class.php
===================================================================
--- skeleton/rdbms/sybase/SybaseResultSet.class.php	(revision 12005)
+++ skeleton/rdbms/sybase/SybaseResultSet.class.php	(working copy)
@@ -39,7 +39,7 @@
      */
     public function seek($offset) { 
       if (!sybase_data_seek($this->handle, $offset)) {
-        throw(new SQLException('Cannot seek to offset '.$offset));
+        throw new SQLException('Cannot seek to offset '.$offset);
       }
       return TRUE;
     }
Index: skeleton/rdbms/DBTableAttribute.class.php
===================================================================
--- skeleton/rdbms/DBTableAttribute.class.php	(revision 12005)
+++ skeleton/rdbms/DBTableAttribute.class.php	(working copy)
@@ -44,7 +44,7 @@
     public 
       $name=        '',
       $type=        -1,
-      $ident=       FALSE,
+      $identity=    FALSE,
       $nullable=    FALSE,
       $length=      0,
       $precision=   0,
@@ -77,10 +77,27 @@
       $this->length= $length;
       $this->precision= $precision;
       $this->scale= $scale;<commit_msg>- Add rdbms.SQLDeadlockException class<commit_after>Index: skeleton/rdbms/sybase/SybaseConnection.class.php
===================================================================
--- skeleton/rdbms/sybase/SybaseConnection.class.php	(revision 12005)
+++ skeleton/rdbms/sybase/SybaseConnection.class.php	(working copy)
@@ -22,7 +22,6 @@
    * @purpose  Database connection
    */
   class SybaseConnection extends DBConnection {
-  
     private
       $formatter= NULL;
 
@@ -62,7 +61,7 @@
       }
 
       if (!is_resource($this->handle)) {
-        throw(new SQLConnectException(trim(sybase_get_last_message()), $this->dsn));
+        throw new SQLConnectException(trim(sybase_get_last_message()), $this->dsn);
       }
       
       $this->_obs && $this->notifyObservers(new DBEvent(__FUNCTION__, $reconnect));
@@ -91,11 +90,11 @@
      */
     public function selectdb($db) {
       if (!sybase_select_db($db, $this->handle)) {
-        throw(new SQLStatementFailedException(
+        throw new SQLStatementFailedException(
           'Cannot select database: '.trim(sybase_get_last_message()),
           'use '.$db,
           current(sybase_fetch_row(sybase_query('select @@error', $this->handle)))
-        ));
+        );
       }
       return TRUE;
     }
@@ -209,11 +208,11 @@
       $sql= call_user_func_array(array($this, 'prepare'), $args);
 
       if (!is_resource($this->handle)) {
-        if (!($this->flags & DB_AUTOCONNECT)) throw(new SQLStateException('Not connected'));
+        if (!($this->flags & DB_AUTOCONNECT)) throw new SQLStateException('Not connected');
         $c= $this->connect();
         
         // Check for subsequent connection errors
-        if (FALSE === $c) throw(new SQLStateException('Previously failed to connect'));
+        if (FALSE === $c) throw new SQLStateException('Previously failed to connect');
       }
       
       $this->_obs && $this->notifyObservers(new DBEvent(__FUNCTION__, $sql));
@@ -233,17 +232,19 @@
           // Sybase:  Client message:  Read from SQL server failed. (severity 78)
           //
           // but that seems a bit errorprone. 
-          throw(new SQLConnectionClosedException(
+          throw new SQLConnectionClosedException(
             'Statement failed: '.trim(sybase_get_last_message()), 
             $sql
-          ));
+          );
         }
-
-        throw(new SQLStatementFailedException(
-          'Statement failed: '.trim(sybase_get_last_message()), 
-          $sql,
-          current(sybase_fetch_row($error))
-        ));
+        
+        $code= current(sybase_fetch_row($error));
+        $message= trim(sybase_get_last_message());
+        if (1205 == $code) {
+          throw new SQLDeadlockException($message, $sql);
+        } else {
+          throw new SQLStatementFailedException('Statement failed: '.$message, $sql, $code);
+        }
       }
       
       if (TRUE === $result) {
Index: skeleton/rdbms/sybase/SybaseResultSet.class.php
===================================================================
--- skeleton/rdbms/sybase/SybaseResultSet.class.php	(revision 12005)
+++ skeleton/rdbms/sybase/SybaseResultSet.class.php	(working copy)
@@ -39,7 +39,7 @@
      */
     public function seek($offset) { 
       if (!sybase_data_seek($this->handle, $offset)) {
-        throw(new SQLException('Cannot seek to offset '.$offset));
+        throw new SQLException('Cannot seek to offset '.$offset);
       }
       return TRUE;
     }
Index: skeleton/rdbms/SQLDeadlockException.class.php
===================================================================
--- skeleton/rdbms/SQLDeadlockException.class.php	(revision 0)
+++ skeleton/rdbms/SQLDeadlockException.class.php	(revision 0)
@@ -0,0 +1,54 @@
+<?php
+/* This class is part of the XP framework
+ *
+ * $Id$
+ */
+
+  uses('rdbms.SQLException');
+
+  /**
+   * Indicates a deadlock occured
+   * 
+   * @purpose  SQL-Exception
+   */
+  class SQLDeadlockException extends SQLException {
+    public 
+      $sql  = '';
+
+    /**
+     * Constructor
+     *
+     * @param   string message
+     * @param   string sql default NULL the SQL query string sent
+     */
+    public function __construct($message, $sql= NULL) {
+      parent::__construct($message);
+      $this->sql= $sql;
+    }
+
+    /**
+     * Get SQL
+     *
+     * @return  string
+     */
+    public function getSql() {
+      return $this->sql;
+    }
+
+    /**
+     * Return compound message of this exception.
+     *
+     * @return  string
+     */
+    public function compoundMessage() {
+      return sprintf(
+        "Exception %s (deadlock: %s) {\n".
+        "  %s\n".
+        "}\n",
+        $this->getClassName(),
+        $this->message,
+        $this->sql
+      );
+    }
+  }
+?>

Property changes on: skeleton/rdbms/SQLDeadlockException.class.php
___________________________________________________________________
Name: svn:keywords
   + Id

Index: skeleton/rdbms/DBConnection.class.php
===================================================================
--- skeleton/rdbms/DBConnection.class.php	(revision 12005)
+++ skeleton/rdbms/DBConnection.class.php	(working copy)
@@ -8,6 +8,7 @@
     'rdbms.SQLException',
     'rdbms.SQLConnectException',
     'rdbms.SQLStateException',
+    'rdbms.SQLDeadlockException',
     'rdbms.SQLStatementFailedException',
     'rdbms.SQLConnectionClosedException',
     'rdbms.DBEvent',
Index: skeleton/rdbms/DBTableAttribute.class.php
===================================================================
--- skeleton/rdbms/DBTableAttribute.class.php	(revision 12005)
+++ skeleton/rdbms/DBTableAttribute.class.php	(working copy)
@@ -44,7 +44,7 @@
     public 
       $name=        '',
       $type=        -1,
-      $ident=       FALSE,
+      $identity=    FALSE,
       $nullable=    FALSE,
       $length=      0,
       $precision=   0,
@@ -77,10 +77,27 @@
       $this->length= $length;
       $this->precision= $precision;
       $this->scale= $scale;
{'fraction_non_alphanumeric': 0.19713225709415422, 'fraction_numerical': 0.018449814499147697, 'mean_word_length': 2.6886094674556213, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2066210', 'n_tokens_mistral': 3157, 'n_tokens_neox': 2971, 'n_words': 569}