Re: Statistics Import and Export - Mailing list pgsql-hackers
From | Tom Lane |
---|---|
Subject | Re: Statistics Import and Export |
Date | |
Msg-id | 1043793.1711984209@sss.pgh.pa.us Whole thread Raw |
In response to | Re: Statistics Import and Export (Corey Huinker <corey.huinker@gmail.com>) |
Responses |
Re: Statistics Import and Export
Re: Statistics Import and Export |
List | pgsql-hackers |
Corey Huinker <corey.huinker@gmail.com> writes: >> IIRC, "variadic any" requires having at least one variadic parameter. >> But that seems fine --- what would be the point, or even the >> semantics, of calling pg_set_attribute_stats with no data fields? > If my pg_dump run emitted a bunch of stats that could never be imported, > I'd want to know. With silent failures, I don't. What do you think would be silent about that? If there's a complaint to be made, it's that it'd be a hard failure ("no such function"). To be clear, I'm ok with emitting ERROR for something that pg_dump clearly did wrong, which in this case would be emitting a set_statistics call for an attribute it had exactly no stats values for. What I think needs to be WARN is conditions that the originating pg_dump couldn't have foreseen, for example cross-version differences. If we do try to check things like sort order, that complaint obviously has to be WARN, since it's checking something potentially different from what was correct at the source server. >> Perhaps we could >> invent a new backend function that extracts the actual element type >> of a non-null anyarray argument. > A backend function that we can't guarantee exists on the source system. :( [ shrug... ] If this doesn't work for source servers below v17, that would be a little sad, but it wouldn't be the end of the world. I see your point that that is an argument for finding another way, though. >> Another way we could get to no-coercions is to stick with your >> signature but declare the relevant parameters as anyarray instead of >> text. > I'm a bit confused here. AFAIK we can't construct an anyarray in SQL: > # select '{1,2,3}'::anyarray; > ERROR: cannot accept a value of type anyarray That's not what I suggested at all. The function parameters would be declared anyarray, but the values passed to them would be coerced to the correct concrete array types. So as far as the coercion rules are concerned this'd be equivalent to the variadic-any approach. > That's pretty persuasive. It also means that we need to trap for error in > the array_in() calls, as that function does not yet have a _safe() mode. Well, the approach I'm advocating for would have the array input and coercion done by the calling query before control ever reaches pg_set_attribute_stats, so that any incorrect-for-the-data-type values would result in hard errors. I think that's okay for the same reason you probably figured you didn't have to trap array_in: it's the fault of the originating pg_dump if it offers a value that doesn't coerce to the datatype it claims the value is of. My formulation is a bit safer though in that it's the originating pg_dump, not the receiving server, that is in charge of saying which type that is. (If that type doesn't agree with what the receiving server thinks it should be, that's a condition that pg_set_attribute_stats itself will detect, and then it can WARN and move on to the next thing.) regards, tom lane
pgsql-hackers by date: