-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Postgres: public should not be considered a "application schema" and should be ignored the same as other system schema from getSchemaNames
#5609
Comments
getSchemaNames
It's only because it's in the user's/session's search_path. |
thanks for pointing that out, I was looking if it was overridable and it was right under my nose. However my other point still stands and this one is slighltly amended , as in the case of a DBA requesting the |
for the records: I'm also affected by the bug for years and I agree with your points (just couldn't resist of being nit-picky, sorry!) :-D |
no offense taken , I also perfectly understand the maintainer point of view of being conservative and I think we're all on the same side of trying to take the best decision, so your nitpicking is welcomed as at least if forces me to really find good arguments :) |
Some other thoughts: https://www.postgresql.org/docs/current/manage-ag-templatedbs.html So theoretically a DBA may modify the template to NOT contain But again, I agree that |
I'm closing the issue as it doesn't state an objective problem. The opinion of "public should not be considered a "application schema" is subjective. The statement "everybody assume that it is present" doesn't have a proof. All issues mentioned in the description are closed except for the one which is in a different repository. If you believe that the current behavior needs to change, please file a new issue and state a problem, not an opinion. |
i feel a bit disappointed , the stated issues are clear not a opinion, the "opinion" is a consequence of these issues, not the other way around,
facts:
when you tried to consider public as a normal schema while adding the possibly for dbal to report SQL to drop schema , you had issues as a consequence of that i see that the way to solve this is to consider public as special schema I'm not some kind of militan that think public should be considered special out of the blue and here find a way to spread my propaganda , i'm just a pragmatic people who try to find solution to problem so please first discard the facts before focusing on the proposed solution |
the other issues have been closed by you these last days , so yes it's a self-fulling prophecy ... |
#1110 <--- it already was explained 7 years ago, the problem hasn't changed since then. |
I'm really sorry but what kind of proof more than that do you need , if I rephrase it as "major projects, including the database itself use it as a default value because except if you're doing very specific stuff, it will be there " would a more objective statement ? if not how do you describe my points ? also what's really frustrating is that these points are from my above comments, I really took the time to gather them, and you decide to discard them |
@allan-simon in the bugs you mentioned, is there one that doesn't relate to migrations? Any thoughts about #1110 (comment) ? |
@greg0ire it's not linked in my issue here, but yes #5596 is also affected by this issue (doctrine:schema:drop , if you try to enable the reporting of drop schem statement in dbal which is for now conveniently disabled ) so no I don't think it make sense to fix it in higher level library , as stated above, doctrine migration on this part is actually simply a think layer on top of the method provided by dbal |
Indeed, I've taken a look, and although it could be fixed in the ORM by tweaking I see that DBAL has a While it is possible to filter out assets in a schema, it's not possible to filter out schemas in a database. A solution could be to add another configuration node just for this, and let the user configure it. That way we don't need to make any assumptions about what the user thinks about |
could be a way yes, at the end of the day I just want the problems quoted to be fixed my "opinion" was just IMHO the most sensible solution but if yours makes everyone happy , yes let's go with it |
if we just can verify it works first ( because I think to have already come accross it, i don't think it worked) |
After taking a deeper look, I'm afraid my proposal would break dbal/src/Schema/PostgreSQLSchemaManager.php Lines 165 to 209 in a5a5877
Also, I'm not sure at what point in the schema comparison the method you're changing in #5600 is called. Maybe we should introduce another method that would return the filtered list of schemas when doing schema comparison, I don't know. I personally don't have to deal with the ORM or migrations so I'm less interested than you are in getting this fixed. |
I think having two separate method with different behaviour would introduce more bugs and will complexify things, if you consider that "listSchemaNames" returns all the user-created schema [0], then it make sense to have it (for the above reaons) to ignore
should be a minority (sorry no hard statitics here [1], the same as I don't have a hard statistics on how many people eat soup with a fork but at some point it feel like pointless to argue...) to the point I feel like these people (if they exists) will not complain that now they are the one that need to manually add the [0] I know the documentation says " * Returns a list of the names of all schemata in the current database." but it's already wrong as it filter some schema ... [1] on AWS , Azure , GCP , on default ubuntu, debian , fedora , windows , Mac installer , the postgres you got has a public schema, so you really must have a DBA that trick the install to remove it before handling it ot , what if we make a poll at the next php conference ? |
I think here you're referring to only one schema called
It seems like you are saying that the only thing we could break is
We can stop the discussion if you want, that's not an issue to me. Anyway, as you can see, I have a proposal, you have a proposal, and there might be more solutions, but I might be wrong about my solution, because I don't know schema comparison that well. For instance, it's unclear where Likewise, you might be wrong. Also, the problem you're willing to solve is not worded clearly, I believe this is why this issue was closed. Shouldn't there be somewhere a sentence like: when I run a comparison between this schema and that schema, the diff should be empty, but isn't? I think instead of jumping to solutions, you should do what @morozov asked and file a new issue with a clearly stated problem, expressed with the DBAL APIs (meaning high-level APIs). A test case would be best. BTW, I'm talking about schema comparison, but it's unclear if the issue you are trying to fix is with schema comparison, with |
I'm arguying with @morozov handling of it , not you, we can continue to discuss, you're not ignoring my arguments or only handpicking the one that fit you. |
it is, it's the summary of dozen of specific issues , which all boils down to the same underlying issue of public being returned , so I was thinking that creating a summary issue, stating all the angle of the problems would be enough (it's not like i throwed a title-only issue without takign the time to git bissect accross 10 years of commit )
I'm sorry but #1110 was worded clearly and very specific but it was closed without any argument so hence my frustration, I have a guy in front of me that contradicts himself:
|
no
I'm not saying that , I'm saying the minority are people that have both a DBA who deleted the public schema but at the same time would allow people to recreate it |
Again, let's not jump to solutions, we don't know that it is the correct one. Not returning
It's quite clear, yet it's not easy to reproduce with just the DBAL APIs. I would expect something like
From reading the issue, you can't tell if there is a bug in the DBAL, or if
Not sure how I missed that, that's indeed the case. The docs say this:
For public, you'll have to admit that it's different: it's kind of common for people to create table and indexes inside
There could also be other packages (different from ORM or migrations) relying on that method to display schema names, for purposes we don't know. The DBAL has 4k dependends: https://packagist.org/packages/doctrine/dbal/dependents?order_by=downloads Hard to tell who is using this API for what. Hence my proposal of having this filtering be opt-in, and affect a new API instead of an existing one. |
I'm locking this because it's starting to consume my energy as well, but anyone feel free to open another issue about this. If you do, make sure that you state a clear problem , preferably reproducible with the DBAL APIs that are used directly by |
Bug Report
For now 10 years
public
has been returned bygetSchemaNames
generating a lot of bug and weird behaviour in higher level libraries relying on it.Summary
For now 10 years since commit b89490a (before that it was not working at all )
public
is returned by PostgreSQLSchemaManager::getSchemaNames()Current behaviour
How to reproduce
(a reproducer is soon coming)
-> public is returned among other user-defined schema
Expected behaviour
all application schema are returned , but not
public
(as well as other postgres-defined schema are also not returnedMore context
This bug is at least the root cause of these issues
the more visible issue of it is with doctrine migration:
down
migration trying toCREATE SCHEMA public
that EVERYBODY deletes or workaround ( 💯 if youhave done that too ) because it fails miserably (as it already exists)
DROP SCHEMA
will never be generated.Why
public
should be considered a "system schema"CREATE TABLE foobar
you're actually doingCREATE TABLE public.foobar
public
in the first migration as it will fail before)@morozov I understand the issue is "scary" because this library is a high profile one and after a time even bugs become part of the API , so I understand we may want to be careful on that one, so maybe we can find a deprecation strategy and changing this behaviour only on a minor/major release (at least not just a bug fix one)
The text was updated successfully, but these errors were encountered: