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

Ability to specify WITH when creating a table + fixes WITH when creating an index #11296

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alphavector
Copy link
Contributor

Description

Adding the ability to specify storage parameters via with + fix for specifying index storage parameters (should it be split into two different PRs?).

Fixes: #11122

Checklist

This pull request is:

  • A documentation / typographical / small typing error fix
    • Good to go, no issue or tests are needed
  • [] A short code fix
    • please include the issue number, and create an issue if none exists, which
      must include a complete example of the issue. one line code fixes without an
      issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • A new feature implementation
    • please include the issue number, and create an issue if none exists, which must
      include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

Copy link
Member

@CaselIT CaselIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change, I'm not sure about changing how the values are compiled since that's potentially a breaking change

]
)
)
with_opts = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about creating a function for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i agree, its fixed

@@ -936,7 +984,19 @@ def test_create_index_with_with(self):
schema.CreateIndex(idx3),
"CREATE INDEX test_idx3 ON testtbl "
"USING gist (data) "
"WITH (buffering = off)",
"WITH (buffering = 'off')",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing this as string seems accepted, but this kinda seems like a breaking change, so not sure this should be a v2 change.

for 2.1 should be ok, but maybe not on 2.0.

what do you think mike @zzzeek

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case sure, but this does not make it not a breaking change:
Something like {'foo': 'true', 'bar': 'null'} would likely not work now, since true and null would be passed as strings, not true the bool and null the missing value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, from that perspective it's a breaking change
Then we'll wait for 2.1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 on quoting "off" , the syntax at https://www.postgresql.org/docs/current/sql-createindex.html shows it without quotes.

Copy link
Member

@CaselIT CaselIT Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string 'off' is also accepted.

But I too would be for taking string to mean sql text as is (current behavior)

If people want to pass arbitrary things we can document that literal() will be properly compiled, so we could support
{'foo': 'this is a literal statement fragment', 'this is compiled': literal(True)}

Copy link
Member

@zzzeek zzzeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are looking to support lots more keywords here, with different kinds of expectations, we either have to look at the type of value and format exactly as would be seen in the examples at https://www.postgresql.org/docs/current/sql-createindex.html or we need to (and I might prefer this) build up a list of all known PG keywords for both indexes and tables and include typing information with each . no backwards-incompat changes

postgresql_using="brin",
postgresql_with={
"pages_per_range": 1,
"autosummarize": None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 on {"autosummarize": None} . looking at docs here: https://www.postgresql.org/docs/current/sql-createindex.html this is a boolean. so this should accept 'off' / 'on'

@@ -936,7 +984,19 @@ def test_create_index_with_with(self):
schema.CreateIndex(idx3),
"CREATE INDEX test_idx3 ON testtbl "
"USING gist (data) "
"WITH (buffering = off)",
"WITH (buffering = 'off')",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 on quoting "off" , the syntax at https://www.postgresql.org/docs/current/sql-createindex.html shows it without quotes.

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

Successfully merging this pull request may close these issues.

Postregresql create table add "with" argument
3 participants