Support postgresql partitioning by making INSERT RETURNING optional#5698
Conversation
|
I'm not sure it's a good idea that you can toggle this on and off at any time. It means that we can't make expectations about the connection behavior (for example someone upstream could just toggle the flag). Would you be opposed to supporting something where the database.yml specified the flag? For example: |
|
That makes sense, I'll make the change and let you know when it's done. |
|
Awesome! Thank you for the work, I really appreciate it. |
|
@tenderlove OK, updated. Let me know what you think, I like the change a lot, thanks for the suggestion and all the help! |
|
Feel free to give more feedback, I'm happy to refactor more. I know I'm adding a lot of complexity to the postgresql adapter for a rarely used feature, I want to make sure it's not too much of pain to maintain. |
|
bump. Sorry to nag, just wanted to make sure you saw the new revision - anything else I can do to help with this? |
Support postgresql partitioning by making INSERT RETURNING optional
|
I am not sure the normal routine as far as rails releases go. I see this has been merged into master. Will it ever be merged into 3.2? Or will it only make it into the next major version? |
|
@tecnobrat it's probably a hard work to backport, and since it seems more like a new feature than a bug fix, it's unlikely to be done by any commiter. In any case, if you want to try out a pull request backporting it, by cherry-picking these commits and doing any required changes, then there's a chance to get it into 3.2. Cheers! |
|
I don't think this should be backported since it is adding feature and changes the public API. If we backport this some database adapters can break. |
|
Ive been stuck on this partitioning problem all week until I found this discussion. How come there's no mention of |
It was introduced in rails#49290 likely to do the same as PostgresqlAdapter, but it's not used anywhere and there not really any reason to have that option. Postgres has it because INSERT RETURNING can't be used in some corner cases, see: rails#5698
It was introduced in rails#49290 likely to do the same as PostgresqlAdapter, but it's not used anywhere and there not really any reason to have that option. Postgres has it because INSERT RETURNING can't be used in some corner cases, see: rails#5698
It was introduced in rails#49290 likely to do the same as PostgresqlAdapter, but it's not used anywhere and there not really any reason to have that option. Postgres has it because INSERT RETURNING can't be used in some corner cases, see: rails#5698
It was introduced in rails#49290 likely to do the same as PostgresqlAdapter, but it's not used anywhere and there not really any reason to have that option. Postgres has it because INSERT RETURNING can't be used in some corner cases, see: rails#5698
Currently the Postgresql adapters use of INSERT RETURNING for insert statements makes using trigger based partitioning of tables impossible (See http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html for more info). This patch adds a per connection option to disable INSERT RETURNING and use a simpler INSERT; SELECT currval() which works with trigger based inserts. Fixes #4955