@@ -7519,17 +7519,19 @@ private function create_result_statement_from_data( array $columns, array $rows
75197519 /**
75207520 * Create a new MySQL-on-SQLite driver exception.
75217521 *
7522- * @param string $message The exception message.
7523- * @param int|string $code The exception code. For PDO errors, a string representing SQLSTATE.
7524- * @param Throwable|null $previous The previous exception.
7522+ * @param string $message The exception message.
7523+ * @param int|string $code The exception code. For PDO errors, a string representing SQLSTATE.
7524+ * @param Throwable|null $previous The previous exception.
7525+ * @param array|null $error_info PDO-style error information.
75257526 * @return WP_MySQL_On_SQLite_Exception
75267527 */
75277528 private function new_driver_exception (
75287529 string $ message ,
75297530 $ code = 0 ,
7530- ?Throwable $ previous = null
7531+ ?Throwable $ previous = null ,
7532+ ?array $ error_info = null
75317533 ): WP_MySQL_On_SQLite_Exception {
7532- return new WP_MySQL_On_SQLite_Exception ( $ this , $ message , $ code , $ previous );
7534+ return new WP_MySQL_On_SQLite_Exception ( $ this , $ message , $ code , $ previous, $ error_info );
75337535 }
75347536
75357537 /**
@@ -7601,52 +7603,55 @@ private function new_access_denied_to_information_schema_exception(): WP_MySQL_O
76017603 private function convert_information_schema_exception ( WP_SQLite_Information_Schema_Exception $ e ): Throwable {
76027604 switch ( $ e ->get_type () ) {
76037605 case WP_SQLite_Information_Schema_Exception::TYPE_DUPLICATE_TABLE_NAME :
7606+ $ driver_message = sprintf ( "Table '%s' already exists " , $ e ->get_data ()['table_name ' ] );
76047607 return $ this ->new_driver_exception (
7605- sprintf (
7606- "SQLSTATE[42S01]: Base table or view already exists: 1050 Table '%s' already exists " ,
7607- $ e ->get_data ()['table_name ' ]
7608- ),
7609- '42S01 '
7608+ 'SQLSTATE[42S01]: Base table or view already exists: 1050 ' . $ driver_message ,
7609+ '42S01 ' ,
7610+ null ,
7611+ array ( '42S01 ' , 1050 , $ driver_message )
76107612 );
76117613 case WP_SQLite_Information_Schema_Exception::TYPE_DUPLICATE_COLUMN_NAME :
7614+ $ driver_message = sprintf ( "Duplicate column name '%s' " , $ e ->get_data ()['column_name ' ] );
76127615 return $ this ->new_driver_exception (
7613- sprintf (
7614- "SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name '%s' " ,
7615- $ e ->get_data ()['column_name ' ]
7616- ),
7617- '42S21 '
7616+ 'SQLSTATE[42S21]: Column already exists: 1060 ' . $ driver_message ,
7617+ '42S21 ' ,
7618+ null ,
7619+ array ( '42S21 ' , 1060 , $ driver_message )
76187620 );
76197621 case WP_SQLite_Information_Schema_Exception::TYPE_DUPLICATE_KEY_NAME :
7622+ $ driver_message = sprintf ( "Duplicate key name '%s' " , $ e ->get_data ()['key_name ' ] );
76207623 return $ this ->new_driver_exception (
7621- sprintf (
7622- "SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name '%s' " ,
7623- $ e ->get_data ()['key_name ' ]
7624- ),
7625- '42S21 '
7624+ 'SQLSTATE[42000]: Syntax error or access violation: 1061 ' . $ driver_message ,
7625+ '42000 ' ,
7626+ null ,
7627+ array ( '42000 ' , 1061 , $ driver_message )
76267628 );
76277629 case WP_SQLite_Information_Schema_Exception::TYPE_KEY_COLUMN_NOT_FOUND :
7630+ $ driver_message = sprintf ( "Key column '%s' doesn't exist in table " , $ e ->get_data ()['column_name ' ] );
76287631 return $ this ->new_driver_exception (
7629- sprintf (
7630- "SQLSTATE[42000]: Syntax error or access violation: 1072 Key column '%s' doesn't exist in table " ,
7631- $ e ->get_data ()['column_name ' ]
7632- ),
7633- '42000 '
7632+ 'SQLSTATE[42000]: Syntax error or access violation: 1072 ' . $ driver_message ,
7633+ '42000 ' ,
7634+ null ,
7635+ array ( '42000 ' , 1072 , $ driver_message )
76347636 );
76357637 case WP_SQLite_Information_Schema_Exception::TYPE_CONSTRAINT_DOES_NOT_EXIST :
7638+ $ driver_message = sprintf ( "Constraint '%s' does not exist. " , $ e ->get_data ()['name ' ] );
76367639 return $ this ->new_driver_exception (
7637- sprintf (
7638- "SQLSTATE[HY000]: General error: 3940 Constraint '%s' does not exist. " ,
7639- $ e ->get_data ()['name ' ]
7640- ),
7641- 'HY000 '
7640+ 'SQLSTATE[HY000]: General error: 3940 ' . $ driver_message ,
7641+ 'HY000 ' ,
7642+ null ,
7643+ array ( 'HY000 ' , 3940 , $ driver_message )
76427644 );
76437645 case WP_SQLite_Information_Schema_Exception::TYPE_MULTIPLE_CONSTRAINTS_WITH_NAME :
7646+ $ driver_message = sprintf (
7647+ "Table has multiple constraints with the name '%s'. Please use constraint specific 'DROP' clause. " ,
7648+ $ e ->get_data ()['name ' ]
7649+ );
76447650 return $ this ->new_driver_exception (
7645- sprintf (
7646- "SQLSTATE[HY000]: General error: 3939 Table has multiple constraints with the name '%s'. Please use constraint specific 'DROP' clause. " ,
7647- $ e ->get_data ()['name ' ]
7648- ),
7649- 'HY000 '
7651+ 'SQLSTATE[HY000]: General error: 3939 ' . $ driver_message ,
7652+ 'HY000 ' ,
7653+ null ,
7654+ array ( 'HY000 ' , 3939 , $ driver_message )
76507655 );
76517656 default :
76527657 return $ e ;
0 commit comments