Skip to content
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 creation fails when partial indexes are present with tablespace #657

Open
mingravity opened this issue May 3, 2024 · 3 comments

Comments

@mingravity
Copy link

In this function: inherit_template_properties

If there is a partial index and also tablespace then the query formed adds TABLESPACE clause to the end like below:
e.g.
CREATE INDEX ON table1(col1) WHERE col1 > 10 TABLESPACE my_tbl_spc;

This is invalid SQL. Instead should be
CREATE INDEX ON table1(col1) TABLESPACE my_tbl_spc WHERE col1 > 10;

Possible solution:

IF (ARRAY_length(regexp_matches(v_sql, ' WHERE ', 'i'), 1) > 0)
THEN
v_sql := regexp_replace (v_sql, ' WHERE ', format(' TABLESPACE %I WHERE ', v_index_list.tablespace_name), 'i' );
ELSE
v_sql := v_sql || format(' TABLESPACE %I', v_index_list.tablespace_name); -- THIS IS THE CURRENT STATEMENT

@keithf4
Copy link
Collaborator

keithf4 commented May 28, 2024

Thank you for finding this issue. Will try and see if I can figure out a fix for this.

@keithf4 keithf4 self-assigned this May 28, 2024
@keithf4 keithf4 modified the milestone: 5.2 May 28, 2024
@keithf4
Copy link
Collaborator

keithf4 commented Oct 16, 2024

Apologies for the delay looking into this.

You're correct in that partial indexes would cause an issue here. However, this code block is only handling unique indexes, so it would be a bit odd for that to occur. I'll still include the fix to handle the odd edge case. Thank you!

@keithf4
Copy link
Collaborator

keithf4 commented Nov 22, 2024

Version 5.2.0 has been released and includes this fix. Thanks for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants