Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

fix for a transaction problem with change_column on postgresql if bad arguments passed in

#861

If you do something like this:


SomeModel.transaction do
  <A:  some queries/statements that alter database>

  change_column :table, :column, :null => false

  <B:  some more queries/statements that alter database>
end

Then the statements in A will be rolled back but the statements in B will be committed, and this happens without any errors or warnings whatsoever, and causes some confusion.

Notice how I forgot to add the column type to the change_column call, causing change_column to build an invalid statement (it tries to use 'nullfalse' as the datatype), but this exception is gobbled up by change_column which then does some transactional work of it's own, giving the said undesired side effects.

This code is there to handle some problem with pg version 7.x. This patch reraises the exception if the postgresql_version is > 80000, which means the above code raises an exception as it should.

Reported by azimux · August 19th, 2008 @ 09:19 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Repository
    Repository
    • State changed from new to resolved

    (from [0d74e72e6de7b96e158950a449ea1ccce6f5b8d7]) Fix postgres bug when change_column is called with invalid parameters. [#861 fix for a transaction problem with change_column on postgresql if bad argumen... state:resolved]

    Signed-off-by: Tarmo Tänav tarmo@itech.ee Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    August 21st, 2008 @ 04:25 PM

  2. Repository
    Repository

    (from [09343166ac213e5fcbd3eb5b21d44606b56afa62]) PostgreSQL: fix transaction bug that can occur if you call change_column with invalid parameters

    [#861 fix for a transaction problem with change_column on postgresql if bad argumen... state:resolved] http://github.com/rails/rails/co...

    August 22nd, 2008 @ 02:16 AM

  3. Repository
    Repository

    (from [6e71a3552921836590ef7b60334cbf92a2f49d1e]) PostgreSQL: fix transaction bug that can occur if you call change_column with invalid parameters

    [#861 fix for a transaction problem with change_column on postgresql if bad argumen... state:resolved] http://github.com/rails/rails/co...

    August 25th, 2008 @ 09:30 AM