Index: src/wp-includes/option.php
===================================================================
--- src/wp-includes/option.php	(revision 30050)
+++ src/wp-includes/option.php	(working copy)
@@ -240,6 +240,11 @@
 	if ( is_object( $value ) )
 		$value = clone $value;
 
+	if( strlen( $option ) > 64 ) {
+		$option = md5( $option );
+		$option = "md5_" . $option;
+	}
+
 	$value = sanitize_option( $option, $value );
 	$old_value = get_option( $option );
 
@@ -377,6 +382,11 @@
 	$serialized_value = maybe_serialize( $value );
 	$autoload = ( 'no' === $autoload ) ? 'no' : 'yes';
 
+	if( strlen( $option ) > 64 ) {
+		$option = md5( $option );
+		$option = "md5_" . $option;
+	}
+
 	/**
 	 * Fires before an option is added.
 	 *
@@ -582,6 +592,12 @@
 	if ( wp_using_ext_object_cache() ) {
 		$value = wp_cache_get( $transient, 'transient' );
 	} else {
+
+		if( strlen( $transient ) > 40 ) {
+			$transient = md5( $transient );
+			$transient = "md5_" . $transient;
+		}
+
 		$transient_option = '_transient_' . $transient;
 		if ( ! defined( 'WP_INSTALLING' ) ) {
 			// If option is not in alloptions, it is not autoloaded and thus has a timeout
@@ -645,8 +661,15 @@
 	if ( wp_using_ext_object_cache() ) {
 		$result = wp_cache_set( $transient, $value, 'transient', $expiration );
 	} else {
+
+		if( strlen( $transient ) > 40 ) {
+			$transient = md5( $transient );
+			$transient = "md5_" . $transient;
+		}
+
 		$transient_timeout = '_transient_timeout_' . $transient;
 		$transient = '_transient_' . $transient;
+
 		if ( false === get_option( $transient ) ) {
 			$autoload = 'yes';
 			if ( $expiration ) {
Index: tests/phpunit/tests/option/transient.php
===================================================================
--- tests/phpunit/tests/option/transient.php	(revision 30050)
+++ tests/phpunit/tests/option/transient.php	(working copy)
@@ -83,4 +83,13 @@
 		update_option( '_transient_timeout_' . $key, $now - 1 );
 		$this->assertFalse( get_transient( $key ) );
 	}
+
+	/**
+	 * ticket 15058
+	 */
+	function test_transient_long() {
+		$long_name = "thisisaverylongnamethatwillnotfitincolumnbecauseitistoolongforthecolumn";
+		set_transient( $long_name, true, 60 );
+		$this->assertTrue( get_transient( $long_name ) );
+	}
 }
