On Tue, Sep 6, 2022 at 10:05 AM Tom Lane <t...@sss.pgh.pa.us> wrote: > > I haven't looked at that patch at all, but I would assume that > > variables would have SQL types, and that we would never add GUCs with > > SQL types, which seems like a pretty major semantic difference. > > Yeah, I do not think we'd want to extend GUCs beyond the existing > bool/int/float/string cases, since they have to be readable under > non-transactional circumstances. Having said that, that covers > an awful lot of practical territory. Schema variables of > arbitrary SQL types sound cool, sure, but how many real use cases > are there that can't be met with the GUC types?
Well, if you use an undefined custom GUC, you're just going to get a string data type, I believe, which is pretty well equivalent to not having any type checking at all. You could extend that in some way to allow users to create dummy GUCs of any type supported by the mechanism, but I think that's mostly stacking one hack on top of another. I believe there's good evidence that users want variables based on SQL data types, whereas I can't see any reason why users would variables based on GUC data types. It is of course true that the GUC data types cover the cases people are mostly likely to want, but that's just because it covers the most generally useful data types. If you can want to pass an integer between one part of your application and another, why can't you want to pass a numeric or a bytea? I think you can, and I think people do. This is not really an endorsement of the SQL variables patch, which I haven't studied and which for all I know may have lots of problems, either as to design or as to implementation. But I think it's a little crazy to pretend that the ability to store strings - or even values of any GUC type - into a fictional GUC is an adequate substitute for SQL variables. Honestly, the fact that you can do that in the first place seems more like an undesirable wart necessitated by the way loadable modules interact with the GUC system than a feature -- but even if it were a feature, it's not the same feature. -- Robert Haas EDB: http://www.enterprisedb.com