Re: [HACKERS] Proposal: variant of regclass

2014-04-16 Thread Robert Haas
On Wed, Apr 16, 2014 at 3:27 AM, Tatsuo Ishii wrote: >>> Well, I noticed that, too, but I didn't think it was my job to tell >>> the patch author what functions he should have wanted. A follow-on >>> patch to add to_regprocedure and to_regoperator wouldn't be much work, >>> if you want that. >> >

Re: [HACKERS] Proposal: variant of regclass

2014-04-16 Thread Tatsuo Ishii
>> Well, I noticed that, too, but I didn't think it was my job to tell >> the patch author what functions he should have wanted. A follow-on >> patch to add to_regprocedure and to_regoperator wouldn't be much work, >> if you want that. > > And here is a patch for that. Looks good to me except du

Re: [HACKERS] Proposal: variant of regclass

2014-01-23 Thread Amit Khandekar
On 22 January 2014 13:09, Tatsuo Ishii wrote: > > I, as a user would be happier if we also have to_regprocedure() and > > to_regoperator(). The following query looks a valid use-case where one > > needs to find if a particular function exists. Using to_regproc('sum') > does > > not make sense her

Re: [HACKERS] Proposal: variant of regclass

2014-01-22 Thread Marti Raudsepp
On Wed, Jan 22, 2014 at 1:44 PM, Yugo Nagata wrote: > On Wed, 22 Jan 2014 20:04:12 +0900 (JST) > Tatsuo Ishii wrote: > parseTypeString() is called by some other functions and I avoided > influences of modifying the definition on them, since this should > raise errors in most cases. This is same r

Re: [HACKERS] Proposal: variant of regclass

2014-01-22 Thread Yugo Nagata
On Wed, 22 Jan 2014 20:04:12 +0900 (JST) Tatsuo Ishii wrote: > > On Tue, Jan 14, 2014 at 9:28 AM, Yugo Nagata wrote: > >> Here is the patch to implement to_regclass, to_regproc, to_regoper, > >> and to_regtype. > > > > + static Datum regclass_guts(char *class_name_or_oid, bool raiseError); > >

Re: [HACKERS] Proposal: variant of regclass

2014-01-22 Thread Tatsuo Ishii
> On Tue, Jan 14, 2014 at 9:28 AM, Yugo Nagata wrote: >> Here is the patch to implement to_regclass, to_regproc, to_regoper, >> and to_regtype. > > + static Datum regclass_guts(char *class_name_or_oid, bool raiseError); > > Minor bikeshedding, a lot of code currently uses an argument named > "mi

Re: [HACKERS] Proposal: variant of regclass

2014-01-22 Thread Marti Raudsepp
On Tue, Jan 14, 2014 at 9:28 AM, Yugo Nagata wrote: > Here is the patch to implement to_regclass, to_regproc, to_regoper, > and to_regtype. + static Datum regclass_guts(char *class_name_or_oid, bool raiseError); Minor bikeshedding, a lot of code currently uses an argument named "missing_ok" for

Re: [HACKERS] Proposal: variant of regclass

2014-01-21 Thread Tatsuo Ishii
> I, as a user would be happier if we also have to_regprocedure() and > to_regoperator(). The following query looks a valid use-case where one > needs to find if a particular function exists. Using to_regproc('sum') does > not make sense here because it will return InvalidOid, which will not tell >

Re: [HACKERS] Proposal: variant of regclass

2014-01-19 Thread Amit Khandekar
Hi, I have begun the review as part of the commitfest. Below are my comments *_guts() functions are defined as returning Datum, while they are actually returning Oid. They should be defined as returning Oid. Also the PG_RETURN_OID() has been still used in some of the *_guts() f

Re: [HACKERS] Proposal: variant of regclass

2014-01-14 Thread Tatsuo Ishii
> On Tue, Jan 14, 2014 at 4:28 PM, Yugo Nagata wrote: >> Here is the patch to implement to_regclass, to_regproc, to_regoper, >> and to_regtype. They are new functions similar to regclass, regproc, >> regoper, and regtype except that if requested object is not found, >> returns InvalidOid, rather t

Re: [HACKERS] Proposal: variant of regclass

2014-01-13 Thread Michael Paquier
Hi, On Tue, Jan 14, 2014 at 4:28 PM, Yugo Nagata wrote: > Here is the patch to implement to_regclass, to_regproc, to_regoper, > and to_regtype. They are new functions similar to regclass, regproc, > regoper, and regtype except that if requested object is not found, > returns InvalidOid, rather th

Re: [HACKERS] Proposal: variant of regclass

