-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
partition_data_*() not work when table PK defined with GENERATED ALWAYS #724
Comments
So I'm not able to re-produced this issue when using the Below is a similar example to what you've given (I just make it all lower case and only set the NOT NULL columns to be the relevant ones to make an easier test case). It works fine ignoring the column and allows the partitioned table to generate the ID columns automatically. If you can provide me a working example of where you're running into an error, maybe we can figure out a better solution to allow users to override identities if desired.
|
Created some new unit tests for version 5.2.4 to test the bug I fixed there. I also had those test use GENERATED IDENTITY columns, one even using it for the partition key, and all seems to be working fine as long as I set So just let me know if you're still having issues even when using the ignored columns options |
Actually, I think I just found the issue. I was testing this in PG17, but apparently the ability for partitioned tables to properly honor IDENTITY was not added until 17! https://www.postgresql.org/docs/17/release-17.html
I got this error when I tested in PG16.
So, this is actually an issue that has been fixed properly in core as of PG17. I don't think I want to allow an override option to get around this for now. The recommended fix would be to upgrade to PostgreSQL 17. |
I have re producted on
Insert a row into default part insert into public.tb1_default (enqueued_at) values ('2025-01-15'::timestamptz);
Merge data:
|
using
|
Ahh I see the issue. I did not test this scenario when dealing with data in the default. The issue is the temp table that's created to hold the data while moving it out of the default then into the proper child (note the table name I'll try and work out a fix for this. In the mean time if you did need to handle this scenario, you could move the data out of the default yourself into another similar table (temporary or not), adjust the premake value so that it creates the necessary future partition in maintenance, then insert that data back in. If the data is in the past, that's a little trickier. You'd have to feed the proper values to the internal |
So I'm going to try and see if I can allow an option for OVERRIDING SYSTEM VALUES. Now that I see where this issue is, I could foresee a scenario where someone may want to preserve the generated value that went into the default or even from an original source table. But others may just want a newly generated value when the data is moved. The latter will be the default action that a user will have to intentionally override. So, may be a bit before I get this fix in. Thanks again for reporting and helping me narrow down the problem. |
I use pgmq with pg_parten,
got error when calling partition_data_time()
Cause Column "msg_id" is an identity column defined as GENERATED ALWAYS:
I committed a PR to handle this situation : #723
The text was updated successfully, but these errors were encountered: