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 duplicate

Re: [HACKERS] Proposal: variant of regclass

2014-04-16 Thread Robert Haas
On Wed, Apr 16, 2014 at 3:27 AM, Tatsuo Ishii is...@postgresql.org 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

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-08 Thread Yugo Nagata
On Mon, 7 Apr 2014 12:00:49 -0400 Robert Haas robertmh...@gmail.com wrote: In other words, let's revert the whole refactoring of this file to create reg*_guts functions, and instead just copy the relevant logic for the name lookups into the new functions. For to_regproc(), for example, it

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-08 Thread Robert Haas
On Tue, Apr 8, 2014 at 3:01 AM, Yugo Nagata nag...@sraoss.co.jp wrote: On Mon, 7 Apr 2014 12:00:49 -0400 Robert Haas robertmh...@gmail.com wrote: In other words, let's revert the whole refactoring of this file to create reg*_guts functions, and instead just copy the relevant logic for the

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-08 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: Looks good, committed with a bit of further cleanup. I had not actually paid attention to the non-regclass parts of this, and now that I look, I've got to say that it seems borderline insane to have chosen to implement regproc/regoper rather than

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-08 Thread Robert Haas
On Tue, Apr 8, 2014 at 10:50 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: Looks good, committed with a bit of further cleanup. I had not actually paid attention to the non-regclass parts of this, and now that I look, I've got to say that it seems borderline

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-08 Thread Robert Haas
On Tue, Apr 8, 2014 at 11:01 AM, Robert Haas robertmh...@gmail.com wrote: On Tue, Apr 8, 2014 at 10:50 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: Looks good, committed with a bit of further cleanup. I had not actually paid attention to the non-regclass

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-07 Thread Robert Haas
On Sat, Apr 5, 2014 at 1:10 AM, Amit Kapila amit.kapil...@gmail.com wrote: The reason of this behavior is that in out functions (regclassout), we return the OID as it is incase it doesn't exist. One way to fix this is incase of OID input parameters, we check if the passed OID exists in to_*

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-07 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: In other words, let's revert the whole refactoring of this file to create reg*_guts functions, and instead just copy the relevant logic for the name lookups into the new functions. The main discomfort I'd had with this patch was the amount of

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-07 Thread Andres Freund
On 2014-04-04 11:18:10 -0400, Robert Haas wrote: On Wed, Apr 2, 2014 at 11:27 PM, Amit Kapila amit.kapil...@gmail.com wrote: Right, it will get reset in error. However still we need to free for missing_ok case and when it is successful in getting typeid. So don't you think it is better

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-07 Thread Tom Lane
Andres Freund and...@2ndquadrant.com writes: There's actually another good reason to not copy regclass's behaviour: postgres=# CREATE TABLE 123(); CREATE TABLE postgres=# SELECT '123'::regclass; regclass -- 123 (1 row) I don't think that's fixable for ::regclass, but we

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-07 Thread Andres Freund
On 2014-04-07 12:59:36 -0400, Tom Lane wrote: Andres Freund and...@2ndquadrant.com writes: There's actually another good reason to not copy regclass's behaviour: postgres=# CREATE TABLE 123(); CREATE TABLE postgres=# SELECT '123'::regclass; regclass -- 123 (1 row)

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-04 Thread Amit Kapila
On Fri, Apr 4, 2014 at 8:48 PM, Robert Haas robertmh...@gmail.com wrote: I see. Here's an updated patch with a bit of minor refactoring to clean that up, and some improvements to the documentation. I was all ready to commit this when I got cold feet. What's bothering me is that the patch,

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-02 Thread Robert Haas
On Wed, Apr 2, 2014 at 1:41 AM, Amit Kapila amit.kapil...@gmail.com wrote: On Mon, Mar 31, 2014 at 7:08 PM, Yugo Nagata nag...@sraoss.co.jp wrote: Hi Amit Kapila, Thank you for your reviewing. I updated the patch to v5. I have checked the latest version and found few minor improvements that

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-02 Thread Amit Kapila
On Thu, Apr 3, 2014 at 5:43 AM, Robert Haas robertmh...@gmail.com wrote: On Wed, Apr 2, 2014 at 1:41 AM, Amit Kapila amit.kapil...@gmail.com wrote: On Mon, Mar 31, 2014 at 7:08 PM, Yugo Nagata nag...@sraoss.co.jp wrote: Hi Amit Kapila, Thank you for your reviewing. I updated the patch to v5.

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-04-01 Thread Amit Kapila
On Mon, Mar 31, 2014 at 7:08 PM, Yugo Nagata nag...@sraoss.co.jp wrote: Hi Amit Kapila, Thank you for your reviewing. I updated the patch to v5. I have checked the latest version and found few minor improvements that are required: 1. ! if (!missing_ok) ! ereport(ERROR, !

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-03-29 Thread Amit Kapila
On Sat, Mar 22, 2014 at 1:17 PM, Amit Kapila amit.kapil...@gmail.com wrote: On Wed, Feb 26, 2014 at 11:56 AM, Yugo Nagata nag...@sraoss.co.jp wrote: Thanks for your a lot of comments. I revised the patch according to comments from Robert Haas and Marti Raudsepp. I have started looking into

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-03-23 Thread Marti Raudsepp
On Sun, Mar 23, 2014 at 7:57 AM, Amit Kapila amit.kapil...@gmail.com wrote: Anyone has any objection for this behaviour difference between usage of ::regclass and to_regclass()? No, I think that makes a lot of sense given the behavior -- if the object is not there, to_regclass() just returns

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-03-22 Thread Amit Kapila
On Wed, Feb 26, 2014 at 11:56 AM, Yugo Nagata nag...@sraoss.co.jp wrote: Thanks for your a lot of comments. I revised the patch according to comments from Robert Haas and Marti Raudsepp. I have started looking into this patch and below are my initial findings: 1. Dependency is not recorded

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-03-22 Thread Amit Kapila
On Sat, Mar 22, 2014 at 1:17 PM, Amit Kapila amit.kapil...@gmail.com wrote: On Wed, Feb 26, 2014 at 11:56 AM, Yugo Nagata nag...@sraoss.co.jp wrote: Thanks for your a lot of comments. I revised the patch according to comments from Robert Haas and Marti Raudsepp. I have started looking into

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-02-06 Thread Marti Raudsepp
On Tue, Jan 28, 2014 at 10:38 AM, Yugo Nagata nag...@sraoss.co.jp wrote: I revised the patch. Could you please review this? I didn't test the patch due to the duplicate OID compilation error. But a few things stuck out from the diffs: * You added some unnecessary spaces at the beginning of the

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-01-31 Thread Amit Khandekar
message -- From: Marti Raudsepp ma...@juffo.org Date: Thu, Jan 23, 2014 at 3:39 AM Subject: Re: [HACKERS] Proposal: variant of regclass To: Yugo Nagata nag...@sraoss.co.jp Cc: Tatsuo Ishii is...@postgresql.org, pgsql-hackers pgsql-hackers@postgresql.org, Vik Fearing vik.fear

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-01-31 Thread Robert Haas
On Fri, Jan 31, 2014 at 6:31 AM, Yugo Nagata nag...@sraoss.co.jp wrote: Hi Amit, Thanks for your reviewing. I updated the patch. I fixed the oids and removed the witespace. This patch contains several whitespace-only hunks. Please revert them. I don't like the changes to

Re: [HACKERS] Proposal: variant of regclass

2014-01-23 Thread Amit Khandekar
On 22 January 2014 13:09, Tatsuo Ishii is...@postgresql.org 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

Re: Fwd: [HACKERS] Proposal: variant of regclass

2014-01-23 Thread Yugo Nagata
for srasce.sra.co.jp loops back to myself t-is...@sra.co.jp: mail for srasce.sra.co.jp loops back to myself -- Forwarded message -- From: Marti Raudsepp ma...@juffo.org Date: Thu, Jan 23, 2014 at 3:39 AM Subject: Re: [HACKERS] Proposal: variant of regclass To: Yugo Nagata nag...@sraoss.co.jp

Re: [HACKERS] Proposal: variant of regclass

2014-01-22 Thread Marti Raudsepp
On Tue, Jan 14, 2014 at 9:28 AM, Yugo Nagata nag...@sraoss.co.jp 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

Re: [HACKERS] Proposal: variant of regclass

2014-01-22 Thread Tatsuo Ishii
On Tue, Jan 14, 2014 at 9:28 AM, Yugo Nagata nag...@sraoss.co.jp 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

Re: [HACKERS] Proposal: variant of regclass

2014-01-22 Thread Yugo Nagata
On Wed, 22 Jan 2014 20:04:12 +0900 (JST) Tatsuo Ishii is...@postgresql.org wrote: On Tue, Jan 14, 2014 at 9:28 AM, Yugo Nagata nag...@sraoss.co.jp wrote: Here is the patch to implement to_regclass, to_regproc, to_regoper, and to_regtype. + static Datum regclass_guts(char

Re: [HACKERS] Proposal: variant of regclass

2014-01-22 Thread Marti Raudsepp
On Wed, Jan 22, 2014 at 1:44 PM, Yugo Nagata nag...@sraoss.co.jp wrote: On Wed, 22 Jan 2014 20:04:12 +0900 (JST) Tatsuo Ishii is...@postgresql.org wrote: parseTypeString() is called by some other functions and I avoided influences of modifying the definition on them, since this should raise

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 us

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()

Re: [HACKERS] Proposal: variant of regclass

2014-01-14 Thread Tatsuo Ishii
On Tue, Jan 14, 2014 at 4:28 PM, Yugo Nagata nag...@sraoss.co.jp 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

Re: [HACKERS] Proposal: variant of regclass

2014-01-13 Thread Michael Paquier
Hi, On Tue, Jan 14, 2014 at 4:28 PM, Yugo Nagata nag...@sraoss.co.jp 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-31 Thread Pavel Stehule
2013/12/31 Tatsuo Ishii is...@postgresql.org 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

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, I would

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 (regtype)

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) toregtype (regtype)

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 toregclass to

Re: [HACKERS] Proposal: variant of regclass

2013-12-17 Thread Robert Haas
On Mon, Dec 16, 2013 at 8:22 PM, Tatsuo Ishii is...@postgresql.org 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
Tatsuo Ishii is...@postgresql.org 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,

Re: [HACKERS] Proposal: variant of regclass

2013-12-16 Thread Tom Lane
Tatsuo Ishii is...@postgresql.org 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

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 job before

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 is...@sraoss.co.jp 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Pavel Stehule
2013/12/5 Andres Freund and...@2ndquadrant.com On 2013-12-04 20:25:53 -0500, Tom Lane wrote: Tatsuo Ishii is...@sraoss.co.jp 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

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 and...@2ndquadrant.com 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Pavel Stehule
2013/12/5 Andres Freund and...@2ndquadrant.com On 2013-12-05 11:54:20 +0100, Pavel Stehule wrote: 2013/12/5 Andres Freund and...@2ndquadrant.com We can introduce some assert polymorphic function CREATE OR REPLACE FUNCTION notnull(any, message text) RETURNS any, that can be used for

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 is...@sraoss.co.jp 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Pavel Golub pa...@microolap.com 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Peter Eisentraut
On 12/5/13, 9:41 AM, Tom Lane wrote: Pavel Golub pa...@microolap.com 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Peter Eisentraut pete...@gmx.net 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Robert Haas
On Thu, Dec 5, 2013 at 9:41 AM, Tom Lane t...@sss.pgh.pa.us wrote: Pavel Golub pa...@microolap.com 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Thu, Dec 5, 2013 at 9:41 AM, Tom Lane t...@sss.pgh.pa.us 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Tom Lane
Robert Haas robertmh...@gmail.com 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.

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread Peter Eisentraut
On 12/5/13, 10:08 AM, Tom Lane wrote: Peter Eisentraut pete...@gmx.net 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-05 Thread David E. Wheeler
On Dec 5, 2013, at 7:52 AM, Tom Lane t...@sss.pgh.pa.us 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

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 Tom Lane
Tatsuo Ishii is...@postgresql.org 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.

[HACKERS] Proposal: variant of regclass

2013-12-04 Thread Tatsuo Ishii
I would like to propose to add a variant of regclass. Background: Pgpool-II (http://www.pgpool.net) needs to get information of tables by querying PostgreSQL's system catalog. For efficiency and correctness of the info (search path consideration), pgpool-II issues such queries piggy packing the

Re: [HACKERS] Proposal: variant of regclass

2013-12-04 Thread Tom Lane
Tatsuo Ishii is...@sraoss.co.jp 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-04 Thread Tatsuo Ishii
Tatsuo Ishii is...@sraoss.co.jp 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

Re: [HACKERS] Proposal: variant of regclass

2013-12-04 Thread Pavel Golub
Hello, Tom. You wrote: TL Tatsuo Ishii is...@sraoss.co.jp 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