2013-12-31 Thread Pavel Stehule
2013/12/31 Tatsuo Ishii > > On 12/31/2013 02:38 AM, Tatsuo Ishii wrote: > >> Before proceeding the work, I would like to make sure that followings > >> are complete list of new functions. Inside parentheses are > >> corresponding original functions. > >> > >> toregproc (regproc) > >> toregoper (r

Re: [HACKERS] Proposal: variant of regclass

2013-12-30 Thread Tatsuo Ishii
> On 12/31/2013 02:38 AM, Tatsuo Ishii wrote: >> Before proceeding the work, I would like to make sure that followings >> are complete list of new functions. Inside parentheses are >> corresponding original functions. >> >> toregproc (regproc) >> toregoper (regoper) >> toregclass (regclass) >> tore

Re: [HACKERS] Proposal: variant of regclass

2013-12-30 Thread Vik Fearing
On 12/31/2013 02:38 AM, Tatsuo Ishii wrote: > Before proceeding the work, I would like to make sure that followings > are complete list of new functions. Inside parentheses are > corresponding original functions. > > toregproc (regproc) > toregoper (regoper) > toregclass (regclass) > toregtype (reg

Re: [HACKERS] Proposal: variant of regclass

2013-12-30 Thread Tatsuo Ishii
>> It seems fine to me if the new function ignores the specific error of >> "relation does not exist" while continuing to throw other errors. > > Thanks. Here is the revised conceptual patch. I'm going to post a > concrete patch and register it to 2014-01 Commit Fest. Before proceeding the work,

Re: [HACKERS] Proposal: variant of regclass

2013-12-18 Thread Tatsuo Ishii
>> For the pgpool-II use case, I'm happy to follow you because pgpool-II >> always does a grammatical check (using raw parser) on a query first >> and such syntax problem will be pointed out, thus never reaches to >> the state where calling toregclass. >> >> One concern is, other users expect toreg

Re: [HACKERS] Proposal: variant of regclass

2013-12-17 Thread Robert Haas
On Mon, Dec 16, 2013 at 8:22 PM, Tatsuo Ishii wrote: >>> static Datum regclass_gut(char *class_name_or_oid, bool raiseError); >>> static List *stringToQualifiedNameList_gut(const char *string, bool >>> raiseError); >> >> Please spell that as "guts" not "gut". > > Thanks. I see. > >>> regclass_gut

Re: [HACKERS] Proposal: variant of regclass

2013-12-16 Thread Tatsuo Ishii
>> static Datum regclass_gut(char *class_name_or_oid, bool raiseError); >> static List *stringToQualifiedNameList_gut(const char *string, bool >> raiseError); > > Please spell that as "guts" not "gut". Thanks. I see. >> regclass_gut is called from regclassin and toregclass and do the most >> jo

Re: [HACKERS] Proposal: variant of regclass

2013-12-16 Thread Tom Lane
Tatsuo Ishii writes: > To implement toregclass, which does not throw errors when invalid > argument is given, src/backend/utils/adt/regproc.c is modified. I > added two static functions: > static Datum regclass_gut(char *class_name_or_oid, bool raiseError); > static List *stringToQualifiedNameLis

Re: [HACKERS] Proposal: variant of regclass

2013-12-16 Thread Tatsuo Ishii
> Tatsuo Ishii writes: >> Can I make sure that we want to keep the current behavior: > >> test=# SELECT 'pg_klass'::regclass; >> ERROR: relation "pg_klass" does not exist > > Yeah, I think the consensus is to not change the behavior of the input > functions, just add some new ones. Ok, here is

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Tatsuo Ishii writes: > Can I make sure that we want to keep the current behavior: > test=# SELECT 'pg_klass'::regclass; > ERROR: relation "pg_klass" does not exist Yeah, I think the consensus is to not change the behavior of the input functions, just add some new ones.

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tatsuo Ishii
> I'm getting less enamored of just-change-the-input-behavior myself. > The case that occurred to me is, suppose somebody's got a table containing > a regclass or regproc column, and he dumps and reloads it. If the input > converter silently replaces unknown names by 0, he's at risk of unexpected

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread David E. Wheeler
On Dec 5, 2013, at 7:52 AM, Tom Lane wrote: > BTW, another arguable advantage of fixing this via new functions is > that users could write equivalent (though no doubt slower) functions > for use in pre-9.4 releases, and thus not need to maintain multiple > versions of app code that relies on this

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Peter Eisentraut
On 12/5/13, 10:08 AM, Tom Lane wrote: > Peter Eisentraut writes: >> We could invent some sneaky syntax variants, like 'pg_klass'::regclass >> errors, but '?pg_klass'::regclass does not. > > Hmm ... cute idea, but shoehorning it into regoperator might be > problematic. You'd have to pick a flag c

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Robert Haas writes: >> Another advantage of this approach is that, IIUC, type input functions >> can't return a NULL value. So 'pg_klass'::regclass could return 0, >> but not NULL. On the other hand, toregclass('pg_klass') *could* >> return NULL, which seems conceptually cleaner. BTW, another a

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Robert Haas writes: > On Thu, Dec 5, 2013 at 9:41 AM, Tom Lane wrote: >> I don't think new types are a good idea. If we are afraid to change >> the behavior of the input converters, what we should do is introduce >> new functions, eg "toregclass(text) returns regclass". > That seems like a pret

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Robert Haas
On Thu, Dec 5, 2013 at 9:41 AM, Tom Lane wrote: > Pavel Golub writes: >> I personally see two approaches: >> 1. Implement GUC variable controling this behaviour per session >> 2. Introduce new safe reg* variables, e.g. "sregclass", "sregtype" etc. > > I don't think new types are a good idea. If

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Peter Eisentraut writes: > We could invent some sneaky syntax variants, like 'pg_klass'::regclass > errors, but '?pg_klass'::regclass does not. Hmm ... cute idea, but shoehorning it into regoperator might be problematic. You'd have to pick a flag character that wasn't a valid operator character,

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Peter Eisentraut
On 12/5/13, 9:41 AM, Tom Lane wrote: > Pavel Golub writes: >> I personally see two approaches: >> 1. Implement GUC variable controling this behaviour per session >> 2. Introduce new safe reg* variables, e.g. "sregclass", "sregtype" etc. > > I don't think new types are a good idea. If we are afra

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Pavel Golub writes: > I personally see two approaches: > 1. Implement GUC variable controling this behaviour per session > 2. Introduce new safe reg* variables, e.g. "sregclass", "sregtype" etc. I don't think new types are a good idea. If we are afraid to change the behavior of the input convert

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Pavel Golub
Hello, Andres. You wrote: AF> On 2013-12-04 20:25:53 -0500, Tom Lane wrote: >> Tatsuo Ishii writes: >> > I would like to add a variant of regclass, which is exactly same as >> > current regclass except it does not raise an error when the target >> > table is not found. Instead it returns Invalid

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Pavel Stehule
2013/12/5 Andres Freund > On 2013-12-05 11:54:20 +0100, Pavel Stehule wrote: > > 2013/12/5 Andres Freund > > We can introduce some assert polymorphic function > > > > CREATE OR REPLACE FUNCTION notnull(any, message text) RETURNS any, that > can > > be used for check inside SQL > > Uh. How is tha

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Andres Freund
On 2013-12-05 11:54:20 +0100, Pavel Stehule wrote: > 2013/12/5 Andres Freund > We can introduce some assert polymorphic function > > CREATE OR REPLACE FUNCTION notnull(any, message text) RETURNS any, that can > be used for check inside SQL Uh. How is that going to help applications that upgraded

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Pavel Stehule
2013/12/5 Andres Freund > On 2013-12-04 20:25:53 -0500, Tom Lane wrote: > > Tatsuo Ishii writes: > > > I would like to add a variant of regclass, which is exactly same as > > > current regclass except it does not raise an error when the target > > > table is not found. Instead it returns Invalid

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Andres Freund
On 2013-12-04 20:25:53 -0500, Tom Lane wrote: > Tatsuo Ishii writes: > > I would like to add a variant of regclass, which is exactly same as > > current regclass except it does not raise an error when the target > > table is not found. Instead it returns InvalidOid (0). > > I've sometimes thought

Re: [HACKERS] Proposal: variant of regclass

2013-12-04 Thread Pavel Golub
Hello, Tom. You wrote: TL> Tatsuo Ishii writes: >> I would like to add a variant of regclass, which is exactly same as >> current regclass except it does not raise an error when the target >> table is not found. Instead it returns InvalidOid (0). TL> I've sometimes thought we should just make a

Re: [HACKERS] Proposal: variant of regclass

2013-12-04 Thread Tatsuo Ishii
> Tatsuo Ishii writes: >> I would like to add a variant of regclass, which is exactly same as >> current regclass except it does not raise an error when the target >> table is not found. Instead it returns InvalidOid (0). > > I've sometimes thought we should just make all the reg* input converter

Re: [HACKERS] Proposal: variant of regclass

2013-12-04 Thread Tom Lane
Tatsuo Ishii writes: > I would like to add a variant of regclass, which is exactly same as > current regclass except it does not raise an error when the target > table is not found. Instead it returns InvalidOid (0). I've sometimes thought we should just make all the reg* input converters act tha