代码之家  ›  专栏  ›  技术社区  ›  MatthewFord

更新记录时出错

  •  0
  • MatthewFord  · 技术社区  · 16 年前

    我得到一个mysql错误:

    #update(activerecord::statementinvalid)“mysql::error:hy000从存储引擎获取错误139:

    当试图用长度为1429个字符的字符串更新记录中的文本字段时,对于如何跟踪问题有什么想法吗?

    下面是stacktrace。

    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:147:in `log'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:299:in `execute'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:167:in `update_sql'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:314:in `update_sql'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:49:in `update_without_query_dirty'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:19:in `update'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/base.rb:2481:in `update_without_lock'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb:70:in `update_without_dirty'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/dirty.rb:137:in `update_without_callbacks'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/callbacks.rb:234:in `update_without_timestamps'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/timestamp.rb:38:in `update'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/base.rb:2472:in `create_or_update_without_callbacks'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/callbacks.rb:207:in `create_or_update'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/base.rb:2200:in `save_without_validation'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/validations.rb:901:in `save_without_dirty'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/dirty.rb:75:in `save_without_transactions'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:106:in `save'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:79:in `transaction'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:98:in `transaction'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:106:in `save'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `rollback_active_record_state!'
    from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:106:in `save'
    
    3 回复  |  直到 16 年前
        1
  •  0
  •   Matthias Winkelmann    16 年前

    可能是这个bug: #1030 - Got error 139 from storage engine ,但如果您发布查询,这将有帮助,查询应该直接出现在错误消息之后。

        2
  •  1
  •   Dave Cheney    16 年前

    当您说文本字段时,它是varchar类型还是文本类型?

    如果是前者,则不能在该列中存储大于255个字符(可能少于UTF-8开销)的字符串。如果是后者,您最好发布您的模式定义,这样人们可以进一步帮助您。

        3
  •  0
  •   MatthewFord    16 年前

    这似乎是一个非常奇怪的MySQL错误,其中文本被截断为256个字符(对于文本类型),抛出上述错误的字符串是1000个字符或更多。将表列修改为文本可再次解决此问题,或者只需自行解决。我还是不确定。

    更新: 将表类型更改为myisam解决了此问题